liquid-sdk 1.0.0 → 1.1.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.
package/dist/index.d.ts CHANGED
@@ -61,15 +61,15 @@ interface DeployTokenParams {
61
61
  context?: string;
62
62
  tokenAdmin?: Address;
63
63
  salt?: Hex;
64
- /** Hook address. Defaults to HOOK_DYNAMIC_FEE_V2 */
64
+ /** Hook address. Defaults to HOOK_STATIC_FEE_V2 (1% fee) */
65
65
  hook?: Address;
66
66
  /** Quote token. Defaults to WETH */
67
67
  pairedToken?: Address;
68
- /** Starting tick. Defaults to -198720 (approx $0.001 WETH per token) */
68
+ /** Starting tick. Defaults to -230400 (≈10 ETH market cap) */
69
69
  tickIfToken0IsLiquid?: number;
70
- /** Tick spacing. Defaults to 60 */
70
+ /** Tick spacing. Defaults to 200 */
71
71
  tickSpacing?: number;
72
- /** Pool-specific hook data */
72
+ /** Pool-specific hook data. Defaults to static 1% fee encoded for V2 hook */
73
73
  poolData?: Hex;
74
74
  /** LP locker address. Defaults to LP_LOCKER */
75
75
  locker?: Address;
@@ -87,9 +87,9 @@ interface DeployTokenParams {
87
87
  positionBps?: number[];
88
88
  /** Locker-specific data */
89
89
  lockerData?: Hex;
90
- /** MEV module address. Defaults to MEV_BLOCK_DELAY */
90
+ /** MEV module address. Defaults to SNIPER_AUCTION_V2 */
91
91
  mevModule?: Address;
92
- /** MEV module initialization data */
92
+ /** MEV module data. Defaults to 80%→40% decay over 32s */
93
93
  mevModuleData?: Hex;
94
94
  /** Extension configs (vault, airdrop, etc.) */
95
95
  extensions?: ExtensionConfig[];
@@ -201,6 +201,11 @@ declare class LiquidSDK {
201
201
  * The paired token must be WETH for simple dev buys.
202
202
  */
203
203
  buildDevBuyExtension(devBuy: DevBuyParams): ExtensionConfig;
204
+ /**
205
+ * Validate a DeploymentConfig before sending to the contract.
206
+ * Catches common mistakes client-side with clear error messages.
207
+ */
208
+ private validateDeploymentConfig;
204
209
  deployToken(params: DeployTokenParams): Promise<DeployTokenResult>;
205
210
  getDeploymentInfo(tokenAddress: Address): Promise<DeploymentInfo>;
206
211
  getTokenInfo(tokenAddress: Address): Promise<{
@@ -281,6 +286,55 @@ declare const TOKEN: {
281
286
  readonly MAX_EXTENSIONS: 10;
282
287
  readonly MAX_EXTENSION_BPS: 9000;
283
288
  };
289
+ interface PoolPosition {
290
+ tickLower: number;
291
+ tickUpper: number;
292
+ positionBps: number;
293
+ }
294
+ /**
295
+ * Pre-built position configurations.
296
+ *
297
+ * - **Standard**: Single position covering full range (~$20K → $1.5B).
298
+ * Default starting tick -230400 (≈10 ETH market cap).
299
+ *
300
+ * - **Liquid**: 3-tranche default for Liquid Protocol.
301
+ * Hardcoded for ≈10 ETH start at ~$2070/ETH.
302
+ * For dynamic market cap targets, use `createPositionsUSD()` instead.
303
+ *
304
+ * Note: positionBps must sum to 10,000 (100%).
305
+ */
306
+ declare const POOL_POSITIONS: {
307
+ /** Single position, 100% of liquidity in one range */
308
+ readonly Standard: PoolPosition[];
309
+ /** 3-tranche Liquid default (hardcoded for ~10 ETH start, ~$2070/ETH) */
310
+ readonly Liquid: PoolPosition[];
311
+ };
312
+ /**
313
+ * Liquid protocol defaults.
314
+ *
315
+ * - Hook: Static fee V2, 1% on buys only (fees in ETH), 0% on sells
316
+ * - MEV: Sniper Auction V2 — 80% → 40% decaying over 32 seconds
317
+ * - Tick spacing: 200
318
+ * - Starting tick: -230400 (≈10 ETH market cap)
319
+ * - Positions: 3-tranche Liquid default (40/50/10)
320
+ */
321
+ declare const DEFAULTS: {
322
+ readonly HOOK: `0x${string}`;
323
+ readonly TICK_SPACING: 200;
324
+ readonly TICK_IF_TOKEN0_IS_LIQUID: -230400;
325
+ /** Static fee on buys (ETH → token): 1% (100 bps). Fees collected in ETH. */
326
+ readonly PAIRED_FEE_BPS: 100;
327
+ /** Static fee on sells (token → ETH): 0%. No fees in liquid token. */
328
+ readonly LIQUID_FEE_BPS: 0;
329
+ /** MEV module: Sniper Auction V2 */
330
+ readonly MEV_MODULE: `0x${string}`;
331
+ /** Sniper auction starting fee: 80% (800,000 uniBps) */
332
+ readonly SNIPER_STARTING_FEE: 800000;
333
+ /** Sniper auction ending fee: 40% (400,000 uniBps) */
334
+ readonly SNIPER_ENDING_FEE: 400000;
335
+ /** Sniper auction decay period: 32 seconds */
336
+ readonly SNIPER_SECONDS_TO_DECAY: 32;
337
+ };
284
338
  declare const DEFAULT_CHAIN: {
285
339
  blockExplorers: {
286
340
  readonly default: {
@@ -600,6 +654,7 @@ declare const DEFAULT_CHAIN: {
600
654
  verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
601
655
  };
602
656
  declare const DEFAULT_CHAIN_ID = 8453;
657
+ declare const DEFAULT_RPC_URL = "https://base.drpc.org";
603
658
 
604
659
  declare const LiquidFactoryAbi: readonly [{
605
660
  readonly type: "function";
@@ -1632,4 +1687,266 @@ declare const ERC20Abi: readonly [{
1632
1687
  readonly stateMutability: "nonpayable";
1633
1688
  }];
1634
1689
 
1635
- export { ADDRESSES, type AirdropInfo, DEFAULT_CHAIN, DEFAULT_CHAIN_ID, type DeployTokenParams, type DeployTokenResult, type DeploymentConfig, type DeploymentInfo, type DevBuyParams, ERC20Abi, EXTERNAL, type ExtensionConfig, FEE, LiquidAirdropV2Abi, LiquidFactoryAbi, LiquidFeeLockerAbi, LiquidHookDynamicFeeV2Abi, LiquidLpLockerAbi, LiquidMevBlockDelayAbi, LiquidPoolExtensionAllowlistAbi, LiquidSDK, type LiquidSDKConfig, LiquidSniperAuctionV2Abi, LiquidSniperUtilV2Abi, LiquidVaultAbi, type LockerConfig, type MevModuleConfig, type PoolConfig, type PoolDynamicConfigVars, type PoolDynamicFeeVars, type PoolKey, type SniperAuctionFeeConfig, type SniperAuctionState, TOKEN, type TokenConfig, type TokenCreatedEvent, type TokenRewardInfo, type VaultAllocation };
1690
+ /**
1691
+ * Tick ↔ market cap conversion utilities for Uniswap V4 concentrated liquidity.
1692
+ *
1693
+ * All tokens have 100B supply (10^11) with 18 decimals.
1694
+ * Price per token = marketCap / totalSupply.
1695
+ * Tick = log(price) / log(1.0001), aligned to tickSpacing.
1696
+ */
1697
+ /**
1698
+ * Convert an ETH-denominated market cap to a Uniswap V4 tick.
1699
+ *
1700
+ * @param marketCapETH - Market cap in ETH (e.g. 10 for a 10 ETH starting cap)
1701
+ * @param tickSpacing - Tick spacing to align to (default 200)
1702
+ * @returns Tick value (int24) aligned to tickSpacing
1703
+ *
1704
+ * @example
1705
+ * ```ts
1706
+ * getTickFromMarketCapETH(10) // → -230400 (≈10 ETH market cap)
1707
+ * getTickFromMarketCapETH(200) // → -200200 (≈200 ETH)
1708
+ * ```
1709
+ */
1710
+ declare function getTickFromMarketCapETH(marketCapETH: number, tickSpacing?: number): number;
1711
+ /**
1712
+ * Convert a USD-denominated market cap to a Uniswap V4 tick.
1713
+ *
1714
+ * @param marketCapUSD - Market cap in USD (e.g. 500_000 for $500K)
1715
+ * @param ethPriceUSD - Current ETH price in USD (e.g. 2070)
1716
+ * @param tickSpacing - Tick spacing to align to (default 200)
1717
+ * @returns Tick value (int24) aligned to tickSpacing
1718
+ *
1719
+ * @example
1720
+ * ```ts
1721
+ * getTickFromMarketCapUSD(500_000, 2070) // tick for $500K market cap
1722
+ * getTickFromMarketCapUSD(10_000_000, 2070) // tick for $10M market cap
1723
+ * ```
1724
+ */
1725
+ declare function getTickFromMarketCapUSD(marketCapUSD: number, ethPriceUSD: number, tickSpacing?: number): number;
1726
+ /**
1727
+ * Convert a tick back to an ETH-denominated market cap.
1728
+ *
1729
+ * @param tick - Uniswap V4 tick value
1730
+ * @returns Market cap in ETH
1731
+ *
1732
+ * @example
1733
+ * ```ts
1734
+ * marketCapFromTickETH(-230400) // ≈ 10 ETH
1735
+ * ```
1736
+ */
1737
+ declare function marketCapFromTickETH(tick: number): number;
1738
+ /**
1739
+ * Convert a tick to a USD-denominated market cap.
1740
+ *
1741
+ * @param tick - Uniswap V4 tick value
1742
+ * @param ethPriceUSD - Current ETH price in USD
1743
+ * @returns Market cap in USD
1744
+ */
1745
+ declare function marketCapFromTickUSD(tick: number, ethPriceUSD: number): number;
1746
+ /**
1747
+ * Convert a market cap in a stablecoin to a tick.
1748
+ * Supports any stablecoin decimal count (6 for USDC, 18 for DAI, etc.)
1749
+ *
1750
+ * @param marketCap - Market cap in stablecoin units
1751
+ * @param stableDecimals - Decimals of the stablecoin (e.g. 6 for USDC)
1752
+ * @param tickSpacing - Tick spacing (default 200)
1753
+ * @returns Tick value aligned to tickSpacing
1754
+ */
1755
+ declare function getTickFromMarketCapStable(marketCap: number, stableDecimals: number, tickSpacing?: number): number;
1756
+
1757
+ /**
1758
+ * Multi-tranche liquidity position builder.
1759
+ *
1760
+ * Creates position arrays (tickLower[], tickUpper[], positionBps[]) from
1761
+ * market cap milestones. Percentages represent share of the *pool supply*
1762
+ * (i.e. after dev buy, airdrop, and vault allocations are deducted).
1763
+ */
1764
+ interface MarketCapTranche {
1765
+ /** Upper bound market cap in ETH for this tranche */
1766
+ upperMarketCapETH: number;
1767
+ /** Percentage of pool supply allocated to this tranche (1-100) */
1768
+ supplyPct: number;
1769
+ }
1770
+ interface MarketCapTrancheUSD {
1771
+ /** Upper bound market cap in USD for this tranche */
1772
+ upperMarketCapUSD: number;
1773
+ /** Percentage of pool supply allocated to this tranche (1-100) */
1774
+ supplyPct: number;
1775
+ }
1776
+ interface PositionConfig {
1777
+ tickLower: number;
1778
+ tickUpper: number;
1779
+ positionBps: number;
1780
+ }
1781
+ interface PositionArrays {
1782
+ tickLower: number[];
1783
+ tickUpper: number[];
1784
+ positionBps: number[];
1785
+ }
1786
+ /**
1787
+ * Default Liquid tranches (USD-denominated).
1788
+ *
1789
+ * - Starting → $500K market cap: 40% of pool supply
1790
+ * - $500K → $10M market cap: 50% of pool supply
1791
+ * - $10M → $1B market cap: 10% of pool supply
1792
+ */
1793
+ declare const DEFAULT_TRANCHES_USD: MarketCapTrancheUSD[];
1794
+ /**
1795
+ * Build position arrays from ETH-denominated market cap tranches.
1796
+ *
1797
+ * @param startingMarketCapETH - Initial market cap in ETH (determines the starting tick)
1798
+ * @param tranches - Array of tranches with upper market cap bounds and supply percentages
1799
+ * @param tickSpacing - Tick spacing (default 200)
1800
+ * @returns Position arrays ready to pass to `deployToken()`
1801
+ *
1802
+ * @example
1803
+ * ```ts
1804
+ * const positions = createPositions(10, [
1805
+ * { upperMarketCapETH: 241.5, supplyPct: 40 }, // ~$500K at $2070/ETH
1806
+ * { upperMarketCapETH: 4830, supplyPct: 50 }, // ~$10M
1807
+ * { upperMarketCapETH: 483050, supplyPct: 10 }, // ~$1B
1808
+ * ]);
1809
+ * // → { tickLower: [-230400, -198600, -168600],
1810
+ * // tickUpper: [-198600, -168600, -122400],
1811
+ * // positionBps: [4000, 5000, 1000] }
1812
+ * ```
1813
+ */
1814
+ declare function createPositions(startingMarketCapETH: number, tranches: MarketCapTranche[], tickSpacing?: number): PositionArrays;
1815
+ /**
1816
+ * Build position arrays from USD-denominated market cap tranches.
1817
+ * Convenience wrapper that converts USD → ETH using the provided ETH price.
1818
+ *
1819
+ * @param startingMarketCapUSD - Initial market cap in USD
1820
+ * @param ethPriceUSD - Current ETH price in USD
1821
+ * @param tranches - Array of tranches with upper USD market cap bounds
1822
+ * @param tickSpacing - Tick spacing (default 200)
1823
+ * @returns Position arrays ready to pass to `deployToken()`
1824
+ *
1825
+ * @example
1826
+ * ```ts
1827
+ * const positions = createPositionsUSD(20_000, 2070, [
1828
+ * { upperMarketCapUSD: 500_000, supplyPct: 40 },
1829
+ * { upperMarketCapUSD: 10_000_000, supplyPct: 50 },
1830
+ * { upperMarketCapUSD: 1_000_000_000, supplyPct: 10 },
1831
+ * ]);
1832
+ * ```
1833
+ */
1834
+ declare function createPositionsUSD(startingMarketCapUSD: number, ethPriceUSD: number, tranches: MarketCapTrancheUSD[], tickSpacing?: number): PositionArrays;
1835
+ /**
1836
+ * Build default Liquid positions using the standard 3-tranche split.
1837
+ *
1838
+ * - Starting → $500K: 40% of pool supply
1839
+ * - $500K → $10M: 50% of pool supply
1840
+ * - $10M → $1B: 10% of pool supply
1841
+ *
1842
+ * @param startingMarketCapUSD - Initial market cap in USD (e.g. 20_000 for ~10 ETH)
1843
+ * @param ethPriceUSD - Current ETH price in USD
1844
+ * @param tickSpacing - Tick spacing (default 200)
1845
+ *
1846
+ * @example
1847
+ * ```ts
1848
+ * const positions = createDefaultPositions(20_000, 2070);
1849
+ * const tx = await sdk.deployToken({
1850
+ * name: "MyToken",
1851
+ * symbol: "MTK",
1852
+ * ...positions,
1853
+ * });
1854
+ * ```
1855
+ */
1856
+ declare function createDefaultPositions(startingMarketCapUSD: number, ethPriceUSD: number, tickSpacing?: number): PositionArrays & {
1857
+ tickIfToken0IsLiquid: number;
1858
+ };
1859
+ /**
1860
+ * Describe positions as human-readable market cap ranges.
1861
+ * Useful for displaying position info in UIs.
1862
+ *
1863
+ * @param positions - Position arrays
1864
+ * @param ethPriceUSD - Optional ETH price for USD display
1865
+ */
1866
+ declare function describePositions(positions: PositionArrays, ethPriceUSD?: number): Array<{
1867
+ index: number;
1868
+ tickLower: number;
1869
+ tickUpper: number;
1870
+ supplyPct: number;
1871
+ marketCapLowerETH: number;
1872
+ marketCapUpperETH: number;
1873
+ marketCapLowerUSD?: number;
1874
+ marketCapUpperUSD?: number;
1875
+ }>;
1876
+
1877
+ /**
1878
+ * ABI encoding helpers for pool data, fee configs, and MEV module data.
1879
+ */
1880
+
1881
+ /**
1882
+ * Encode pool data for the static fee V2 hook.
1883
+ *
1884
+ * Uses two-layer encoding:
1885
+ * 1. Inner: static fee params [liquidFee, pairedFee] in uniBps
1886
+ * 2. Outer: PoolInitializationData wrapper
1887
+ *
1888
+ * @param liquidFeeBps - Fee when swapping for the liquid token (in bps, e.g. 100 = 1%)
1889
+ * @param pairedFeeBps - Fee when swapping for the paired token (in bps, e.g. 100 = 1%)
1890
+ * @param extension - Optional pool extension address (defaults to zero)
1891
+ * @param extensionData - Optional pool extension init data (defaults to "0x")
1892
+ * @returns Encoded poolData hex string
1893
+ *
1894
+ * @example
1895
+ * ```ts
1896
+ * // 1% fee both directions (default)
1897
+ * const poolData = encodeStaticFeePoolData(100, 100);
1898
+ * ```
1899
+ */
1900
+ declare function encodeStaticFeePoolData(liquidFeeBps: number, pairedFeeBps: number, extension?: `0x${string}`, extensionData?: Hex): Hex;
1901
+ interface DynamicFeeConfig {
1902
+ /** Base LP fee in bps (e.g. 100 = 1%) */
1903
+ baseFeeBps: number;
1904
+ /** Max LP fee in bps (e.g. 500 = 5%) */
1905
+ maxFeeBps: number;
1906
+ /** Reference tick filter period in seconds */
1907
+ referenceTickFilterPeriod: number;
1908
+ /** Reset period in seconds */
1909
+ resetPeriod: number;
1910
+ /** Reset tick filter (tick units) */
1911
+ resetTickFilter: number;
1912
+ /** Fee control numerator (scaling constant) */
1913
+ feeControlNumerator: bigint;
1914
+ /** Decay filter in bps */
1915
+ decayFilterBps: number;
1916
+ }
1917
+ /**
1918
+ * Encode pool data for the dynamic fee V2 hook.
1919
+ *
1920
+ * @param config - Dynamic fee configuration
1921
+ * @param extension - Optional pool extension address
1922
+ * @param extensionData - Optional pool extension init data
1923
+ * @returns Encoded poolData hex string
1924
+ */
1925
+ declare function encodeDynamicFeePoolData(config: DynamicFeeConfig, extension?: `0x${string}`, extensionData?: Hex): Hex;
1926
+ interface SniperAuctionConfig {
1927
+ /** Starting fee in uniBps (e.g. 800_000 = 80%) */
1928
+ startingFee: number;
1929
+ /** Ending fee in uniBps (e.g. 400_000 = 40%) */
1930
+ endingFee: number;
1931
+ /** Seconds for fee to decay from starting to ending */
1932
+ secondsToDecay: number;
1933
+ }
1934
+ /**
1935
+ * Encode MEV module data for the Sniper Auction V2.
1936
+ *
1937
+ * @param config - Sniper auction fee configuration
1938
+ * @returns Encoded mevModuleData hex string
1939
+ *
1940
+ * @example
1941
+ * ```ts
1942
+ * // 80% → 40% over 32 seconds (default)
1943
+ * const mevData = encodeSniperAuctionData({
1944
+ * startingFee: 800_000,
1945
+ * endingFee: 400_000,
1946
+ * secondsToDecay: 32,
1947
+ * });
1948
+ * ```
1949
+ */
1950
+ declare function encodeSniperAuctionData(config: SniperAuctionConfig): Hex;
1951
+
1952
+ export { ADDRESSES, type AirdropInfo, 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, LiquidAirdropV2Abi, LiquidFactoryAbi, LiquidFeeLockerAbi, LiquidHookDynamicFeeV2Abi, LiquidLpLockerAbi, LiquidMevBlockDelayAbi, LiquidPoolExtensionAllowlistAbi, LiquidSDK, type LiquidSDKConfig, LiquidSniperAuctionV2Abi, LiquidSniperUtilV2Abi, 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, TOKEN, type TokenConfig, type TokenCreatedEvent, type TokenRewardInfo, type VaultAllocation, createDefaultPositions, createPositions, createPositionsUSD, describePositions, encodeDynamicFeePoolData, encodeSniperAuctionData, encodeStaticFeePoolData, getTickFromMarketCapETH, getTickFromMarketCapStable, getTickFromMarketCapUSD, marketCapFromTickETH, marketCapFromTickUSD };