@black-market/sdk 0.15.1 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +6 -5
  2. package/dist/lifecycle/deployments/raeto-dynamic-pool-v1-20261029.d.ts +71 -0
  3. package/dist/lifecycle/deployments/raeto-dynamic-pool-v1-20261029.d.ts.map +1 -0
  4. package/dist/lifecycle/deployments/raeto-dynamic-pool-v1-20261029.js +73 -0
  5. package/dist/lifecycle/deployments/raeto-dynamic-pool-v1-20261029.js.map +1 -0
  6. package/dist/lifecycle/deployments/raeto-fixed-pool-v1-20261029.d.ts +71 -0
  7. package/dist/lifecycle/deployments/raeto-fixed-pool-v1-20261029.d.ts.map +1 -0
  8. package/dist/lifecycle/deployments/raeto-fixed-pool-v1-20261029.js +73 -0
  9. package/dist/lifecycle/deployments/raeto-fixed-pool-v1-20261029.js.map +1 -0
  10. package/dist/lifecycle/gas-profile.d.ts +1 -1
  11. package/dist/lifecycle/gas-profile.d.ts.map +1 -1
  12. package/dist/lifecycle/gas-profile.js +24 -9
  13. package/dist/lifecycle/gas-profile.js.map +1 -1
  14. package/dist/lifecycle/index.d.ts +2 -0
  15. package/dist/lifecycle/index.d.ts.map +1 -1
  16. package/dist/lifecycle/index.js +2 -0
  17. package/dist/lifecycle/index.js.map +1 -1
  18. package/dist/lifecycle/markets.d.ts +2 -0
  19. package/dist/lifecycle/markets.d.ts.map +1 -1
  20. package/dist/lifecycle/markets.js +30 -2
  21. package/dist/lifecycle/markets.js.map +1 -1
  22. package/dist/lifecycle/opening-buys.js +3 -3
  23. package/dist/lifecycle/opening-buys.js.map +1 -1
  24. package/dist/lifecycle/planner.d.ts.map +1 -1
  25. package/dist/lifecycle/planner.js +21 -2
  26. package/dist/lifecycle/planner.js.map +1 -1
  27. package/dist/lifecycle/presets.d.ts +4 -2
  28. package/dist/lifecycle/presets.d.ts.map +1 -1
  29. package/dist/lifecycle/presets.js +8 -1
  30. package/dist/lifecycle/presets.js.map +1 -1
  31. package/dist/lifecycle/raeto-abi.d.ts +175 -0
  32. package/dist/lifecycle/raeto-abi.d.ts.map +1 -0
  33. package/dist/lifecycle/raeto-abi.js +224 -0
  34. package/dist/lifecycle/raeto-abi.js.map +1 -0
  35. package/dist/lifecycle/raeto.d.ts +21 -0
  36. package/dist/lifecycle/raeto.d.ts.map +1 -0
  37. package/dist/lifecycle/raeto.js +59 -0
  38. package/dist/lifecycle/raeto.js.map +1 -0
  39. package/dist/lifecycle/transactions.d.ts.map +1 -1
  40. package/dist/lifecycle/transactions.js +8 -1
  41. package/dist/lifecycle/transactions.js.map +1 -1
  42. package/dist/lifecycle/types.d.ts +2 -2
  43. package/dist/lifecycle/types.d.ts.map +1 -1
  44. package/docs/launch-lifecycle.md +106 -40
  45. package/docs/lifecycle-gas-profiles.md +173 -24
  46. package/docs/reference.md +73 -15
  47. package/examples/README.md +6 -3
  48. package/package.json +1 -1
  49. package/src/lifecycle/deployments/raeto-dynamic-pool-v1-20261029.ts +74 -0
  50. package/src/lifecycle/deployments/raeto-fixed-pool-v1-20261029.ts +74 -0
  51. package/src/lifecycle/gas-profile.ts +21 -9
  52. package/src/lifecycle/index.ts +2 -0
  53. package/src/lifecycle/markets.ts +23 -1
  54. package/src/lifecycle/opening-buys.ts +3 -3
  55. package/src/lifecycle/planner.ts +19 -2
  56. package/src/lifecycle/presets.ts +8 -1
  57. package/src/lifecycle/raeto-abi.ts +223 -0
  58. package/src/lifecycle/raeto.ts +61 -0
  59. package/src/lifecycle/transactions.ts +8 -1
  60. package/src/lifecycle/types.ts +2 -2
