@peddles/sdk 0.2.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.
Files changed (124) hide show
  1. package/CLAUDE_PROMPT.md +159 -0
  2. package/LICENSE +21 -0
  3. package/README.md +186 -0
  4. package/dist/abis.d.ts +19 -0
  5. package/dist/abis.d.ts.map +1 -0
  6. package/dist/abis.generated.d.ts +2029 -0
  7. package/dist/abis.generated.d.ts.map +1 -0
  8. package/dist/abis.generated.js +2723 -0
  9. package/dist/abis.generated.js.map +1 -0
  10. package/dist/abis.js +19 -0
  11. package/dist/abis.js.map +1 -0
  12. package/dist/artDex.d.ts +937 -0
  13. package/dist/artDex.d.ts.map +1 -0
  14. package/dist/artDex.js +155 -0
  15. package/dist/artDex.js.map +1 -0
  16. package/dist/client.d.ts +10 -0
  17. package/dist/client.d.ts.map +1 -0
  18. package/dist/client.js +2 -0
  19. package/dist/client.js.map +1 -0
  20. package/dist/clog.d.ts +75 -0
  21. package/dist/clog.d.ts.map +1 -0
  22. package/dist/clog.js +91 -0
  23. package/dist/clog.js.map +1 -0
  24. package/dist/clogInflow.d.ts +136 -0
  25. package/dist/clogInflow.d.ts.map +1 -0
  26. package/dist/clogInflow.js +177 -0
  27. package/dist/clogInflow.js.map +1 -0
  28. package/dist/deployments.d.ts +30 -0
  29. package/dist/deployments.d.ts.map +1 -0
  30. package/dist/deployments.generated.d.ts +92 -0
  31. package/dist/deployments.generated.d.ts.map +1 -0
  32. package/dist/deployments.generated.js +93 -0
  33. package/dist/deployments.generated.js.map +1 -0
  34. package/dist/deployments.js +52 -0
  35. package/dist/deployments.js.map +1 -0
  36. package/dist/feeSplit.d.ts +54 -0
  37. package/dist/feeSplit.d.ts.map +1 -0
  38. package/dist/feeSplit.js +69 -0
  39. package/dist/feeSplit.js.map +1 -0
  40. package/dist/feeTerms.d.ts +46 -0
  41. package/dist/feeTerms.d.ts.map +1 -0
  42. package/dist/feeTerms.js +80 -0
  43. package/dist/feeTerms.js.map +1 -0
  44. package/dist/index.d.ts +102 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +108 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/launch/abi.generated.d.ts +2667 -0
  49. package/dist/launch/abi.generated.d.ts.map +1 -0
  50. package/dist/launch/abi.generated.js +2472 -0
  51. package/dist/launch/abi.generated.js.map +1 -0
  52. package/dist/launch/addresses.d.ts +24 -0
  53. package/dist/launch/addresses.d.ts.map +1 -0
  54. package/dist/launch/addresses.js +35 -0
  55. package/dist/launch/addresses.js.map +1 -0
  56. package/dist/launch/feeTerms.d.ts +52 -0
  57. package/dist/launch/feeTerms.d.ts.map +1 -0
  58. package/dist/launch/feeTerms.js +72 -0
  59. package/dist/launch/feeTerms.js.map +1 -0
  60. package/dist/launch/index.d.ts +33 -0
  61. package/dist/launch/index.d.ts.map +1 -0
  62. package/dist/launch/index.js +24 -0
  63. package/dist/launch/index.js.map +1 -0
  64. package/dist/launch/revert.d.ts +23 -0
  65. package/dist/launch/revert.d.ts.map +1 -0
  66. package/dist/launch/revert.js +169 -0
  67. package/dist/launch/revert.js.map +1 -0
  68. package/dist/launch/salt.d.ts +90 -0
  69. package/dist/launch/salt.d.ts.map +1 -0
  70. package/dist/launch/salt.js +153 -0
  71. package/dist/launch/salt.js.map +1 -0
  72. package/dist/launch/stockCall.d.ts +122 -0
  73. package/dist/launch/stockCall.d.ts.map +1 -0
  74. package/dist/launch/stockCall.js +144 -0
  75. package/dist/launch/stockCall.js.map +1 -0
  76. package/dist/launch/tickMath.d.ts +39 -0
  77. package/dist/launch/tickMath.d.ts.map +1 -0
  78. package/dist/launch/tickMath.js +109 -0
  79. package/dist/launch/tickMath.js.map +1 -0
  80. package/dist/launch/variants.d.ts +64 -0
  81. package/dist/launch/variants.d.ts.map +1 -0
  82. package/dist/launch/variants.js +131 -0
  83. package/dist/launch/variants.js.map +1 -0
  84. package/dist/launch/wethCall.d.ts +133 -0
  85. package/dist/launch/wethCall.d.ts.map +1 -0
  86. package/dist/launch/wethCall.js +173 -0
  87. package/dist/launch/wethCall.js.map +1 -0
  88. package/dist/launch/wethPlan.d.ts +71 -0
  89. package/dist/launch/wethPlan.d.ts.map +1 -0
  90. package/dist/launch/wethPlan.js +146 -0
  91. package/dist/launch/wethPlan.js.map +1 -0
  92. package/dist/perps/abi.generated.d.ts +794 -0
  93. package/dist/perps/abi.generated.d.ts.map +1 -0
  94. package/dist/perps/abi.generated.js +738 -0
  95. package/dist/perps/abi.generated.js.map +1 -0
  96. package/dist/perps/index.d.ts +160 -0
  97. package/dist/perps/index.d.ts.map +1 -0
  98. package/dist/perps/index.js +147 -0
  99. package/dist/perps/index.js.map +1 -0
  100. package/package.json +105 -0
  101. package/src/abis.generated.ts +2738 -0
  102. package/src/abis.ts +35 -0
  103. package/src/artDex.ts +254 -0
  104. package/src/client.ts +10 -0
  105. package/src/clog.ts +171 -0
  106. package/src/clogInflow.ts +217 -0
  107. package/src/deployments.generated.ts +98 -0
  108. package/src/deployments.ts +60 -0
  109. package/src/feeSplit.ts +76 -0
  110. package/src/feeTerms.ts +137 -0
  111. package/src/index.ts +233 -0
  112. package/src/launch/abi.generated.ts +2481 -0
  113. package/src/launch/addresses.ts +58 -0
  114. package/src/launch/feeTerms.ts +93 -0
  115. package/src/launch/index.ts +93 -0
  116. package/src/launch/revert.ts +188 -0
  117. package/src/launch/salt.ts +216 -0
  118. package/src/launch/stockCall.ts +223 -0
  119. package/src/launch/tickMath.ts +139 -0
  120. package/src/launch/variants.ts +183 -0
  121. package/src/launch/wethCall.ts +240 -0
  122. package/src/launch/wethPlan.ts +257 -0
  123. package/src/perps/abi.generated.ts +741 -0
  124. package/src/perps/index.ts +263 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Salt handling for the two CREATE2 launch paths — a pure port of the web app's
