@kronsdk/kron-sdk 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1098 @@
1
+ import { K as Kaspa } from './kaspa.types-DkjvUkCM.js';
2
+ import * as vendor_kaspa_kaspa_js from 'vendor/kaspa/kaspa.js';
3
+ import '../vendor/kaspa/kaspa.js';
4
+
5
+ declare const SCALE$1 = 1000000n;
6
+ declare const FEE_OUT_MIN = 20000000n;
7
+ declare const MAX_KAS = 900000000000000n;
8
+ /** Live curve state for quoting. realKas/graduationKas are sompi; vKas is in SCALE units; tokenReserve whole. */
9
+ type CpState$1 = {
10
+ realKas: bigint;
11
+ tokenReserve: bigint;
12
+ vKas: bigint;
13
+ graduationKas: bigint;
14
+ creatorFeeBps: bigint;
15
+ platformFeeBps: bigint;
16
+ };
17
+ declare const DEFAULT_SLIPPAGE_BPS = 100;
18
+ /** Minimum acceptable output after a slippage tolerance (bps). `out` is tokenOut (buy) or net KAS (sell). */
19
+ declare const minOutWithSlippage: (out: bigint, bps: number) => bigint;
20
+ type CpBuyQuote = {
21
+ kasIn: bigint;
22
+ tokenOut: bigint;
23
+ creatorFee: bigint;
24
+ platformFee: bigint;
25
+ fee: bigint;
26
+ total: bigint;
27
+ newRealKas: bigint;
28
+ newTokenReserve: bigint;
29
+ };
30
+ type CpSellQuote = {
31
+ tokenIn: bigint;
32
+ kasOut: bigint;
33
+ creatorFee: bigint;
34
+ platformFee: bigint;
35
+ fee: bigint;
36
+ net: bigint;
37
+ newRealKas: bigint;
38
+ newTokenReserve: bigint;
39
+ };
40
+ /** Buy: spend `kasInSompi` into the reserve (floored to a SCALE step) → tokenOut, plus the fee on top. */
41
+ declare function quoteCpBuy(s: CpState$1, kasInSompi: bigint): CpBuyQuote | null;
42
+ /** Sell: return `tokenIn` tokens to inventory → kasOut sompi (a SCALE step), minus the fee. */
43
+ declare function quoteCpSell(s: CpState$1, tokenIn: bigint): CpSellQuote | null;
44
+ /** Marginal price in sompi per token: (vKas + realKas/SCALE) · SCALE / tokenReserve. */
45
+ declare function cpPrice(s: CpState$1): number;
46
+ /** Progress to graduation (0..100), measured by KAS raised vs the target. */
47
+ declare function cpProgress(s: CpState$1): number;
48
+ /** Tokens sold so far (circulating from the curve) = initial inventory − current inventory. */
49
+ declare const cpSold: (initialInventory: bigint, tokenReserve: bigint) => bigint;
50
+
51
+ type cpCurve_CpBuyQuote = CpBuyQuote;
52
+ type cpCurve_CpSellQuote = CpSellQuote;
53
+ declare const cpCurve_DEFAULT_SLIPPAGE_BPS: typeof DEFAULT_SLIPPAGE_BPS;
54
+ declare const cpCurve_FEE_OUT_MIN: typeof FEE_OUT_MIN;
55
+ declare const cpCurve_MAX_KAS: typeof MAX_KAS;
56
+ declare const cpCurve_cpPrice: typeof cpPrice;
57
+ declare const cpCurve_cpProgress: typeof cpProgress;
58
+ declare const cpCurve_cpSold: typeof cpSold;
59
+ declare const cpCurve_minOutWithSlippage: typeof minOutWithSlippage;
60
+ declare const cpCurve_quoteCpBuy: typeof quoteCpBuy;
61
+ declare const cpCurve_quoteCpSell: typeof quoteCpSell;
62
+ declare namespace cpCurve {
63
+ export { type cpCurve_CpBuyQuote as CpBuyQuote, type cpCurve_CpSellQuote as CpSellQuote, type CpState$1 as CpState, cpCurve_DEFAULT_SLIPPAGE_BPS as DEFAULT_SLIPPAGE_BPS, cpCurve_FEE_OUT_MIN as FEE_OUT_MIN, cpCurve_MAX_KAS as MAX_KAS, SCALE$1 as SCALE, cpCurve_cpPrice as cpPrice, cpCurve_cpProgress as cpProgress, cpCurve_cpSold as cpSold, cpCurve_minOutWithSlippage as minOutWithSlippage, cpCurve_quoteCpBuy as quoteCpBuy, cpCurve_quoteCpSell as quoteCpSell };
64
+ }
65
+
66
+ type K$7 = Kaspa;
67
+ /** 8-byte little-endian encoding of a non-negative int (encode_fixed_size_value for `int`, width 8). */
68
+ declare function int8LE(v: bigint): Uint8Array;
69
+ /**
70
+ * A SilverScript ScriptBuilder wrapper that records pushes in the compiler's order, then drains to hex.
71
+ * Use the scalar push helpers for struct fields / scalar args and the column helpers for struct arrays,
72
+ * then `selector()` (if multi-entrypoint) and `redeem()` last (the standard P2SH spend layout).
73
+ */
74
+ declare class SigScriptBuilder {
75
+ sb: any;
76
+ constructor(k: K$7);
77
+ /** int scalar (minimal CScriptNum). */
78
+ int(v: bigint): this;
79
+ /** bool scalar → 1|0 via addI64 (matches push_sigscript_arg Bool). */
80
+ bool(b: boolean): this;
81
+ /** single byte → addData([b]). */
82
+ byte(b: number): this;
83
+ /** raw bytes (byte[N], pubkey, sig, byte[]) → addData. */
84
+ data(bytes: Uint8Array): this;
85
+ /** a column of N values pushed as one fixed-width-concatenated array item (encode_array_literal). */
86
+ column(items: Uint8Array[]): this;
87
+ /** the entrypoint selector (branch index). Omit for single-entrypoint contracts. */
88
+ selector(index: number): this;
89
+ /** the P2SH redeem script (pushed last; the VM pops it, hash-checks, then runs it on the arg stack). */
90
+ redeem(script: Uint8Array): this;
91
+ /** finalize → signature-script hex. */
92
+ drain(): string;
93
+ }
94
+
95
+ type sigscript_SigScriptBuilder = SigScriptBuilder;
96
+ declare const sigscript_SigScriptBuilder: typeof SigScriptBuilder;
97
+ declare const sigscript_int8LE: typeof int8LE;
98
+ declare namespace sigscript {
99
+ export { sigscript_SigScriptBuilder as SigScriptBuilder, sigscript_int8LE as int8LE };
100
+ }
101
+
102
+ type K$6 = Kaspa;
103
+ /** SDK ScriptPublicKey instance, or a plain {version, script-hex} object. Kept loose, matching SDK style. */
104
+ type Spk$5 = any;
105
+ /** The genesis outpoint = the spending tx's FIRST input outpoint (`tx.inputs[0]`). */
106
+ type GenesisOutpoint = {
107
+ transactionId: string;
108
+ index: number;
109
+ };
110
+ /** An output the genesis outpoint authorizes for covenant-id derivation (its index + the output itself). */
111
+ type AuthOutput = {
112
+ index: number;
113
+ value: bigint;
114
+ scriptPublicKey: Spk$5;
115
+ };
116
+ /**
117
+ * Compute the KIP-20 genesis covenant-id (32-byte hex, no 0x) for a covenant UTXO created by a tx whose
118
+ * first input is `genesisOutpoint` and whose authorized outputs are `authOutputs`. Byte-exact with
119
+ * consensus. Used to:
120
+ * - bind the curve `C` ↔ its token `A` (curve_cp `init`),
121
+ * - pre-compute the pool covenant-id `P` a graduation will assign,
122
+ * - derive a freshly-created covenant's own id client-side before broadcast.
123
+ */
124
+ declare function genesisCovenantId(k: K$6, genesisOutpoint: GenesisOutpoint, authOutputs: AuthOutput[]): string;
125
+ /** Covenant-ids are byte[32] in the covenants; convert between the hex form and bytes for state encoding. */
126
+ declare const covidToBytes: (covidHex: string) => Uint8Array;
127
+ declare const bytesToCovid: (u8: Uint8Array) => string;
128
+ /** The all-zero covenant-id placeholder (a curve's `tokenCovid` before `init` binds it; ZERO_COVID). */
129
+ declare const ZERO_COVID: string;
130
+
131
+ type genesis_AuthOutput = AuthOutput;
132
+ type genesis_GenesisOutpoint = GenesisOutpoint;
133
+ declare const genesis_ZERO_COVID: typeof ZERO_COVID;
134
+ declare const genesis_bytesToCovid: typeof bytesToCovid;
135
+ declare const genesis_covidToBytes: typeof covidToBytes;
136
+ declare const genesis_genesisCovenantId: typeof genesisCovenantId;
137
+ declare namespace genesis {
138
+ export { type genesis_AuthOutput as AuthOutput, type genesis_GenesisOutpoint as GenesisOutpoint, genesis_ZERO_COVID as ZERO_COVID, genesis_bytesToCovid as bytesToCovid, genesis_covidToBytes as covidToBytes, genesis_genesisCovenantId as genesisCovenantId };
139
+ }
140
+
141
+ type K$5 = Kaspa;
142
+ type Spk$4 = any;
143
+ /** A covenant UTXO being spent, already carrying its signature script (no wallet signature needed). */
144
+ type CovInput = {
145
+ transactionId: string;
146
+ index: number;
147
+ value: bigint;
148
+ scriptPublicKey: Spk$4;
149
+ /** the covenant signature script (hex): <args> [selector] <redeem>, or kcc20 <transfer args> <redeem>. */
150
+ signatureScript: string;
151
+ /** redeem script bytes (kept so a caller can re-derive / inspect the spend). */
152
+ redeem: Uint8Array;
153
+ /** what this input is, for assembly/debugging: 'curve' | 'minterBranch' | 'burn' | 'pool' | 'poolToken'. */
154
+ role: string;
155
+ };
156
+ /** A covenant-required output (value + scriptPublicKey). */
157
+ type CovOutput = {
158
+ value: bigint;
159
+ scriptPublicKey: Spk$4;
160
+ role: string;
161
+ };
162
+ /** A complete covenant action: the inputs it spends + the outputs it must create + computed economics. */
163
+ type CovenantSpend = {
164
+ kind: 'init' | 'initVested' | 'buy' | 'sell' | 'graduate' | 'swapKasForToken' | 'swapTokenForKas' | 'addLiquidity' | 'removeLiquidity' | 'bindLp' | 'claim' | 'claimFinal';
165
+ inputs: CovInput[];
166
+ outputs: CovOutput[];
167
+ economics: Record<string, bigint>;
168
+ /** covenant-ids this action establishes/uses (hex): the bound token `A`, a new pool `P`, the curve `C`. */
169
+ covids?: {
170
+ tokenCovid?: string;
171
+ poolCovid?: string;
172
+ curveCovid?: string;
173
+ };
174
+ };
175
+ /** A funding UTXO entry (SDK UtxoEntryReference from rpc.getUtxosByAddresses, or a plain IUtxoEntry). */
176
+ type FundingEntry = any;
177
+ type AssembledNativeTx = {
178
+ transaction: any;
179
+ /** indices of inputs the trader/wallet must sign (the covenant inputs come first and are pre-scripted). */
180
+ fundingInputIndexes: number[];
181
+ totalIn: bigint;
182
+ covenantOut: bigint;
183
+ change: bigint;
184
+ };
185
+ /**
186
+ * Assemble a complete tx: the spend's covenant inputs (pre-scripted) + the trader's funding inputs + a
187
+ * change output. `networkFee` is caller-provided (derive from the node; KIP-9 storage mass depends on
188
+ * output values, so the node confirms the exact fee/change at broadcast). Covenant inputs carry sigOpCount
189
+ * 0 (no checkSig on the accept path used here); funding inputs are signed via signFundingInputs.
190
+ */
191
+ declare function assembleNativeTx(k: K$5, opts: {
192
+ spend: CovenantSpend;
193
+ fundingEntries: FundingEntry[];
194
+ changeAddress: string;
195
+ networkFee: bigint;
196
+ }): AssembledNativeTx;
197
+ /** Sign the trader's funding inputs (P2PK) in place; covenant inputs are left untouched (pre-scripted). */
198
+ declare function signFundingInputs(k: K$5, tx: any, privKey: any, fundingInputIndexes: number[]): any;
199
+ /**
200
+ * Shape the assembled tx for a signPskt-style wallet bridge. Returns the tx JSON the wallet deserializes
201
+ * plus the inputs it should sign (the trader's P2PK funding inputs only).
202
+ */
203
+ declare function toPsktJson(asm: AssembledNativeTx, sighashType?: number): {
204
+ txJsonString: string;
205
+ signInputs: {
206
+ index: number;
207
+ sighashType: number;
208
+ }[];
209
+ };
210
+ /**
211
+ * The local side of a signPskt-style wallet bridge: deserialize a tx (Safe JSON), sign ONLY the listed
212
+ * inputs with `privKey` (the user's P2PK inputs — funding, or the co-present presence input that authorizes
213
+ * a sell/transfer of an address-owned token), reserialize to Safe JSON. Covenant inputs (not listed) are
214
+ * left untouched: their transition rules — or the presence-based ownership check against a co-present
215
+ * signed P2PK input — authorize them, so the wallet never signs a covenant P2SH input directly. This is
216
+ * exactly what an extension wallet's native `signPskt({ txJsonString, options: { signInputs } })` does; use
217
+ * this function to emulate that bridge with a raw key (e.g. for a backend bot holding its own key).
218
+ */
219
+ declare function signPsktWithKey(k: K$5, txJsonString: string, signInputs: {
220
+ index: number;
221
+ }[], privKey: any): string;
222
+
223
+ type spend_AssembledNativeTx = AssembledNativeTx;
224
+ type spend_CovInput = CovInput;
225
+ type spend_CovOutput = CovOutput;
226
+ type spend_CovenantSpend = CovenantSpend;
227
+ type spend_FundingEntry = FundingEntry;
228
+ declare const spend_assembleNativeTx: typeof assembleNativeTx;
229
+ declare const spend_signFundingInputs: typeof signFundingInputs;
230
+ declare const spend_signPsktWithKey: typeof signPsktWithKey;
231
+ declare const spend_toPsktJson: typeof toPsktJson;
232
+ declare namespace spend {
233
+ export { type spend_AssembledNativeTx as AssembledNativeTx, type spend_CovInput as CovInput, type spend_CovOutput as CovOutput, type spend_CovenantSpend as CovenantSpend, type spend_FundingEntry as FundingEntry, spend_assembleNativeTx as assembleNativeTx, spend_signFundingInputs as signFundingInputs, spend_signPsktWithKey as signPsktWithKey, spend_toPsktJson as toPsktJson };
234
+ }
235
+
236
+ type K$4 = Kaspa;
237
+ type Spk$3 = any;
238
+ /** kcc20 identifierType (ownership mode) values — dispatched by `transfer`'s checkSigs. */
239
+ declare const IDENTIFIER: {
240
+ readonly PUBKEY: 0;
241
+ readonly SCRIPT_HASH: 1;
242
+ readonly COVENANT_ID: 2;
243
+ readonly ADDRESS: 3;
244
+ };
245
+ type IdentifierType = (typeof IDENTIFIER)[keyof typeof IDENTIFIER];
246
+ /** A kcc20 token balance's full state (the 4 reference fields). `ownerIdentifier` is 32 bytes. */
247
+ type Kcc20State = {
248
+ ownerIdentifier: Uint8Array;
249
+ identifierType: IdentifierType;
250
+ amount: bigint;
251
+ isMinter: boolean;
252
+ };
253
+ /** Compiled token template: silverc output at the genesis state + the (maxIns,maxOuts) it was built for. */
254
+ type Kcc20Template = {
255
+ script: Uint8Array;
256
+ stateStart: number;
257
+ maxIns: number;
258
+ maxOuts: number;
259
+ };
260
+ /** Produce the kcc20 redeem script for `state` by splicing the 46-byte region. Byte-identical to silverc. */
261
+ declare function materializeKcc20Script(tpl: Kcc20Template, state: Kcc20State): Uint8Array;
262
+ /** Token P2SH scriptPublicKey for a redeem script. */
263
+ declare const kcc20Spk: (k: K$4, redeem: Uint8Array) => Spk$3;
264
+ /** Token P2SH scriptPublicKey for a balance state (materialize → P2SH). */
265
+ declare const kcc20SpkForState: (k: K$4, tpl: Kcc20Template, state: Kcc20State) => Spk$3;
266
+ /** Token P2SH address (where this balance lives) for a balance state. */
267
+ declare function kcc20Address(k: K$4, tpl: Kcc20Template, state: Kcc20State, network: string): string;
268
+ /** A balance owned by a covenant-id `C` (mode 0x02): spendable only in a tx that also spends an input
269
+ * carrying `C`. This is how the curve owns its minter branch and the pool owns its token UTXO. */
270
+ declare const covenantIdOwned: (covid32: Uint8Array, amount: bigint, isMinter?: boolean) => Kcc20State;
271
+ /** A balance owned by a 32-byte x-only pubkey (mode 0x00): a user's normal holding (needs a signature). */
272
+ declare const pubkeyOwned: (pubkey32: Uint8Array, amount: bigint) => Kcc20State;
273
+ /** A balance owned by a 32-byte P2SH script-hash (mode 0x01): needs a matching P2SH input in the tx. */
274
+ declare const scriptHashOwned: (hash32: Uint8Array, amount: bigint) => Kcc20State;
275
+ /** A balance owned by a normal ADDRESS (mode 0x03, presence-based): spendable when the tx carries a
276
+ * co-present input at the owner's P2PK address (a wallet-signed input). The token UTXO itself carries NO
277
+ * signature, so sell/transfer work with existing wallets via a signPskt-style bridge. owner = x-only pubkey. */
278
+ declare const addressPresenceOwned: (pubkey32: Uint8Array, amount: bigint) => Kcc20State;
279
+ /** Push a SINGLE `State`/`TokenState` struct arg field-by-field (declared order, scalar rules) — used by
280
+ * entrypoints whose covenant takes individual structs (e.g. curve buy/sell/graduate, pool swap). */
281
+ declare function pushKcc20StateScalar(b: SigScriptBuilder, st: Kcc20State): void;
282
+ /** Push a `State[]` arg column-major (owners ‖ types ‖ amounts ‖ isMinters), per build_sig_script. */
283
+ declare function pushKcc20States(b: SigScriptBuilder, states: Kcc20State[]): void;
284
+ /**
285
+ * Build the kcc20 `transfer` signature script for a token covenant input:
286
+ * <newStates column-major> <sigs> <witnesses> <redeem> (single entrypoint → no selector)
287
+ * `witnesses[i]` is the tx-input index that authorizes input i (for covenant-id ownership, the input
288
+ * carrying that covenant id). `sigs` are 65-byte Schnorr sigs (empty for covenant-id-only ownership).
289
+ */
290
+ declare function transferSigScript(k: K$4, redeem: Uint8Array, newStates: Kcc20State[], witnesses: number[], sigs?: Uint8Array[]): string;
291
+
292
+ declare const kcc20Tx_IDENTIFIER: typeof IDENTIFIER;
293
+ type kcc20Tx_IdentifierType = IdentifierType;
294
+ type kcc20Tx_Kcc20State = Kcc20State;
295
+ type kcc20Tx_Kcc20Template = Kcc20Template;
296
+ declare const kcc20Tx_addressPresenceOwned: typeof addressPresenceOwned;
297
+ declare const kcc20Tx_covenantIdOwned: typeof covenantIdOwned;
298
+ declare const kcc20Tx_kcc20Address: typeof kcc20Address;
299
+ declare const kcc20Tx_kcc20Spk: typeof kcc20Spk;
300
+ declare const kcc20Tx_kcc20SpkForState: typeof kcc20SpkForState;
301
+ declare const kcc20Tx_materializeKcc20Script: typeof materializeKcc20Script;
302
+ declare const kcc20Tx_pubkeyOwned: typeof pubkeyOwned;
303
+ declare const kcc20Tx_pushKcc20StateScalar: typeof pushKcc20StateScalar;
304
+ declare const kcc20Tx_pushKcc20States: typeof pushKcc20States;
305
+ declare const kcc20Tx_scriptHashOwned: typeof scriptHashOwned;
306
+ declare const kcc20Tx_transferSigScript: typeof transferSigScript;
307
+ declare namespace kcc20Tx {
308
+ export { kcc20Tx_IDENTIFIER as IDENTIFIER, type kcc20Tx_IdentifierType as IdentifierType, type kcc20Tx_Kcc20State as Kcc20State, type kcc20Tx_Kcc20Template as Kcc20Template, kcc20Tx_addressPresenceOwned as addressPresenceOwned, kcc20Tx_covenantIdOwned as covenantIdOwned, kcc20Tx_kcc20Address as kcc20Address, kcc20Tx_kcc20Spk as kcc20Spk, kcc20Tx_kcc20SpkForState as kcc20SpkForState, kcc20Tx_materializeKcc20Script as materializeKcc20Script, kcc20Tx_pubkeyOwned as pubkeyOwned, kcc20Tx_pushKcc20StateScalar as pushKcc20StateScalar, kcc20Tx_pushKcc20States as pushKcc20States, kcc20Tx_scriptHashOwned as scriptHashOwned, kcc20Tx_transferSigScript as transferSigScript };
309
+ }
310
+
311
+ type K$3 = Kaspa;
312
+ type Spk$2 = any;
313
+ /** pool entrypoint selectors (declaration order in amm_pool_cp_v3.sil). */
314
+ declare const POOL_CP_SELECTOR: {
315
+ readonly swapKasForToken: 0;
316
+ readonly swapTokenForKas: 1;
317
+ readonly addLiquidity: 2;
318
+ readonly removeLiquidity: 3;
319
+ readonly bindLp: 4;
320
+ };
321
+ /** the LP-share token's FIXED total supply S_MAX (== MAX_SHARES in amm_pool_cp_v3.sil). */
322
+ declare const MAX_SHARES = 10000000n;
323
+ /** Compiled pool template (silverc output; one template per (lockedShares,bps...) — only state varies). */
324
+ type PoolCpTemplate = {
325
+ script: Uint8Array;
326
+ stateStart: number;
327
+ };
328
+ /** Pool state: KAS reserve (SCALE units; pool UTXO value == kasReserve·SCALE), token reserve, the token
329
+ * covid A, issued LP shares, and the LP-share token covid L (ZERO until bindLp). */
330
+ type PoolCpState = {
331
+ kasReserve: bigint;
332
+ tokenReserve: bigint;
333
+ tokenCovid: Uint8Array;
334
+ totalShares: bigint;
335
+ lpCovid: Uint8Array;
336
+ };
337
+ /** Produce the pool redeem script for `state` by splicing the 93-byte region. Byte-identical to silverc. */
338
+ declare function materializePoolCpScript(tpl: PoolCpTemplate, state: PoolCpState): Uint8Array;
339
+ declare const poolCpSpk: (k: K$3, redeem: Uint8Array) => Spk$2;
340
+ declare const poolCpSpkForState: (k: K$3, tpl: PoolCpTemplate, state: PoolCpState) => Spk$2;
341
+ declare function poolCpAddress(k: K$3, tpl: PoolCpTemplate, state: PoolCpState, network: string): string;
342
+ /** Fixed per-pool fee schedule (baked into the redeem script by silverc; the builder needs them for quotes). */
343
+ type PoolCpParams = {
344
+ creatorFeeOwner: Uint8Array;
345
+ platformFeeOwner: Uint8Array;
346
+ creatorFeeBps: bigint;
347
+ platformFeeBps: bigint;
348
+ lpFeeBps: bigint;
349
+ lockedShares: bigint;
350
+ };
351
+ /** The live pool UTXO (value = kasReserve·SCALE) + its P-owned token-A reserve UTXO. */
352
+ type PoolCpUtxo = {
353
+ transactionId: string;
354
+ index: number;
355
+ state: PoolCpState;
356
+ /** the pool's token-A reserve UTXO (kcc20 owned by the pool covid P, amount = tokenReserve). */
357
+ tokenUtxo: {
358
+ transactionId: string;
359
+ index: number;
360
+ value: bigint;
361
+ };
362
+ };
363
+ /** The pool's P-owned LP-share (L) inventory UTXO (amount = the unissued shares the pool holds). */
364
+ type PoolLpInventoryUtxo = {
365
+ transactionId: string;
366
+ index: number;
367
+ value: bigint;
368
+ amount: bigint;
369
+ };
370
+ type PoolCpBuyQuote = {
371
+ kasInUnits: bigint;
372
+ kasIn: bigint;
373
+ tokenOut: bigint;
374
+ creatorFee: bigint;
375
+ creatorFloorRent: bigint;
376
+ platformFee: bigint;
377
+ lpFee: bigint;
378
+ creatorOut: bigint;
379
+ platformOut: bigint;
380
+ total: bigint;
381
+ newKas: bigint;
382
+ newToken: bigint;
383
+ };
384
+ type PoolCpSellQuote = {
385
+ tokenIn: bigint;
386
+ kasOutUnits: bigint;
387
+ kasOut: bigint;
388
+ creatorFee: bigint;
389
+ creatorFloorRent: bigint;
390
+ platformFee: bigint;
391
+ lpFee: bigint;
392
+ creatorOut: bigint;
393
+ platformOut: bigint;
394
+ net: bigint;
395
+ newKas: bigint;
396
+ newToken: bigint;
397
+ };
398
+ /** Buy from the pool: spend `kasInSompi` (floored to a SCALE step) → tokenOut, retaining the voluntary LP fee in-pool. */
399
+ declare function quotePoolCpBuy(state: PoolCpState, p: PoolCpParams, kasInSompi: bigint): PoolCpBuyQuote | null;
400
+ /** Sell to the pool: fold `tokenIn` tokens in → kasOut sompi (a SCALE step), retaining the voluntary LP fee in-pool. */
401
+ declare function quotePoolCpSell(state: PoolCpState, p: PoolCpParams, tokenIn: bigint): PoolCpSellQuote | null;
402
+ type AddLiquidityQuote = {
403
+ dKas: bigint;
404
+ dToken: bigint;
405
+ dShares: bigint;
406
+ newKas: bigint;
407
+ newToken: bigint;
408
+ newShares: bigint;
409
+ };
410
+ type RemoveLiquidityQuote = {
411
+ dShares: bigint;
412
+ dKas: bigint;
413
+ dToken: bigint;
414
+ newKas: bigint;
415
+ newToken: bigint;
416
+ newShares: bigint;
417
+ };
418
+ /** The smallest deposit (in SCALE units) that mints ≥ 1 LP share at the current ratio. The covenant floors
419
+ * dShares = floor(totalShares·dKas/kasReserve), so dShares ≥ 1 ⟺ dKas ≥ ceil(kasReserve/totalShares). ANY dKas
420
+ * at/above this deposits — the old exact-integer lcm "step" (which could force a near-whole-pool minimum when the
421
+ * reserves were coprime to totalShares) is gone now that addLiquidity is floored like removeLiquidity. */
422
+ declare function addMinDKas(state: PoolCpState): bigint;
423
+ /** Clamp a desired `dKas` to a valid deposit: unchanged if ≥ the minimum (see addMinDKas), else 0 (too small to
424
+ * mint an integer share). No down-stepping — every value at/above the min is valid now that the covenant floors. */
425
+ declare function snapAddDKas(state: PoolCpState, desiredDKas: bigint): bigint;
426
+ /** Size a balanced deposit from `dKas` (SCALE units), FLOORED to match the covenant: dShares =
427
+ * floor(totalShares·dKas/kasReserve) (the depositor never gets more than their KAS-contribution fraction, so
428
+ * existing LPs aren't diluted), dToken = ceil(tokenReserve·dShares/totalShares) (they supply ≥ the proportional
429
+ * token). Any dKas ≥ addMinDKas works; throws only if dKas rounds to 0 shares. */
430
+ declare function quoteAddLiquidity(state: PoolCpState, dKas: bigint): AddLiquidityQuote;
431
+ /** The smallest withdrawable dShares — the floored covenant only needs the payout to round to ≥ 1 on BOTH sides
432
+ * (dKas ≥ 1 ⟺ dShares ≥ ⌈totalShares/kasReserve⌉; dToken ≥ 1 likewise). No exact-integer "step" exists anymore,
433
+ * so any dShares at/above this withdraws (the old lcm-step that could strand a voluntary LP is gone). */
434
+ declare function removeMinDShares(state: PoolCpState): bigint;
435
+ /** Clamp a desired `dShares` to a withdrawable amount: returns it unchanged if ≥ the minimum (see removeMinDShares),
436
+ * else 0 (too small to round to ≥ 1 of either side). No down-stepping — every value at/above the min is valid. */
437
+ declare function snapRemoveDShares(state: PoolCpState, desiredDShares: bigint): bigint;
438
+ /** Compute a FLOORED-proportional withdrawal for `dShares` (matches the covenant): dKas/dToken are floored, so
439
+ * the sub-unit remainder stays in the pool. Throws only if dShares is non-positive, would dip below the locked
440
+ * floor (totalShares − dShares < lockedShares), or is so small the floored payout rounds to < 1 of either side. */
441
+ declare function quoteRemoveLiquidity(state: PoolCpState, p: Pick<PoolCpParams, 'lockedShares'>, dShares: bigint): RemoveLiquidityQuote;
442
+ /**
443
+ * addLiquidity — deposit dKas (SCALE units) + dToken at the current ratio, receive dShares of L moved out of
444
+ * the pool's inventory. The LP must supply a token-A UTXO of EXACTLY dToken (full-UTXO deposit — the covenant
445
+ * allows only ONE covid-A output, the grown pool reserve) and a co-present P2PK input at `presenceWitnessIdx`.
446
+ *
447
+ * Inputs: [0]=pool [1]=LP token-A deposit(presence, =dToken) [2]=pool token-A reserve(P) [3]=pool L inventory(P)
448
+ * Outputs: [0]=pool(grown) [1]=pool token-A reserve(P, newToken) [2]=reduced pool L inventory(P) [3]=LP dShares(presence)
449
+ */
450
+ declare function buildAddLiquidity(k: K$3, tpl: PoolCpTemplate, tokenTpl: Kcc20Template, utxo: PoolCpUtxo, lpInventory: PoolLpInventoryUtxo, poolCovid: Uint8Array, lpDepositToken: {
451
+ transactionId: string;
452
+ index: number;
453
+ value: bigint;
454
+ state: Kcc20State;
455
+ }, lpPubkey: Uint8Array, q: AddLiquidityQuote, presenceWitnessIdx: number, opts?: {
456
+ tokenDust?: bigint;
457
+ }): CovenantSpend;
458
+ /**
459
+ * removeLiquidity — return dShares of L to the pool inventory, withdraw a strictly-proportional dKas + dToken.
460
+ * The withdrawn KAS is the tx change (the pool value drops by dKas·SCALE). The LP must supply an L UTXO of
461
+ * EXACTLY dShares (full-UTXO) and a co-present P2PK input at `presenceWitnessIdx`. The covenant floor guard
462
+ * (totalShares − dShares ≥ lockedShares) makes the graduation floor un-withdrawable.
463
+ *
464
+ * Inputs: [0]=pool [1]=pool token-A reserve(P) [2]=LP L shares(presence, =dShares)
465
+ * Outputs: [0]=pool(shrunk) [1]=pool token-A reserve(P, newToken) [2]=LP withdrawn token(presence, dToken)
466
+ * [3]=dShares returned to the pool L inventory(P)
467
+ */
468
+ declare function buildRemoveLiquidity(k: K$3, tpl: PoolCpTemplate, tokenTpl: Kcc20Template, utxo: PoolCpUtxo, lpShares: {
469
+ transactionId: string;
470
+ index: number;
471
+ value: bigint;
472
+ state: Kcc20State;
473
+ }, poolCovid: Uint8Array, lpPubkey: Uint8Array, q: RemoveLiquidityQuote, presenceWitnessIdx: number, opts?: {
474
+ tokenDust?: bigint;
475
+ }): CovenantSpend;
476
+ /** The result of buildBindLp: the spend + the freshly-derived L covid + the inventory the pool now holds. */
477
+ type BindLpResult = CovenantSpend & {
478
+ lpCovidHex: string;
479
+ lpInventoryAmount: bigint;
480
+ };
481
+ /**
482
+ * bindLp — runs once on a freshly-graduated pool (lpCovid == ZERO, totalShares == lockedShares). Genesis-mints
483
+ * the FIXED supply (MAX_SHARES) of the LP-share token L: the floor (lockedShares) is burned to an unspendable
484
+ * ZERO-covid owner, the rest (MAX_SHARES − lockedShares) seeds the pool's inventory (owned by the pool covid
485
+ * P). L carries NO minter branch → its supply is fixed forever (mint-renounced, like token A's init). The pool
486
+ * continuation carries lpCovid = the new L genesis covid; value + reserves + totalShares are unchanged.
487
+ *
488
+ * Inputs: [0]=pool (lpCovid == ZERO)
489
+ * Outputs: [0]=pool(lpCovid bound) [1]=locked floor L(ZERO-owned, lockedShares) [2]=pool L inventory(P-owned)
490
+ */
491
+ declare function buildBindLp(k: K$3, tpl: PoolCpTemplate, tokenTpl: Kcc20Template, utxo: PoolCpUtxo, poolCovid: Uint8Array, lockedShares: bigint, opts?: {
492
+ tokenDust?: bigint;
493
+ }): BindLpResult;
494
+
495
+ type poolCpTx_AddLiquidityQuote = AddLiquidityQuote;
496
+ type poolCpTx_BindLpResult = BindLpResult;
497
+ declare const poolCpTx_MAX_SHARES: typeof MAX_SHARES;
498
+ declare const poolCpTx_POOL_CP_SELECTOR: typeof POOL_CP_SELECTOR;
499
+ type poolCpTx_PoolCpBuyQuote = PoolCpBuyQuote;
500
+ type poolCpTx_PoolCpParams = PoolCpParams;
501
+ type poolCpTx_PoolCpSellQuote = PoolCpSellQuote;
502
+ type poolCpTx_PoolCpState = PoolCpState;
503
+ type poolCpTx_PoolCpTemplate = PoolCpTemplate;
504
+ type poolCpTx_PoolCpUtxo = PoolCpUtxo;
505
+ type poolCpTx_PoolLpInventoryUtxo = PoolLpInventoryUtxo;
506
+ type poolCpTx_RemoveLiquidityQuote = RemoveLiquidityQuote;
507
+ declare const poolCpTx_addMinDKas: typeof addMinDKas;
508
+ declare const poolCpTx_buildAddLiquidity: typeof buildAddLiquidity;
509
+ declare const poolCpTx_buildBindLp: typeof buildBindLp;
510
+ declare const poolCpTx_buildRemoveLiquidity: typeof buildRemoveLiquidity;
511
+ declare const poolCpTx_materializePoolCpScript: typeof materializePoolCpScript;
512
+ declare const poolCpTx_poolCpAddress: typeof poolCpAddress;
513
+ declare const poolCpTx_poolCpSpk: typeof poolCpSpk;
514
+ declare const poolCpTx_poolCpSpkForState: typeof poolCpSpkForState;
515
+ declare const poolCpTx_quoteAddLiquidity: typeof quoteAddLiquidity;
516
+ declare const poolCpTx_quotePoolCpBuy: typeof quotePoolCpBuy;
517
+ declare const poolCpTx_quotePoolCpSell: typeof quotePoolCpSell;
518
+ declare const poolCpTx_quoteRemoveLiquidity: typeof quoteRemoveLiquidity;
519
+ declare const poolCpTx_removeMinDShares: typeof removeMinDShares;
520
+ declare const poolCpTx_snapAddDKas: typeof snapAddDKas;
521
+ declare const poolCpTx_snapRemoveDShares: typeof snapRemoveDShares;
522
+ declare namespace poolCpTx {
523
+ export { type poolCpTx_AddLiquidityQuote as AddLiquidityQuote, type poolCpTx_BindLpResult as BindLpResult, poolCpTx_MAX_SHARES as MAX_SHARES, poolCpTx_POOL_CP_SELECTOR as POOL_CP_SELECTOR, type poolCpTx_PoolCpBuyQuote as PoolCpBuyQuote, type poolCpTx_PoolCpParams as PoolCpParams, type poolCpTx_PoolCpSellQuote as PoolCpSellQuote, type poolCpTx_PoolCpState as PoolCpState, type poolCpTx_PoolCpTemplate as PoolCpTemplate, type poolCpTx_PoolCpUtxo as PoolCpUtxo, type poolCpTx_PoolLpInventoryUtxo as PoolLpInventoryUtxo, type poolCpTx_RemoveLiquidityQuote as RemoveLiquidityQuote, poolCpTx_addMinDKas as addMinDKas, poolCpTx_buildAddLiquidity as buildAddLiquidity, poolCpTx_buildBindLp as buildBindLp, poolCpTx_buildRemoveLiquidity as buildRemoveLiquidity, poolCpTx_materializePoolCpScript as materializePoolCpScript, poolCpTx_poolCpAddress as poolCpAddress, poolCpTx_poolCpSpk as poolCpSpk, poolCpTx_poolCpSpkForState as poolCpSpkForState, poolCpTx_quoteAddLiquidity as quoteAddLiquidity, poolCpTx_quotePoolCpBuy as quotePoolCpBuy, poolCpTx_quotePoolCpSell as quotePoolCpSell, poolCpTx_quoteRemoveLiquidity as quoteRemoveLiquidity, poolCpTx_removeMinDShares as removeMinDShares, poolCpTx_snapAddDKas as snapAddDKas, poolCpTx_snapRemoveDShares as snapRemoveDShares };
524
+ }
525
+
526
+ type K$2 = Kaspa;
527
+ type Spk$1 = any;
528
+ declare const SCALE = 1000000n;
529
+ declare const SELECTOR: {
530
+ readonly init: 0;
531
+ readonly buy: 1;
532
+ readonly sell: 2;
533
+ readonly graduate: 3;
534
+ readonly initVested: 4;
535
+ };
536
+ /** Fixed per-token curve parameters (baked into the redeem script by silverc). */
537
+ type CpParams = {
538
+ creatorFeeOwner: Uint8Array;
539
+ platformFeeOwner: Uint8Array;
540
+ vKas: bigint;
541
+ graduationKas: bigint;
542
+ creatorFeeBps: bigint;
543
+ platformFeeBps: bigint;
544
+ graduationFeeBps: bigint;
545
+ };
546
+ type CpTemplate = {
547
+ script: Uint8Array;
548
+ stateStart: number;
549
+ params: CpParams;
550
+ };
551
+ type CpCurveState = {
552
+ graduated: boolean;
553
+ tokenCovid: Uint8Array;
554
+ };
555
+ /** The live curve UTXO. `realKas` (sompi) = its value = KAS raised. */
556
+ type CpCurveUtxo = {
557
+ transactionId: string;
558
+ index: number;
559
+ realKas: bigint;
560
+ state: CpCurveState;
561
+ };
562
+ /** The curve's C-owned token inventory UTXO (covid A). `amount` = tokens remaining. */
563
+ type CpInventoryUtxo = {
564
+ transactionId: string;
565
+ index: number;
566
+ value: bigint;
567
+ amount: bigint;
568
+ };
569
+ declare function materializeCpScript(tpl: CpTemplate, state: CpCurveState): Uint8Array;
570
+ declare const cpSpk: (k: K$2, redeem: Uint8Array) => Spk$1;
571
+ declare const cpSpkForState: (k: K$2, tpl: CpTemplate, state: CpCurveState) => Spk$1;
572
+ declare function cpAddress(k: K$2, tpl: CpTemplate, state: CpCurveState, network: string): string;
573
+ /** Fee output scriptPublicKey: P2PK (`<32-byte pubkey> OP_CHECKSIG`). */
574
+ declare function p2pkSpk(k: K$2, pubkey: Uint8Array): Spk$1;
575
+ declare function buildCpBuy(k: K$2, tpl: CpTemplate, tokenTpl: Kcc20Template, utxo: CpCurveUtxo, inventory: CpInventoryUtxo, curveCovid: Uint8Array, buyerPubkey: Uint8Array, kasIn: bigint, tokenOut: bigint, opts?: {
576
+ tokenDust?: bigint;
577
+ }): CovenantSpend;
578
+ declare function buildCpSell(k: K$2, tpl: CpTemplate, tokenTpl: Kcc20Template, utxo: CpCurveUtxo, sellerToken: {
579
+ transactionId: string;
580
+ index: number;
581
+ value: bigint;
582
+ state: Kcc20State;
583
+ }, inventory: CpInventoryUtxo, curveCovid: Uint8Array, tokenIn: bigint, kasOut: bigint, presenceWitnessIdx: number, opts?: {
584
+ tokenDust?: bigint;
585
+ }): CovenantSpend;
586
+ declare function buildCpGraduate(k: K$2, tpl: CpTemplate, tokenTpl: Kcc20Template, poolTemplate: PoolCpTemplate, utxo: CpCurveUtxo, inventory: CpInventoryUtxo, curveCovid: Uint8Array, poolLockedShares: bigint, opts?: {
587
+ lockedCurveValue?: bigint;
588
+ tokenDust?: bigint;
589
+ }): CovenantSpend;
590
+ /**
591
+ * Split a presence-owned token UTXO into [sellAmount, change], both still presence-owned by the same holder —
592
+ * a plain conserving kcc20 transfer authorized by a co-present P2PK input at `presenceWitnessIdx`. Lets a
593
+ * holder sell an ARBITRARY amount on covenants that require full-UTXO sells (curve/pool): split, then sell the
594
+ * `sellAmount` piece. No curve/pool involved — just the token covenant.
595
+ */
596
+ declare function buildSplitToken(k: K$2, tokenTpl: Kcc20Template, sellerToken: {
597
+ transactionId: string;
598
+ index: number;
599
+ value: bigint;
600
+ state: Kcc20State;
601
+ }, sellAmount: bigint, presenceWitnessIdx: number, opts?: {
602
+ tokenDust?: bigint;
603
+ }): CovenantSpend;
604
+ /**
605
+ * Consolidate several presence-owned token UTXOs (same owner) into ONE — a conserving kcc20 transfer (N covid-A
606
+ * inputs → 1 output) authorized by a single co-present P2PK input at `presenceWitnessIdx`. Lets a holder merge
607
+ * many small buys into one piece so a later sell needs just one (or two) inputs. No curve/pool involved.
608
+ */
609
+ declare function buildConsolidate(k: K$2, tokenTpl: Kcc20Template, tokens: {
610
+ transactionId: string;
611
+ index: number;
612
+ value: bigint;
613
+ state: Kcc20State;
614
+ }[], presenceWitnessIdx: number, opts?: {
615
+ tokenDust?: bigint;
616
+ }): CovenantSpend;
617
+
618
+ type curveCpTx_CpCurveState = CpCurveState;
619
+ type curveCpTx_CpCurveUtxo = CpCurveUtxo;
620
+ type curveCpTx_CpInventoryUtxo = CpInventoryUtxo;
621
+ type curveCpTx_CpParams = CpParams;
622
+ type curveCpTx_CpTemplate = CpTemplate;
623
+ declare const curveCpTx_SCALE: typeof SCALE;
624
+ declare const curveCpTx_SELECTOR: typeof SELECTOR;
625
+ declare const curveCpTx_buildConsolidate: typeof buildConsolidate;
626
+ declare const curveCpTx_buildCpBuy: typeof buildCpBuy;
627
+ declare const curveCpTx_buildCpGraduate: typeof buildCpGraduate;
628
+ declare const curveCpTx_buildCpSell: typeof buildCpSell;
629
+ declare const curveCpTx_buildSplitToken: typeof buildSplitToken;
630
+ declare const curveCpTx_cpAddress: typeof cpAddress;
631
+ declare const curveCpTx_cpSpk: typeof cpSpk;
632
+ declare const curveCpTx_cpSpkForState: typeof cpSpkForState;
633
+ declare const curveCpTx_materializeCpScript: typeof materializeCpScript;
634
+ declare const curveCpTx_p2pkSpk: typeof p2pkSpk;
635
+ declare namespace curveCpTx {
636
+ export { type curveCpTx_CpCurveState as CpCurveState, type curveCpTx_CpCurveUtxo as CpCurveUtxo, type curveCpTx_CpInventoryUtxo as CpInventoryUtxo, type curveCpTx_CpParams as CpParams, type curveCpTx_CpTemplate as CpTemplate, curveCpTx_SCALE as SCALE, curveCpTx_SELECTOR as SELECTOR, curveCpTx_buildConsolidate as buildConsolidate, curveCpTx_buildCpBuy as buildCpBuy, curveCpTx_buildCpGraduate as buildCpGraduate, curveCpTx_buildCpSell as buildCpSell, curveCpTx_buildSplitToken as buildSplitToken, curveCpTx_cpAddress as cpAddress, curveCpTx_cpSpk as cpSpk, curveCpTx_cpSpkForState as cpSpkForState, curveCpTx_materializeCpScript as materializeCpScript, curveCpTx_p2pkSpk as p2pkSpk };
637
+ }
638
+
639
+ type K$1 = Kaspa;
640
+ type PoolCpV3Template = PoolCpTemplate;
641
+ type PoolCpV3State = PoolCpState;
642
+ type PoolV3Params = PoolCpParams;
643
+ type PoolCpV3Utxo = PoolCpUtxo;
644
+ declare const materializePoolCpV3Script: typeof materializePoolCpScript;
645
+ declare const poolCpV3Spk: (k: typeof vendor_kaspa_kaspa_js, redeem: Uint8Array) => any;
646
+ declare const poolCpV3SpkForState: (k: typeof vendor_kaspa_kaspa_js, tpl: PoolCpTemplate, state: PoolCpState) => any;
647
+ declare const poolCpV3Address: typeof poolCpAddress;
648
+ declare const quotePoolV3Buy: typeof quotePoolCpBuy;
649
+ declare const quotePoolV3Sell: typeof quotePoolCpSell;
650
+ /** v3 pool entrypoint selectors (same declaration order as v2). */
651
+ declare const POOL_V3_SELECTOR: {
652
+ readonly swapKasForToken: 0;
653
+ readonly swapTokenForKas: 1;
654
+ readonly addLiquidity: 2;
655
+ readonly removeLiquidity: 3;
656
+ readonly bindLp: 4;
657
+ };
658
+ /** swapKasForToken (v3 — MERGE): buy `q.tokenOut`, optionally merging the buyer's EXISTING token UTXO(s)
659
+ * (`mergeTokens`, presence-owned, authorized by the co-present P2PK at `presenceWitnessIdx`) into ONE trader
660
+ * output of amount `tokenOut + Σ(existing)`. With no mergeTokens it's a plain buy. Outputs: [0]=pool [1]=pool
661
+ * token(P) [2]=trader token(presence, merged) [3]=creatorFee [4]=platformFee. kcc20 conservation pins the merge. */
662
+ declare function buildPoolV3SwapKasForToken(k: K$1, tpl: PoolCpV3Template, tokenTpl: Kcc20Template, params: PoolV3Params, utxo: PoolCpV3Utxo, poolCovid: Uint8Array, traderPubkey: Uint8Array, q: PoolCpBuyQuote, mergeTokens?: {
663
+ transactionId: string;
664
+ index: number;
665
+ value: bigint;
666
+ state: Kcc20State;
667
+ }[], presenceWitnessIdx?: number, opts?: {
668
+ tokenDust?: bigint;
669
+ }): CovenantSpend;
670
+ /** swapTokenForKas (v3 — FRACTIONAL): fold `q.tokenIn` of the trader's piece(s) into the pool, getting kasOut;
671
+ * the UNSOLD remainder (Σ trader inputs − q.tokenIn) returns as ONE presence-owned change output (placed LAST).
672
+ * Outputs: [0]=pool [1]=pool token(P) [2]=creatorFee [3]=platformFee [4]=OPTIONAL trader change(presence). */
673
+ declare function buildPoolV3SwapTokenForKas(k: K$1, tpl: PoolCpV3Template, tokenTpl: Kcc20Template, params: PoolV3Params, utxo: PoolCpV3Utxo, poolCovid: Uint8Array, traderPubkey: Uint8Array, traderTokens: {
674
+ transactionId: string;
675
+ index: number;
676
+ value: bigint;
677
+ state: Kcc20State;
678
+ }[], q: PoolCpSellQuote, presenceWitnessIdx: number, opts?: {
679
+ tokenDust?: bigint;
680
+ }): CovenantSpend;
681
+
682
+ declare const poolCpV3Tx_POOL_V3_SELECTOR: typeof POOL_V3_SELECTOR;
683
+ type poolCpV3Tx_PoolCpV3State = PoolCpV3State;
684
+ type poolCpV3Tx_PoolCpV3Template = PoolCpV3Template;
685
+ type poolCpV3Tx_PoolCpV3Utxo = PoolCpV3Utxo;
686
+ type poolCpV3Tx_PoolV3Params = PoolV3Params;
687
+ declare const poolCpV3Tx_buildPoolV3SwapKasForToken: typeof buildPoolV3SwapKasForToken;
688
+ declare const poolCpV3Tx_buildPoolV3SwapTokenForKas: typeof buildPoolV3SwapTokenForKas;
689
+ declare const poolCpV3Tx_materializePoolCpV3Script: typeof materializePoolCpV3Script;
690
+ declare const poolCpV3Tx_poolCpV3Address: typeof poolCpV3Address;
691
+ declare const poolCpV3Tx_poolCpV3Spk: typeof poolCpV3Spk;
692
+ declare const poolCpV3Tx_poolCpV3SpkForState: typeof poolCpV3SpkForState;
693
+ declare const poolCpV3Tx_quotePoolV3Buy: typeof quotePoolV3Buy;
694
+ declare const poolCpV3Tx_quotePoolV3Sell: typeof quotePoolV3Sell;
695
+ declare namespace poolCpV3Tx {
696
+ export { poolCpV3Tx_POOL_V3_SELECTOR as POOL_V3_SELECTOR, type poolCpV3Tx_PoolCpV3State as PoolCpV3State, type poolCpV3Tx_PoolCpV3Template as PoolCpV3Template, type poolCpV3Tx_PoolCpV3Utxo as PoolCpV3Utxo, type poolCpV3Tx_PoolV3Params as PoolV3Params, poolCpV3Tx_buildPoolV3SwapKasForToken as buildPoolV3SwapKasForToken, poolCpV3Tx_buildPoolV3SwapTokenForKas as buildPoolV3SwapTokenForKas, poolCpV3Tx_materializePoolCpV3Script as materializePoolCpV3Script, poolCpV3Tx_poolCpV3Address as poolCpV3Address, poolCpV3Tx_poolCpV3Spk as poolCpV3Spk, poolCpV3Tx_poolCpV3SpkForState as poolCpV3SpkForState, poolCpV3Tx_quotePoolV3Buy as quotePoolV3Buy, poolCpV3Tx_quotePoolV3Sell as quotePoolV3Sell };
697
+ }
698
+
699
+ type K = Kaspa;
700
+ type Spk = any;
701
+ declare const VEST_SELECTOR: {
702
+ readonly claim: 0;
703
+ readonly claimFinal: 1;
704
+ };
705
+ /** Tokens vested by DAA score `daaScore` (linear from startScore over durationScore; capped at total). Mirrors
706
+ * the covenant's cross-multiplied bound exactly, so the flow can offer `vested − claimed` to claim. */
707
+ declare function vestedAmount(total: bigint, startScore: number, durationScore: number, daaScore: number): bigint;
708
+ /** Fixed per-token vesting parameters (baked into the lock script by silverc). */
709
+ type VestingParams = {
710
+ creatorIdentifier: string;
711
+ total: number;
712
+ startScore: number;
713
+ durationScore: number;
714
+ };
715
+ type VestingTemplate = {
716
+ script: Uint8Array;
717
+ stateStart: number;
718
+ stateLen: number;
719
+ params: VestingParams;
720
+ };
721
+ declare function materializeVestingScript(tpl: VestingTemplate, claimed: bigint): Uint8Array;
722
+ declare const vestingSpk: (k: K, redeem: Uint8Array) => Spk;
723
+ declare const vestingSpkForState: (k: K, tpl: VestingTemplate, claimed: bigint) => Spk;
724
+ type VestUtxo = {
725
+ transactionId: string;
726
+ index: number;
727
+ value: bigint;
728
+ };
729
+ /**
730
+ * Partial claim: release `release` (0 < release < remaining) to the creator's presence, re-lock the rest under
731
+ * V. inputs [vesting(0), lockedToken(1)]; outputs [vesting cont(0), relock(1, A/V-owned), recipient(2, A/creator)].
732
+ * The flow must set tx.lockTime = current DAA score (consensus blocks the tx until then; the covenant reads it).
733
+ */
734
+ declare function buildVestingClaim(k: K, vestTpl: VestingTemplate, tokenTpl: Kcc20Template, vestingUtxo: VestUtxo, lockedToken: VestUtxo, vestingCovid: Uint8Array, creatorPubkey: Uint8Array, claimed: bigint, release: bigint, opts?: {
735
+ tokenDust?: bigint;
736
+ }): CovenantSpend;
737
+ /** Final claim: once fully vested, pay ALL remaining to the creator and continue V with claimed=total (husk).
738
+ * inputs [vesting(0), lockedToken(1)]; outputs [vesting cont(0), recipient(1, A/creator)]. */
739
+ declare function buildVestingClaimFinal(k: K, vestTpl: VestingTemplate, tokenTpl: Kcc20Template, vestingUtxo: VestUtxo, lockedToken: VestUtxo, vestingCovid: Uint8Array, creatorPubkey: Uint8Array, claimed: bigint, opts?: {
740
+ tokenDust?: bigint;
741
+ }): CovenantSpend;
742
+
743
+ declare const vestingTx_VEST_SELECTOR: typeof VEST_SELECTOR;
744
+ type vestingTx_VestUtxo = VestUtxo;
745
+ type vestingTx_VestingParams = VestingParams;
746
+ type vestingTx_VestingTemplate = VestingTemplate;
747
+ declare const vestingTx_buildVestingClaim: typeof buildVestingClaim;
748
+ declare const vestingTx_buildVestingClaimFinal: typeof buildVestingClaimFinal;
749
+ declare const vestingTx_materializeVestingScript: typeof materializeVestingScript;
750
+ declare const vestingTx_vestedAmount: typeof vestedAmount;
751
+ declare const vestingTx_vestingSpk: typeof vestingSpk;
752
+ declare const vestingTx_vestingSpkForState: typeof vestingSpkForState;
753
+ declare namespace vestingTx {
754
+ export { vestingTx_VEST_SELECTOR as VEST_SELECTOR, type vestingTx_VestUtxo as VestUtxo, type vestingTx_VestingParams as VestingParams, type vestingTx_VestingTemplate as VestingTemplate, vestingTx_buildVestingClaim as buildVestingClaim, vestingTx_buildVestingClaimFinal as buildVestingClaimFinal, vestingTx_materializeVestingScript as materializeVestingScript, vestingTx_vestedAmount as vestedAmount, vestingTx_vestingSpk as vestingSpk, vestingTx_vestingSpkForState as vestingSpkForState };
755
+ }
756
+
757
+ type Provider = string;
758
+ type Connected = {
759
+ provider: Provider;
760
+ address: string;
761
+ };
762
+ /** Which of the optional signing capabilities a given adapter instance actually implements. Check this
763
+ * before relying on a method — an adapter that returns `signPskt: false` will throw if you call it anyway. */
764
+ type WalletCapabilities = {
765
+ signPskt: boolean;
766
+ getXOnlyPublicKey: boolean;
767
+ signMessage: boolean;
768
+ reconnect: boolean;
769
+ };
770
+ interface WalletAdapter {
771
+ readonly provider: Provider;
772
+ readonly label: string;
773
+ isAvailable(): boolean;
774
+ /** Which optional methods this adapter actually implements (vs. throws on call). */
775
+ capabilities(): WalletCapabilities;
776
+ /** Connect/authorize; resolves to the active kaspa:/kaspatest: address. */
777
+ connect(): Promise<string>;
778
+ /** Silently restore a prior session on page load WITHOUT prompting the user (an already-authorized
779
+ * accounts lookup with no popup, if the wallet supports one). Resolves to the address, or null if there
780
+ * is nothing to restore. */
781
+ reconnect?(): Promise<string | null>;
782
+ getAddress(): string | null;
783
+ /**
784
+ * The signPskt wallet bridge: sign ONLY the listed inputs (the user's P2PK inputs) of a tx (Safe JSON)
785
+ * and return the signed tx (Safe JSON). Covenant inputs are never signed by the wallet — their
786
+ * transition rules / presence-based ownership authorize them. This is what makes sell/transfer work with
787
+ * existing wallets without KRON ever holding a key. See ../native/spend.ts `toPsktJson`.
788
+ */
789
+ signPskt?(txJsonString: string, signInputs: {
790
+ index: number;
791
+ sighashType?: number;
792
+ }[]): Promise<string>;
793
+ /** The connected account's 32-byte x-only pubkey hex (the curve/pool fee owner at deploy, or a
794
+ * presence-owned token's owner identifier). null if unavailable. */
795
+ getXOnlyPublicKey?(): Promise<string | null>;
796
+ /** Sign a UTF-8 message with the account key (KIP-5 Kaspa message-signing scheme — see README "Message
797
+ * signing"). Returns the Schnorr signature hex + the signer's x-only pubkey hex. null if unavailable. */
798
+ signMessage?(message: string): Promise<{
799
+ signature: string;
800
+ publicKey: string;
801
+ } | null>;
802
+ disconnect(): void;
803
+ }
804
+ /** Thrown by a wallet adapter method that exists on the interface but isn't implemented by a given wallet.
805
+ * Distinct from a generic Error so callers can detect "not supported" vs. "failed". */
806
+ declare class WalletCapabilityError extends Error {
807
+ readonly provider: Provider;
808
+ readonly method: string;
809
+ constructor(provider: Provider, method: string, hint?: string);
810
+ }
811
+
812
+ /**
813
+ * ExampleWalletAdapter — a template, not a real integration. It assumes a provider shaped like:
814
+ * requestAccounts(): Promise<string[]>
815
+ * getAccounts(): Promise<string[]> // already-authorized, no popup
816
+ * signPskt({ txJsonString, options: { signInputs } }): Promise<string | { txJsonString }>
817
+ * getPublicKey(): Promise<string> // compressed hex
818
+ * signMessage(text: string): Promise<string> // KIP-5 scheme
819
+ * If your wallet's provider looks different (a different method name, a different sighash encoding, a
820
+ * different signing call shape entirely), adapt the method bodies accordingly — the `WalletAdapter`
821
+ * interface only constrains what you expose, not how you get there.
822
+ */
823
+ declare class ExampleWalletAdapter implements WalletAdapter {
824
+ readonly provider = "exampleWallet";
825
+ readonly label = "Example Wallet (template)";
826
+ private address;
827
+ isAvailable(): boolean;
828
+ capabilities(): WalletCapabilities;
829
+ connect(): Promise<string>;
830
+ reconnect(): Promise<string | null>;
831
+ getAddress(): string | null;
832
+ signPskt(txJsonString: string, signInputs: {
833
+ index: number;
834
+ sighashType?: number;
835
+ }[]): Promise<string>;
836
+ getXOnlyPublicKey(): Promise<string | null>;
837
+ signMessage(message: string): Promise<{
838
+ signature: string;
839
+ publicKey: string;
840
+ } | null>;
841
+ disconnect(): void;
842
+ }
843
+
844
+ type index$1_Connected = Connected;
845
+ type index$1_ExampleWalletAdapter = ExampleWalletAdapter;
846
+ declare const index$1_ExampleWalletAdapter: typeof ExampleWalletAdapter;
847
+ type index$1_Provider = Provider;
848
+ type index$1_WalletAdapter = WalletAdapter;
849
+ type index$1_WalletCapabilities = WalletCapabilities;
850
+ type index$1_WalletCapabilityError = WalletCapabilityError;
851
+ declare const index$1_WalletCapabilityError: typeof WalletCapabilityError;
852
+ declare namespace index$1 {
853
+ export { type index$1_Connected as Connected, index$1_ExampleWalletAdapter as ExampleWalletAdapter, type index$1_Provider as Provider, type index$1_WalletAdapter as WalletAdapter, type index$1_WalletCapabilities as WalletCapabilities, index$1_WalletCapabilityError as WalletCapabilityError };
854
+ }
855
+
856
+ type CpState = {
857
+ realKas: number;
858
+ tokenReserve: number;
859
+ graduated: boolean;
860
+ poolTokenReserve?: number;
861
+ poolKas?: number;
862
+ poolTotalShares?: number;
863
+ poolLpCovid?: string;
864
+ };
865
+ type TokenInfo = {
866
+ tick: string;
867
+ name: string;
868
+ dec: number;
869
+ max: string;
870
+ minted: string;
871
+ holderTotal: number;
872
+ covenantId: string;
873
+ curveCovenantId: string;
874
+ poolCovenantId: string | null;
875
+ graduated: boolean;
876
+ tokenReserve: string;
877
+ cpState: CpState;
878
+ price?: number;
879
+ change24h?: number;
880
+ volume24h?: number;
881
+ volumeTotal?: number;
882
+ trades24h?: number;
883
+ tradesTotal?: number;
884
+ tvl?: number;
885
+ reserveKas?: string;
886
+ };
887
+ type Balance = {
888
+ tick: string;
889
+ balance: string;
890
+ dec: number;
891
+ };
892
+ type TokenUtxo = {
893
+ outpoint: {
894
+ transactionId: string;
895
+ index: number;
896
+ };
897
+ amount: string;
898
+ scriptPublicKey: string;
899
+ redeemScriptHex: string;
900
+ ownerAddress: string;
901
+ };
902
+ type PoolHead = {
903
+ pool: {
904
+ transactionId: string;
905
+ index: number;
906
+ };
907
+ poolToken: {
908
+ transactionId: string;
909
+ index: number;
910
+ };
911
+ reserves: {
912
+ kasReserve: string;
913
+ tokenReserve: string;
914
+ totalShares: string;
915
+ lpCovid: string | null;
916
+ };
917
+ };
918
+ type LpUtxo = {
919
+ outpoint: {
920
+ transactionId: string;
921
+ index: number;
922
+ };
923
+ amount: string;
924
+ };
925
+ type LpEarnings = {
926
+ tick: string;
927
+ address: string;
928
+ earnedKas: string;
929
+ };
930
+ type IndexerInfo = {
931
+ tokenTotal: number;
932
+ daaScore: number;
933
+ synced: boolean;
934
+ network: string;
935
+ };
936
+ type Trade = Record<string, unknown>;
937
+ type Holder = {
938
+ address: string;
939
+ balance: string;
940
+ };
941
+ type Ohlc = {
942
+ t: number;
943
+ o: number;
944
+ h: number;
945
+ l: number;
946
+ c: number;
947
+ v: number;
948
+ };
949
+ declare class IndexerClient {
950
+ private baseUrl;
951
+ /** @param baseUrl e.g. 'https://idx.kron.technology/v1/kcc20' (TN10) — no default baked in; pass the
952
+ * network-appropriate URL explicitly (mainnet endpoints publish separately at launch). */
953
+ constructor(baseUrl: string);
954
+ info(): Promise<IndexerInfo>;
955
+ markets(opts?: {
956
+ kind?: 'curve' | 'pool';
957
+ }): Promise<TokenInfo[]>;
958
+ topTraders(): Promise<unknown[]>;
959
+ token(tick: string): Promise<TokenInfo>;
960
+ balance(tick: string, address: string): Promise<Balance>;
961
+ tokenlist(address: string): Promise<Balance[]>;
962
+ tokenUtxos(tick: string, address: string): Promise<TokenUtxo[]>;
963
+ holders(tick: string): Promise<Holder[]>;
964
+ trades(tick: string, opts?: {
965
+ offset?: number;
966
+ limit?: number;
967
+ }): Promise<Trade[]>;
968
+ ohlc(tick: string, opts: {
969
+ interval: string;
970
+ from?: number;
971
+ to?: number;
972
+ }): Promise<Ohlc[]>;
973
+ addressTrades(address: string): Promise<Trade[]>;
974
+ poolhead(tick: string): Promise<PoolHead>;
975
+ lpUtxos(tick: string, address: string): Promise<LpUtxo[]>;
976
+ lpEarnings(tick: string, address: string): Promise<LpEarnings>;
977
+ /**
978
+ * Subscribe to the SSE update stream (all tokens, or one if `tick` is given). Returns an unsubscribe
979
+ * function. Browser: uses the native EventSource. Node: pass an EventSource-compatible constructor (e.g.
980
+ * the `eventsource` npm package) via `EventSourceImpl` — Node has no built-in EventSource on most
981
+ * supported versions.
982
+ */
983
+ stream(onUpdate: (data: unknown) => void, opts?: {
984
+ tick?: string;
985
+ EventSourceImpl?: typeof EventSource;
986
+ }): () => void;
987
+ }
988
+
989
+ type CpCurveParamsRecord = {
990
+ creatorFeeOwner: string;
991
+ platformFeeOwner: string;
992
+ vKas: number;
993
+ graduationKas: number;
994
+ creatorFeeBps: number;
995
+ platformFeeBps: number;
996
+ graduationFeeBps: number;
997
+ dexCreatorFeeBps: number;
998
+ dexPlatformFeeBps: number;
999
+ dexLpFeeBps?: number;
1000
+ poolLockedShares?: number;
1001
+ vestingCovid?: string;
1002
+ };
1003
+ type RegistryToken = {
1004
+ tick: string;
1005
+ name: string;
1006
+ creator: string;
1007
+ txid: string;
1008
+ dec: number;
1009
+ max: string;
1010
+ description?: string;
1011
+ image?: string;
1012
+ links?: {
1013
+ website?: string;
1014
+ x?: string;
1015
+ telegram?: string;
1016
+ };
1017
+ cp: {
1018
+ curveParams: CpCurveParamsRecord;
1019
+ tokenCovid?: string;
1020
+ curveCovid?: string;
1021
+ poolCovid?: string;
1022
+ genesisTxid?: string;
1023
+ };
1024
+ chainVerified?: boolean;
1025
+ };
1026
+ declare class RegistryClient {
1027
+ private baseUrl;
1028
+ /** @param baseUrl e.g. 'https://api.kron.technology' (TN10) */
1029
+ constructor(baseUrl: string);
1030
+ tokens(): Promise<RegistryToken[]>;
1031
+ }
1032
+
1033
+ type SequencerHead = {
1034
+ head: {
1035
+ poolOutpoint: {
1036
+ transactionId: string;
1037
+ index: number;
1038
+ };
1039
+ poolTokenOutpoint: {
1040
+ transactionId: string;
1041
+ index: number;
1042
+ };
1043
+ reserves: {
1044
+ kasReserve: string;
1045
+ tokenReserve: string;
1046
+ totalShares: string;
1047
+ lpCovid: string | null;
1048
+ };
1049
+ };
1050
+ depth: number;
1051
+ };
1052
+ type SubmitResult = {
1053
+ ok: true;
1054
+ txid: string;
1055
+ position: number;
1056
+ } | {
1057
+ ok: false;
1058
+ reason: string;
1059
+ retry: boolean;
1060
+ };
1061
+ declare class SequencerClient {
1062
+ private baseUrl;
1063
+ /** @param baseUrl e.g. 'https://seq.kron.technology' (TN10) */
1064
+ constructor(baseUrl: string);
1065
+ health(): Promise<{
1066
+ ok: boolean;
1067
+ }>;
1068
+ /** The in-flight head + queue depth for a pool — use this instead of the indexer's confirmed `poolhead`
1069
+ * when the pool is busy, so you build on the latest unconfirmed state. */
1070
+ head(poolP2sh: string): Promise<SequencerHead>;
1071
+ /** Enqueue a signed swap tx built against a `head()` snapshot. A 409-shaped `{ok:false, retry:true}`
1072
+ * means `prevHead` is stale — re-fetch `head()` and rebuild. */
1073
+ submit(body: {
1074
+ pool: string;
1075
+ signedTx: string;
1076
+ prevHead: SequencerHead['head'];
1077
+ declaredReserves: {
1078
+ kasReserve: string;
1079
+ tokenReserve: string;
1080
+ totalShares: string;
1081
+ lpCovid: string | null;
1082
+ };
1083
+ }): Promise<SubmitResult>;
1084
+ /** SSE: head changes for a pool. Same Node-EventSource caveat as IndexerClient.stream. */
1085
+ events(poolP2sh: string, onEvent: (data: unknown) => void, EventSourceImpl?: typeof EventSource): () => void;
1086
+ }
1087
+
1088
+ type index_IndexerClient = IndexerClient;
1089
+ declare const index_IndexerClient: typeof IndexerClient;
1090
+ type index_RegistryClient = RegistryClient;
1091
+ declare const index_RegistryClient: typeof RegistryClient;
1092
+ type index_SequencerClient = SequencerClient;
1093
+ declare const index_SequencerClient: typeof SequencerClient;
1094
+ declare namespace index {
1095
+ export { index_IndexerClient as IndexerClient, index_RegistryClient as RegistryClient, index_SequencerClient as SequencerClient };
1096
+ }
1097
+
1098
+ export { index as client, cpCurve as curve, curveCpTx as curveCp, genesis, kcc20Tx as kcc20, poolCpTx as poolCp, poolCpV3Tx as poolCpV3, sigscript, spend, vestingTx as vesting, index$1 as wallet };