liquid-sdk 1.7.3 → 1.7.4

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.
package/dist/index.d.ts CHANGED
@@ -471,6 +471,9 @@ declare const ADDRESSES: {
471
471
  declare const EXTERNAL: {
472
472
  readonly POOL_MANAGER: Address;
473
473
  readonly WETH: Address;
474
+ /** DIEM — Liquid's intelligence-economy token. Also a pair token for
475
+ * agent-token launches (see `createLiquidPositionsUSD`). */
476
+ readonly DIEM: Address;
474
477
  readonly UNIVERSAL_ROUTER: Address;
475
478
  readonly PERMIT2: Address;
476
479
  };
@@ -621,31 +624,7 @@ declare const DEFAULT_CHAIN: {
621
624
  formatters: {
622
625
  readonly block: {
623
626
  exclude: [] | undefined;
624
- format: (args: viem_chains.OpStackRpcBlock, action
625
- /**
626
- * Pre-built position configurations.
627
- *
628
- * - **Standard**: Single position covering full range (~$20K → $1.5B).
629
- * Default starting tick -230400 (≈10 ETH market cap).
630
- *
631
- * - **Liquid**: 3-tranche default for Liquid Protocol.
632
- * Hardcoded for ≈10 ETH start at ~$2070/ETH.
633
- * For dynamic market cap targets, use `createPositionsUSD()` instead.
634
- *
635
- * Note: positionBps must sum to 10,000 (100%).
636
- */
637
- ? /**
638
- * Pre-built position configurations.
639
- *
640
- * - **Standard**: Single position covering full range (~$20K → $1.5B).
641
- * Default starting tick -230400 (≈10 ETH market cap).
642
- *
643
- * - **Liquid**: 3-tranche default for Liquid Protocol.
644
- * Hardcoded for ≈10 ETH start at ~$2070/ETH.
645
- * For dynamic market cap targets, use `createPositionsUSD()` instead.
646
- *
647
- * Note: positionBps must sum to 10,000 (100%).
648
- */: string | undefined) => {
627
+ format: (args: viem_chains.OpStackRpcBlock, action?: string | undefined) => {
649
628
  baseFeePerGas: bigint | null;
650
629
  blobGasUsed: bigint;
651
630
  difficulty: bigint;
@@ -2323,6 +2302,7 @@ declare function getTickFromMarketCapStable(marketCap: number, stableDecimals: n
2323
2302
  * market cap milestones. Percentages represent share of the *pool supply*
2324
2303
  * (i.e. after dev buy, airdrop, and vault allocations are deducted).
2325
2304
  */
2305
+
2326
2306
  interface MarketCapTranche {
2327
2307
  /** Upper bound market cap in ETH for this tranche */
2328
2308
  upperMarketCapETH: number;
@@ -2418,6 +2398,55 @@ declare function createPositionsUSD(startingMarketCapUSD: number, ethPriceUSD: n
2418
2398
  declare function createDefaultPositions(startingMarketCapUSD: number, ethPriceUSD: number, tickSpacing?: number): PositionArrays & {
2419
2399
  tickIfToken0IsLiquid: number;
2420
2400
  };
2401
+ /**
2402
+ * Shift every tick in a position layout by a fixed amount, preserving the
2403
+ * positionBps splits. The primitive behind `createLiquidPositionsUSD` — it
2404
+ * re-anchors a fixed-shape layout (e.g. `POOL_POSITIONS.Liquid`) to a
2405
+ * different starting tick.
2406
+ *
2407
+ * `shiftBy` should be a multiple of the pool's tick spacing so the shifted
2408
+ * ticks stay aligned. A difference of two aligned ticks is always aligned,
2409
+ * so deriving it as `targetTick - sourceBottomTick` is safe.
2410
+ *
2411
+ * @param positions - Source positions (e.g. `POOL_POSITIONS.Liquid`)
2412
+ * @param shiftBy - Ticks to add to every tickLower/tickUpper (may be negative)
2413
+ * @returns A fresh array — the source is not mutated
2414
+ */
2415
+ declare function shiftPositions(positions: readonly PoolPosition[], shiftBy: number): PoolPosition[];
2416
+ /**
2417
+ * Build the canonical 5-position "Liquid" layout (10/50/15/20/5) re-anchored
2418
+ * to a starting market cap, denominated in the *paired token's* USD price.
2419
+ *
2420
+ * Works for any pair token — pass the price of whatever the pool is paired
2421
+ * against:
2422
+ * - WETH-paired: `createLiquidPositionsUSD(20_000, ethPriceUSD)`
2423
+ * - DIEM-paired: `createLiquidPositionsUSD(20_000, diemPriceUSD)`
2424
+ *
2425
+ * Unlike `createDefaultPositions` (a 3-tranche layout), this preserves the
2426
+ * exact shape of `POOL_POSITIONS.Liquid` — the same curve `deployToken()`
2427
+ * uses by default — just shifted so its bottom sits at the requested start.
2428
+ *
2429
+ * @param startingMarketCapUSD - Initial market cap in USD
2430
+ * @param pairedTokenPriceUSD - USD price of the token the pool is paired against
2431
+ * @param tickSpacing - Tick spacing (default 200)
2432
+ * @returns Position arrays + `tickIfToken0IsLiquid`, ready to spread into `deployToken()`
2433
+ *
2434
+ * @example
2435
+ * ```ts
2436
+ * import { LiquidSDK, EXTERNAL, createLiquidPositionsUSD } from "liquid-sdk";
2437
+ *
2438
+ * const positions = createLiquidPositionsUSD(20_000, diemPriceUSD);
2439
+ * await sdk.deployToken({
2440
+ * name: "Agent Token",
2441
+ * symbol: "AGENT",
2442
+ * pairedToken: EXTERNAL.DIEM,
2443
+ * ...positions,
2444
+ * });
2445
+ * ```
2446
+ */
2447
+ declare function createLiquidPositionsUSD(startingMarketCapUSD: number, pairedTokenPriceUSD: number, tickSpacing?: number): PositionArrays & {
2448
+ tickIfToken0IsLiquid: number;
2449
+ };
2421
2450
  /**
2422
2451
  * Describe positions as human-readable market cap ranges.
2423
2452
  * Useful for displaying position info in UIs.
@@ -2595,4 +2624,4 @@ declare function parseContext(contextString: string): LiquidContext | null;
2595
2624
  */
2596
2625
  declare function parseMetadata(metadataString: string): LiquidMetadata | null;
2597
2626
 
2598
- export { ADDRESSES, type AirdropExtensionParams, type AirdropInfo, type BidInAuctionParams, type BidInAuctionResult, DEFAULTS, DEFAULT_CHAIN, DEFAULT_CHAIN_ID, DEFAULT_RPC_URL, DEFAULT_TRANCHES_USD, type DeployTokenParams, type DeployTokenResult, type DeploymentConfig, type DeploymentInfo, type DevBuyParams, type DynamicFeeConfig, ERC20Abi, EXTERNAL, type ExtensionConfig, FEE, FeePreference, type GetTokensOptions, LiquidAirdropV2Abi, type LiquidContext, LiquidFactoryAbi, LiquidFeeLockerAbi, LiquidHookDynamicFeeV2Abi, LiquidLpLockerAbi, type LiquidMetadata, LiquidMevBlockDelayAbi, LiquidMevDescendingFeesAbi, LiquidPoolExtensionAllowlistAbi, LiquidSDK, type LiquidSDKConfig, LiquidSniperAuctionV2Abi, LiquidSniperUtilV2Abi, LiquidTokenAbi, LiquidUniv4EthDevBuyAbi, LiquidVaultAbi, type LockerConfig, type MarketCapTranche, type MarketCapTrancheUSD, type MevModuleConfig, POOL_POSITIONS, type PoolConfig, type PoolDynamicConfigVars, type PoolDynamicFeeVars, type PoolKey, type PoolPosition, type PositionArrays, type PositionConfig, type SniperAuctionConfig, type SniperAuctionFeeConfig, type SniperAuctionState, type SocialMediaUrl, TOKEN, type TokenConfig, type TokenCreatedEvent, type TokenRewardInfo, type VaultAllocation, type VaultExtensionParams, buildContext, buildMetadata, createDefaultPositions, createPositions, createPositionsUSD, describePositions, encodeDynamicFeePoolData, encodeFeeConversionLockerData, encodeSniperAuctionData, encodeStaticFeePoolData, getTickFromMarketCapETH, getTickFromMarketCapStable, getTickFromMarketCapUSD, marketCapFromTickETH, marketCapFromTickUSD, parseContext, parseMetadata };
2627
+ export { ADDRESSES, type AirdropExtensionParams, type AirdropInfo, type BidInAuctionParams, type BidInAuctionResult, DEFAULTS, DEFAULT_CHAIN, DEFAULT_CHAIN_ID, DEFAULT_RPC_URL, DEFAULT_TRANCHES_USD, type DeployTokenParams, type DeployTokenResult, type DeploymentConfig, type DeploymentInfo, type DevBuyParams, type DynamicFeeConfig, ERC20Abi, EXTERNAL, type ExtensionConfig, FEE, FeePreference, type GetTokensOptions, LiquidAirdropV2Abi, type LiquidContext, LiquidFactoryAbi, LiquidFeeLockerAbi, LiquidHookDynamicFeeV2Abi, LiquidLpLockerAbi, type LiquidMetadata, LiquidMevBlockDelayAbi, LiquidMevDescendingFeesAbi, LiquidPoolExtensionAllowlistAbi, LiquidSDK, type LiquidSDKConfig, LiquidSniperAuctionV2Abi, LiquidSniperUtilV2Abi, LiquidTokenAbi, LiquidUniv4EthDevBuyAbi, LiquidVaultAbi, type LockerConfig, type MarketCapTranche, type MarketCapTrancheUSD, type MevModuleConfig, POOL_POSITIONS, type PoolConfig, type PoolDynamicConfigVars, type PoolDynamicFeeVars, type PoolKey, type PoolPosition, type PositionArrays, type PositionConfig, type SniperAuctionConfig, type SniperAuctionFeeConfig, type SniperAuctionState, type SocialMediaUrl, TOKEN, type TokenConfig, type TokenCreatedEvent, type TokenRewardInfo, type VaultAllocation, type VaultExtensionParams, buildContext, buildMetadata, createDefaultPositions, createLiquidPositionsUSD, createPositions, createPositionsUSD, describePositions, encodeDynamicFeePoolData, encodeFeeConversionLockerData, encodeSniperAuctionData, encodeStaticFeePoolData, getTickFromMarketCapETH, getTickFromMarketCapStable, getTickFromMarketCapUSD, marketCapFromTickETH, marketCapFromTickUSD, parseContext, parseMetadata, shiftPositions };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  buildContext: () => buildContext,
50
50
  buildMetadata: () => buildMetadata,
51
51
  createDefaultPositions: () => createDefaultPositions,
52
+ createLiquidPositionsUSD: () => createLiquidPositionsUSD,
52
53
  createPositions: () => createPositions,
53
54
  createPositionsUSD: () => createPositionsUSD,
54
55
  describePositions: () => describePositions,
@@ -62,7 +63,8 @@ __export(index_exports, {
62
63
  marketCapFromTickETH: () => marketCapFromTickETH,
63
64
  marketCapFromTickUSD: () => marketCapFromTickUSD,
64
65
  parseContext: () => parseContext,
65
- parseMetadata: () => parseMetadata
66
+ parseMetadata: () => parseMetadata,
67
+ shiftPositions: () => shiftPositions
66
68
  });
67
69
  module.exports = __toCommonJS(index_exports);
68
70
 
@@ -92,6 +94,9 @@ var ADDRESSES = {
92
94
  var EXTERNAL = {
93
95
  POOL_MANAGER: "0x498581fF718922c3f8e6A244956aF099B2652b2b",
94
96
  WETH: "0x4200000000000000000000000000000000000006",
97
+ /** DIEM — Liquid's intelligence-economy token. Also a pair token for
98
+ * agent-token launches (see `createLiquidPositionsUSD`). */
99
+ DIEM: "0xF4d97F2da56e8c3098f3a8D538DB630A2606a024",
95
100
  UNIVERSAL_ROUTER: "0x6fF5693b99212Da76ad316178A184AB56D299b43",
96
101
  PERMIT2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
97
102
  };
@@ -1443,7 +1448,16 @@ var LiquidSDK = class {
1443
1448
  account: this.walletClient.account
1444
1449
  });
1445
1450
  gas = estimated * 120n / 100n;
1446
- } catch {
1451
+ } catch (err) {
1452
+ const e = err;
1453
+ const looksLikeRevert = e?.name === "ContractFunctionExecutionError" || e?.name === "CallExecutionError" || typeof e?.shortMessage === "string" && /reverted|revert reason|execution reverted/i.test(e.shortMessage);
1454
+ if (looksLikeRevert) throw err;
1455
+ if (typeof console !== "undefined" && console.warn) {
1456
+ console.warn(
1457
+ "[liquid-sdk] deployToken gas estimation failed; falling back to 6M gas limit:",
1458
+ e?.shortMessage ?? err
1459
+ );
1460
+ }
1447
1461
  gas = 6000000n;
1448
1462
  }
1449
1463
  const txHash = await this.walletClient.writeContract({
@@ -2437,6 +2451,33 @@ function createDefaultPositions(startingMarketCapUSD, ethPriceUSD, tickSpacing =
2437
2451
  tickIfToken0IsLiquid: positions.tickLower[0]
2438
2452
  };
2439
2453
  }
2454
+ function shiftPositions(positions, shiftBy) {
2455
+ return positions.map((p) => ({
2456
+ tickLower: p.tickLower + shiftBy,
2457
+ tickUpper: p.tickUpper + shiftBy,
2458
+ positionBps: p.positionBps
2459
+ }));
2460
+ }
2461
+ function createLiquidPositionsUSD(startingMarketCapUSD, pairedTokenPriceUSD, tickSpacing = 200) {
2462
+ if (pairedTokenPriceUSD <= 0) {
2463
+ throw new Error("pairedTokenPriceUSD must be positive");
2464
+ }
2465
+ const startingTick = getTickFromMarketCapUSD(
2466
+ startingMarketCapUSD,
2467
+ pairedTokenPriceUSD,
2468
+ tickSpacing
2469
+ );
2470
+ const shifted = shiftPositions(
2471
+ POOL_POSITIONS.Liquid,
2472
+ startingTick - DEFAULTS.TICK_IF_TOKEN0_IS_LIQUID
2473
+ );
2474
+ return {
2475
+ tickLower: shifted.map((p) => p.tickLower),
2476
+ tickUpper: shifted.map((p) => p.tickUpper),
2477
+ positionBps: shifted.map((p) => p.positionBps),
2478
+ tickIfToken0IsLiquid: startingTick
2479
+ };
2480
+ }
2440
2481
  function describePositions(positions, ethPriceUSD) {
2441
2482
  return positions.tickLower.map((_, i) => {
2442
2483
  const lowerETH = Math.pow(1.0001, positions.tickLower[i]) * 1e11;
@@ -2486,6 +2527,7 @@ function describePositions(positions, ethPriceUSD) {
2486
2527
  buildContext,
2487
2528
  buildMetadata,
2488
2529
  createDefaultPositions,
2530
+ createLiquidPositionsUSD,
2489
2531
  createPositions,
2490
2532
  createPositionsUSD,
2491
2533
  describePositions,
@@ -2499,6 +2541,7 @@ function describePositions(positions, ethPriceUSD) {
2499
2541
  marketCapFromTickETH,
2500
2542
  marketCapFromTickUSD,
2501
2543
  parseContext,
2502
- parseMetadata
2544
+ parseMetadata,
2545
+ shiftPositions
2503
2546
  });
2504
2547
  //# sourceMappingURL=index.js.map