@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,46 @@
1
+ import type { ReadClient } from './client.js';
2
+ import type { Address, Hex } from 'viem';
3
+ /**
4
+ * A launch pool's permanent terms, read from `PeddlesFeeHook`.
5
+ *
6
+ * Every launch pool — stock-paired, WETH-paired, Clog, and both NFT graduations —
7
+ * is registered with the hook once, at launch, and nothing can change these
8
+ * afterwards. What a buyer pays is `creatorTaxBps`; `excessToCreatorBps` decides
9
+ * who receives the part above the fixed 1% (creator vs holders).
10
+ */
11
+ export interface PoolTerms {
12
+ readonly poolId: Hex;
13
+ readonly token: Address;
14
+ /** The asset the tax is charged in, and the asset holder rewards pay out in. */
15
+ readonly quote: Address;
16
+ readonly creator: Address;
17
+ /** All-in tax a trader pays, in bps (100..1000). Excludes any opening-window premium. */
18
+ readonly creatorTaxBps: number;
19
+ /** Creator's share of the tax above the fixed 1%, in bps (0..10000). The rest goes to holders. */
20
+ readonly excessToCreatorBps: number;
21
+ /** The pool's `PeddlesHolderRewards` distributor. */
22
+ readonly rewards: Address;
23
+ }
24
+ /** Why `getPoolTerms` could not answer. It never substitutes a default. */
25
+ export type PoolTermsFailure = 'legacy-fee-hook' | 'not-registered' | 'ambiguous';
26
+ export declare class PoolTermsUnavailableError extends Error {
27
+ readonly reason: PoolTermsFailure;
28
+ constructor(reason: PoolTermsFailure, message: string);
29
+ }
30
+ /**
31
+ * The launch terms of `token`'s pool on `chainId`.
32
+ *
33
+ * FINDING THE POOL. The hook is keyed by pool id, not by token, so the id comes
34
+ * from the contract that created the pool: `PeddlesStockLaunchpad.coins(token)`
35
+ * for stock-paired coins (including NFT stock graduations), and
36
+ * `PeddlesV4LiquidityExecutor.poolIdFor(token)` for WETH-paired ones. The hook's
37
+ * own record must then name this token and be registered — anything else throws.
38
+ *
39
+ * FAILS CLOSED, the same as the address book:
40
+ * - a deployment whose hook predates the fixed-terms model throws
41
+ * (`legacy-fee-hook`) — its third config field meant something else, so
42
+ * decoding it with this ABI would return a plausible, wrong number;
43
+ * - a token with no registered launch pool throws (`not-registered`).
44
+ */
45
+ export declare function getPoolTerms(client: ReadClient, chainId: number, token: Address): Promise<PoolTerms>;
46
+ //# sourceMappingURL=feeTerms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feeTerms.d.ts","sourceRoot":"","sources":["../src/feeTerms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIzC;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kGAAkG;IAClG,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAElF,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;gBACtB,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM;CAKtD;AAcD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAsE1G"}
@@ -0,0 +1,80 @@
1
+ import { feeHookAbi, liquidityExecutorAbi, stockLaunchpadAbi } from './abis.js';
2
+ import { addressOf } from './deployments.js';
3
+ export class PoolTermsUnavailableError extends Error {
4
+ reason;
5
+ constructor(reason, message) {
6
+ super(message);
7
+ this.name = 'PoolTermsUnavailableError';
8
+ this.reason = reason;
9
+ }
10
+ }
11
+ const ZERO_ID = /^0x0{64}$/i;
12
+ /**
13
+ * The launch terms of `token`'s pool on `chainId`.
14
+ *
15
+ * FINDING THE POOL. The hook is keyed by pool id, not by token, so the id comes
16
+ * from the contract that created the pool: `PeddlesStockLaunchpad.coins(token)`
17
+ * for stock-paired coins (including NFT stock graduations), and
18
+ * `PeddlesV4LiquidityExecutor.poolIdFor(token)` for WETH-paired ones. The hook's
19
+ * own record must then name this token and be registered — anything else throws.
20
+ *
21
+ * FAILS CLOSED, the same as the address book:
22
+ * - a deployment whose hook predates the fixed-terms model throws
23
+ * (`legacy-fee-hook`) — its third config field meant something else, so
24
+ * decoding it with this ABI would return a plausible, wrong number;
25
+ * - a token with no registered launch pool throws (`not-registered`).
26
+ */
27
+ export async function getPoolTerms(client, chainId, token) {
28
+ const hook = addressOf(chainId, 'PeddlesFeeHook');
29
+ const launchpad = addressOf(chainId, 'PeddlesStockLaunchpad');
30
+ const executor = addressOf(chainId, 'PeddlesV4LiquidityExecutor');
31
+ const [factory, coin, wethPoolId] = await client.multicall({
32
+ allowFailure: true,
33
+ contracts: [
34
+ { address: hook, abi: feeHookAbi, functionName: 'holderRewardsFactory' },
35
+ { address: launchpad, abi: stockLaunchpadAbi, functionName: 'coins', args: [token] },
36
+ { address: executor, abi: liquidityExecutorAbi, functionName: 'poolIdFor', args: [token] },
37
+ ],
38
+ });
39
+ // `holderRewardsFactory` exists only on the fixed-terms hook. A hook that does not
40
+ // answer it is the previous model, not a transient failure to be guessed around.
41
+ if (factory.status !== 'success' || /^0x0{40}$/i.test(factory.result)) {
42
+ throw new PoolTermsUnavailableError('legacy-fee-hook', `PeddlesFeeHook ${hook} on chain ${chainId} does not expose holderRewardsFactory(); ` +
43
+ `this deployment predates fixed launch terms, so they cannot be read from it.`);
44
+ }
45
+ const candidates = [];
46
+ if (coin.status === 'success') {
47
+ const poolId = coin.result[2];
48
+ if (!ZERO_ID.test(poolId))
49
+ candidates.push(poolId);
50
+ }
51
+ if (wethPoolId.status === 'success' && !ZERO_ID.test(wethPoolId.result)) {
52
+ candidates.push(wethPoolId.result);
53
+ }
54
+ const configs = candidates.length === 0
55
+ ? []
56
+ : await client.multicall({
57
+ allowFailure: false,
58
+ contracts: candidates.map((poolId) => ({ address: hook, abi: feeHookAbi, functionName: 'poolConfig', args: [poolId] })),
59
+ });
60
+ const matches = candidates
61
+ .map((poolId, i) => ({ poolId, config: configs[i] }))
62
+ .filter(({ config }) => config.registered && config.token.toLowerCase() === token.toLowerCase());
63
+ if (matches.length === 0) {
64
+ throw new PoolTermsUnavailableError('not-registered', `No registered Peddles launch pool for ${token} on chain ${chainId}.`);
65
+ }
66
+ if (matches.length > 1) {
67
+ throw new PoolTermsUnavailableError('ambiguous', `${token} has more than one registered launch pool on chain ${chainId}; refusing to pick one.`);
68
+ }
69
+ const { poolId, config } = matches[0];
70
+ return {
71
+ poolId,
72
+ token: config.token,
73
+ quote: config.quote,
74
+ creator: config.creator,
75
+ creatorTaxBps: Number(config.creatorTaxBps),
76
+ excessToCreatorBps: Number(config.excessToCreatorBps),
77
+ rewards: config.rewards,
78
+ };
79
+ }
80
+ //# sourceMappingURL=feeTerms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feeTerms.js","sourceRoot":"","sources":["../src/feeTerms.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AA2B7C,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,MAAM,CAAmB;IAClC,YAAY,MAAwB,EAAE,OAAe;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,GAAG,YAAY,CAAC;AAY7B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAkB,EAAE,OAAe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MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAA2C,CAAC;IAChF,OAAO;QACL,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3C,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;QACrD,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,102 @@
1
+ import type { ReadClient } from './client.js';
2
+ /**
3
+ * @peddles/sdk — read and build against Peddles launches.
4
+ *
5
+ * ONE PACKAGE, SIX ENTRY POINTS. Take only what you import:
6
+ *
7
+ * @peddles/sdk this file — chain resolution, launch reads, pool terms
8
+ * @peddles/sdk/abis ABI fragments alone, no runtime
9
+ * @peddles/sdk/clog the Clog launch type
10
+ * @peddles/sdk/deployments the address book
11
+ * @peddles/sdk/launch launch calldata builders, salts, revert decoding
12
+ * @peddles/sdk/perps the perp launchpad (PeddlesPerpFactory)
13
+ *
14
+ * `viem` is a PEER dependency, not a bundled one: an integrator already has a
15
+ * client, and two copies of viem in a bundle is both bloat and a source of
16
+ * "instance is not a PublicClient" errors that are miserable to diagnose.
17
+ *
18
+ * WHAT IS DELIBERATELY ABSENT. This package exposes reads and calldata, not
19
+ * infrastructure. `ContractService`, `WalletService` and the log-source used by
20
+ * the indexer stay internal to the monorepo: publishing them would freeze this
21
+ * project's internals as public API and commit it to supporting them.
22
+ */
23
+ import type { Address, Hex } from 'viem';
24
+ export { DEPLOYMENTS, addressOf, deploymentFor, isKnownChain, UnknownChainError, UnknownContractError, } from './deployments.js';
25
+ export type { KnownChainId, ContractName } from './deployments.js';
26
+ export type { ReadClient } from './client.js';
27
+ export { getVariantAllocation, getClogVault, getClogState, inflowShareBps, isReleaseReady, CLOG_MODEL_FLOW_MULTIPLE, CLOG_TABLE_SLICE_BPS, clogShareOfInflows, clogShareOfInflowsFromBps, clogInflowShareBps, } from './clog.js';
28
+ export type { VariantAllocation, ClogState, ShareOfInflows, ClogModelInput } from './clog.js';
29
+ export { factoryAbi, clogVaultAbi, clogVaultFactoryAbi, erc20Abi, tokenV20Abi, feeHookAbi, stockLaunchpadAbi, holderRewardsAbi, nftFactoryAbi, nftCollectionAbi, nftFeeDistributorFactoryAbi, nftFeeDistributorAbi, nftBondingGraduationOrchestratorAbi, nftStockGraduationOrchestratorAbi, liquidityExecutorAbi, } from './abis.js';
30
+ export { relayParamsHash, stockGraduationOptInRequest, graduateToStockWithTermsRequest, graduateAndBuyRequest, predictDistributor, getHolderCommitment, getDistributorState, holderClaimable, } from './artDex.js';
31
+ export type { RelayParams, StockTermsLaunch, HolderCommitment, DistributorState, HolderClaimable } from './artDex.js';
32
+ export { getPoolTerms, PoolTermsUnavailableError } from './feeTerms.js';
33
+ export type { PoolTerms, PoolTermsFailure } from './feeTerms.js';
34
+ export { feeSplit, PLATFORM_FEE_BPS, CREATOR_FEE_BPS, MIN_CREATOR_TAX_BPS, MAX_CREATOR_TAX_BPS, MAX_FEE_AMOUNT, } from './feeSplit.js';
35
+ export type { FeeSplit } from './feeSplit.js';
36
+ /** A launched token, as the chain describes it. */
37
+ export interface TokenInfo {
38
+ readonly address: Address;
39
+ readonly name: string;
40
+ readonly symbol: string;
41
+ readonly decimals: number;
42
+ readonly totalSupply: bigint;
43
+ }
44
+ /**
45
+ * Identity and supply, read from the token itself.
46
+ *
47
+ * `decimals` travels with `totalSupply` on purpose. Every amount this SDK
48
+ * returns is a raw `bigint` in base units and MUST be formatted against its own
49
+ * decimals — never assume 18, and never route a token amount through a JS
50
+ * `number`, which loses precision above 2^53 and will silently mis-price a
51
+ * large-supply token.
52
+ */
53
+ export declare function getTokenInfo(client: ReadClient, token: Address): Promise<TokenInfo>;
54
+ /**
55
+ * Whether a launch type can be launched on this chain right now.
56
+ *
57
+ * Ask before offering one. A variant with no code registered, or one an owner
58
+ * has retired, reports false — and a UI that offers it anyway sends a creator
59
+ * into a transaction that cannot succeed.
60
+ */
61
+ export declare function isVariantSupported(client: ReadClient, chainId: number, variant: number): Promise<boolean>;
62
+ /** Everything `PeddlesFactoryV20` hashes into a token's CREATE2 address. */
63
+ export interface TokenAddressInput {
64
+ readonly factory: Address;
65
+ readonly variant: number;
66
+ /** The launcher that calls the factory (e.g. the orchestrator), not the end user. */
67
+ readonly sender: Address;
68
+ readonly salt: Hex;
69
+ /** keccak256 of the variant's creation code, as the factory reports it. */
70
+ readonly creationCodeHash: Hex;
71
+ }
72
+ /**
73
+ * The CREATE2 address, computed locally — the exact formula the factory uses:
74
+ *
75
+ * boundSalt = keccak256(abi.encode(uint8 variant, address sender, bytes32 salt))
76
+ * address = keccak256(0xff ‖ factory ‖ boundSalt ‖ creationCodeHash)[12:]
77
+ *
78
+ * `creationCodeHash` is deliberately an input, not a constant shipped here. For
79
+ * the plain token it is the factory's immutable `TOKEN_CREATION_CODE_HASH`
80
+ * (keccak256 of `type(PeddlesTokenV20).creationCode` in the build that
81
+ * deployed it), and for a registered variant the hash stored at registration.
82
+ * Any recompile moves it, so the deployed factory is the only reliable source —
83
+ * read it with `predictTokenAddress`, or pass one you read yourself.
84
+ */
85
+ export declare function computeTokenAddress(input: TokenAddressInput): Address;
86
+ /**
87
+ * The CREATE2 address a launch will deploy to, before it is launched.
88
+ *
89
+ * THE VARIANT IS PART OF THE ADDRESS: the factory binds
90
+ * `keccak256(abi.encode(variant, sender, salt))`, so the same salt under two
91
+ * launch types produces two different addresses. Passing the wrong variant here
92
+ * yields an address the factory will never deploy to.
93
+ *
94
+ * The creation-code hash is read from the deployed factory (`variantInfo`, which
95
+ * returns `TOKEN_CREATION_CODE_HASH` for the plain token), never assumed. An
96
+ * unknown variant throws, as `getPeddlesAddress` does; a retired one still
97
+ * resolves, so an address quoted before retirement stays recoverable.
98
+ */
99
+ export declare function predictTokenAddress(client: ReadClient, chainId: number, variant: number, sender: Address, salt: Hex): Promise<Address>;
100
+ /** Chains this build ships an address book for. */
101
+ export declare function supportedChains(): number[];
102
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAKzC,OAAO,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE9F,OAAO,EACL,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,mCAAmC,EACnC,iCAAiC,EACjC,oBAAoB,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,+BAA+B,EAC/B,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAA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YG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAarE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED,mDAAmD;AACnD,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C"}
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ import { encodeAbiParameters, getContractAddress, keccak256 } from 'viem';
2
+ import { erc20Abi, factoryAbi } from './abis.js';
3
+ import { addressOf } from './deployments.js';
4
+ export { DEPLOYMENTS, addressOf, deploymentFor, isKnownChain, UnknownChainError, UnknownContractError, } from './deployments.js';
5
+ export { getVariantAllocation, getClogVault, getClogState, inflowShareBps, isReleaseReady, CLOG_MODEL_FLOW_MULTIPLE, CLOG_TABLE_SLICE_BPS, clogShareOfInflows, clogShareOfInflowsFromBps, clogInflowShareBps, } from './clog.js';
6
+ export { factoryAbi, clogVaultAbi, clogVaultFactoryAbi, erc20Abi, tokenV20Abi, feeHookAbi, stockLaunchpadAbi, holderRewardsAbi, nftFactoryAbi, nftCollectionAbi, nftFeeDistributorFactoryAbi, nftFeeDistributorAbi, nftBondingGraduationOrchestratorAbi, nftStockGraduationOrchestratorAbi, liquidityExecutorAbi, } from './abis.js';
7
+ export { relayParamsHash, stockGraduationOptInRequest, graduateToStockWithTermsRequest, graduateAndBuyRequest, predictDistributor, getHolderCommitment, getDistributorState, holderClaimable, } from './artDex.js';
8
+ export { getPoolTerms, PoolTermsUnavailableError } from './feeTerms.js';
9
+ export { feeSplit, PLATFORM_FEE_BPS, CREATOR_FEE_BPS, MIN_CREATOR_TAX_BPS, MAX_CREATOR_TAX_BPS, MAX_FEE_AMOUNT, } from './feeSplit.js';
10
+ /**
11
+ * Identity and supply, read from the token itself.
12
+ *
13
+ * `decimals` travels with `totalSupply` on purpose. Every amount this SDK
14
+ * returns is a raw `bigint` in base units and MUST be formatted against its own
15
+ * decimals — never assume 18, and never route a token amount through a JS
16
+ * `number`, which loses precision above 2^53 and will silently mis-price a
17
+ * large-supply token.
18
+ */
19
+ export async function getTokenInfo(client, token) {
20
+ const base = { address: token, abi: erc20Abi };
21
+ const [name, symbol, decimals, totalSupply] = await client.multicall({
22
+ allowFailure: false,
23
+ contracts: [
24
+ { ...base, functionName: 'name' },
25
+ { ...base, functionName: 'symbol' },
26
+ { ...base, functionName: 'decimals' },
27
+ { ...base, functionName: 'totalSupply' },
28
+ ],
29
+ });
30
+ return {
31
+ address: token,
32
+ name: name,
33
+ symbol: symbol,
34
+ decimals: decimals,
35
+ totalSupply: totalSupply,
36
+ };
37
+ }
38
+ /**
39
+ * Whether a launch type can be launched on this chain right now.
40
+ *
41
+ * Ask before offering one. A variant with no code registered, or one an owner
42
+ * has retired, reports false — and a UI that offers it anyway sends a creator
43
+ * into a transaction that cannot succeed.
44
+ */
45
+ export async function isVariantSupported(client, chainId, variant) {
46
+ return (await client.readContract({
47
+ address: addressOf(chainId, 'PeddlesFactoryV20'),
48
+ abi: factoryAbi,
49
+ functionName: 'isVariantSupported',
50
+ args: [variant],
51
+ }));
52
+ }
53
+ /**
54
+ * The CREATE2 address, computed locally — the exact formula the factory uses:
55
+ *
56
+ * boundSalt = keccak256(abi.encode(uint8 variant, address sender, bytes32 salt))
57
+ * address = keccak256(0xff ‖ factory ‖ boundSalt ‖ creationCodeHash)[12:]
58
+ *
59
+ * `creationCodeHash` is deliberately an input, not a constant shipped here. For
60
+ * the plain token it is the factory's immutable `TOKEN_CREATION_CODE_HASH`
61
+ * (keccak256 of `type(PeddlesTokenV20).creationCode` in the build that
62
+ * deployed it), and for a registered variant the hash stored at registration.
63
+ * Any recompile moves it, so the deployed factory is the only reliable source —
64
+ * read it with `predictTokenAddress`, or pass one you read yourself.
65
+ */
66
+ export function computeTokenAddress(input) {
67
+ const boundSalt = keccak256(encodeAbiParameters([{ type: 'uint8' }, { type: 'address' }, { type: 'bytes32' }], [input.variant, input.sender, input.salt]));
68
+ return getContractAddress({
69
+ opcode: 'CREATE2',
70
+ from: input.factory,
71
+ salt: boundSalt,
72
+ bytecodeHash: input.creationCodeHash,
73
+ });
74
+ }
75
+ /**
76
+ * The CREATE2 address a launch will deploy to, before it is launched.
77
+ *
78
+ * THE VARIANT IS PART OF THE ADDRESS: the factory binds
79
+ * `keccak256(abi.encode(variant, sender, salt))`, so the same salt under two
80
+ * launch types produces two different addresses. Passing the wrong variant here
81
+ * yields an address the factory will never deploy to.
82
+ *
83
+ * The creation-code hash is read from the deployed factory (`variantInfo`, which
84
+ * returns `TOKEN_CREATION_CODE_HASH` for the plain token), never assumed. An
85
+ * unknown variant throws, as `getPeddlesAddress` does; a retired one still
86
+ * resolves, so an address quoted before retirement stays recoverable.
87
+ */
88
+ export async function predictTokenAddress(client, chainId, variant, sender, salt) {
89
+ const factory = addressOf(chainId, 'PeddlesFactoryV20');
90
+ const [, creationCodeHash] = (await client.readContract({
91
+ address: factory,
92
+ abi: factoryAbi,
93
+ functionName: 'variantInfo',
94
+ args: [variant],
95
+ }));
96
+ if (/^0x0{64}$/i.test(creationCodeHash)) {
97
+ throw new Error(`PeddlesFactoryV20 on chain ${chainId} has no launch type ${variant}.`);
98
+ }
99
+ return computeTokenAddress({ factory, variant, sender, salt, creationCodeHash });
100
+ }
101
+ /** Chains this build ships an address book for. */
102
+ export function supportedChains() {
103
+ return Object.keys(DEPLOYMENTS_KEYS).map(Number);
104
+ }
105
+ // Imported lazily-shaped to keep the public surface honest: `supportedChains`
106
+ // reads the same generated map every other entry point does.
107
+ import { DEPLOYMENTS as DEPLOYMENTS_KEYS } from './deployments.generated.js';
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,E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