@black-market/sdk 0.4.0 → 0.5.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 (46) hide show
  1. package/README.md +128 -149
  2. package/assets/splash.png +0 -0
  3. package/dist/addresses.d.ts +3 -1
  4. package/dist/addresses.d.ts.map +1 -1
  5. package/dist/addresses.js +23 -17
  6. package/dist/addresses.js.map +1 -1
  7. package/dist/client.js +2 -2
  8. package/dist/client.js.map +1 -1
  9. package/dist/launch-api.d.ts +2 -1
  10. package/dist/launch-api.d.ts.map +1 -1
  11. package/dist/launch-api.js +2 -1
  12. package/dist/launch-api.js.map +1 -1
  13. package/dist/lifecycle/abi.d.ts +1246 -292
  14. package/dist/lifecycle/abi.d.ts.map +1 -1
  15. package/dist/lifecycle/abi.js +106 -12
  16. package/dist/lifecycle/abi.js.map +1 -1
  17. package/dist/lifecycle/progress.js +9 -9
  18. package/dist/lifecycle/progress.js.map +1 -1
  19. package/dist/lifecycle/schema.d.ts +3 -4
  20. package/dist/lifecycle/schema.d.ts.map +1 -1
  21. package/dist/lifecycle/schema.js +3 -4
  22. package/dist/lifecycle/schema.js.map +1 -1
  23. package/docs/launch-lifecycle.md +199 -41
  24. package/examples/.env.example +20 -0
  25. package/examples/README.md +223 -0
  26. package/examples/generate-lifecycle-commitment-fixture.mjs +49 -0
  27. package/examples/launch-erc20-abyss.mjs +7 -0
  28. package/examples/launch-erc20-burn-mixed.mjs +7 -0
  29. package/examples/launch-erc20-dividends-abyss.mjs +7 -0
  30. package/examples/launch-erc20-staking-v4.mjs +7 -0
  31. package/examples/launch-erc20-v4.mjs +7 -0
  32. package/examples/launch-erc404-abyss.mjs +7 -0
  33. package/examples/launch-erc404-dividends-mixed.mjs +7 -0
  34. package/examples/launch-erc404-v4.mjs +7 -0
  35. package/examples/launch-example-support.mjs +397 -0
  36. package/examples/launch-example.mjs +589 -0
  37. package/examples/launch-lifecycle-smoke.mjs +180 -0
  38. package/examples/launch.mjs +38 -0
  39. package/examples/quickstart.mjs +37 -0
  40. package/package.json +8 -3
  41. package/src/addresses.ts +25 -18
  42. package/src/client.ts +2 -2
  43. package/src/launch-api.ts +3 -2
  44. package/src/lifecycle/abi.ts +107 -12
  45. package/src/lifecycle/progress.ts +9 -9
  46. package/src/lifecycle/schema.ts +3 -4
@@ -1,5 +1,5 @@
1
1
  import { concatHex, decodeFunctionData, encodeAbiParameters, encodeFunctionData, keccak256, stringToHex, toHex, zeroAddress, zeroHash, type Address, type Hash, type Hex } from "viem";