@@ -0,0 +1,223 @@
1
+ // Generated from the verified RaetoFeeCollectorV1 ABI by scripts/generate-raeto-presets.mjs.
2
+ // Provenance: test/fixtures/raeto-registry-readback.json, abiProvenance.
3
+ export const raetoFeeCollectorV1Abi = [
4
+ {
5
+ "anonymous": false,
6
+ "inputs": [
7
+ {
8
+ "indexed": true,
9
+ "internalType": "address",
10
+ "name": "launchToken",
11
+ "type": "address"
12
+ },
13
+ {
14
+ "indexed": true,
15
+ "internalType": "bytes32",
16
+ "name": "poolId",
17
+ "type": "bytes32"
18
+ },
19
+ {
20
+ "indexed": true,
21
+ "internalType": "address",
22
+ "name": "asset",
23
+ "type": "address"
24
+ },
25
+ {
26
+ "indexed": false,
27
+ "internalType": "uint256",
28
+ "name": "grossQuoteCollected",
29
+ "type": "uint256"
30
+ },
31
+ {
32
+ "indexed": false,
33
+ "internalType": "uint256",
34
+ "name": "raetoAmount",
35
+ "type": "uint256"
36
+ },
37
+ {
38
+ "indexed": false,
39
+ "internalType": "uint256",
40
+ "name": "forwardedQuote",
41
+ "type": "uint256"
42
+ },
43
+ {
44
+ "indexed": false,
45
+ "internalType": "uint16",
46
+ "name": "shareBps",
47
+ "type": "uint16"
48
+ },
49
+ {
50
+ "indexed": false,
51
+ "internalType": "uint256",
52
+ "name": "owedAfter",
53
+ "type": "uint256"
54
+ }
55
+ ],
56
+ "name": "RaetoFeesBooked",
57
+ "type": "event"
58
+ },
59
+ {
60
+ "anonymous": false,
61
+ "inputs": [
62
+ {
63
+ "indexed": true,
64
+ "internalType": "address",
65
+ "name": "launchToken",
66
+ "type": "address"
67
+ },
68
+ {
69
+ "indexed": true,
70
+ "internalType": "bytes32",
71
+ "name": "poolId",
72
+ "type": "bytes32"
73
+ },
74
+ {
75
+ "indexed": true,
76
+ "internalType": "address",
77
+ "name": "payout",
78
+ "type": "address"
79
+ },
80
+ {
81
+ "indexed": false,
82
+ "internalType": "address",
83
+ "name": "asset",
84
+ "type": "address"
85
+ },
86
+ {
87
+ "indexed": false,
88
+ "internalType": "uint256",
89
+ "name": "amount",
90
+ "type": "uint256"
91
+ }
92
+ ],
93
+ "name": "RaetoFeesClaimed",
94
+ "type": "event"
95
+ },
96
+ {
97
+ "anonymous": false,
98
+ "inputs": [
99
+ {
100
+ "indexed": true,
101
+ "internalType": "address",
102
+ "name": "launchToken",
103
+ "type": "address"
104
+ },
105
+ {
106
+ "indexed": true,
107
+ "internalType": "bytes32",
108
+ "name": "poolId",
109
+ "type": "bytes32"
110
+ },
111
+ {
112
+ "indexed": true,
113
+ "internalType": "address",
114
+ "name": "operator",
115
+ "type": "address"
116
+ },
117
+ {
118
+ "indexed": false,
119
+ "internalType": "uint16",
120
+ "name": "previousShareBps",
121
+ "type": "uint16"
122
+ },
123
+ {
124
+ "indexed": false,
125
+ "internalType": "uint16",
126
+ "name": "newShareBps",
127
+ "type": "uint16"
128
+ }
129
+ ],
130
+ "name": "RaetoShareUpdated",
131
+ "type": "event"
132
+ },
133
+ {
134
+ "inputs": [
135
+ {
136
+ "internalType": "address",
137
+ "name": "asset",
138
+ "type": "address"
139
+ }
140
+ ],
141
+ "name": "claimRaeto",
142
+ "outputs": [
143
+ {
144
+ "internalType": "uint256",
145
+ "name": "amount",
146
+ "type": "uint256"
147
+ }
148
+ ],
149
+ "stateMutability": "nonpayable",
150
+ "type": "function"
151
+ },
152
+ {
153
+ "inputs": [],
154
+ "name": "launchToken",
155
+ "outputs": [
156
+ {
157
+ "internalType": "address",
158
+ "name": "",
159
+ "type": "address"
160
+ }
161
+ ],
162
+ "stateMutability": "view",
163
+ "type": "function"
164
+ },
165
+ {
166
+ "inputs": [
167
+ {
168
+ "internalType": "address",
169
+ "name": "asset",
170
+ "type": "address"
171
+ }
172
+ ],
173
+ "name": "owed",
174
+ "outputs": [
175
+ {
176
+ "internalType": "uint256",
177
+ "name": "amount",
178
+ "type": "uint256"
179
+ }
180
+ ],
181
+ "stateMutability": "view",
182
+ "type": "function"
183
+ },
184
+ {
185
+ "inputs": [],
186
+ "name": "quoteAsset",
187
+ "outputs": [
188
+ {
189
+ "internalType": "address",
190
+ "name": "",
191
+ "type": "address"
192
+ }
193
+ ],
194
+ "stateMutability": "view",
195
+ "type": "function"
196
+ },
197
+ {
198
+ "inputs": [
199
+ {
200
+ "internalType": "uint16",
201
+ "name": "newShareBps",
202
+ "type": "uint16"
203
+ }
204
+ ],
205
+ "name": "setShareBps",
206
+ "outputs": [],
207
+ "stateMutability": "nonpayable",
208
+ "type": "function"
209
+ },
210
+ {
211
+ "inputs": [],
212
+ "name": "shareBps",
213
+ "outputs": [
214
+ {
215
+ "internalType": "uint16",
216
+ "name": "",
217
+ "type": "uint16"
218
+ }
219
+ ],
220
+ "stateMutability": "view",
221
+ "type": "function"
222
+ }
223
+ ] as const;
@@ -0,0 +1,61 @@
1
+ import { encodeAbiParameters, type Hex } from "viem";
2
+ import { decodePoolBoundV4LifecycleMarketConfig } from "./markets.js";
3
+ import type { LaunchPlanV1 } from "./schema.js";
4
+ import { LifecyclePlanningError } from "./types.js";
5
+
6
+ export const RAETO_FIXED_PROFILE_ID: Hex = "0x9161833b162e7ca8160b11c64aedb307561e19a9136fd32f99cd797aab6da3ca";
7
+ export const RAETO_DYNAMIC_PROFILE_ID: Hex = "0x08387d00ee4f75f860810cc8fb434087328592c2f39ea3321109e589039f80e1";
8
+ export const RAETO_FIXED_ADAPTER_ID: Hex = "0x911d7ecefe56489d329235e3484829717dc00400d4181902f0f2de45f9338615";
9
+ export const RAETO_DYNAMIC_ADAPTER_ID: Hex = "0x8ab9c8c9b8fd4c8bbf12b780d9474463fa0fa52e3b450f0d5f68fd067dc1674d";
10
+ export const RAETO_PAYOUT_REGISTRY_ADDRESS = "0xBEC2C0e91612090F82df6743F31CDF18B4386b50";
11
+ /** The deployed collectors accept this menu, not the wider range in later source. */
12
+ export const RAETO_SHARE_BPS_OPTIONS = Object.freeze([500, 1000, 2500, 5000, 7500] as const);
13
+ export const RAETO_QUOTE_ASSETS = Object.freeze([
14
+ "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
15
+ "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
16
+ ] as const);
17
+ export type RaetoLaunchConfigV1 = { shareBps: number };
18
+
19
+ export function isRaetoProfile(profileId: Hex): boolean {
20
+ const id = profileId.toLowerCase();
21
+ return id === RAETO_FIXED_PROFILE_ID || id === RAETO_DYNAMIC_PROFILE_ID;
22
+ }
23
+
24
+ export function validateRaetoLaunchConfig(config: RaetoLaunchConfigV1): void {
25
+ if (!RAETO_SHARE_BPS_OPTIONS.some((share) => share === config.shareBps)) {
26
+ throw new LifecyclePlanningError("INVALID_RAETO_CONFIG", "Raeto shareBps must be one of 500, 1000, 2500, 5000 or 7500");
27
+ }
28
+ }
29
+
30
+ /** Exactly abi.encode(RaetoLaunchConfigV1): one static uint16 word. */
31
+ export function encodeRaetoLaunchTail(config: RaetoLaunchConfigV1): Hex {
32
+ validateRaetoLaunchConfig(config);
33
+ return encodeAbiParameters([{ type: "uint16" }], [config.shareBps]);
34
+ }
35
+
36
+ export function decodeRaetoLaunchTail(encoded: Hex): RaetoLaunchConfigV1 {
37
+ if (!/^0x[0-9a-fA-F]{64}$/.test(encoded)) throw new LifecyclePlanningError("INVALID_RAETO_CONFIG", "Raeto tail must be exactly one ABI word");
38
+ const share = BigInt(encoded);
39
+ if (share > 65535n) throw new LifecyclePlanningError("INVALID_RAETO_CONFIG", "Raeto tail must contain a canonical uint16");
40
+ const config = { shareBps: Number(share) };
41
+ validateRaetoLaunchConfig(config);
42
+ return config;
43
+ }
44
+
45
+ /** Raeto uses the normal lifecycle creator/funding route, not the UFG proxy. */
46
+ export function validateRaetoLaunchPlan(plan: LaunchPlanV1): void {
47
+ try {
48
+ if (plan.markets.length === 0) throw new Error("A Raeto plan requires at least one market");
49
+ for (const market of plan.markets) {
50
+ if (!isRaetoProfile(market.profileId) || market.configVersion !== 6 ||
51
+ !RAETO_QUOTE_ASSETS.some((quote) => quote.toLowerCase() === market.quoteAsset.toLowerCase()) ||
52
+ market.adapterId.toLowerCase() !== (market.profileId.toLowerCase() === RAETO_FIXED_PROFILE_ID ? RAETO_FIXED_ADAPTER_ID : RAETO_DYNAMIC_ADAPTER_ID)) {
53
+ throw new Error("Every Raeto market requires its Raeto config6 profile/adapter and a WETH or USDG quote");
54
+ }
55
+ const config = decodePoolBoundV4LifecycleMarketConfig(market.config, 6);
56
+ if (config.profileId.toLowerCase() !== market.profileId.toLowerCase()) throw new Error("Raeto config profile differs from its market");
57
+ }
58
+ } catch (error) {
59
+ throw new LifecyclePlanningError("INVALID_RAETO_PLAN", error instanceof Error ? error.message : "Invalid Raeto launch plan");
60
+ }
61
+ }
@@ -7,6 +7,8 @@ import { ufgLaunchProxyV1Abi } from "./ufg-abi.js";
7
7
  import { UFG_LAUNCH_PROXY_ADDRESS, isUfgProfile } from "./ufg-config.js";
