@black-market/sdk 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -20
- package/dist/abyss.d.ts +4 -2748
- package/dist/abyss.d.ts.map +1 -1
- package/dist/abyss.js +3 -1029
- package/dist/abyss.js.map +1 -1
- package/dist/addresses.d.ts +3 -7
- package/dist/addresses.d.ts.map +1 -1
- package/dist/addresses.js +6 -21
- package/dist/addresses.js.map +1 -1
- package/dist/auction.d.ts +2 -2
- package/dist/auction.d.ts.map +1 -1
- package/dist/auction.js +2 -2
- package/dist/auction.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/launch-api.d.ts +151 -0
- package/dist/launch-api.d.ts.map +1 -0
- package/dist/launch-api.js +117 -0
- package/dist/launch-api.js.map +1 -0
- package/dist/launch.d.ts +23 -185
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +35 -272
- package/dist/launch.js.map +1 -1
- package/dist/lifecycle/abi.d.ts +6391 -0
- package/dist/lifecycle/abi.d.ts.map +1 -0
- package/dist/lifecycle/abi.js +335 -0
- package/dist/lifecycle/abi.js.map +1 -0
- package/dist/lifecycle/authors.d.ts +133 -0
- package/dist/lifecycle/authors.d.ts.map +1 -0
- package/dist/lifecycle/authors.js +217 -0
- package/dist/lifecycle/authors.js.map +1 -0
- package/dist/lifecycle/fork.d.ts +15 -0
- package/dist/lifecycle/fork.d.ts.map +1 -0
- package/dist/lifecycle/fork.js +36 -0
- package/dist/lifecycle/fork.js.map +1 -0
- package/dist/lifecycle/index.d.ts +10 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +10 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/lifecycle/markets.d.ts +349 -0
- package/dist/lifecycle/markets.d.ts.map +1 -0
- package/dist/lifecycle/markets.js +186 -0
- package/dist/lifecycle/markets.js.map +1 -0
- package/dist/lifecycle/planner.d.ts +20 -0
- package/dist/lifecycle/planner.d.ts.map +1 -0
- package/dist/lifecycle/planner.js +481 -0
- package/dist/lifecycle/planner.js.map +1 -0
- package/dist/lifecycle/progress.d.ts +43 -0
- package/dist/lifecycle/progress.d.ts.map +1 -0
- package/dist/lifecycle/progress.js +449 -0
- package/dist/lifecycle/progress.js.map +1 -0
- package/dist/lifecycle/rpc.d.ts +17 -0
- package/dist/lifecycle/rpc.d.ts.map +1 -0
- package/dist/lifecycle/rpc.js +100 -0
- package/dist/lifecycle/rpc.js.map +1 -0
- package/dist/lifecycle/schema.d.ts +1068 -0
- package/dist/lifecycle/schema.d.ts.map +1 -0
- package/dist/lifecycle/schema.js +335 -0
- package/dist/lifecycle/schema.js.map +1 -0
- package/dist/lifecycle/simulation.d.ts +3 -0
- package/dist/lifecycle/simulation.d.ts.map +1 -0
- package/dist/lifecycle/simulation.js +393 -0
- package/dist/lifecycle/simulation.js.map +1 -0
- package/dist/lifecycle/types.d.ts +273 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/lifecycle/types.js +11 -0
- package/dist/lifecycle/types.js.map +1 -0
- package/docs/launch-lifecycle.md +243 -0
- package/package.json +12 -3
- package/src/abyss.ts +3 -1059
- package/src/addresses.ts +9 -26
- package/src/auction.ts +2 -2
- package/src/index.ts +2 -0
- package/src/launch-api.ts +110 -0
- package/src/launch.ts +43 -411
- package/src/lifecycle/abi.ts +343 -0
- package/src/lifecycle/authors.ts +203 -0
- package/src/lifecycle/fork.ts +36 -0
- package/src/lifecycle/index.ts +9 -0
- package/src/lifecycle/markets.ts +205 -0
- package/src/lifecycle/planner.ts +396 -0
- package/src/lifecycle/progress.ts +378 -0
- package/src/lifecycle/rpc.ts +88 -0
- package/src/lifecycle/schema.ts +387 -0
- package/src/lifecycle/simulation.ts +329 -0
- package/src/lifecycle/types.ts +132 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { keccak256, stringToHex } from "viem";
|
|
2
|
+
export const DEFAULT_LAUNCH_API_URL = "https://api.abyss.trading";
|
|
3
|
+
export const LAUNCH_IMAGE_CONTENT_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
4
|
+
export const MAX_LAUNCH_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
5
|
+
export class LaunchApiError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
retryAfterMs;
|
|
9
|
+
constructor(status, code, message, retryAfterMs) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "LaunchApiError";
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.retryAfterMs = retryAfterMs;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class LaunchPublishPending extends Error {
|
|
18
|
+
session;
|
|
19
|
+
retryAfterMs;
|
|
20
|
+
constructor(session, retryAfterMs) {
|
|
21
|
+
super("Launch transaction is confirmed but indexing is still pending.");
|
|
22
|
+
this.name = "LaunchPublishPending";
|
|
23
|
+
this.session = session;
|
|
24
|
+
this.retryAfterMs = retryAfterMs;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Optional client for the web app's signed metadata/upload/publication lifecycle. */
|
|
28
|
+
export class LaunchApiClient {
|
|
29
|
+
baseUrl;
|
|
30
|
+
fetch;
|
|
31
|
+
retries;
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_LAUNCH_API_URL).replace(/\/+$/, "");
|
|
34
|
+
this.fetch = options.fetch ?? globalThis.fetch;
|
|
35
|
+
if (this.fetch === undefined)
|
|
36
|
+
throw new Error("A fetch implementation is required for LaunchApiClient");
|
|
37
|
+
this.retries = options.retries ?? 3;
|
|
38
|
+
}
|
|
39
|
+
async createUploadSession(body, idempotencyKey) {
|
|
40
|
+
return this.request("POST", "/api/v1/launch-upload-sessions", body.chainId, { body, idempotencyKey });
|
|
41
|
+
}
|
|
42
|
+
async getUploadSession(chainId, sessionId, capability) {
|
|
43
|
+
return this.request("GET", `/api/v1/launch-upload-sessions/${encodeURIComponent(sessionId)}`, chainId, { capability });
|
|
44
|
+
}
|
|
45
|
+
async renewUploadUrl(chainId, sessionId, capability) {
|
|
46
|
+
return this.request("POST", `/api/v1/launch-upload-sessions/${encodeURIComponent(sessionId)}/upload-url`, chainId, { body: {}, capability });
|
|
47
|
+
}
|
|
48
|
+
async completeUpload(chainId, sessionId, capability) {
|
|
49
|
+
return this.request("POST", `/api/v1/launch-upload-sessions/${encodeURIComponent(sessionId)}/upload/complete`, chainId, { body: {}, capability });
|
|
50
|
+
}
|
|
51
|
+
async publishUploadSession(chainId, sessionId, capability, body) {
|
|
52
|
+
return this.request("POST", `/api/v1/launch-upload-sessions/${encodeURIComponent(sessionId)}/publish`, chainId, { body, capability, pendingOnAccepted: true });
|
|
53
|
+
}
|
|
54
|
+
async putImage(upload, body) {
|
|
55
|
+
const response = await this.fetch(upload.url, { method: "PUT", headers: upload.headers, body });
|
|
56
|
+
if (!response.ok)
|
|
57
|
+
throw new LaunchApiError(response.status, "UPLOAD_CONFLICT", `Launch image upload failed with status ${response.status}.`);
|
|
58
|
+
}
|
|
59
|
+
async request(method, path, chainId, options) {
|
|
60
|
+
const url = new URL(path, `${this.baseUrl}/`);
|
|
61
|
+
url.searchParams.set("chainId", String(chainId));
|
|
62
|
+
const headers = {};
|
|
63
|
+
if (options.body !== undefined)
|
|
64
|
+
headers["Content-Type"] = "application/json";
|
|
65
|
+
if (options.capability !== undefined)
|
|
66
|
+
headers.Authorization = `Launch-Upload-Capability ${options.capability}`;
|
|
67
|
+
if (options.idempotencyKey !== undefined)
|
|
68
|
+
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
69
|
+
let lastError;
|
|
70
|
+
for (let attempt = 0; attempt < this.retries; attempt += 1) {
|
|
71
|
+
try {
|
|
72
|
+
const response = await this.fetch(url, { method, headers, body: options.body === undefined ? undefined : JSON.stringify(options.body) });
|
|
73
|
+
const retryAfterMs = Math.max(250, Number(response.headers.get("Retry-After")) * 1000 || 0) || undefined;
|
|
74
|
+
if (response.ok) {
|
|
75
|
+
const value = await response.json();
|
|
76
|
+
if (response.status === 202 && options.pendingOnAccepted)
|
|
77
|
+
throw new LaunchPublishPending(value, retryAfterMs ?? 5_000);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
let code = "INVALID_REQUEST";
|
|
81
|
+
let message = `Launch API request failed with status ${response.status}.`;
|
|
82
|
+
try {
|
|
83
|
+
const value = await response.json();
|
|
84
|
+
if (typeof value.code === "string")
|
|
85
|
+
code = value.code;
|
|
86
|
+
if (typeof value.error === "string")
|
|
87
|
+
message = value.error;
|
|
88
|
+
}
|
|
89
|
+
catch { /* response body is optional */ }
|
|
90
|
+
const error = new LaunchApiError(response.status, code, message, retryAfterMs);
|
|
91
|
+
if (![429, 502, 503, 504].includes(response.status) || attempt + 1 === this.retries)
|
|
92
|
+
throw error;
|
|
93
|
+
lastError = error;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error instanceof LaunchPublishPending || error instanceof LaunchApiError && ![429, 502, 503, 504].includes(error.status))
|
|
97
|
+
throw error;
|
|
98
|
+
lastError = error;
|
|
99
|
+
}
|
|
100
|
+
await new Promise((resolve) => globalThis.setTimeout(resolve, 750 * 2 ** attempt));
|
|
101
|
+
}
|
|
102
|
+
throw lastError instanceof LaunchApiError ? lastError : new LaunchApiError(0, "RPC_UNAVAILABLE", lastError instanceof Error ? lastError.message : "The launch API is unreachable.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const launchAttributionTypes = { LaunchAttribution: [
|
|
106
|
+
{ name: "chainId", type: "uint256" }, { name: "wallet", type: "address" }, { name: "metadataHash", type: "bytes32" },
|
|
107
|
+
{ name: "imageSha256", type: "bytes32" }, { name: "imageContentType", type: "string" }, { name: "imageContentLength", type: "uint256" },
|
|
108
|
+
{ name: "idempotencyKey", type: "string" }, { name: "nonce", type: "bytes32" }, { name: "deadline", type: "uint256" },
|
|
109
|
+
] };
|
|
110
|
+
export function canonicalLaunchMetadataHash(metadata) {
|
|
111
|
+
return keccak256(stringToHex(JSON.stringify({ name: metadata.name.normalize("NFC").trim(), symbol: metadata.symbol.normalize("NFC").trim(), description: (metadata.description ?? "").normalize("NFC").trim(), websiteUrl: metadata.websiteUrl ?? null, twitterUrl: metadata.twitterUrl ?? null, telegramUrl: metadata.telegramUrl ?? null, discordUrl: metadata.discordUrl ?? null, imageKey: metadata.imageKey ?? null })));
|
|
112
|
+
}
|
|
113
|
+
export async function sha256Hex(bytes) {
|
|
114
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
115
|
+
return `0x${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=launch-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch-api.js","sourceRoot":"","sources":["../src/launch-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAqC,MAAM,MAAM,CAAC;AAEjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAClE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAE7F,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAetD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAS;IACf,IAAI,CAAqB;IACzB,YAAY,CAAU;IAC/B,YAAY,MAAc,EAAE,IAAwB,EAAE,OAAe,EAAE,YAAqB;QAC1F,KAAK,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAAC,IAAI,C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CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACha,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAkB;IAChD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAS,CAAC;AACjH,CAAC"}
|
package/dist/launch.d.ts
CHANGED
|
@@ -1,225 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ABYSS_FEE_TIERS, AbyssPoolProfile, TokenKind } from "./abyss.js";
|
|
3
|
-
export declare const INITIAL_TEMPLATE_VERSION: 1;
|
|
4
|
-
export declare const STANDARD_TEMPLATE_ID: `0x${string}`;
|
|
5
|
-
export declare const QUOTE_STAKING_TEMPLATE_ID: `0x${string}`;
|
|
6
|
-
export declare const QUOTE_DIVIDENDS_TEMPLATE_ID: `0x${string}`;
|
|
7
|
-
export declare const DUAL_STAKING_TEMPLATE_ID: `0x${string}`;
|
|
8
|
-
export declare const DUAL_DIVIDENDS_TEMPLATE_ID: `0x${string}`;
|
|
9
|
-
export declare const FEE_BURN_TEMPLATE_ID: `0x${string}`;
|
|
10
|
-
export declare const STANDARD_TEMPLATE_VERSION: 1;
|
|
1
|
+
import { ABYSS_FEE_TIERS } from "./abyss.js";
|
|
11
2
|
export declare const LAUNCH_REWARD_DURATION: number;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export declare const
|
|
17
|
-
/** Existing Abyss execution policy: Atomic launch requests expire after 20 minutes. */
|
|
18
|
-
export declare const ATOMIC_LAUNCH_DEADLINE_SECONDS: number;
|
|
19
|
-
/** Existing Abyss execution policy: initial Atomic buys tolerate 50 basis points of price movement. */
|
|
20
|
-
export declare const ATOMIC_LAUNCH_BUY_SLIPPAGE_BPS = 50;
|
|
21
|
-
/**
|
|
22
|
-
* Atomic lifecycle recipes and tests use a $5,000 initial fully diluted market cap.
|
|
23
|
-
* The form converts this editable whole-USD default to an X18 value before recipe derivation.
|
|
24
|
-
*/
|
|
25
|
-
export declare const DEFAULT_ATOMIC_LAUNCH_TARGET_MARKET_CAP_USD = 5000;
|
|
26
|
-
export declare enum LaunchRewardMode {
|
|
27
|
-
None = 0,
|
|
28
|
-
Staking = 1,
|
|
29
|
-
Dividends = 2
|
|
30
|
-
}
|
|
31
|
-
export declare enum LaunchFeeAssetMode {
|
|
32
|
-
Profile = 0,
|
|
33
|
-
PairedOnly = 1,
|
|
34
|
-
Both = 2,
|
|
35
|
-
LaunchedOnly = 3
|
|
36
|
-
}
|
|
37
|
-
export declare enum LaunchFeeDestination {
|
|
38
|
-
Owner = 1,
|
|
39
|
-
Rewards = 2,
|
|
40
|
-
Burn = 4
|
|
41
|
-
}
|
|
42
|
-
export type LaunchTemplateId = "standard" | "quote-staking" | "quote-dividends" | "dual-staking" | "dual-dividends" | "fee-burn";
|
|
3
|
+
/** Canonical P3 oracle default; reviewed V4 markets may select any valid registered oracle within their cardinality bounds. */
|
|
4
|
+
export declare const LAUNCH_ORACLE_CONFIG_ID: "0xc0e9bed88d70a13fd3ab31451fefdd073b7266e838aee0ad1c236c8c9eff855d";
|
|
5
|
+
export declare const LAUNCH_DEADLINE_SECONDS: number;
|
|
6
|
+
export declare const LAUNCH_BUY_SLIPPAGE_BPS = 50;
|
|
7
|
+
export declare const DEFAULT_LAUNCH_TARGET_MARKET_CAP_USD = 5000;
|
|
43
8
|
export type AbyssFeePips = (typeof ABYSS_FEE_TIERS)[number]["feePips"];
|
|
44
|
-
export type
|
|
45
|
-
ownerBps: number;
|
|
46
|
-
rewardsBps: number;
|
|
47
|
-
burnBps: number;
|
|
48
|
-
};
|
|
49
|
-
export type LaunchTemplate = {
|
|
50
|
-
id: LaunchTemplateId;
|
|
51
|
-
templateId: Hex;
|
|
52
|
-
version: typeof INITIAL_TEMPLATE_VERSION;
|
|
53
|
-
label: string;
|
|
54
|
-
tokenKinds: readonly TokenKind[];
|
|
55
|
-
poolProfiles: readonly AbyssPoolProfile[];
|
|
56
|
-
launchedTokenIsQuote: boolean;
|
|
57
|
-
rewardMode: LaunchRewardMode;
|
|
58
|
-
rewardDuration: number;
|
|
59
|
-
feeAssetMode: LaunchFeeAssetMode;
|
|
60
|
-
launchedTokenDestinations: number;
|
|
61
|
-
pairedTokenDestinations: number;
|
|
62
|
-
};
|
|
63
|
-
export declare const LAUNCH_TEMPLATES: readonly [{
|
|
64
|
-
readonly id: "standard";
|
|
65
|
-
readonly templateId: `0x${string}`;
|
|
66
|
-
readonly version: 1;
|
|
67
|
-
readonly label: "Standard";
|
|
68
|
-
readonly tokenKinds: readonly [TokenKind.Burnable];
|
|
69
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.StandardOracle, AbyssPoolProfile.QuoteOracle];
|
|
70
|
-
readonly launchedTokenIsQuote: false;
|
|
71
|
-
readonly rewardMode: LaunchRewardMode.None;
|
|
72
|
-
readonly rewardDuration: 0;
|
|
73
|
-
readonly feeAssetMode: LaunchFeeAssetMode.Profile;
|
|
74
|
-
readonly launchedTokenDestinations: LaunchFeeDestination.Owner;
|
|
75
|
-
readonly pairedTokenDestinations: LaunchFeeDestination.Owner;
|
|
76
|
-
}, {
|
|
77
|
-
readonly id: "quote-staking";
|
|
78
|
-
readonly templateId: `0x${string}`;
|
|
79
|
-
readonly version: 1;
|
|
80
|
-
readonly label: "Quote Staking";
|
|
81
|
-
readonly tokenKinds: readonly [TokenKind.Burnable];
|
|
82
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.QuoteOracle];
|
|
83
|
-
readonly launchedTokenIsQuote: false;
|
|
84
|
-
readonly rewardMode: LaunchRewardMode.Staking;
|
|
85
|
-
readonly rewardDuration: number;
|
|
86
|
-
readonly feeAssetMode: LaunchFeeAssetMode.PairedOnly;
|
|
87
|
-
readonly launchedTokenDestinations: 0;
|
|
88
|
-
readonly pairedTokenDestinations: number;
|
|
89
|
-
}, {
|
|
90
|
-
readonly id: "quote-dividends";
|
|
91
|
-
readonly templateId: `0x${string}`;
|
|
92
|
-
readonly version: 1;
|
|
93
|
-
readonly label: "Quote Dividends";
|
|
94
|
-
readonly tokenKinds: readonly [TokenKind.HolderDividend];
|
|
95
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.QuoteOracle];
|
|
96
|
-
readonly launchedTokenIsQuote: false;
|
|
97
|
-
readonly rewardMode: LaunchRewardMode.Dividends;
|
|
98
|
-
readonly rewardDuration: number;
|
|
99
|
-
readonly feeAssetMode: LaunchFeeAssetMode.PairedOnly;
|
|
100
|
-
readonly launchedTokenDestinations: 0;
|
|
101
|
-
readonly pairedTokenDestinations: number;
|
|
102
|
-
}, {
|
|
103
|
-
readonly id: "dual-staking";
|
|
104
|
-
readonly templateId: `0x${string}`;
|
|
105
|
-
readonly version: 1;
|
|
106
|
-
readonly label: "Dual Staking";
|
|
107
|
-
readonly tokenKinds: readonly [TokenKind.Burnable];
|
|
108
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.StandardOracle];
|
|
109
|
-
readonly launchedTokenIsQuote: false;
|
|
110
|
-
readonly rewardMode: LaunchRewardMode.Staking;
|
|
111
|
-
readonly rewardDuration: number;
|
|
112
|
-
readonly feeAssetMode: LaunchFeeAssetMode.Both;
|
|
113
|
-
readonly launchedTokenDestinations: number;
|
|
114
|
-
readonly pairedTokenDestinations: number;
|
|
115
|
-
}, {
|
|
116
|
-
readonly id: "dual-dividends";
|
|
117
|
-
readonly templateId: `0x${string}`;
|
|
118
|
-
readonly version: 1;
|
|
119
|
-
readonly label: "Dual Dividends";
|
|
120
|
-
readonly tokenKinds: readonly [TokenKind.HolderDividend];
|
|
121
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.StandardOracle];
|
|
122
|
-
readonly launchedTokenIsQuote: false;
|
|
123
|
-
readonly rewardMode: LaunchRewardMode.Dividends;
|
|
124
|
-
readonly rewardDuration: number;
|
|
125
|
-
readonly feeAssetMode: LaunchFeeAssetMode.Both;
|
|
126
|
-
readonly launchedTokenDestinations: number;
|
|
127
|
-
readonly pairedTokenDestinations: number;
|
|
128
|
-
}, {
|
|
129
|
-
readonly id: "fee-burn";
|
|
130
|
-
readonly templateId: `0x${string}`;
|
|
131
|
-
readonly version: 1;
|
|
132
|
-
readonly label: "Fee Burn";
|
|
133
|
-
readonly tokenKinds: readonly [TokenKind.Burnable];
|
|
134
|
-
readonly poolProfiles: readonly [AbyssPoolProfile.QuoteOracle];
|
|
135
|
-
readonly launchedTokenIsQuote: true;
|
|
136
|
-
readonly rewardMode: LaunchRewardMode.None;
|
|
137
|
-
readonly rewardDuration: 0;
|
|
138
|
-
readonly feeAssetMode: LaunchFeeAssetMode.LaunchedOnly;
|
|
139
|
-
readonly launchedTokenDestinations: LaunchFeeDestination.Burn;
|
|
140
|
-
readonly pairedTokenDestinations: 0;
|
|
141
|
-
}];
|
|
142
|
-
export type AtomicLaunchRequest = {
|
|
143
|
-
creator: Address;
|
|
144
|
-
templateId: Hex;
|
|
145
|
-
templateVersion: number;
|
|
146
|
-
token: {
|
|
147
|
-
kind: TokenKind;
|
|
148
|
-
name: string;
|
|
149
|
-
symbol: string;
|
|
150
|
-
decimals: number;
|
|
151
|
-
supply: bigint;
|
|
152
|
-
};
|
|
153
|
-
pool: {
|
|
154
|
-
pairedToken: Address;
|
|
155
|
-
launchedTokenIsQuote: boolean;
|
|
156
|
-
profile: AbyssPoolProfile;
|
|
157
|
-
fee: AbyssFeePips;
|
|
158
|
-
oracleConfigId: Hex;
|
|
159
|
-
launchTick: number;
|
|
160
|
-
liquidity: bigint;
|
|
161
|
-
launchedTokenAmountMaximum: bigint;
|
|
162
|
-
pairedTokenAmountMaximum: bigint;
|
|
163
|
-
};
|
|
164
|
-
initialBuy: {
|
|
165
|
-
pairedTokenAmountIn: bigint;
|
|
166
|
-
launchedTokenAmountOutMinimum: bigint;
|
|
167
|
-
sqrtPriceLimitX96: bigint;
|
|
168
|
-
};
|
|
169
|
-
launchedTokenFees: FeeDisposition;
|
|
170
|
-
pairedTokenFees: FeeDisposition;
|
|
171
|
-
deadline: bigint;
|
|
172
|
-
};
|
|
173
|
-
export type AtomicLaunchPoolRecipeInput = {
|
|
9
|
+
export type LaunchPoolRecipeInput = {
|
|
174
10
|
pairedTokenDecimals: number;
|
|
175
11
|
pairedTokenUsdPriceX18: bigint;
|
|
176
12
|
targetMarketCapUsdX18: bigint;
|
|
177
13
|
launchedTokenIsQuote: boolean;
|
|
178
14
|
fee: AbyssFeePips;
|
|
15
|
+
supply?: bigint;
|
|
16
|
+
tokenBudget?: bigint;
|
|
17
|
+
tickSpacing?: number;
|
|
179
18
|
};
|
|
180
|
-
export type
|
|
19
|
+
export type LaunchPoolRecipe = {
|
|
181
20
|
launchTick: number;
|
|
182
21
|
launchSqrtPriceX96: bigint;
|
|
183
22
|
liquidity: bigint;
|
|
184
23
|
launchedTokenAmountMaximum: bigint;
|
|
185
24
|
pairedTokenAmountMaximum: 0n;
|
|
25
|
+
tickLower: number;
|
|
26
|
+
tickUpper: number;
|
|
186
27
|
};
|
|
187
|
-
export type
|
|
28
|
+
export type LaunchBuySqrtPriceLimitInput = {
|
|
188
29
|
launchSqrtPriceX96: bigint;
|
|
189
30
|
launchedTokenIsQuote: boolean;
|
|
190
31
|
slippageBps?: number;
|
|
191
32
|
};
|
|
192
33
|
/**
|
|
193
|
-
* Derives
|
|
34
|
+
* Derives one-sided launch geometry from explicit supply, budget and fully diluted market cap.
|
|
194
35
|
* The raw price remains a rational bigint until the canonical Q64.96 square root conversion.
|
|
195
36
|
*/
|
|
196
|
-
export declare function
|
|
197
|
-
export type
|
|
37
|
+
export declare function deriveLaunchPoolRecipe(input: LaunchPoolRecipeInput): LaunchPoolRecipe;
|
|
38
|
+
export type LaunchInitialBuyEstimateInput = {
|
|
198
39
|
launchSqrtPriceX96: bigint;
|
|
199
40
|
liquidity: bigint;
|
|
200
41
|
pairedTokenAmountIn: bigint;
|
|
201
42
|
launchedTokenIsQuote: boolean;
|
|
202
|
-
fee:
|
|
43
|
+
fee: number;
|
|
203
44
|
sqrtPriceLimitX96?: bigint;
|
|
204
45
|
};
|
|
205
|
-
export type
|
|
46
|
+
export type LaunchInitialBuyEstimate = {
|
|
206
47
|
launchedTokenAmountOut: bigint;
|
|
207
48
|
pairedTokenAmountConsumed: bigint;
|
|
208
49
|
sqrtPriceAfterX96: bigint;
|
|
209
50
|
};
|
|
210
51
|
/**
|
|
211
|
-
* Pure estimate for the first exact-input buy against a fresh one-sided
|
|
52
|
+
* Pure estimate for the first exact-input buy against a fresh one-sided
|
|
212
53
|
* launch position. No wallet balance, allowance, pool deployment, or RPC state.
|
|
213
54
|
* Uses conservative input-fee rounding; execution simulation remains the final
|
|
214
55
|
* authority before submission.
|
|
215
56
|
*/
|
|
216
|
-
export declare function
|
|
57
|
+
export declare function estimateLaunchInitialBuy(input: LaunchInitialBuyEstimateInput): LaunchInitialBuyEstimate;
|
|
217
58
|
/**
|
|
218
59
|
* Produces the router's exclusive sqrt-price guard for the paired-token initial buy.
|
|
219
|
-
* A paired input moves down
|
|
60
|
+
* A paired input moves down when the launch token is currency1 and up when it is currency0.
|
|
220
61
|
*/
|
|
221
|
-
export declare function
|
|
222
|
-
export declare function getLaunchTemplate(id: LaunchTemplateId): LaunchTemplate;
|
|
223
|
-
export declare function getLaunchTemplateByHash(templateId: Hex): LaunchTemplate;
|
|
224
|
-
export declare function buildAtomicLaunchCalldata(request: AtomicLaunchRequest, nativeBuyAmount?: bigint): Hex;
|
|
62
|
+
export declare function deriveLaunchBuySqrtPriceLimitX96(input: LaunchBuySqrtPriceLimitInput): bigint;
|
|
225
63
|
//# sourceMappingURL=launch.d.ts.map
|
package/dist/launch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,eAAO,MAAM,sBAAsB,QAAmB,CAAC;AAEvD,+HAA+H;AAC/H,eAAO,MAAM,uBAAuB,EAClC,oEAA6E,CAAC;AAChF,eAAO,MAAM,uBAAuB,QAAU,CAAC;AAC/C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,oCAAoC,OAAQ,CAAC;AAG1D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EA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