@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,109 @@
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 const MIN_TICK = -887272;
19
+ export const MAX_TICK = 887272;
20
+ export const Q96 = 1n << 96n;
21
+ const UINT256_MAX = (1n << 256n) - 1n;
22
+ const UINT160_MAX = (1n << 160n) - 1n;
23
+ const UINT128_MAX = (1n << 128n) - 1n;
24
+ /** The exact magic-constant ladder from `StockTickMath`, in bit order. */
25
+ const RATIOS = [
26
+ [0x2n, 0xfff97272373d413259a46990580e213an],
27
+ [0x4n, 0xfff2e50f5f656932ef12357cf3c7fdccn],
28
+ [0x8n, 0xffe5caca7e10e4e61c3624eaa0941cd0n],
29
+ [0x10n, 0xffcb9843d60f6159c9db58835c926644n],
30
+ [0x20n, 0xff973b41fa98c081472e6896dfb254c0n],
31
+ [0x40n, 0xff2ea16466c96a3843ec78b326b52861n],
32
+ [0x80n, 0xfe5dee046a99a2a811c461f1969c3053n],
33
+ [0x100n, 0xfcbe86c7900a88aedcffc83b479aa3a4n],
34
+ [0x200n, 0xf987a7253ac413176f2b074cf7815e54n],
35
+ [0x400n, 0xf3392b0822b70005940c7a398e4b70f3n],
36
+ [0x800n, 0xe7159475a2c29b7443b29c7fa6e889d9n],
37
+ [0x1000n, 0xd097f3bdfd2022b8845ad8f792aa5825n],
38
+ [0x2000n, 0xa9f746462d870fdf8a65dc1f90e061e5n],
39
+ [0x4000n, 0x70d869a156d2a1b890bb3df62baf32f7n],
40
+ [0x8000n, 0x31be135f97d08fd981231505542fcfa6n],
41
+ [0x10000n, 0x9aa508b5b7a84e1c677de54f3e99bc9n],
42
+ [0x20000n, 0x5d6af8dedb81196699c329225ee604n],
43
+ [0x40000n, 0x2216e584f5fa1ea926041bedfe98n],
44
+ [0x80000n, 0x48a170391f7dc42444e8fa2n],
45
+ ];
46
+ /** `sqrt(1.0001^tick) * 2^96`, identical to the on-chain implementation. Throws on an out-of-range tick. */
47
+ export function getSqrtPriceAtTick(tick) {
48
+ if (!Number.isInteger(tick))
49
+ throw new Error(`tick must be an integer, got ${tick}`);
50
+ const absTick = BigInt(Math.abs(tick));
51
+ if (absTick > BigInt(MAX_TICK))
52
+ throw new Error(`tick ${tick} is outside the v4 range`);
53
+ let price = (absTick & 0x1n) !== 0n
54
+ ? 0xfffcb933bd6fad37aa2d162d1a594001n
55
+ : 0x100000000000000000000000000000000n;
56
+ for (const [bit, ratio] of RATIOS) {
57
+ if ((absTick & bit) !== 0n)
58
+ price = (price * ratio) >> 128n;
59
+ }
60
+ if (tick > 0)
61
+ price = UINT256_MAX / price;
62
+ const sqrtPriceX96 = (price >> 32n) + ((price & 0xffffffffn) === 0n ? 0n : 1n);
63
+ if (sqrtPriceX96 > UINT160_MAX)
64
+ throw new Error('sqrtPriceX96 overflowed uint160');
65
+ return sqrtPriceX96;
66
+ }
67
+ function mulDivUp(a, b, denominator) {
68
+ const product = a * b;
69
+ return product / denominator + (product % denominator === 0n ? 0n : 1n);
70
+ }
71
+ /** Token amount a position of `liquidity` over [sqrtA, sqrtB] costs, rounded UP — how the mint charges. */
72
+ export function amountForLiquidity(tokenIsCurrency0, sqrtA, sqrtB, liquidity) {
73
+ if (tokenIsCurrency0) {
74
+ const numerator = mulDivUp(liquidity << 96n, sqrtB - sqrtA, sqrtB);
75
+ return numerator / sqrtA + (numerator % sqrtA === 0n ? 0n : 1n);
76
+ }
77
+ return mulDivUp(liquidity, sqrtB - sqrtA, Q96);
78
+ }
79
+ /**
80
+ * The largest liquidity whose rounded-up token requirement still fits `amount`.
81
+ * Returns `null` when no liquidity fits — the caller must then refuse the launch, never guess.
82
+ */
83
+ export function liquidityForAmount(tokenIsCurrency0, tickLower, tickUpper, amount) {
84
+ if (amount <= 0n)
85
+ return null;
86
+ const sqrtLower = getSqrtPriceAtTick(tickLower);
87
+ const sqrtUpper = getSqrtPriceAtTick(tickUpper);
88
+ if (sqrtUpper <= sqrtLower)
89
+ return null;
90
+ let liquidity = tokenIsCurrency0
91
+ ? (amount * ((sqrtLower * sqrtUpper) / Q96)) / (sqrtUpper - sqrtLower)
92
+ : (amount * Q96) / (sqrtUpper - sqrtLower);
93
+ if (liquidity > UINT128_MAX)
94
+ liquidity = UINT128_MAX;
95
+ for (let i = 0; i < 512 && liquidity > 0n && amountForLiquidity(tokenIsCurrency0, sqrtLower, sqrtUpper, liquidity) > amount; i += 1) {
96
+ liquidity -= 1n;
97
+ }
98
+ if (liquidity === 0n)
99
+ return null;
100
+ const amountUsed = amountForLiquidity(tokenIsCurrency0, sqrtLower, sqrtUpper, liquidity);
101
+ if (amountUsed > amount)
102
+ return null;
103
+ return { liquidity, sqrtLower, sqrtUpper, amountUsed };
104
+ }
105
+ /** `sqrtPriceX96` for a token/quote pair at `startTick`, mirroring `startSqrtPriceFor`. */
106
+ export function startSqrtPrice(startTick, tokenIsCurrency0) {
107
+ return getSqrtPriceAtTick(tokenIsCurrency0 ? startTick : -startTick);
108
+ }
109
+ //# sourceMappingURL=tickMath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tickMath.js","sourceRoot":"","sources":["../../src/launch/tickMath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC;AAChC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,GAAG,CAAC;AAE7B,MAAM,WAAW,GAAG,CAAC,EAA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ClC,MAAM,UAAU,GAAG,kBAAkB,CAAC,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACzF,IAAI,UAAU,GAAG,MAAM;QAAE,OAAO,IAAI,CAAC;IAErC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACzD,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,gBAAyB;IACzE,OAAO,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { ReadClient } from '../client.js';
2
+ import type { LaunchAddresses } from './addresses.js';
3
+ /**
4
+ * The launch types the factory will take a WETH-type launch for, READ FROM THE
5
+ * CHAIN. A port of the web's `useLaunchVariants` + `variantTerms`.
6
+ *
7
+ * The factory's registry is keyed by a uint8 with no enumerator, so the whole
8
+ * id space is read in ONE multicall (`variantInfo(1..255)`, batching off). Type 0
9
+ * is the built-in type; it is never registered and launches against the
10
+ * orchestrator's own owner-set defaults, so that is what is read for it.
11
+ *
12
+ * FAIL CLOSED: any failed read makes the whole list unavailable (the multicall
13
+ * throws). A partial list is not offered.
14
+ */
15
+ /** The factory's permanently reserved asset variant. */
16
+ export declare const VARIANT_ASSET = 0;
17
+ export declare const BPS_DENOMINATOR = 10000n;
18
+ export interface VariantAllocation {
19
+ readonly liquidityBps: bigint;
20
+ readonly airdropBps: bigint;
21
+ readonly vestingBps: bigint;
22
+ readonly burnBps: bigint;
23
+ readonly clogBps: bigint;
24
+ /** Per-release cap, in bps of TOTAL supply. */
25
+ readonly clogSliceBps: bigint;
26
+ readonly clogMinIntervalSeconds: bigint;
27
+ }
28
+ export type LaunchTypeShape = 'full-liquidity' | 'clog';
29
+ export type ResolvedTerms = {
30
+ readonly ok: true;
31
+ readonly shape: LaunchTypeShape;
32
+ readonly allocation: VariantAllocation;
33
+ } | {
34
+ readonly ok: false;
35
+ readonly reason: string;
36
+ };
37
+ /** Can this split be launched and described? Mirrors what the contracts refuse. */
38
+ export declare function resolveTerms(allocation: VariantAllocation): ResolvedTerms;
39
+ /** A launch type, as the chain describes it. */
40
+ export interface LaunchVariant {
41
+ /** The factory's uint8 id. Carried into the launch; never shown as a name. */
42
+ readonly id: number;
43
+ /** Retired types stay registered but take no new launches. */
44
+ readonly enabled: boolean;
45
+ readonly allocation: VariantAllocation;
46
+ readonly terms: ResolvedTerms;
47
+ /** Null when this type can be launched on this chain right now. */
48
+ readonly refusal: string | null;
49
+ }
50
+ /** Every launch type on this chain, type 0 first, then registered ids ascending. */
51
+ export declare function readLaunchVariants(client: ReadClient, addresses: LaunchAddresses): Promise<readonly LaunchVariant[]>;
52
+ /** The public launch type names the REST API, the CLI and the widget speak. */
53
+ export type LaunchTypeName = 'standard' | 'clog' | 'stock';
54
+ /**
55
+ * The variant a public type name resolves to on this chain, or a refusal.
56
+ * `standard` is always type 0; `clog` is the ONE enabled registered clog-shaped
57
+ * type — two of them is ambiguous and is refused rather than picked between.
58
+ */
59
+ export declare function variantForType(variants: readonly LaunchVariant[], type: 'standard' | 'clog'): {
60
+ variant: LaunchVariant;
61
+ } | {
62
+ refusal: string;
63
+ };
64
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/launch/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD;;;;;;;;;;;GAWG;AAEH,wDAAwD;AACxD,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,MAAM,eAAe,SAAU,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QA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;AAE3D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAW9I"}
@@ -0,0 +1,131 @@
1
+ import { factoryAbi } from '../abis.js';
2
+ import { launchOrchestratorAbi } from './abi.generated.js';
3
+ /**
4
+ * The launch types the factory will take a WETH-type launch for, READ FROM THE
5
+ * CHAIN. A port of the web's `useLaunchVariants` + `variantTerms`.
6
+ *
7
+ * The factory's registry is keyed by a uint8 with no enumerator, so the whole
8
+ * id space is read in ONE multicall (`variantInfo(1..255)`, batching off). Type 0
9
+ * is the built-in type; it is never registered and launches against the
10
+ * orchestrator's own owner-set defaults, so that is what is read for it.
11
+ *
12
+ * FAIL CLOSED: any failed read makes the whole list unavailable (the multicall
13
+ * throws). A partial list is not offered.
14
+ */
15
+ /** The factory's permanently reserved asset variant. */
16
+ export const VARIANT_ASSET = 0;
17
+ export const BPS_DENOMINATOR = 10000n;
18
+ /** Can this split be launched and described? Mirrors what the contracts refuse. */
19
+ export function resolveTerms(allocation) {
20
+ const { liquidityBps, airdropBps, vestingBps, burnBps, clogBps, clogSliceBps, clogMinIntervalSeconds } = allocation;
21
+ const sum = liquidityBps + airdropBps + vestingBps + burnBps + clogBps;
22
+ if (sum !== BPS_DENOMINATOR) {
23
+ return { ok: false, reason: 'This launch type’s split does not add up to the whole supply, so it cannot launch.' };
24
+ }
25
+ if (liquidityBps <= 0n) {
26
+ return { ok: false, reason: 'This launch type puts nothing into the pool, so it cannot launch.' };
27
+ }
28
+ if (airdropBps !== 0n || vestingBps !== 0n || burnBps !== 0n) {
29
+ return { ok: false, reason: 'This launch type airdrops, vests or burns supply, which Peddles does not offer.' };
30
+ }
31
+ if (clogBps > 0n && (clogSliceBps <= 0n || clogMinIntervalSeconds <= 0n)) {
32
+ return { ok: false, reason: 'This launch type holds supply back with no limit on how it is sold, so it cannot launch.' };
33
+ }
34
+ return { ok: true, shape: clogBps > 0n ? 'clog' : 'full-liquidity', allocation };
35
+ }
36
+ const ZERO = '0x0000000000000000000000000000000000000000';
37
+ /** Registrable ids are 1..255; 0 is reserved for the built-in type. */
38
+ const REGISTRABLE_IDS = Array.from({ length: 255 }, (_, i) => i + 1);
39
+ function toAllocation(raw) {
40
+ return {
41
+ liquidityBps: BigInt(raw.liquidityBps),
42
+ airdropBps: BigInt(raw.airdropBps),
43
+ vestingBps: BigInt(raw.vestingBps),
44
+ burnBps: BigInt(raw.burnBps),
45
+ clogBps: BigInt(raw.clogBps),
46
+ clogSliceBps: BigInt(raw.clogSliceBps),
47
+ clogMinIntervalSeconds: BigInt(raw.clogMinInterval),
48
+ };
49
+ }
50
+ function refusalFor(enabled, terms, clogVaultReady) {
51
+ if (!enabled)
52
+ return 'This launch type is not open for new launches.';
53
+ if (!terms.ok)
54
+ return terms.reason;
55
+ if (terms.shape === 'clog' && !clogVaultReady) {
56
+ return 'This launch type withholds supply into a clog vault, and no clog vault factory is deployed on this chain.';
57
+ }
58
+ return null;
59
+ }
60
+ /** Every launch type on this chain, type 0 first, then registered ids ascending. */
61
+ export async function readLaunchVariants(client, addresses) {
62
+ const { factory, orchestrator } = addresses;
63
+ const infos = (await client.multicall({
64
+ allowFailure: false,
65
+ batchSize: 0,
66
+ contracts: REGISTRABLE_IDS.map((id) => ({ address: factory, abi: factoryAbi, functionName: 'variantInfo', args: [id] })),
67
+ }));
68
+ const registered = REGISTRABLE_IDS.map((id, i) => ({ id, info: infos[i] })).filter(({ info }) => info[0] !== ZERO);
69
+ const [defaults, allocations] = await Promise.all([
70
+ client.multicall({
71
+ allowFailure: false,
72
+ contracts: [
73
+ { address: orchestrator, abi: launchOrchestratorAbi, functionName: 'defaultLiquidityBps' },
74
+ { address: orchestrator, abi: launchOrchestratorAbi, functionName: 'defaultAirdropBps' },
75
+ { address: orchestrator, abi: launchOrchestratorAbi, functionName: 'defaultVestingBps' },
76
+ { address: orchestrator, abi: launchOrchestratorAbi, functionName: 'defaultBurnBps' },
77
+ { address: orchestrator, abi: launchOrchestratorAbi, functionName: 'clogVaultFactory' },
78
+ ],
79
+ }),
80
+ registered.length === 0
81
+ ? Promise.resolve([])
82
+ : client.multicall({
83
+ allowFailure: false,
84
+ batchSize: 0,
85
+ contracts: registered.map(({ id }) => ({ address: factory, abi: factoryAbi, functionName: 'variantAllocation', args: [id] })),
86
+ }),
87
+ ]);
88
+ const [liquidityBps, airdropBps, vestingBps, burnBps, clogVaultFactory] = defaults;
89
+ const clogVaultReady = clogVaultFactory !== ZERO && addresses.clogVaultFactory !== null;
90
+ const rows = [
91
+ {
92
+ id: VARIANT_ASSET,
93
+ enabled: true,
94
+ allocation: {
95
+ liquidityBps: BigInt(liquidityBps),
96
+ airdropBps: BigInt(airdropBps),
97
+ vestingBps: BigInt(vestingBps),
98
+ burnBps: BigInt(burnBps),
99
+ clogBps: 0n,
100
+ clogSliceBps: 0n,
101
+ clogMinIntervalSeconds: 0n,
102
+ },
103
+ },
104
+ ...registered.map(({ id, info }, i) => ({ id, enabled: info[2], allocation: toAllocation(allocations[i]) })),
105
+ ];
106
+ return rows.map((row) => {
107
+ const terms = resolveTerms(row.allocation);
108
+ return { id: row.id, enabled: row.enabled, allocation: row.allocation, terms, refusal: refusalFor(row.enabled, terms, clogVaultReady) };
109
+ });
110
+ }
111
+ /**
112
+ * The variant a public type name resolves to on this chain, or a refusal.
113
+ * `standard` is always type 0; `clog` is the ONE enabled registered clog-shaped
114
+ * type — two of them is ambiguous and is refused rather than picked between.
115
+ */
116
+ export function variantForType(variants, type) {
117
+ if (type === 'standard') {
118
+ const v = variants.find((x) => x.id === VARIANT_ASSET);
119
+ if (!v)
120
+ return { refusal: 'The built-in launch type is not available on this chain.' };
121
+ return v.refusal ? { refusal: v.refusal } : { variant: v };
122
+ }
123
+ const clogs = variants.filter((x) => x.id !== VARIANT_ASSET && x.terms.ok && x.terms.shape === 'clog' && x.enabled);
124
+ if (clogs.length === 0)
125
+ return { refusal: 'No Drip launch type is open on this chain.' };
126
+ if (clogs.length > 1)
127
+ return { refusal: 'More than one Drip launch type is open on this chain; pass the variant id explicitly.' };
128
+ const v = clogs[0];
129
+ return v.refusal ? { refusal: v.refusal } : { variant: v };
130
+ }
131
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.js","sourceRoot":"","sources":["../../src/launch/variants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D;;;;;;;;;;;GAWG;AAEH,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAO,CAAC;AAmBvC,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,UAA6B;IACxD,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,GAAG,UAAU,CAAC;IACpH,MAAM,GAAG,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;IACvE,IAAI,GAAG,KAAK,eAAe,EAAE,CAAC;QAC5B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oFAAoF,EAAE,CAAC;IACrH,CAAC;IACD,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QACvB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,mEAAmE,EAAE,CAAC;IACpG,CAAC;IACD,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,EAAE,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC7D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iFAAi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Aa,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;IACpH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAAC;IACzF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,uFAAuF,EAAE,CAAC;IAClI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IACpB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,133 @@
1
+ import type { ReadClient } from '../client.js';
2
+ import type { Address, ContractFunctionArgs, Hex } from 'viem';
3
+ import { launchOrchestratorAbi } from './abi.generated.js';
4
+ import { type FeeTerms } from './feeTerms.js';
5
+ import { type WethLaunchPlan } from './wethPlan.js';
6
+ /**
7
+ * The WETH-type launch call — `PeddlesLaunchOrchestratorV20.launch(LaunchInput)`,
8
+ * or `launchAndBuy(LaunchInput, devBuyValue, minTokensOut)` with a first buy.
9
+ * A pure port of the web app's `buildWethLaunchInput` / `buildWethLaunchCall`
10
+ * (`features/launch/useWethLaunch.ts`), held identical by test.
11
+ *
12
+ * ONE builder, every consumer: the web form, the REST API's `/prepare`, the CLI
13
+ * and the widget all sign exactly these bytes. Assembling the struct twice is how
14
+ * a form ends up simulating one transaction and sending another.
15
+ *
16
+ * `msg.value` is the orchestrator's `launchFee()` plus the first buy. The fee is read LIVE by the
17
+ * caller (it is owner-tunable beneath an immutable cap) and passed in as `launchFeeWei`; the
18
+ * orchestrator takes it off the top and reverts `LAUNCH_FEE_REQUIRED` when the value is short.
19
+ */
20
+ /** The components of the `AssetParamsV1` struct `LaunchInput.params` carries — encoded as ONE tuple. */
21
+ export declare const assetParamsV1Components: readonly [{
22
+ readonly name: "version";
23
+ readonly type: "uint8";
24
+ }, {
25
+ readonly name: "name";
26
+ readonly type: "string";
27
+ }, {
28
+ readonly name: "symbol";
29
+ readonly type: "string";
30
+ }, {
31
+ readonly name: "initialAdmin";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly name: "decimals";
35
+ readonly type: "uint8";
36
+ }];
37
+ /** On-chain metadata carried by `initCalls`. Only these writes are permitted. */
38
+ export interface WethMetadata {
39
+ readonly contractUri: string;
40
+ readonly image: string;
41
+ readonly website: string;
42
+ readonly x: string;
43
+ readonly telegram: string;
44
+ }
45
+ export declare const EMPTY_WETH_METADATA: WethMetadata;
46
+ export interface WethLaunchArgs {
47
+ readonly name: string;
48
+ readonly symbol: string;
49
+ readonly salt: `0x${string}`;
50
+ /** The wallet that will sign. The orchestrator requires `vaultInput.creator == msg.sender`. */
51
+ readonly creator: `0x${string}`;
52
+ /** The creator's permanent fee terms. `null` is refused, never defaulted. */
53
+ readonly feeTerms: FeeTerms | null;
54
+ readonly metadata: WethMetadata;
55
+ readonly plan: WethLaunchPlan;
56
+ /** Native wei spent on the first buy. 0n launches without one. */
57
+ readonly devBuyWei: bigint;
58
+ /** Slippage floor for the first buy, in the launched token's base units. 0n with no first buy. */
59
+ readonly minTokensOut: bigint;
60
+ /** The orchestrator's `launchFee()`, read from the chain. Never assumed. */
61
+ readonly launchFeeWei: bigint;
62
+ }
63
+ /**
64
+ * The metadata writes, in `initCalls` order. Empty fields are OMITTED rather than
65
+ * written as empty strings — an `extraMetadata("x", "")` entry is a permanent
66
+ * on-chain claim, and clearing it later costs another transaction.
67
+ */
68
+ export declare function buildInitCalls(metadata: WethMetadata): readonly Hex[];
69
+ /** The `LaunchInput` struct, as the generated ABI types it. */
70
+ export type WethLaunchInput = ContractFunctionArgs<typeof launchOrchestratorAbi, 'payable' | 'nonpayable', 'launch'>[0];
71
+ export type WethLaunchCall = {
72
+ readonly functionName: 'launch';
73
+ readonly input: WethLaunchInput;
74
+ readonly args: readonly [WethLaunchInput];
75
+ readonly value: bigint;
76
+ } | {
77
+ readonly functionName: 'launchAndBuy';
78
+ readonly input: WethLaunchInput;
79
+ readonly args: readonly [WethLaunchInput, bigint, bigint];
80
+ readonly value: bigint;
81
+ };
82
+ /** Why these terms cannot ride in a launch, or null when they can. */
83
+ export declare function wethLaunchTermsIssue(feeTerms: FeeTerms | null): string | null;
84
+ /** The `LaunchInput` itself. Throws when the terms are missing or out of range. */
85
+ export declare function buildWethLaunchInput(args: WethLaunchArgs, orchestrator: `0x${string}`): WethLaunchInput;
86
+ /** Assemble the exact call for a launch. `launch` without a first buy, `launchAndBuy` with one. */
87
+ export declare function buildWethLaunchCall(args: WethLaunchArgs, orchestrator: `0x${string}`): WethLaunchCall;
88
+ /** An unsigned transaction: the bytes a wallet, the CLI or an agent signs. */
89
+ export interface UnsignedLaunchTx {
90
+ readonly to: `0x${string}`;
91
+ readonly data: Hex;
92
+ /** Native wei to attach. */
93
+ readonly value: bigint;
94
+ }
95
+ /** The calldata of a WETH-type launch call. */
96
+ export declare function encodeWethLaunchCall(call: WethLaunchCall, orchestrator: `0x${string}`): UnsignedLaunchTx;
97
+ /**
98
+ * The two launch-fee reads every V20 orchestrator (`PeddlesLaunchOrchestratorV20`,
99
+ * `PeddlesNFTBondingGraduationOrchestratorV20`) exposes since 2026-09-19. Hand-written because it
100
+ * MIRRORS `PeddlesAtomicBaseV20` in `contracts/src/PeddlesV20.sol` ahead of the next ABI
101
+ * regeneration; the signatures are the same ones the stock launchpad has always had.
102
+ */
103
+ export declare const orchestratorLaunchFeeAbi: readonly [{
104
+ readonly type: "function";
105
+ readonly name: "launchFee";
106
+ readonly stateMutability: "view";
107
+ readonly inputs: readonly [];
108
+ readonly outputs: readonly [{
109
+ readonly name: "";
110
+ readonly type: "uint256";
111
+ }];
112
+ }, {
113
+ readonly type: "function";
114
+ readonly name: "maxLaunchFee";
115
+ readonly stateMutability: "view";
116
+ readonly inputs: readonly [];
117
+ readonly outputs: readonly [{
118
+ readonly name: "";
119
+ readonly type: "uint256";
120
+ }];
121
+ }];
122
+ export interface OrchestratorLaunchFee {
123
+ /** Exact wei the orchestrator takes off the top of `msg.value`. */
124
+ readonly launchFee: bigint;
125
+ /** Immutable per-deployment ceiling — disclosure, not something to send. */
126
+ readonly maxLaunchFee: bigint;
127
+ }
128
+ /**
129
+ * A V20 orchestrator's launch fee, READ FROM THE CHAIN. Owner-tunable storage under an immutable
130
+ * cap, so never a constant; a failed read throws rather than falling back to zero.
131
+ */
132
+ export declare function readOrchestratorLaunchFee(client: ReadClient, orchestrator: Address): Promise<OrchestratorLaunchFee>;
133
+ //# sourceMappingURL=wethCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wethCall.d.ts","sourceRoot":"","sources":["../../src/launch/wethCall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AAEH,wGAAwG;AACxG,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAM1B,CAAC;AAEX,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B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EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAI7E;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,eAAe,CA+DvG;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,cAAc,CAerG;AAED,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,+CAA+C;AAC/C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,GAAG,gBAAgB,CAMxG;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAG3B,CAAC;AAEX,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CASzH"}
@@ -0,0 +1,173 @@
1
+ import { encodeAbiParameters, encodeFunctionData } from 'viem';
2
+ import { launchOrchestratorAbi, tokenMetadataAbi } from './abi.generated.js';
3
+ import { validateFeeTerms } from './feeTerms.js';
4
+ import { LAUNCH_COIN_DECIMALS } from './wethPlan.js';
5
+ /**
6
+ * The WETH-type launch call — `PeddlesLaunchOrchestratorV20.launch(LaunchInput)`,
7
+ * or `launchAndBuy(LaunchInput, devBuyValue, minTokensOut)` with a first buy.
8
+ * A pure port of the web app's `buildWethLaunchInput` / `buildWethLaunchCall`
9
+ * (`features/launch/useWethLaunch.ts`), held identical by test.
10
+ *
11
+ * ONE builder, every consumer: the web form, the REST API's `/prepare`, the CLI
12
+ * and the widget all sign exactly these bytes. Assembling the struct twice is how
13
+ * a form ends up simulating one transaction and sending another.
14
+ *
15
+ * `msg.value` is the orchestrator's `launchFee()` plus the first buy. The fee is read LIVE by the
16
+ * caller (it is owner-tunable beneath an immutable cap) and passed in as `launchFeeWei`; the
17
+ * orchestrator takes it off the top and reverts `LAUNCH_FEE_REQUIRED` when the value is short.
18
+ */
19
+ /** The components of the `AssetParamsV1` struct `LaunchInput.params` carries — encoded as ONE tuple. */
20
+ export const assetParamsV1Components = [
21
+ { name: 'version', type: 'uint8' },
22
+ { name: 'name', type: 'string' },
23
+ { name: 'symbol', type: 'string' },
24
+ { name: 'initialAdmin', type: 'address' },
25
+ { name: 'decimals', type: 'uint8' },
26
+ ];
27
+ export const EMPTY_WETH_METADATA = { contractUri: '', image: '', website: '', x: '', telegram: '' };
28
+ /**
29
+ * The metadata writes, in `initCalls` order. Empty fields are OMITTED rather than
30
+ * written as empty strings — an `extraMetadata("x", "")` entry is a permanent
31
+ * on-chain claim, and clearing it later costs another transaction.
32
+ */
33
+ export function buildInitCalls(metadata) {
34
+ const calls = [];
35
+ if (metadata.contractUri.trim().length > 0) {
36
+ calls.push(encodeFunctionData({ abi: tokenMetadataAbi, functionName: 'updateContractURI', args: [metadata.contractUri.trim()] }));
37
+ }
38
+ const entries = [
39
+ ['image', metadata.image],
40
+ ['website', metadata.website],
41
+ ['x', metadata.x],
42
+ ['telegram', metadata.telegram],
43
+ ];
44
+ for (const [key, value] of entries) {
45
+ if (value.trim().length === 0)
46
+ continue;
47
+ calls.push(encodeFunctionData({ abi: tokenMetadataAbi, functionName: 'updateExtraMetadata', args: [key, value.trim()] }));
48
+ }
49
+ return calls;
50
+ }
51
+ /** Why these terms cannot ride in a launch, or null when they can. */
52
+ export function wethLaunchTermsIssue(feeTerms) {
53
+ if (feeTerms === null)
54
+ return 'Choose the trading fee for this token before launching.';
55
+ if (validateFeeTerms(feeTerms) !== null)
56
+ return 'The trading fee or its split is outside the range a launch can set.';
57
+ return null;
58
+ }
59
+ /** The `LaunchInput` itself. Throws when the terms are missing or out of range. */
60
+ export function buildWethLaunchInput(args, orchestrator) {
61
+ const { plan, feeTerms } = args;
62
+ const issue = wethLaunchTermsIssue(feeTerms);
63
+ if (issue !== null)
64
+ throw new Error(issue);
65
+ if (feeTerms === null)
66
+ throw new Error('Choose the trading fee for this token before launching.');
67
+ return {
68
+ variant: plan.variant,
69
+ salt: args.salt,
70
+ // AssetParamsV1 is a DYNAMIC STRUCT, so it must be encoded as a single tuple (with the leading
71
+ // offset word), never as a flat parameter list — the flat form reverts with EMPTY data.
72
+ params: encodeAbiParameters([{ type: 'tuple', components: assetParamsV1Components }], [{ version: 1, name: args.name, symbol: args.symbol, initialAdmin: orchestrator, decimals: LAUNCH_COIN_DECIMALS }]),
73
+ initCalls: [...buildInitCalls(args.metadata)],
74
+ vaultInput: {
75
+ // The orchestrator sets this itself and REJECTS a pre-set one, so it goes in as zero.
76
+ token: '0x0000000000000000000000000000000000000000',
77
+ creator: args.creator,
78
+ // MIRRORS THE LAUNCH TYPE the plan read from the chain; the orchestrator refuses any mismatch.
79
+ liquidityBps: plan.allocationBps.liquidity,
80
+ airdropBps: 0,
81
+ vestingBps: 0,
82
+ burnBps: 0,
83
+ vaultBps: 0,
84
+ clogBps: plan.allocationBps.clog,
85
+ airdropEnabled: false,
86
+ liquidityAmount: plan.pooledSupply,
87
+ airdropAmount: 0n,
88
+ vestingAmount: 0n,
89
+ burnAmount: 0n,
90
+ vestingStart: 0n,
91
+ vestingCliff: 5184000n,
92
+ vestingDuration: 46656000n,
93
+ airdropStartsAt: 0n,
94
+ airdropEpochLength: 864_000,
95
+ airdropEpochCount: 10,
96
+ burnStartsAt: 0n,
97
+ burnEpochLength: 864_000,
98
+ firstBurnBps: 1_000,
99
+ minVoteBps: 0,
100
+ maxVoteBps: 2_000,
101
+ defaultVoteBps: 1_000,
102
+ quoteToken: plan.quoteToken,
103
+ poolManager: plan.poolManager,
104
+ positionManager: plan.positionManager,
105
+ hook: plan.hook,
106
+ liquidityManager: plan.liquidityManager,
107
+ airdropPublisher: plan.airdropPublisher,
108
+ fee: plan.poolFeePpm,
109
+ tickSpacing: plan.tickSpacing,
110
+ },
111
+ // uint16 on-chain, bounded by `validateFeeTerms` above, so `Number` is exact.
112
+ creatorTaxBps: Number(feeTerms.taxBps),
113
+ excessToCreatorBps: Number(feeTerms.excessToCreatorBps),
114
+ factoryValue: 0n,
115
+ amountPeddles: plan.pooledSupply,
116
+ sqrtPriceX96: plan.sqrtPriceX96,
117
+ tickLower: plan.tickLower,
118
+ tickUpper: plan.tickUpper,
119
+ liquidity: plan.liquidity,
120
+ };
121
+ }
122
+ /** Assemble the exact call for a launch. `launch` without a first buy, `launchAndBuy` with one. */
123
+ export function buildWethLaunchCall(args, orchestrator) {
124
+ const input = buildWethLaunchInput(args, orchestrator);
125
+ if (args.devBuyWei < 0n || args.minTokensOut < 0n)
126
+ throw new Error('A first-buy amount cannot be negative.');
127
+ if (args.launchFeeWei < 0n)
128
+ throw new Error('The launch fee cannot be negative.');
129
+ if (args.devBuyWei === 0n) {
130
+ // A floor with nothing to spend is `NO_DEV_BUY` on-chain; refused here, never dropped.
131
+ if (args.minTokensOut !== 0n)
132
+ throw new Error('Set a first-buy amount, or clear the minimum.');
133
+ return { functionName: 'launch', input, args: [input], value: args.launchFeeWei };
134
+ }
135
+ return {
136
+ functionName: 'launchAndBuy',
137
+ input,
138
+ args: [input, args.devBuyWei, args.minTokensOut],
139
+ value: args.launchFeeWei + args.devBuyWei,
140
+ };
141
+ }
142
+ /** The calldata of a WETH-type launch call. */
143
+ export function encodeWethLaunchCall(call, orchestrator) {
144
+ const data = call.functionName === 'launchAndBuy'
145
+ ? encodeFunctionData({ abi: launchOrchestratorAbi, functionName: 'launchAndBuy', args: call.args })
146
+ : encodeFunctionData({ abi: launchOrchestratorAbi, functionName: 'launch', args: call.args });
147
+ return { to: orchestrator, data, value: call.value };
148
+ }
149
+ /**
150
+ * The two launch-fee reads every V20 orchestrator (`PeddlesLaunchOrchestratorV20`,
151
+ * `PeddlesNFTBondingGraduationOrchestratorV20`) exposes since 2026-09-19. Hand-written because it
152
+ * MIRRORS `PeddlesAtomicBaseV20` in `contracts/src/PeddlesV20.sol` ahead of the next ABI
153
+ * regeneration; the signatures are the same ones the stock launchpad has always had.
154
+ */
155
+ export const orchestratorLaunchFeeAbi = [
156
+ { type: 'function', name: 'launchFee', stateMutability: 'view', inputs: [], outputs: [{ name: '', type: 'uint256' }] },
157
+ { type: 'function', name: 'maxLaunchFee', stateMutability: 'view', inputs: [], outputs: [{ name: '', type: 'uint256' }] },
158
+ ];
159
+ /**
160
+ * A V20 orchestrator's launch fee, READ FROM THE CHAIN. Owner-tunable storage under an immutable
161
+ * cap, so never a constant; a failed read throws rather than falling back to zero.
162
+ */
163
+ export async function readOrchestratorLaunchFee(client, orchestrator) {
164
+ const [launchFee, maxLaunchFee] = (await client.multicall({
165
+ allowFailure: false,
166
+ contracts: [
167
+ { address: orchestrator, abi: orchestratorLaunchFeeAbi, functionName: 'launchFee' },
168
+ { address: orchestrator, abi: orchestratorLaunchFeeAbi, functionName: 'maxLaunchFee' },
169
+ ],
170
+ }));
171
+ return { launchFee, maxLaunchFee };
172
+ }
173
+ //# sourceMappingURL=wethCall.js.map