@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 @@
1
+ {"version":3,"file":"artDex.d.ts","sourceRoot":"","sources":["../src/artDex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO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AAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA4B7G;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAW9I"}
package/dist/artDex.js ADDED
@@ -0,0 +1,155 @@
1
+ import { encodeAbiParameters, keccak256 } from 'viem';
2
+ import { nftBondingGraduationOrchestratorAbi, nftCollectionAbi, nftFactoryAbi, nftFeeDistributorAbi, nftFeeDistributorFactoryAbi, nftStockGraduationOrchestratorAbi, } from './abis.js';
3
+ /**
4
+ * Art->DEX: a Peddles NFT collection launches ONE coin, paired to WETH or a tokenised stock, and may
5
+ * commit — permanently — a share of the creator's fee streams to its NFT holders.
6
+ *
7
+ * The commitment is the collection's write-once `holderRewards` binding to its canonical
8
+ * `PeddlesNftFeeDistributor` (made by `PeddlesNftFeeDistributorFactory`), plus the `holderShareBps`
9
+ * the creator passes at launch (0..10000). Nobody can change either afterwards.
10
+ *
11
+ * Addresses are parameters here rather than looked up from `DEPLOYMENTS`: the distributor factory ships
12
+ * with the Art->DEX deployment, and an address book that predates it has no entry to look up.
13
+ */
14
+ const ZERO = /^0x0{40}$/i;
15
+ const BPS = 10_000;
16
+ /** Bps bound shared by every holder-share argument. Throws rather than letting the chain revert. */
17
+ function assertBps(name, v) {
18
+ if (!Number.isInteger(v) || v < 0 || v > BPS)
19
+ throw new RangeError(`${name} must be an integer 0..10000, got ${v}`);
20
+ }
21
+ /**
22
+ * `relayParamsHash` computed off chain — `keccak256(abi.encode(chainid, orchestrator, collection, name,
23
+ * symbol, quote, holderShareBps))`, exactly as the orchestrator hashes it. The collection owner signs
24
+ * `setStockGraduationOptIn(collection, hash)`; a relay whose parameters hash to anything else reverts.
25
+ * Chain id and orchestrator are part of it, so consent never carries across chains or deployments.
26
+ */
27
+ export function relayParamsHash(p) {
28
+ assertBps('holderShareBps', p.holderShareBps);
29
+ return keccak256(encodeAbiParameters([{ type: 'uint256' }, { type: 'address' }, { type: 'address' }, { type: 'string' }, { type: 'string' }, { type: 'address' }, { type: 'uint16' }], [BigInt(p.chainId), p.orchestrator, p.collection, p.name, p.symbol, p.quote, p.holderShareBps]));
30
+ }
31
+ /** Request for `setStockGraduationOptIn(collection, relayParamsHash(p))` (collection owner only). Zero revokes. */
32
+ export function stockGraduationOptInRequest(p) {
33
+ return {
34
+ address: p.orchestrator,
35
+ abi: nftStockGraduationOrchestratorAbi,
36
+ functionName: 'setStockGraduationOptIn',
37
+ args: [p.collection, relayParamsHash(p)],
38
+ };
39
+ }
40
+ /** Request for `graduateToStockWithTerms` (collection owner only). */
41
+ export function graduateToStockWithTermsRequest(l) {
42
+ assertBps('holderShareBps', l.holderShareBps);
43
+ assertBps('excessToCreatorBps', l.excessToCreatorBps);
44
+ return {
45
+ address: l.orchestrator,
46
+ abi: nftStockGraduationOrchestratorAbi,
47
+ functionName: 'graduateToStockWithTerms',
48
+ args: [
49
+ {
50
+ collection: l.collection,
51
+ name: l.name,
52
+ symbol: l.symbol,
53
+ quote: l.quote,
54
+ creatorTaxBps: l.creatorTaxBps,
55
+ excessToCreatorBps: l.excessToCreatorBps,
56
+ holderShareBps: l.holderShareBps,
57
+ devBuyQuoteIn: l.devBuyQuoteIn,
58
+ minTokensOut: l.minTokensOut,
59
+ },
60
+ ],
61
+ value: l.launchFee,
62
+ };
63
+ }
64
+ /**
65
+ * Request for `graduateAndBuy(input, holderShareBps, devBuyValue, minTokensOut)` — the ONLY WETH-path
66
+ * entry since 94d6564 (`graduate` was removed). A plain launch is `holderShareBps = 0, devBuyValue = 0,
67
+ * minTokensOut = 0`. `value` must cover the orchestrator's `launchFee()` (read it live —
68
+ * `readOrchestratorLaunchFee` in `@peddles/sdk/launch`) `+ input.factoryValue + devBuyValue`; a relay of
69
+ * a committed graduation carries exactly `launchFee()` (`RELAY_FEE_ONLY`).
70
+ *
71
+ * `input` is the orchestrator's `GraduateInput` tuple, built by the launch kit exactly as for any V20
72
+ * launch; this helper only positions the Art->DEX arguments around it.
73
+ */
74
+ export function graduateAndBuyRequest(p) {
75
+ assertBps('holderShareBps', p.holderShareBps);
76
+ if (p.devBuyValue > p.value)
77
+ throw new RangeError('devBuyValue exceeds value');
78
+ return {
79
+ address: p.orchestrator,
80
+ abi: nftBondingGraduationOrchestratorAbi,
81
+ functionName: 'graduateAndBuy',
82
+ args: [p.input, p.holderShareBps, p.devBuyValue, p.minTokensOut],
83
+ value: p.value,
84
+ };
85
+ }
86
+ /* ------------------------------ reads ------------------------------ */
87
+ /** The canonical distributor address for `collection` (CREATE2; exists or not). */
88
+ export async function predictDistributor(client, distributorFactory, collection) {
89
+ return (await client.readContract({ address: distributorFactory, abi: nftFeeDistributorFactoryAbi, functionName: 'predict', args: [collection] }));
90
+ }
91
+ /**
92
+ * Whether a collection's creator streams are committed to its holders — the same three reads the
93
+ * orchestrators make: `holderRewards()`, `factory.isDistributor(d)`, `d.collection() == collection`.
94
+ * Also reports factory provenance, which the orchestrators do NOT check.
95
+ */
96
+ export async function getHolderCommitment(client, a) {
97
+ const [holderRewards, peddlesCollection] = await Promise.all([
98
+ client.readContract({ address: a.collection, abi: nftCollectionAbi, functionName: 'holderRewards' }),
99
+ client.readContract({ address: a.nftFactory, abi: nftFactoryAbi, functionName: 'isPeddlesCollection', args: [a.collection] }),
100
+ ]);
101
+ if (ZERO.test(holderRewards))
102
+ return { committed: false, holderRewards, peddlesCollection };
103
+ const isDistributor = (await client.readContract({
104
+ address: a.distributorFactory,
105
+ abi: nftFeeDistributorFactoryAbi,
106
+ functionName: 'isDistributor',
107
+ args: [holderRewards],
108
+ }));
109
+ if (!isDistributor)
110
+ return { committed: false, holderRewards, peddlesCollection };
111
+ const bound = (await client.readContract({ address: holderRewards, abi: nftFeeDistributorAbi, functionName: 'collection' }));
112
+ return { committed: bound.toLowerCase() === a.collection.toLowerCase(), holderRewards, peddlesCollection };
113
+ }
114
+ export async function getDistributorState(client, distributor) {
115
+ const base = { address: distributor, abi: nftFeeDistributorAbi };
116
+ const [collection, quote, token, holderShareBps, assetsInitialized, creatorShareOwed, owedToHolders, mirrorComplete] = await client.multicall({
117
+ allowFailure: false,
118
+ contracts: [
119
+ { ...base, functionName: 'collection' },
120
+ { ...base, functionName: 'quote' },
121
+ { ...base, functionName: 'token' },
122
+ { ...base, functionName: 'holderShareBps' },
123
+ { ...base, functionName: 'assetsInitialized' },
124
+ { ...base, functionName: 'creatorShareOwed' },
125
+ { ...base, functionName: 'owedToHolders' },
126
+ { ...base, functionName: 'mirrorComplete' },
127
+ ],
128
+ });
129
+ const [cq, ct] = creatorShareOwed;
130
+ const [hq, ht] = owedToHolders;
131
+ return {
132
+ distributor,
133
+ collection: collection,
134
+ quote: quote,
135
+ token: token,
136
+ holderShareBps: Number(holderShareBps),
137
+ assetsInitialized: assetsInitialized,
138
+ creatorShareOwed: { quote: cq, token: ct },
139
+ owedToHolders: { quote: hq, token: ht },
140
+ mirrorComplete: mirrorComplete,
141
+ };
142
+ }
143
+ export async function holderClaimable(client, distributor, collection, holder) {
144
+ const [pending, shares, pieces] = await client.multicall({
145
+ allowFailure: false,
146
+ contracts: [
147
+ { address: distributor, abi: nftFeeDistributorAbi, functionName: 'pending', args: [holder] },
148
+ { address: distributor, abi: nftFeeDistributorAbi, functionName: 'sharesOf', args: [holder] },
149
+ { address: collection, abi: nftCollectionAbi, functionName: 'balanceOf', args: [holder] },
150
+ ],
151
+ });
152
+ const [quote, token] = pending;
153
+ return { quote, token, shares: shares, pieces: pieces, needsSync: shares !== pieces };
154
+ }
155
+ //# sourceMappingURL=artDex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artDex.js","sourceRoot":"","sources":["../src/artDex.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,EACL,mCAAmC,EACnC,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,2BAA2B,EAC3B,iCAAiC,GAClC,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;GAUG;AAEH,MAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,MAAM,GAAG,GAAG,MAAM,CAAC;AAEnB,oGAAoG;AACpG,SAAS,SAAS,CAAC,IAAY,EAAE,CAAS;IACxC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,qCAAqC,CAAC,EAAE,CAAC,CAAC;AACtH,CAAC;AAeD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,CAAc;IAC5C,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;IAC9C,OAAO,SAAS,CACd,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAChJ,CAAC,MAAM,CAAC,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oB,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE;YAC7F,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE;SAC1F;KACF,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,OAAoC,CAAC;IAC5D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAgB,EAAE,MAAM,EAAE,MAAgB,EAAE,SAAS,EAAG,MAAiB,KAAM,MAAiB,EAAE,CAAC;AACpI,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { PublicClient } from 'viem';
2
+ /**
3
+ * The client every SDK read takes: any viem client that can `readContract`, `multicall` and
4
+ * `getBalance`. Narrower than `PublicClient` on purpose — a `PublicClient` built for a chain with its
5
+ * own formatters (Base and every OP-stack chain add `deposit` transactions) is NOT assignable to the
6
+ * generic `PublicClient`, so typing parameters that way made `createPublicClient({ chain: base })`
7
+ * a compile error for every Base integrator. Only the three methods the SDK calls are required.
8
+ */
9
+ export type ReadClient = Pick<PublicClient, 'readContract' | 'multicall' | 'getBalance'>;
10
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":""}
package/dist/clog.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import type { ReadClient } from './client.js';
2
+ import type { Address } from 'viem';
3
+ /**
4
+ * The Clog launch type, read from the chain.
5
+ *
6
+ * A clog withholds a share of a launch's supply in a `PeddlesClogVault` and
7
+ * sells it into that launch's own pool a capped slice at a time. The proceeds
8
+ * (native) STAY IN THE VAULT until the creator calls `withdrawProceeds`, and a
9
+ * creator-set release floor bounds the price a release may sell at. It funds marketing without the creator putting up
10
+ * capital — and it only ever extracts from volume that actually arrived, since
11
+ * a sale into an empty book returns nothing and reverts.
12
+ */
13
+ /** A launch type's declared economics. Write-once at variant registration. */
14
+ export interface VariantAllocation {
15
+ readonly liquidityBps: number;
16
+ readonly airdropBps: number;
17
+ readonly vestingBps: number;
18
+ readonly burnBps: number;
19
+ readonly clogBps: number;
20
+ /** Per-release cap, in bps OF TOTAL SUPPLY — not of the allocation. */
21
+ readonly clogSliceBps: number;
22
+ readonly clogMinIntervalSeconds: bigint;
23
+ }
24
+ /** One clog vault's live state. */
25
+ export interface ClogState {
26
+ readonly vault: Address;
27
+ readonly token: Address;
28
+ readonly creator: Address;
29
+ readonly router: Address;
30
+ /** Raw units still held, i.e. not yet sold. */
31
+ readonly held: bigint;
32
+ /** Raw units sold to date, across every release. */
33
+ readonly totalSold: bigint;
34
+ /** Max raw units one release may sell. */
35
+ readonly sliceCap: bigint;
36
+ readonly minIntervalSeconds: bigint;
37
+ /** What `release` would sell right now. */
38
+ readonly nextSlice: bigint;
39
+ /** Unix seconds at which `release` stops reverting `TooSoon`. */
40
+ readonly readyAt: bigint;
41
+ /** Native proceeds held by the vault, owed to the creator (`withdrawProceeds`). */
42
+ readonly proceedsOwed: bigint;
43
+ /** The creator's minimum release price, 1e18-scaled quote per token; 0 = none. */
44
+ readonly releaseFloorX18: bigint;
45
+ }
46
+ /**
47
+ * Read a launch type's allocation.
48
+ *
49
+ * `registerVariant` is write-once, so this is the deal a creator and every
50
+ * buyer of their token accepted — it cannot be changed under them afterwards.
51
+ * Read it rather than assuming: the shares differ per launch type, and a clog
52
+ * type is not 100% liquidity.
53
+ */
54
+ export declare function getVariantAllocation(client: ReadClient, chainId: number, variant: number): Promise<VariantAllocation>;
55
+ /** The clog vault a launch's orchestrator created for `token`, or null. */
56
+ export declare function getClogVault(client: ReadClient, chainId: number, token: Address): Promise<Address | null>;
57
+ /** Everything about one clog vault, in a single multicall. */
58
+ export declare function getClogState(client: ReadClient, vault: Address): Promise<ClogState>;
59
+ /**
60
+ * What share of INFLOWS a clog routes to the creator, given its share of supply.
61
+ *
62
+ * THESE ARE NOT THE SAME NUMBER, and the second is the one that matters to a
63
+ * buyer. The allocation is a share of supply, but it is sold into the pool the
64
+ * buyer is buying from, so it captures a much larger share of the money coming
65
+ * in. Surface it wherever the allocation is shown: a launch page that says "5%"
66
+ * and stops has told the buyer the smaller of two true numbers.
67
+ *
68
+ * The model (exact, bigint, documented in `clogInflow.ts`) lives in its own
69
+ * import-free module and is re-exported here.
70
+ */
71
+ export { CLOG_MODEL_FLOW_MULTIPLE, CLOG_TABLE_SLICE_BPS, clogShareOfInflows, clogShareOfInflowsFromBps, clogInflowShareBps, inflowShareBps, } from './clogInflow.js';
72
+ export type { ShareOfInflows, ClogModelInput } from './clogInflow.js';
73
+ /** True when `release` would not revert `TooSoon`. */
74
+ export declare function isReleaseReady(state: ClogState, nowSeconds: bigint): boolean;
75
+ //# sourceMappingURL=clog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clog.d.ts","sourceRoot":"","sources":["../src/clog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC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B,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAqCzF;AAED;;;;;;;;;;;GAWG;AACH,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAE5E"}
package/dist/clog.js ADDED
@@ -0,0 +1,91 @@
1
+ import { clogVaultAbi, clogVaultFactoryAbi, erc20Abi, factoryAbi } from './abis.js';
2
+ import { addressOf } from './deployments.js';
3
+ /**
4
+ * Read a launch type's allocation.
5
+ *
6
+ * `registerVariant` is write-once, so this is the deal a creator and every
7
+ * buyer of their token accepted — it cannot be changed under them afterwards.
8
+ * Read it rather than assuming: the shares differ per launch type, and a clog
9
+ * type is not 100% liquidity.
10
+ */
11
+ export async function getVariantAllocation(client, chainId, variant) {
12
+ const a = (await client.readContract({
13
+ address: addressOf(chainId, 'PeddlesFactoryV20'),
14
+ abi: factoryAbi,
15
+ functionName: 'variantAllocation',
16
+ args: [variant],
17
+ }));
18
+ return {
19
+ liquidityBps: a.liquidityBps,
20
+ airdropBps: a.airdropBps,
21
+ vestingBps: a.vestingBps,
22
+ burnBps: a.burnBps,
23
+ clogBps: a.clogBps,
24
+ clogSliceBps: a.clogSliceBps,
25
+ clogMinIntervalSeconds: a.clogMinInterval,
26
+ };
27
+ }
28
+ /** The clog vault a launch's orchestrator created for `token`, or null. */
29
+ export async function getClogVault(client, chainId, token) {
30
+ const vault = (await client.readContract({
31
+ address: addressOf(chainId, 'PeddlesClogVaultFactory'),
32
+ abi: clogVaultFactoryAbi,
33
+ functionName: 'vaultOf',
34
+ args: [addressOf(chainId, 'PeddlesLaunchOrchestratorV20'), token],
35
+ }));
36
+ return /^0x0{40}$/i.test(vault) ? null : vault;
37
+ }
38
+ /** Everything about one clog vault, in a single multicall. */
39
+ export async function getClogState(client, vault) {
40
+ const base = { address: vault, abi: clogVaultAbi };
41
+ const [token, creator, router, sliceCap, minInterval, totalSold, preview, releaseFloorX18] = await client.multicall({
42
+ allowFailure: false,
43
+ contracts: [
44
+ { ...base, functionName: 'token' },
45
+ { ...base, functionName: 'creator' },
46
+ { ...base, functionName: 'router' },
47
+ { ...base, functionName: 'sliceCap' },
48
+ { ...base, functionName: 'minInterval' },
49
+ { ...base, functionName: 'totalSold' },
50
+ { ...base, functionName: 'previewRelease' },
51
+ { ...base, functionName: 'releaseFloorX18' },
52
+ ],
53
+ });
54
+ const [held, proceedsOwed] = await Promise.all([
55
+ client.readContract({ address: token, abi: erc20Abi, functionName: 'balanceOf', args: [vault] }),
56
+ client.getBalance({ address: vault }),
57
+ ]);
58
+ const [nextSlice, readyAt] = preview;
59
+ return {
60
+ vault,
61
+ token: token,
62
+ creator: creator,
63
+ router: router,
64
+ held,
65
+ totalSold: totalSold,
66
+ sliceCap: sliceCap,
67
+ minIntervalSeconds: minInterval,
68
+ nextSlice,
69
+ readyAt,
70
+ proceedsOwed,
71
+ releaseFloorX18: releaseFloorX18,
72
+ };
73
+ }
74
+ /**
75
+ * What share of INFLOWS a clog routes to the creator, given its share of supply.
76
+ *
77
+ * THESE ARE NOT THE SAME NUMBER, and the second is the one that matters to a
78
+ * buyer. The allocation is a share of supply, but it is sold into the pool the
79
+ * buyer is buying from, so it captures a much larger share of the money coming
80
+ * in. Surface it wherever the allocation is shown: a launch page that says "5%"
81
+ * and stops has told the buyer the smaller of two true numbers.
82
+ *
83
+ * The model (exact, bigint, documented in `clogInflow.ts`) lives in its own
84
+ * import-free module and is re-exported here.
85
+ */
86
+ export { CLOG_MODEL_FLOW_MULTIPLE, CLOG_TABLE_SLICE_BPS, clogShareOfInflows, clogShareOfInflowsFromBps, clogInflowShareBps, inflowShareBps, } from './clogInflow.js';
87
+ /** True when `release` would not revert `TooSoon`. */
88
+ export function isReleaseReady(state, nowSeconds) {
89
+ return nowSeconds >= state.readyAt;
90
+ }
91
+ //# sourceMappingURL=clog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clog.js","sourceRoot":"","sources":["../src/clog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAgD7C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAkB,EAClB,OAAe,EACf,OAAe;IAEf,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;QACnC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,mBAAmB,CAAC;QAChD,GAAG,EAAE,UAAU;QACf,YAAY,EAAE,mBAAmB;QACjC,IAAI,EAAE,CAAC,OAAO,CAAC;KAChB,CAAC,CAQD,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,sBAAsB,EAAE,CAAC,CAAC,eAAe;KAC1C,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAkB,EAClB,OAAe,EACf,KAAc;IAEd,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC;QACvC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,yBAAyB,CAAC;QACtD,GAAG,EAAE,mBAAmB;QACxB,YA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AW,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAoB;QAC9H,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;KACtC,CAAC,CAAC;IAEH,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,OAAoC,CAAC;IAElE,OAAO;QACL,KAAK;QACL,KAAK,EAAE,KAAgB;QACvB,OAAO,EAAE,OAAkB;QAC3B,MAAM,EAAE,MAAiB;QACzB,IAAI;QACJ,SAAS,EAAE,SAAmB;QAC9B,QAAQ,EAAE,QAAkB;QAC5B,kBAAkB,EAAE,WAAqB;QACzC,SAAS;QACT,OAAO;QACP,YAAY;QACZ,eAAe,EAAE,eAAyB;KAC3C,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,sDAAsD;AACtD,MAAM,UAAU,cAAc,CAAC,KAAgB,EAAE,UAAkB;IACjE,OAAO,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC;AACrC,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * What share of the money buyers put in a clog routes to the creator.
3
+ *
4
+ * A clog allocation is a share of SUPPLY, but it is sold into the pool buyers are
5
+ * buying from, so it captures a far larger share of the money coming in. That
6
+ * second number is the one a buyer is accepting, and it must be stated wherever
7
+ * the allocation is. This module derives it; nothing here is a lookup table.
8
+ *
9
+ * Pure: no imports, bigint only, no floating point at any step. Every step is
10
+ * exact rational arithmetic, so the result is a fraction `num / den`; the only
11
+ * rounding is in `clogInflowShareBps`, once, at the end.
12
+ *
13
+ * SINGLE SOURCE OF TRUTH. `apps/web/src/features/launch/clogInflow.ts` carries a
14
+ * copy (the web app does not depend on this package). `__tests__/clogInflow.test.ts`
15
+ * imports that copy and holds the two to identical fractions over a grid, so a
16
+ * change to one without the other fails the SDK's tests.
17
+ *
18
+ * ── THE MODEL ───────────────────────────────────────────────────────────────
19
+ * Pure buy flow — nobody but the clog ever sells. That is the most favourable
20
+ * case for the design: any real selling makes the clog sell into a weaker pool.
21
+ *
22
+ * The pool. A Peddles launch opens a single-sided position from the launch
23
+ * price upward holding the liquidity share `x0 = supply - clog`. For such a
24
+ * position, token reserve `x` and quote `y` satisfy
25
+ *
26
+ * x · (y + x0·p0) = x0² · p0 (a constant product, k)
27
+ *
28
+ * i.e. constant product against a virtual quote reserve `x0·p0`. Write
29
+ * `q = y + x0·p0`, so `q0 = x0·p0` and `k = x0·q0`.
30
+ *
31
+ * One round. Buyers spend `B` (a buy never changes k): q ← q + B
32
+ * then the clog sells `s = min(slice, remaining)` tokens:
33
+ *
34
+ * q ← k · q / (k + s · q) (x ← x + s, q = k / x)
35
+ *
36
+ * Rounds repeat until the clog is empty. After `n` rounds buyers have put in
37
+ * `n·B`, and the pool holds `q_n − q0` of it; everything else was paid out to
38
+ * the creator. So, exactly:
39
+ *
40
+ * share of inflows = 1 − (q_n − q0) / (n · B)
41
+ *
42
+ * Buy flow per round — THE ONE ASSUMPTION. `B = flowMultiple × slice × p0`:
43
+ * buyers spend between releases `flowMultiple` times what a slice was worth at
44
+ * the launch price. Default `CLOG_MODEL_FLOW_MULTIPLE` (100).
45
+ *
46
+ * p0 cancels. Measuring quote in units of `p0` makes every term an integer
47
+ * count of tokens (`q0 = x0`, `k = x0²`, `B = flowMultiple × slice`), so the
48
+ * result depends only on (supply, clog, slice) and the flow multiple — never
49
+ * on the launch price, which is why it can be stated before the pool exists.
50
+ *
51
+ * The floor. A single-sided position holds no quote below its launch price, so
52
+ * a release can never take the price under `p0`. If a round's sale would, the
53
+ * model does not apply and the functions return null rather than a number from
54
+ * a pool that cannot exist. At flowMultiple = 100 this cannot happen anywhere
55
+ * in the range the factory accepts (clog ≤ `PeddlesFactoryV20.CLOG_BPS_MAX`,
56
+ * 25%): a round starts at `q ≥ q0`, its buys take at least `x0·B / (x0 + B)`
57
+ * tokens out of the pool, and a sale `s ≤ clog` fits back under the floor
58
+ * whenever `99·x0 ≥ 100·s` — true for every `x0 ≥ 75%` and `s ≤ 25%`.
59
+ *
60
+ * ── REFERENCE ───────────────────────────────────────────────────────────────
61
+ * With slices of 1% of supply (`CLOG_TABLE_SLICE_BPS`) and flowMultiple = 100
62
+ * this reproduces the policy table in CLAUDE.md at its 0.1% resolution
63
+ * (5% → 16.5%, 10% → 37.1%, 15% → 54.6%, 25% → 75.0%). A launch type's real
64
+ * slice is smaller — the live Sepolia Clog type sells 5% in 0.25% slices, which
65
+ * is ≈14.2% — so pass the slice the chain reports, never the table's.
66
+ */
67
+ /**
68
+ * Buyer spend between two clog releases, as a multiple of what one slice was
69
+ * worth at the launch price. The one assumption in the model; see the header.
70
+ */
71
+ export declare const CLOG_MODEL_FLOW_MULTIPLE = 100n;
72
+ /** The slice (1% of supply) at which the model reproduces the CLAUDE.md policy table. */
73
+ export declare const CLOG_TABLE_SLICE_BPS = 100n;
74
+ export interface ShareOfInflows {
75
+ /**
76
+ * Share of all buyer money paid out to the creator, as `num / den` (0 ≤ share < 1).
77
+ * Not reduced to lowest terms — compare two shares by cross-multiplying.
78
+ */
79
+ readonly num: bigint;
80
+ readonly den: bigint;
81
+ /** How many releases it takes to sell the whole clog. */
82
+ readonly releases: bigint;
83
+ }
84
+ export interface ClogModelInput {
85
+ /** Total supply, in any unit — basis points (10000) or raw token units. */
86
+ readonly supply: bigint;
87
+ /** The clog allocation, in the same unit. */
88
+ readonly clog: bigint;
89
+ /** The most one release sells, in the same unit. */
90
+ readonly slice: bigint;
91
+ /** Defaults to `CLOG_MODEL_FLOW_MULTIPLE`. */
92
+ readonly flowMultiple?: bigint;
93
+ }
94
+ /**
95
+ * The share of buyer money a clog routes to the creator, as an exact fraction,
96
+ * or null when the model does not apply (a malformed input, or a release that
97
+ * would breach the floor). A zero clog captures nothing:
98
+ * `{ num: 0n, den: 1n, releases: 0n }`.
99
+ */
100
+ export declare function clogShareOfInflows(input: ClogModelInput): ShareOfInflows | null;
101
+ /** The same model, stated in basis points of supply — the unit a launch type declares. */
102
+ export declare function clogShareOfInflowsFromBps(clogBps: bigint, sliceBps: bigint, flowMultiple?: bigint): ShareOfInflows | null;
103
+ /**
104
+ * Share of inflows, in basis points, for a clog of `clogBps` of supply sold in
105
+ * slices of `sliceBps` of supply.
106
+ *
107
+ * Pass the launch type's own `clogSliceBps` (from `getVariantAllocation`), not
108
+ * the policy table's 1%: the slice moves the answer (5% in 1% slices is 1649 bps;
109
+ * in the live 0.25% slices it is 1417 bps).
110
+ *
111
+ * @param clogBps Clog allocation, bps of total supply.
112
+ * @param sliceBps Per-release cap, bps of total supply.
113
+ * @param flowMultiple Buyer spend between releases, in slices at the launch
114
+ * price. The model's one assumption; defaults to
115
+ * `CLOG_MODEL_FLOW_MULTIPLE` (100).
116
+ * @returns Nearest basis point, rounded half up — the only rounding in the model
117
+ * (use `clogShareOfInflows` for the exact fraction) — or null when the
118
+ * model does not apply.
119
+ */
120
+ export declare function clogInflowShareBps(clogBps: bigint, sliceBps: bigint, flowMultiple?: bigint): bigint | null;
121
+ /**
122
+ * What share of INFLOWS a clog routes to the creator, given its share of supply —
123
+ * AT THE POLICY TABLE'S 1% SLICE AND 0.1% RESOLUTION.
124
+ *
125
+ * @deprecated Kept for existing callers. It answers for the CLAUDE.md table's
126
+ * assumed slice, not for any real launch type's, so it overstates the live Sepolia
127
+ * Clog type (5%: 1650 here vs 1417 at its real 0.25% slice). Use
128
+ * `clogInflowShareBps(clogBps, allocation.clogSliceBps)`.
129
+ *
130
+ * Output is unchanged for the four table rows (500 → 1650, 1000 → 3710,
131
+ * 1500 → 5460, 2500 → 7500). It is now derived from the model rather than looked
132
+ * up, so any integer clog in [0, 10000) returns a value (a multiple of 10) where
133
+ * it used to return null; non-integer or out-of-range input still returns null.
134
+ */
135
+ export declare function inflowShareBps(clogBps: number): number | null;
136
+ //# sourceMappingURL=clogInflow.d.ts.map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