8
8
  import { decodeAbyssLifecycleMarketConfig, decodePoolBoundV4LifecycleMarketConfig, decodeV4LifecycleMarketConfig, isPoolBoundV4ConfigVersion } from "./markets.js";
9
9
  import { isHmmProfile } from "./hmm.js";
10
+ import { isRaetoProfile } from "./raeto.js";
11
+ import { isAutoCompoundProfile } from "./auto-compound.js";
10
12
  import type { UfgLaunchConfig } from "./ufg-config.js";
11
13
 
12
14
  // Native9,723,187 Abyss3 (0x679d…e77), fork32-position10,900,786;
@@ -16,6 +18,10 @@ const preparationCosts = {
16
18
  v4: { market: 9_000_000n, position: 40_000n },
17
19
  ufg: { market: 10_000_000n, position: 70_000n },
18
20
  hmm: { market: 15_000_000n, position: 50_000n },
21
+ // template-gas-matrix.json: Raeto1 <=9.13M,32 <=11.23M.
22
+ raeto: { market: 9_300_000n, position: 70_000n },
23
+ // Same matrix: auto-compound1 <=8.71M,32 <=10.76M.
24
+ autoCompound: { market: 8_900_000n, position: 70_000n },
19
25
  } as const;
20
26
  export const LIFECYCLE_CAPACITY_PADDING_BPS = 2500;