3
+ * `features/launch/salt.ts`, held identical by test.
4
+ *
5
+ * ─── EVERY PEDDLES ADDRESS ENDS IN `1978` ────────────────────────────────────
6
+ * The platform contracts do, and launched tokens do too, with no option to choose
7
+ * otherwise. So there is no vanity field: a launch MINES a salt whose address
8
+ * carries the suffix, and the creator sees the address they will get.
9
+ *
10
+ * A salt does two jobs, and only one of them is the suffix:
11
+ *
12
+ * 1. It picks the address. Both contracts mix the variant AND `msg.sender`
13
+ * into it (`keccak256(abi.encode(variant, sender, salt))`), so a salt only
14
+ * ever addresses the caller's OWN CREATE2 space.
15
+ * 2. It defeats front-running. The token address is an input to the pool key,
16
+ * so anyone who can predict it can open that pool first at a price of their
17
+ * choosing — the launch then reverts `POOL_PRICE_MISMATCH`. Mining starts
18
+ * from a CSPRNG value, so the mined salt is as unguessable as a random one.
19
+ *
20
+ * ─── LOCAL DERIVATION, CONTRACT CONFIRMATION ─────────────────────────────────
21
+ * Mining computes the address locally (65,536 expected attempts is not an RPC
22
+ * job), and the plan builders then CONFIRM the candidate with the contract's own
23
+ * `getPeddlesAddress` / `predictCoin` before it is shown or submitted.
24
+ */
25
+ /** The required address suffix, lowercase hex, no `0x`. */
26
+ export declare const ADDRESS_SUFFIX = "1978";
27
+ /**
28
+ * `keccak256(abi.encode(uint8 variant, address sender, bytes32 salt))` — the
29
+ * salt binding both `PeddlesStockLaunchpad._boundSalt` and
30
+ * `PeddlesFactoryV20._boundSalt` apply.
31
+ */
32
+ export declare function boundSalt(variant: number, sender: `0x${string}`, salt: `0x${string}`): `0x${string}`;
33
+ /** Standard CREATE2: `keccak256(0xff ‖ deployer ‖ salt ‖ initCodeHash)[12:]`. */
34
+ export declare function create2Address(deployer: `0x${string}`, salt: `0x${string}`, initCodeHash: `0x${string}`): `0x${string}`;
35
+ export declare function hasSuffix(address: string, suffix?: string): boolean;
36
+ /**
37
+ * A fresh unguessable salt from the platform CSPRNG (`crypto.getRandomValues`,
38
+ * never `Math.random`): this value is the only thing standing between a launch
39
+ * and a mempool watcher who opens the pool first.
40
+ */
41
+ export declare function randomSalt(): `0x${string}`;
42
+ /** `0x00…00` — the salt a caller means by "none", still bound to the sender. */
43
+ export declare const ZERO_SALT: `0x${string}`;
44
+ export interface MineParams {
45
+ /** The contract that runs CREATE2 — the launchpad or the factory. */
46
+ readonly deployer: `0x${string}`;
47
+ /** The variant byte the contract mixes into the salt. */
48
+ readonly variant: number;
49
+ /** The `msg.sender` the contract binds the salt to — the creator, or the orchestrator. */
50
+ readonly sender: `0x${string}`;
51
+ readonly initCodeHash: `0x${string}`;
52
+ readonly suffix?: string;
53
+ /** Anything with an `aborted` flag — an `AbortSignal`, or a plain object a caller flips. */
54
+ readonly signal?: {
55
+ readonly aborted: boolean;
56
+ };
57
+ /** Called every chunk with the attempt count so far. */
58
+ readonly onProgress?: (attempts: number) => void;
59
+ /**
60
+ * Hard ceiling on attempts. A 4-hex suffix is 1 in 65,536; the default is ~60×
61
+ * that, so hitting it means something is wrong with the inputs, not bad luck,
62
+ * and the caller fails closed rather than looping forever.
63
+ */
64
+ readonly maxAttempts?: number;
65
+ }
66
+ export interface MinedSalt {
67
+ readonly salt: `0x${string}`;
68
+ /** The locally derived address. Confirm it with the contract before use. */
69
+ readonly address: `0x${string}`;
70
+ readonly attempts: number;
71
+ }
72
+ export declare class MiningAbortedError extends Error {
73
+ constructor();
74
+ }
75
+ export declare class MiningExhaustedError extends Error {
76
+ readonly attempts: number;
77
+ constructor(suffix: string, attempts: number);
78
+ }
79
+ /**
80
+ * Find a salt whose bound CREATE2 address ends in `suffix`.
81
+ *
82
+ * The hot loop works on bytes: two keccaks per attempt, preimages preallocated
83
+ * once, the suffix compared on the raw hash bytes. The winner is re-derived
84
+ * through `boundSalt` + `create2Address` before it is returned, so the fast path
85
+ * can never quietly disagree with the readable one. Runs in chunks and yields
86
+ * between them, so a caller can cancel through `signal` and a main thread keeps
87
+ * painting.
88
+ */
89
+ export declare function mineSalt(params: MineParams): Promise<MinedSalt>;
90
+ //# sourceMappingURL=salt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salt.d.ts","sourceRoot":"","sources":["../../src/launch/salt.ts"],"names":[],"mapp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C,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;;CAK5C;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAK7C;AAiBD;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAuErE"}
@@ -0,0 +1,153 @@
1
+ import { concat, encodeAbiParameters, getAddress, keccak256 } from 'viem';
2
+ /**
3
+ * Salt handling for the two CREATE2 launch paths — a pure port of the web app's
4
+ * `features/launch/salt.ts`, held identical by test.
5
+ *
6
+ * ─── EVERY PEDDLES ADDRESS ENDS IN `1978` ────────────────────────────────────
7
+ * The platform contracts do, and launched tokens do too, with no option to choose
8
+ * otherwise. So there is no vanity field: a launch MINES a salt whose address
9
+ * carries the suffix, and the creator sees the address they will get.
10
+ *
11
+ * A salt does two jobs, and only one of them is the suffix:
12
+ *
13
+ * 1. It picks the address. Both contracts mix the variant AND `msg.sender`
14
+ * into it (`keccak256(abi.encode(variant, sender, salt))`), so a salt only
15
+ * ever addresses the caller's OWN CREATE2 space.
16
+ * 2. It defeats front-running. The token address is an input to the pool key,
17
+ * so anyone who can predict it can open that pool first at a price of their
18
+ * choosing — the launch then reverts `POOL_PRICE_MISMATCH`. Mining starts
19
+ * from a CSPRNG value, so the mined salt is as unguessable as a random one.
20
+ *
21
+ * ─── LOCAL DERIVATION, CONTRACT CONFIRMATION ─────────────────────────────────
22
+ * Mining computes the address locally (65,536 expected attempts is not an RPC
23
+ * job), and the plan builders then CONFIRM the candidate with the contract's own
24
+ * `getPeddlesAddress` / `predictCoin` before it is shown or submitted.
25
+ */
26
+ /** The required address suffix, lowercase hex, no `0x`. */
27
+ export const ADDRESS_SUFFIX = '1978';
28
+ /**
29
+ * `keccak256(abi.encode(uint8 variant, address sender, bytes32 salt))` — the
30
+ * salt binding both `PeddlesStockLaunchpad._boundSalt` and
31
+ * `PeddlesFactoryV20._boundSalt` apply.
32
+ */
33
+ export function boundSalt(variant, sender, salt) {
34
+ return keccak256(encodeAbiParameters([{ type: 'uint8' }, { type: 'address' }, { type: 'bytes32' }], [variant, sender, salt]));
35
+ }
36
+ /** Standard CREATE2: `keccak256(0xff ‖ deployer ‖ salt ‖ initCodeHash)[12:]`. */
37
+ export function create2Address(deployer, salt, initCodeHash) {
38
+ const digest = keccak256(concat(['0xff', deployer, salt, initCodeHash]));
39
+ return getAddress(`0x${digest.slice(26)}`);
40
+ }
41
+ export function hasSuffix(address, suffix = ADDRESS_SUFFIX) {
42
+ return address.toLowerCase().endsWith(suffix.toLowerCase());
43
+ }
44
+ /**
45
+ * A fresh unguessable salt from the platform CSPRNG (`crypto.getRandomValues`,
46
+ * never `Math.random`): this value is the only thing standing between a launch
47
+ * and a mempool watcher who opens the pool first.
48
+ */
49
+ export function randomSalt() {
50
+ const bytes = new Uint8Array(32);
51
+ // Typed structurally: this package ships no DOM or Node lib, and both runtimes expose the same API.
52
+ const cryptoApi = globalThis.crypto;
53
+ if (!cryptoApi)
54
+ throw new Error('No CSPRNG (globalThis.crypto) is available; refusing to mine a guessable salt.');
55
+ cryptoApi.getRandomValues(bytes);
56
+ return `0x${Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')}`;
57
+ }
58
+ /** `0x00…00` — the salt a caller means by "none", still bound to the sender. */
59
+ export const ZERO_SALT = `0x${'0'.repeat(64)}`;
60
+ export class MiningAbortedError extends Error {
61
+ constructor() {
62
+ super('Address mining was cancelled.');
63
+ this.name = 'MiningAbortedError';
64
+ }
65
+ }
66
+ export class MiningExhaustedError extends Error {
67
+ attempts;
68
+ constructor(suffix, attempts) {
69
+ super(`No address ending in ${suffix} was found after ${attempts.toLocaleString()} attempts.`);
70
+ this.name = 'MiningExhaustedError';
71
+ this.attempts = attempts;
72
+ }
73
+ }
74
+ const CHUNK = 4096;
75
+ function hexToBytes(hex) {
76
+ const clean = hex.startsWith('0x') ? hex.slice(2) : hex;
77
+ const out = new Uint8Array(clean.length / 2);
78
+ for (let i = 0; i < out.length; i += 1)
79
+ out[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
80
+ return out;
81
+ }
82
+ function bytesToHex(bytes) {
83
+ let s = '0x';
84
+ for (const b of bytes)
85
+ s += b.toString(16).padStart(2, '0');
86
+ return s;
87
+ }
88
+ /**
89
+ * Find a salt whose bound CREATE2 address ends in `suffix`.
90
+ *
91
+ * The hot loop works on bytes: two keccaks per attempt, preimages preallocated
92
+ * once, the suffix compared on the raw hash bytes. The winner is re-derived
93
+ * through `boundSalt` + `create2Address` before it is returned, so the fast path
94
+ * can never quietly disagree with the readable one. Runs in chunks and yields
95
+ * between them, so a caller can cancel through `signal` and a main thread keeps
96
+ * painting.
97
+ */
98
+ export async function mineSalt(params) {
99
+ const { deployer, variant, sender, initCodeHash, suffix = ADDRESS_SUFFIX, signal, onProgress, maxAttempts = 4_000_000, } = params;
100
+ if (!/^[0-9a-fA-F]+$/.test(suffix) || suffix.length % 2 !== 0) {
101
+ throw new Error(`The address suffix must be whole hex bytes; got "${suffix}".`);
102
+ }
103
+ const want = hexToBytes(suffix);
104
+ // abi.encode(uint8 variant, address sender, bytes32 salt): three 32-byte words.
105
+ const bound = new Uint8Array(96);
106
+ bound[31] = variant & 0xff;
107
+ bound.set(hexToBytes(sender), 32 + 12);
108
+ const saltView = bound.subarray(64, 96);
109
+ saltView.set(hexToBytes(randomSalt()));
110
+ // 0xff ‖ deployer ‖ boundSalt ‖ initCodeHash.
111
+ const create2 = new Uint8Array(85);
112
+ create2[0] = 0xff;
113
+ create2.set(hexToBytes(deployer), 1);
114
+ create2.set(hexToBytes(initCodeHash), 53);
115
+ const bump = () => {
116
+ for (let i = 31; i >= 0; i -= 1) {
117
+ saltView[i] = (saltView[i] + 1) & 0xff;
118
+ if (saltView[i] !== 0)
119
+ break;
120
+ }
121
+ };
122
+ let attempts = 0;
123
+ while (attempts < maxAttempts) {
124
+ if (signal?.aborted)
125
+ throw new MiningAbortedError();
126
+ for (let i = 0; i < CHUNK && attempts < maxAttempts; i += 1) {
127
+ create2.set(keccak256(bound, 'bytes'), 21);
128
+ const digest = keccak256(create2, 'bytes');
129
+ attempts += 1;
130
+ let hit = true;
131
+ for (let j = 0; j < want.length; j += 1) {
132
+ if (digest[32 - want.length + j] !== want[j]) {
133
+ hit = false;
134
+ break;
135
+ }
136
+ }
137
+ if (hit) {
138
+ const salt = bytesToHex(saltView);
139
+ const address = create2Address(deployer, boundSalt(variant, sender, salt), initCodeHash);
140
+ if (!hasSuffix(address, suffix)) {
141
+ throw new Error('The address miner disagreed with itself; nothing was reserved.');
142
+ }
143
+ return { salt, address, attempts };
144
+ }
145
+ bump();
146
+ }
147
+ onProgress?.(attempts);
148
+ // A macrotask yield (`setTimeout(0)`), so a main-thread caller gets to paint between chunks.
149
+ await new Promise((resolve) => globalThis.setTimeout(resolve, 0));
150
+ }
151
+ throw new MiningExhaustedError(suffix, attempts);
152
+ }
153
+ //# sourceMappingURL=salt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salt.js","sourceRoot":"","sources":["../../src/launch/salt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE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AClC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;gBACzF,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;oBAChC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;gBACpF,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;YACrC,CAAC;YACD,IAAI,EAAE,CAAC;QACT,CAAC;QAED,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;QACvB,6FAA6F;QAC7F,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAE,UAA6E,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9I,CAAC;IAED,MAAM,IAAI,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,122 @@
1
+ import type { ReadClient } from '../client.js';
2
+ import type { Address, Hex } from 'viem';
3
+ import { type FeeTerms } from './feeTerms.js';
4
+ import type { UnsignedLaunchTx } from './wethCall.js';
5
+ /**
6
+ * The stock-paired launch call — `PeddlesStockLaunchpad.createCoin` (two
7
+ * overloads) or `createCoinAndBuy`. A pure port of the web app's
8
+ * `buildStockLaunchCall` (`features/launch/useStockLaunch.ts`), held identical by test.
9
+ *
10
+ * dev buy, any salt → createCoinAndBuy(name, symbol, quote, tax, excess, salt, quoteIn, minOut)
11
+ * no dev buy, vanity salt → createCoin(name, symbol, quote, tax, excess, salt)
12
+ * no dev buy, no salt → createCoin(name, symbol, quote, tax, excess) (auto-salt)
13
+ *
14
+ * Every entrypoint is payable and requires `msg.value >= launchFee`. The fee is
15
+ * READ LIVE (`readStockLaunchFee`) and attached exactly; a dev buy pulls the
16
+ * quote asset through `transferFrom`, so the launchpad must be approved first.
17
+ */
18
+ export interface StockLaunchArgs {
19
+ readonly name: string;
20
+ readonly symbol: string;
21
+ readonly quote: `0x${string}`;
22
+ /** null → the auto-salt overload. */
23
+ readonly salt: `0x${string}` | null;
24
+ /** Quote base units to spend on the dev buy. 0n → no dev buy. */
25
+ readonly quoteIn: bigint;
26
+ /** Slippage floor for the dev buy, in the launched token's base units. */
27
+ readonly minTokensOut: bigint;
28
+ /** The creator's permanent fee terms. `null` is refused, never defaulted. */
29
+ readonly feeTerms: FeeTerms | null;
30
+ }
31
+ export type StockLaunchCall = {
32
+ readonly kind: 'buy';
33
+ readonly functionName: 'createCoinAndBuy';
34
+ readonly args: readonly [string, string, `0x${string}`, number, number, `0x${string}`, bigint, bigint];
35
+ } | {
36
+ readonly kind: 'salt';
37
+ readonly functionName: 'createCoin';
38
+ readonly args: readonly [string, string, `0x${string}`, number, number, `0x${string}`];
39
+ } | {
40
+ readonly kind: 'auto';
41
+ readonly functionName: 'createCoin';
42
+ readonly args: readonly [string, string, `0x${string}`, number, number];
43
+ };
44
+ /** Why these terms cannot ride in a launch, or null when they can. */
45
+ export declare function stockLaunchTermsIssue(feeTerms: FeeTerms | null): string | null;
46
+ export declare function buildStockLaunchCall({ name, symbol, quote, salt, quoteIn, minTokensOut, feeTerms }: StockLaunchArgs): StockLaunchCall;
47
+ /** The calldata of a stock launch call. `launchFeeWei` is the live `launchFee()`, attached exactly. */
48
+ export declare function encodeStockLaunchCall(call: StockLaunchCall, launchpad: `0x${string}`, launchFeeWei: bigint): UnsignedLaunchTx;
49
+ /** ERC-20 `approve` / `allowance` — the standard shapes; the SDK's read-only `erc20Abi` carries neither. */
50
+ export declare const erc20ApprovalAbi: readonly [{
51
+ readonly type: "function";
52
+ readonly name: "approve";
53
+ readonly stateMutability: "nonpayable";
54
+ readonly inputs: readonly [{
55
+ readonly name: "spender";
56
+ readonly type: "address";
57
+ }, {
58
+ readonly name: "value";
59
+ readonly type: "uint256";
60
+ }];
61
+ readonly outputs: readonly [{
62
+ readonly type: "bool";
63
+ }];
64
+ }, {
65
+ readonly type: "function";
66
+ readonly name: "allowance";
67
+ readonly stateMutability: "view";
68
+ readonly inputs: readonly [{
69
+ readonly name: "owner";
70
+ readonly type: "address";
71
+ }, {
72
+ readonly name: "spender";
73
+ readonly type: "address";
74
+ }];
75
+ readonly outputs: readonly [{
76
+ readonly type: "uint256";
77
+ }];
78
+ }];
79
+ /** The ERC-20 approval a dev buy needs: EXACTLY `quoteIn`, never unlimited. */
80
+ export declare function encodeStockApproval(quote: `0x${string}`, launchpad: `0x${string}`, quoteIn: bigint): UnsignedLaunchTx;
81
+ /** The launchpad's current allowance on `quote` from `owner`. */
82
+ export declare function readStockAllowance(client: ReadClient, quote: Address, owner: Address, launchpad: Address): Promise<bigint>;
83
+ export interface StockLaunchFee {
84
+ /** Exact wei to attach to the launch call. */
85
+ readonly launchFee: bigint;
86
+ /** Immutable per-deployment ceiling — disclosure, not something to send. */
87
+ readonly maxLaunchFee: bigint;
88
+ }
89
+ /** The launch fee, READ FROM THE CHAIN. Owner-tunable storage under an immutable cap; never a constant. */
90
+ export declare function readStockLaunchFee(client: ReadClient, launchpad: Address): Promise<StockLaunchFee>;
91
+ export interface StockMiningInputs {
92
+ /** `COIN_VARIANT()` — the variant byte the launchpad binds into the salt. */
93
+ readonly variant: number;
94
+ /** `coinInitCodeHash(name, symbol)` — depends on the name and symbol, so a rename re-mines. */
95
+ readonly initCodeHash: Hex;
96
+ }
97
+ /** What `mineSalt` needs for a stock coin: the variant and the name/symbol-dependent init code hash. */
98
+ export declare function readStockMiningInputs(client: ReadClient, launchpad: Address, name: string, symbol: string): Promise<StockMiningInputs>;
99
+ /** The launchpad's own prediction for (creator, salt, name, symbol) — the confirmation a mined salt needs. */
100
+ export declare function predictStockCoin(client: ReadClient, launchpad: Address, creator: Address, salt: Hex, name: string, symbol: string): Promise<Address>;
101
+ /** One whitelisted quote leg, as the launchpad and its own ERC-20 describe it. */
102
+ export interface StockQuote {
103
+ readonly address: Address;
104
+ /** Position in `allQuotes` — append-ordered, the only recency signal the chain offers. */
105
+ readonly registryIndex: number;
106
+ /** On-chain symbol; `null` when the ERC-20 did not answer. Never defaulted. */
107
+ readonly symbol: string | null;
108
+ readonly name: string | null;
109
+ /** On-chain decimals; `null` when unreadable. Never defaulted. */
110
+ readonly decimals: number | null;
111
+ /** `quoteConfig.startTick` — the launch price, set by the launchpad owner. */
112
+ readonly startTick: number;
113
+ }
114
+ /**
115
+ * The stock-paired launch whitelist — READ FROM THE CHAIN (`quoteCount` / `allQuotes`,
116
+ * each gated on `quoteConfig(quote).allowed`), identity read off each ERC-20. An entry whose
117
+ * identity cannot be read is kept and marked unresolved, never dropped or defaulted.
118
+ */
119
+ export declare function readStockQuotes(client: ReadClient, launchpad: Address): Promise<readonly StockQuote[]>;
120
+ /** Whether the launchpad allows `quote` right now. */
121
+ export declare function isQuoteAllowed(client: ReadClient, launchpad: Address, quote: Address): Promise<boolean>;
122
+ //# sourceMappingURL=stockCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stockCall.d.ts","sourceRoot":"","sources":["../../src/launch/stockCall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAO,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAG9C,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,iEAAiE;IACjE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I,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1J;AAED,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAkC5G;AAED,sDAAsD;AACtD,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAG7G"}
@@ -0,0 +1,144 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { erc20Abi } from '../abis.js';
3
+ import { stockLaunchpadLaunchAbi } from './abi.generated.js';
4
+ import { validateFeeTerms } from './feeTerms.js';
5
+ /** Why these terms cannot ride in a launch, or null when they can. */
6
+ export function stockLaunchTermsIssue(feeTerms) {
7
+ if (feeTerms === null)
8
+ return 'Choose the trading fee for this token before launching.';
9
+ if (validateFeeTerms(feeTerms) !== null)
10
+ return 'The trading fee or its split is outside the range a launch can set.';
11
+ return null;
12
+ }
13
+ export function buildStockLaunchCall({ name, symbol, quote, salt, quoteIn, minTokensOut, feeTerms }) {
14
+ const issue = stockLaunchTermsIssue(feeTerms);
15
+ if (issue !== null)
16
+ throw new Error(issue);
17
+ if (feeTerms === null)
18
+ throw new Error('Choose the trading fee for this token before launching.');
19
+ if (quoteIn < 0n || minTokensOut < 0n)
20
+ throw new Error('A dev-buy amount cannot be negative.');
21
+ // uint16 on-chain; both are bounded (at most 10000) by `validateFeeTerms`, so the conversion is exact.
22
+ const tax = Number(feeTerms.taxBps);
23
+ const excess = Number(feeTerms.excessToCreatorBps);
24
+ if (quoteIn > 0n) {
25
+ return { kind: 'buy', functionName: 'createCoinAndBuy', args: [name, symbol, quote, tax, excess, salt ?? `0x${'00'.repeat(32)}`, quoteIn, minTokensOut] };
26
+ }
27
+ if (minTokensOut !== 0n)
28
+ throw new Error('Set a dev-buy amount, or clear the minimum.');
29
+ if (salt !== null) {
30
+ return { kind: 'salt', functionName: 'createCoin', args: [name, symbol, quote, tax, excess, salt] };
31
+ }
32
+ return { kind: 'auto', functionName: 'createCoin', args: [name, symbol, quote, tax, excess] };
33
+ }
34
+ /** The calldata of a stock launch call. `launchFeeWei` is the live `launchFee()`, attached exactly. */
35
+ export function encodeStockLaunchCall(call, launchpad, launchFeeWei) {
36
+ // viem selects the `createCoin` overload by argument count (5 or 6).
37
+ const data = encodeFunctionData({ abi: stockLaunchpadLaunchAbi, functionName: call.functionName, args: call.args });
38
+ return { to: launchpad, data, value: launchFeeWei };
39
+ }
40
+ /** ERC-20 `approve` / `allowance` — the standard shapes; the SDK's read-only `erc20Abi` carries neither. */
41
+ export const erc20ApprovalAbi = [
42
+ {
43
+ type: 'function',
44
+ name: 'approve',
45
+ stateMutability: 'nonpayable',
46
+ inputs: [
47
+ { name: 'spender', type: 'address' },
48
+ { name: 'value', type: 'uint256' },
49
+ ],
50
+ outputs: [{ type: 'bool' }],
51
+ },
52
+ {
53
+ type: 'function',
54
+ name: 'allowance',
55
+ stateMutability: 'view',
56
+ inputs: [
57
+ { name: 'owner', type: 'address' },
58
+ { name: 'spender', type: 'address' },
59
+ ],
60
+ outputs: [{ type: 'uint256' }],
61
+ },
62
+ ];
63
+ /** The ERC-20 approval a dev buy needs: EXACTLY `quoteIn`, never unlimited. */
64
+ export function encodeStockApproval(quote, launchpad, quoteIn) {
65
+ return { to: quote, data: encodeFunctionData({ abi: erc20ApprovalAbi, functionName: 'approve', args: [launchpad, quoteIn] }), value: 0n };
66
+ }
67
+ /** The launchpad's current allowance on `quote` from `owner`. */
68
+ export async function readStockAllowance(client, quote, owner, launchpad) {
69
+ return (await client.readContract({ address: quote, abi: erc20ApprovalAbi, functionName: 'allowance', args: [owner, launchpad] }));
70
+ }
71
+ /** The launch fee, READ FROM THE CHAIN. Owner-tunable storage under an immutable cap; never a constant. */
72
+ export async function readStockLaunchFee(client, launchpad) {
73
+ const [launchFee, maxLaunchFee] = (await client.multicall({
74
+ allowFailure: false,
75
+ contracts: [
76
+ { address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'launchFee' },
77
+ { address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'maxLaunchFee' },
78
+ ],
79
+ }));
80
+ return { launchFee, maxLaunchFee };
81
+ }
82
+ /** What `mineSalt` needs for a stock coin: the variant and the name/symbol-dependent init code hash. */
83
+ export async function readStockMiningInputs(client, launchpad, name, symbol) {
84
+ const [variant, initCodeHash] = (await client.multicall({
85
+ allowFailure: false,
86
+ contracts: [
87
+ { address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'COIN_VARIANT' },
88
+ { address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'coinInitCodeHash', args: [name, symbol] },
89
+ ],
90
+ }));
91
+ return { variant: Number(variant), initCodeHash };
92
+ }
93
+ /** The launchpad's own prediction for (creator, salt, name, symbol) — the confirmation a mined salt needs. */
94
+ export async function predictStockCoin(client, launchpad, creator, salt, name, symbol) {
95
+ return (await client.readContract({ address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'predictCoin', args: [creator, salt, name, symbol] }));
96
+ }
97
+ /**
98
+ * The stock-paired launch whitelist — READ FROM THE CHAIN (`quoteCount` / `allQuotes`,
99
+ * each gated on `quoteConfig(quote).allowed`), identity read off each ERC-20. An entry whose
100
+ * identity cannot be read is kept and marked unresolved, never dropped or defaulted.
101
+ */
102
+ export async function readStockQuotes(client, launchpad) {
103
+ const count = Number(await client.readContract({ address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'quoteCount' }));
104
+ if (count === 0)
105
+ return [];
106
+ const addresses = (await client.multicall({
107
+ allowFailure: false,
108
+ contracts: Array.from({ length: count }, (_, i) => ({ address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'allQuotes', args: [BigInt(i)] })),
109
+ }));
110
+ const configs = (await client.multicall({
111
+ allowFailure: false,
112
+ contracts: addresses.map((quote) => ({ address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'quoteConfig', args: [quote] })),
113
+ }));
114
+ const allowed = addresses.map((address, i) => ({ address, i, config: configs[i] })).filter(({ config }) => config[0]);
115
+ if (allowed.length === 0)
116
+ return [];
117
+ const identity = await client.multicall({
118
+ allowFailure: true,
119
+ contracts: allowed.flatMap(({ address }) => [
120
+ { address, abi: erc20Abi, functionName: 'symbol' },
121
+ { address, abi: erc20Abi, functionName: 'name' },
122
+ { address, abi: erc20Abi, functionName: 'decimals' },
123
+ ]),
124
+ });
125
+ return allowed.map(({ address, i, config }, k) => {
126
+ const sym = identity[k * 3];
127
+ const nm = identity[k * 3 + 1];
128
+ const dec = identity[k * 3 + 2];
129
+ return {
130
+ address,
131
+ registryIndex: i,
132
+ symbol: sym.status === 'success' ? String(sym.result) : null,
133
+ name: nm.status === 'success' ? String(nm.result) : null,
134
+ decimals: dec.status === 'success' ? Number(dec.result) : null,
135
+ startTick: Number(config[2]),
136
+ };
137
+ });
138
+ }
139
+ /** Whether the launchpad allows `quote` right now. */
140
+ export async function isQuoteAllowed(client, launchpad, quote) {
141
+ const [allowed] = (await client.readContract({ address: launchpad, abi: stockLaunchpadLaunchAbi, functionName: 'quoteConfig', args: [quote] }));
142
+ return allowed;
143
+ }
144
+ //# s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,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC9D,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAkB,EAAE,SAAkB,EAAE,KAAc;IACzF,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,uBAAuB,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAwC,CAAC;IACvL,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Uniswap v4 tick maths, in `bigint` — a pure port of the web app's
3
+ * `features/launch/tickMath.ts`.
4
+ *
5
+ * The WETH-type launch (`PeddlesLaunchOrchestratorV20.launch`) makes the CALLER do
6
+ * the pool maths: `LaunchInput` carries `sqrtPriceX96`, `tickLower`, `tickUpper`
7
+ * and `liquidity`, and the executor mints exactly the position those describe.
8
+ * Get `liquidity` one wei too high and `modifyLiquidities` reverts.
9
+ *
10
+ * - `getSqrtPriceAtTick` ← `StockTickMath.getSqrtPriceAtTick`
11
+ * - `liquidityForAmount` ← `_liquidityFor` / `_amountForLiquidity` (VerifyLive.s.sol),
12
+ * Uniswap's `getLiquidityForAmount0/1` plus the round-down
13
+ * shave the mint's round-UP demands.
14
+ *
15
+ * `number` appears nowhere below the tick index itself (`int24`). Every price and
16
+ * amount is `bigint`.
17
+ */
18
+ export declare const MIN_TICK = -887272;
19
+ export declare const MAX_TICK = 887272;
20
+ export declare const Q96: bigint;
21
+ /** `sqrt(1.0001^tick) * 2^96`, identical to the on-chain implementation. Throws on an out-of-range tick. */
22
+ export declare function getSqrtPriceAtTick(tick: number): bigint;
23
+ /** Token amount a position of `liquidity` over [sqrtA, sqrtB] costs, rounded UP — how the mint charges. */
24
+ export declare function amountForLiquidity(tokenIsCurrency0: boolean, sqrtA: bigint, sqrtB: bigint, liquidity: bigint): bigint;
25
+ export interface LiquidityQuote {
26
+ readonly liquidity: bigint;
27
+ readonly sqrtLower: bigint;
28
+ readonly sqrtUpper: bigint;
29
+ /** What the mint will actually pull, rounded up. Always <= the allocation. */
30
+ readonly amountUsed: bigint;
31
+ }
32
+ /**
33
+ * The largest liquidity whose rounded-up token requirement still fits `amount`.
34
+ * Returns `null` when no liquidity fits — the caller must then refuse the launch, never guess.
35
+ */
36
+ export declare function liquidityForAmount(tokenIsCurrency0: boolean, tickLower: number, tickUpper: number, amount: bigint): LiquidityQuote | null;
37
+ /** `sqrtPriceX96` for a token/quote pair at `startTick`, mirroring `startSqrtPriceFor`. */
38
+ export declare function startSqrtPrice(startTick: number, tokenIsCurrency0: boolean): bigint;
39
+ //# sourceMappingURL=tickMath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tickMath.d.ts","sourceRoot":"","sources":["../../src/launch/tickMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,QAAQ,UAAU,CAAC;AAChC,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,GAAG,QAAY,CAAC;AA6B7B,4GAA4G;AAC5G,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBvD;AAOD,2GAA2G;AAC3G,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,OAAO,EACzB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,MAAM,CAMR;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,OAAO,EACzB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,cAAc,GAAG,IAAI,CA0BvB;AAED,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,MAAM,CAEnF"}