2
- import { abyssLifecycleAdapterAbi, launchLifecycleAbi, lifecycleAdapterAbi, lifecycleDirectoryAbi, lifecycleErc20Abi, lifecycleOracleFactoryAbi, lifecycleRegistryAbi, poolFeeCollectorFactoryV1Abi, lifecycleV4HookAbi, lifecycleV4LockerAbi, poolHookDeployerV1Abi, sharedHookDeployerV1Abi, poolBoundLaunchFeeHookV1Abi, poolMarketAdapterV1Abi, sharedMarketAdapterV1Abi } from "./abi.js";
2
+ import { abyssLifecycleAdapterAbi, launchLifecycleAbi, lifecycleAdapterAbi, lifecycleDirectoryAbi, lifecycleErc20Abi, lifecycleOracleFactoryAbi, lifecycleRegistryAbi, poolFeeCollectorFactoryV1Abi, lifecycleV4HookAbi, lifecycleV4LockerAbi, poolHookDeployerV1Abi, sharedHookDeployerV1Abi, fixedFeePoolHookV1Abi, poolMarketAdapterV1Abi, sharedMarketAdapterV1Abi } from "./abi.js";
3
3
  import { decodePoolBoundV4LifecycleMarketConfig, encodePoolBoundHookParameters, hasLifecycleV4HookPermissions, hashPoolBoundV4MarketCommitment, poolBoundHookInitCodeHash, predictPoolBoundHookAddress, validateV4LifecycleMarket, V4_LIFECYCLE_CONFIG_SCHEMA, V4_POOL_BOUND_LIFECYCLE_CONFIG_SCHEMA, type PoolBoundHookParametersV1 } from "./markets.js";
4
4
  import { hashLaunchIdentity, hashLaunchPlan, hashLaunchBounds, hashLaunchDependencies, hashLifecycleProfile, launchProgressV1Components, LifecycleMode, LifecyclePhase, LifecycleVenue, LIFECYCLE_REQUIRED_CAPABILITIES, LIFECYCLE_ERC404_CAPABILITY, LIFECYCLE_MULTI_POSITION_CAPABILITY, type AdapterRegistrationV1, type LaunchPlanV1, type LaunchProgressV1, type MarketIdentityV1, type MarketLiveStateV1, type PreparedMarketV1, type ProfileRegistrationV1, type ProfileTopologyV1, type LaunchEnvelopeV2, type LifecycleDeveloperTerms } from "./schema.js";
5
5
  import { assertLifecycleBlock, lifecycleRpc, readLifecycleBlock, readLifecycleContract, readLifecycleProfileTopology, rpcHex, rpcObject, rpcQuantity } from "./rpc.js";
@@ -214,18 +214,18 @@ async function readPoolBoundHookDeploymentDetails(options: { client: LifecycleRp
214
214
  ["poolManager", expected.poolManager], ["registrar", expected.registrar], ["oracleFactory", expected.oracleFactory],
215
215
  ["core", expected.core], ["liquidityLocker", expected.liquidityLocker], ["token", expected.token],
216
216
  ] as const) {
217
- const actual = await readLifecycleContract<Address>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, getter, [], block);
217
+ const actual = await readLifecycleContract<Address>(client, predictedHook, fixedFeePoolHookV1Abi, getter, [], block);
218
218
  if (actual.toLowerCase() !== expectedAddress.toLowerCase()) throw new LifecyclePlanningError("HOOK_DEPLOYMENT_CHANGED", "Existing hook immutable dependency graph differs from the committed constructor");
219
219
  }
220
- if (await readLifecycleContract<bigint>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "REQUIRED_HOOK_FLAGS", [], block) !== 0x1afcn ||
221
- await readLifecycleContract<bigint>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "ALL_HOOK_MASK", [], block) !== 0x3fffn) throw new LifecyclePlanningError("HOOK_DEPLOYMENT_CHANGED", "Existing bound hook callback declarations differ from the reviewed envelope");
220
+ if (await readLifecycleContract<bigint>(client, predictedHook, fixedFeePoolHookV1Abi, "REQUIRED_HOOK_FLAGS", [], block) !== 0x1afcn ||
221
+ await readLifecycleContract<bigint>(client, predictedHook, fixedFeePoolHookV1Abi, "ALL_HOOK_MASK", [], block) !== 0x3fffn) throw new LifecyclePlanningError("HOOK_DEPLOYMENT_CHANGED", "Existing bound hook callback declarations differ from the reviewed envelope");
222
222
  const [currency0, currency1] = BigInt(token) < BigInt(market.quoteAsset) ? [token, market.quoteAsset] : [market.quoteAsset, token];