21
27
  /** Full single-market observations include call overhead. Add conservative full
@@ -30,7 +36,8 @@ export function preparationGasEstimate(plan: LaunchPlanV1, first: number, count:
30
36
  : isPoolBoundV4ConfigVersion(market.configVersion) ? decodePoolBoundV4LifecycleMarketConfig(market.config, market.configVersion).positions.length
31
37
  : decodeV4LifecycleMarketConfig(market.config).positions.length;
32
38
  const cost = market.configVersion === 1 ? preparationCosts.abyss : isHmmProfile(market.profileId) ? preparationCosts.hmm
33
- : isUfgProfile(market.profileId) ? preparationCosts.ufg : preparationCosts.v4;
39
+ : isUfgProfile(market.profileId) ? preparationCosts.ufg : isRaetoProfile(market.profileId) ? preparationCosts.raeto
40
+ : isAutoCompoundProfile(market.profileId) ? preparationCosts.autoCompound : preparationCosts.v4;
34
41
  gas += cost.market + cost.position * BigInt(positions - 1);
35
42
  }
36
43
  return gas;
@@ -86,7 +86,7 @@ export type LifecycleOpeningBuyQuote = {
86
86
  tokenOut: bigint; sqrtPriceAfterX96: bigint;
87
87
  };
88
88
  /** Versioned compute budgets with headroom, never transaction gas-limit sizing.
89
- * Atomic budget is absent when conversion work is outside the template model. */
89
+ * Atomic budget is absent for launches with more than one market. */
90
90
  export type LifecycleLaunchGasBounds = {
91
91
  atomicComputeGasUpperBound?: bigint; activationComputeGasUpperBound: bigint;
92
92
  };
@@ -164,7 +164,7 @@ export type PlannedLaunch = {
164
164
  };
165
165
  export type PlanLaunchOptions = {
166
166
  client: LifecycleRpcClient; account: Address; plan: LaunchPlanV1;
167
- /** Atomic requires one market, no conversion and a known budget fitting with headroom.
167
+ /** Atomic requires one market and a known budget, including conversions, fitting with headroom.
168
168
  * All other unstarted launches are staged; started launches retain canonical mode. */
169
169
  mode: LaunchExecutionMode; limits?: LifecycleLimitSource; receipts?: readonly LifecycleReceiptReference[];
170
170
  confirmations?: number; signal?: AbortSignal;