223
223
  const expectedPoolId = keccak256(encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }], [currency0, currency1, config.lpFeePips, config.tickSpacing, predictedHook]));
224
- const actualPoolId = await readLifecycleContract<Hex>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "boundPoolId", [], block);
225
- const deploymentConfigHash = await readLifecycleContract<Hex>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "deploymentConfigHash", [], block);
226
- const marketCommitment = await readLifecycleContract<Hex>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "marketCommitment", [], block);
227
- const opening = await readLifecycleContract<bigint>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "openingSqrtPriceX96", [], block);
228
- const positions = await readLifecycleContract<number>(client, predictedHook, poolBoundLaunchFeeHookV1Abi, "expectedPositionCount", [], block);
224
+ const actualPoolId = await readLifecycleContract<Hex>(client, predictedHook, fixedFeePoolHookV1Abi, "boundPoolId", [], block);
225
+ const deploymentConfigHash = await readLifecycleContract<Hex>(client, predictedHook, fixedFeePoolHookV1Abi, "deploymentConfigHash", [], block);
226
+ const marketCommitment = await readLifecycleContract<Hex>(client, predictedHook, fixedFeePoolHookV1Abi, "marketCommitment", [], block);
227
+ const opening = await readLifecycleContract<bigint>(client, predictedHook, fixedFeePoolHookV1Abi, "openingSqrtPriceX96", [], block);
228
+ const positions = await readLifecycleContract<number>(client, predictedHook, fixedFeePoolHookV1Abi, "expectedPositionCount", [], block);
229
229
  if (actualPoolId.toLowerCase() !== expectedPoolId.toLowerCase() || deploymentConfigHash.toLowerCase() !== keccak256(encodePoolBoundHookParameters(expected)).toLowerCase() || marketCommitment.toLowerCase() !== expected.marketCommitment.toLowerCase() || opening !== expected.sqrtPriceX96 || positions !== expected.expectedPositionCount) throw new LifecyclePlanningError("HOOK_DEPLOYMENT_CHANGED", "Existing hook key, economic commitment or immutable opening geometry changed");
230
230
  }
231
231
  return { deployment: { deployer, initCodeHash, salt, predictedHook }, parameters: expected };
@@ -179,10 +179,9 @@ export const LIFECYCLE_PERMANENT_CUSTODY_CAPABILITY = 8n;
179
179
  export const LIFECYCLE_CANONICAL_FEES_CAPABILITY = 16n;
180
180
  export const LIFECYCLE_ERC404_CAPABILITY = 32n;
181
181
  export const LIFECYCLE_MULTI_POSITION_CAPABILITY = 64n;
182
- /** TOKEN_ONLY|EMPTY_PREPARE|PERMANENT_CUSTODY|CANONICAL_FEES. The retired POOL_GATE bit
183
- * is never requested: preactivation safety is token transfer restrictions plus the
184
- * activation-time canonical opening-state verification on both canonical venues. Atomic
185
- * and staged share this mask; mode changes execution grouping, never venue eligibility. */
182
+ /** TOKEN_ONLY|EMPTY_PREPARE|PERMANENT_CUSTODY|CANONICAL_FEES. Preactivation safety
183
+ * uses token transfer restrictions and activation-time canonical opening-state
184
+ * verification on both venues. Atomic and staged share this capability mask. */
186
185
  export const LIFECYCLE_REQUIRED_CAPABILITIES = LIFECYCLE_TOKEN_ONLY_CAPABILITY | LIFECYCLE_EMPTY_PREPARE_CAPABILITY | LIFECYCLE_PERMANENT_CUSTODY_CAPABILITY | LIFECYCLE_CANONICAL_FEES_CAPABILITY;
187
186
  export const LIFECYCLE_MAX_ERC20_SUPPLY = (1n << 256n) - 1n;
188
187
  export const LIFECYCLE_MAX_REWARD_ERC20_SUPPLY = 10n ** 77n;