@baseline-markets/sdk 1.0.1 → 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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getContract, BaseError, UserRejectedRequestError, InsufficientFundsError, ContractFunctionRevertedError, HttpRequestError, WebSocketRequestError, SocketClosedError, TimeoutError, decodeErrorResult } from 'viem';
1
+ import { toHex, getContract, BaseError, UserRejectedRequestError, InsufficientFundsError, ContractFunctionRevertedError, HttpRequestError, WebSocketRequestError, SocketClosedError, TimeoutError, decodeErrorResult, encodeFunctionData, isAddress } from 'viem';
2
2
  import { baseSepolia, base, mainnet } from 'viem/chains';
3
3
 
4
4
  // ../contracts/abis/external/chainlinkOracle.ts
@@ -1570,1825 +1570,10 @@ var bCredit = [
1570
1570
  ];
1571
1571
 
1572
1572
  // ../contracts/abis/mercury/bFactory.ts
1573
- var bFactory = [
1574
- {
1575
- type: "function",
1576
- name: "LABEL",
1577
- inputs: [],
1578
- outputs: [
1579
- {
1580
- name: "",
1581
- type: "bytes32",
1582
- internalType: "bytes32"
1583
- }
1584
- ],
1585
- stateMutability: "pure"
1586
- },
1587
- {
1588
- type: "function",
1589
- name: "ROUTES",
1590
- inputs: [],
1591
- outputs: [
1592
- {
1593
- name: "routes_",
1594
- type: "bytes4[]",
1595
- internalType: "bytes4[]"
1596
- }
1597
- ],
1598
- stateMutability: "pure"
1599
- },
1600
- {
1601
- type: "function",
1602
- name: "VERSION",
1603
- inputs: [],
1604
- outputs: [
1605
- {
1606
- name: "",
1607
- type: "uint256",
1608
- internalType: "uint256"
1609
- }
1610
- ],
1611
- stateMutability: "pure"
1612
- },
1613
- {
1614
- type: "function",
1615
- name: "createBToken",
1616
- inputs: [
1617
- {
1618
- name: "_name",
1619
- type: "string",
1620
- internalType: "string"
1621
- },
1622
- {
1623
- name: "_symbol",
1624
- type: "string",
1625
- internalType: "string"
1626
- },
1627
- {
1628
- name: "_totalSupply",
1629
- type: "uint256",
1630
- internalType: "uint256"
1631
- },
1632
- {
1633
- name: "_salt",
1634
- type: "bytes32",
1635
- internalType: "bytes32"
1636
- }
1637
- ],
1638
- outputs: [
1639
- {
1640
- name: "bToken_",
1641
- type: "address",
1642
- internalType: "contract BToken"
1643
- }
1644
- ],
1645
- stateMutability: "nonpayable"
1646
- },
1647
- {
1648
- type: "function",
1649
- name: "createPool",
1650
- inputs: [
1651
- {
1652
- name: "params",
1653
- type: "tuple",
1654
- internalType: "struct BFactory.CreateParams",
1655
- components: [
1656
- {
1657
- name: "bToken",
1658
- type: "address",
1659
- internalType: "contract BToken"
1660
- },
1661
- {
1662
- name: "initialPoolBTokens",
1663
- type: "uint256",
1664
- internalType: "uint256"
1665
- },
1666
- {
1667
- name: "reserve",
1668
- type: "address",
1669
- internalType: "address"
1670
- },
1671
- {
1672
- name: "initialPoolReserves",
1673
- type: "uint256",
1674
- internalType: "uint256"
1675
- },
1676
- {
1677
- name: "initialActivePrice",
1678
- type: "uint256",
1679
- internalType: "uint256"
1680
- },
1681
- {
1682
- name: "initialBLV",
1683
- type: "uint256",
1684
- internalType: "uint256"
1685
- },
1686
- {
1687
- name: "creator",
1688
- type: "address",
1689
- internalType: "address"
1690
- },
1691
- {
1692
- name: "feeRecipient",
1693
- type: "address",
1694
- internalType: "address"
1695
- },
1696
- {
1697
- name: "creatorFeePct",
1698
- type: "uint256",
1699
- internalType: "uint256"
1700
- },
1701
- {
1702
- name: "swapFeePct",
1703
- type: "uint256",
1704
- internalType: "uint256"
1705
- },
1706
- {
1707
- name: "createHook",
1708
- type: "bool",
1709
- internalType: "bool"
1710
- },
1711
- {
1712
- name: "claimMerkleRoot",
1713
- type: "bytes32",
1714
- internalType: "bytes32"
1715
- },
1716
- {
1717
- name: "initialCollateral",
1718
- type: "uint256",
1719
- internalType: "uint256"
1720
- },
1721
- {
1722
- name: "initialDebt",
1723
- type: "uint256",
1724
- internalType: "uint256"
1725
- }
1726
- ]
1727
- }
1728
- ],
1729
- outputs: [],
1730
- stateMutability: "payable"
1731
- },
1732
- {
1733
- type: "function",
1734
- name: "precomputeBTokenAddress",
1735
- inputs: [
1736
- {
1737
- name: "_name",
1738
- type: "string",
1739
- internalType: "string"
1740
- },
1741
- {
1742
- name: "_symbol",
1743
- type: "string",
1744
- internalType: "string"
1745
- },
1746
- {
1747
- name: "_totalSupply",
1748
- type: "uint256",
1749
- internalType: "uint256"
1750
- },
1751
- {
1752
- name: "_salt",
1753
- type: "bytes32",
1754
- internalType: "bytes32"
1755
- },
1756
- {
1757
- name: "_deployer",
1758
- type: "address",
1759
- internalType: "address"
1760
- }
1761
- ],
1762
- outputs: [
1763
- {
1764
- name: "computedAddress_",
1765
- type: "address",
1766
- internalType: "address"
1767
- }
1768
- ],
1769
- stateMutability: "view"
1770
- },
1771
- {
1772
- type: "function",
1773
- name: "supportsInterface",
1774
- inputs: [
1775
- {
1776
- name: "_interfaceId",
1777
- type: "bytes4",
1778
- internalType: "bytes4"
1779
- }
1780
- ],
1781
- outputs: [
1782
- {
1783
- name: "",
1784
- type: "bool",
1785
- internalType: "bool"
1786
- }
1787
- ],
1788
- stateMutability: "pure"
1789
- },
1790
- {
1791
- type: "event",
1792
- name: "BTokenCreated",
1793
- inputs: [
1794
- {
1795
- name: "bTokenAddress",
1796
- type: "address",
1797
- indexed: false,
1798
- internalType: "contract BToken"
1799
- },
1800
- {
1801
- name: "name",
1802
- type: "string",
1803
- indexed: false,
1804
- internalType: "string"
1805
- },
1806
- {
1807
- name: "symbol",
1808
- type: "string",
1809
- indexed: false,
1810
- internalType: "string"
1811
- },
1812
- {
1813
- name: "decimals",
1814
- type: "uint8",
1815
- indexed: false,
1816
- internalType: "uint8"
1817
- },
1818
- {
1819
- name: "totalSupply",
1820
- type: "uint256",
1821
- indexed: false,
1822
- internalType: "uint256"
1823
- },
1824
- {
1825
- name: "creator",
1826
- type: "address",
1827
- indexed: false,
1828
- internalType: "address"
1829
- }
1830
- ],
1831
- anonymous: false
1832
- },
1833
- {
1834
- type: "event",
1835
- name: "Initialized",
1836
- inputs: [
1837
- {
1838
- name: "bToken",
1839
- type: "address",
1840
- indexed: false,
1841
- internalType: "contract BToken"
1842
- },
1843
- {
1844
- name: "activePrice",
1845
- type: "uint256",
1846
- indexed: false,
1847
- internalType: "uint256"
1848
- },
1849
- {
1850
- name: "blvPrice",
1851
- type: "uint256",
1852
- indexed: false,
1853
- internalType: "uint256"
1854
- },
1855
- {
1856
- name: "swapFeePct",
1857
- type: "uint256",
1858
- indexed: false,
1859
- internalType: "uint256"
1860
- }
1861
- ],
1862
- anonymous: false
1863
- },
1864
- {
1865
- type: "event",
1866
- name: "PoolCreated",
1867
- inputs: [
1868
- {
1869
- name: "bTokenAddress",
1870
- type: "address",
1871
- indexed: false,
1872
- internalType: "contract BToken"
1873
- },
1874
- {
1875
- name: "reserveAddress",
1876
- type: "address",
1877
- indexed: false,
1878
- internalType: "address"
1879
- },
1880
- {
1881
- name: "creator",
1882
- type: "address",
1883
- indexed: false,
1884
- internalType: "address"
1885
- },
1886
- {
1887
- name: "feeRecipient",
1888
- type: "address",
1889
- indexed: false,
1890
- internalType: "address"
1891
- },
1892
- {
1893
- name: "creatorFeePct",
1894
- type: "uint256",
1895
- indexed: false,
1896
- internalType: "uint256"
1897
- },
1898
- {
1899
- name: "initialActivePrice",
1900
- type: "uint256",
1901
- indexed: false,
1902
- internalType: "uint256"
1903
- },
1904
- {
1905
- name: "initialBlvPrice",
1906
- type: "uint256",
1907
- indexed: false,
1908
- internalType: "uint256"
1909
- },
1910
- {
1911
- name: "totalReserves",
1912
- type: "uint256",
1913
- indexed: false,
1914
- internalType: "uint256"
1915
- },
1916
- {
1917
- name: "totalBTokens",
1918
- type: "uint256",
1919
- indexed: false,
1920
- internalType: "uint256"
1921
- },
1922
- {
1923
- name: "totalCollateral",
1924
- type: "uint256",
1925
- indexed: false,
1926
- internalType: "uint256"
1927
- },
1928
- {
1929
- name: "totalDebt",
1930
- type: "uint256",
1931
- indexed: false,
1932
- internalType: "uint256"
1933
- },
1934
- {
1935
- name: "poolId",
1936
- type: "bytes32",
1937
- indexed: false,
1938
- internalType: "bytes32"
1939
- }
1940
- ],
1941
- anonymous: false
1942
- },
1943
- {
1944
- type: "error",
1945
- name: "AlreadyInitialized",
1946
- inputs: []
1947
- },
1948
- {
1949
- type: "error",
1950
- name: "Component_NotPermitted",
1951
- inputs: []
1952
- },
1953
- {
1954
- type: "error",
1955
- name: "GuardLib_Paused",
1956
- inputs: []
1957
- },
1958
- {
1959
- type: "error",
1960
- name: "GuardLib_Reentrant",
1961
- inputs: []
1962
- },
1963
- {
1964
- type: "error",
1965
- name: "GuardLib_ReserveAccountingMismatch",
1966
- inputs: []
1967
- },
1968
- {
1969
- type: "error",
1970
- name: "InsolventInitialCreditPosition",
1971
- inputs: []
1972
- },
1973
- {
1974
- type: "error",
1975
- name: "InvalidActivePrice",
1976
- inputs: []
1977
- },
1978
- {
1979
- type: "error",
1980
- name: "InvalidBLVPrice",
1981
- inputs: []
1982
- },
1983
- {
1984
- type: "error",
1985
- name: "InvalidConvexityExp",
1986
- inputs: []
1987
- },
1988
- {
1989
- type: "error",
1990
- name: "InvalidConvexityExp",
1991
- inputs: []
1992
- },
1993
- {
1994
- type: "error",
1995
- name: "InvalidCreator",
1996
- inputs: []
1997
- },
1998
- {
1999
- type: "error",
2000
- name: "InvalidCreatorFee",
2001
- inputs: []
2002
- },
2003
- {
2004
- type: "error",
2005
- name: "InvalidFeeRecipient",
2006
- inputs: []
2007
- },
2008
- {
2009
- type: "error",
2010
- name: "InvalidInitialCollateralOrDebt",
2011
- inputs: []
2012
- },
2013
- {
2014
- type: "error",
2015
- name: "InvalidName",
2016
- inputs: []
2017
- },
2018
- {
2019
- type: "error",
2020
- name: "InvalidPoolSupply",
2021
- inputs: []
2022
- },
2023
- {
2024
- type: "error",
2025
- name: "InvalidSalt",
2026
- inputs: []
2027
- },
2028
- {
2029
- type: "error",
2030
- name: "InvalidSwapFeePct",
2031
- inputs: []
2032
- },
2033
- {
2034
- type: "error",
2035
- name: "InvalidSymbol",
2036
- inputs: []
2037
- },
2038
- {
2039
- type: "error",
2040
- name: "InvariantDecreased",
2041
- inputs: [
2042
- {
2043
- name: "prevInvariant",
2044
- type: "uint256",
2045
- internalType: "uint256"
2046
- },
2047
- {
2048
- name: "newInvariant",
2049
- type: "uint256",
2050
- internalType: "uint256"
2051
- }
2052
- ]
2053
- },
2054
- {
2055
- type: "error",
2056
- name: "NativeLib_AmountMismatch",
2057
- inputs: []
2058
- },
2059
- {
2060
- type: "error",
2061
- name: "NativeLib_NotWrapped",
2062
- inputs: []
2063
- },
2064
- {
2065
- type: "error",
2066
- name: "NotApprovedReserve",
2067
- inputs: []
2068
- },
2069
- {
2070
- type: "error",
2071
- name: "NotDeployer",
2072
- inputs: []
2073
- },
2074
- {
2075
- type: "error",
2076
- name: "PoolAlreadyInitialized",
2077
- inputs: []
2078
- },
2079
- {
2080
- type: "error",
2081
- name: "TotalSupplyTooHigh",
2082
- inputs: []
2083
- },
2084
- {
2085
- type: "error",
2086
- name: "TotalSupplyTooLow",
2087
- inputs: []
2088
- },
2089
- {
2090
- type: "error",
2091
- name: "UnauthorizedCreditPositionCreation",
2092
- inputs: []
2093
- }
2094
- ];
2095
-
2096
- // ../contracts/abis/mercury/bLens.ts
2097
- var bLens = [
2098
- {
2099
- type: "function",
2100
- name: "LABEL",
2101
- inputs: [],
2102
- outputs: [
2103
- {
2104
- name: "",
2105
- type: "bytes32",
2106
- internalType: "bytes32"
2107
- }
2108
- ],
2109
- stateMutability: "view"
2110
- },
2111
- {
2112
- type: "function",
2113
- name: "ROUTES",
2114
- inputs: [],
2115
- outputs: [
2116
- {
2117
- name: "routes_",
2118
- type: "bytes4[]",
2119
- internalType: "bytes4[]"
2120
- }
2121
- ],
2122
- stateMutability: "pure"
2123
- },
2124
- {
2125
- type: "function",
2126
- name: "VERSION",
2127
- inputs: [],
2128
- outputs: [
2129
- {
2130
- name: "",
2131
- type: "uint256",
2132
- internalType: "uint256"
2133
- }
2134
- ],
2135
- stateMutability: "view"
2136
- },
2137
- {
2138
- type: "function",
2139
- name: "accumulator",
2140
- inputs: [
2141
- {
2142
- name: "_bToken",
2143
- type: "address",
2144
- internalType: "contract BToken"
2145
- }
2146
- ],
2147
- outputs: [
2148
- {
2149
- name: "",
2150
- type: "uint256",
2151
- internalType: "uint256"
2152
- }
2153
- ],
2154
- stateMutability: "view"
2155
- },
2156
- {
2157
- type: "function",
2158
- name: "activePrice",
2159
- inputs: [
2160
- {
2161
- name: "_bToken",
2162
- type: "address",
2163
- internalType: "contract BToken"
2164
- }
2165
- ],
2166
- outputs: [
2167
- {
2168
- name: "",
2169
- type: "uint256",
2170
- internalType: "uint256"
2171
- }
2172
- ],
2173
- stateMutability: "view"
2174
- },
2175
- {
2176
- type: "function",
2177
- name: "blvPrice",
2178
- inputs: [
2179
- {
2180
- name: "_bToken",
2181
- type: "address",
2182
- internalType: "contract BToken"
2183
- }
2184
- ],
2185
- outputs: [
2186
- {
2187
- name: "",
2188
- type: "uint256",
2189
- internalType: "uint256"
2190
- }
2191
- ],
2192
- stateMutability: "view"
2193
- },
2194
- {
2195
- type: "function",
2196
- name: "claimableYield",
2197
- inputs: [
2198
- {
2199
- name: "_bToken",
2200
- type: "address",
2201
- internalType: "contract BToken"
2202
- }
2203
- ],
2204
- outputs: [
2205
- {
2206
- name: "",
2207
- type: "uint256",
2208
- internalType: "uint256"
2209
- }
2210
- ],
2211
- stateMutability: "view"
2212
- },
2213
- {
2214
- type: "function",
2215
- name: "convexityExp",
2216
- inputs: [
2217
- {
2218
- name: "_bToken",
2219
- type: "address",
2220
- internalType: "contract BToken"
2221
- }
2222
- ],
2223
- outputs: [
2224
- {
2225
- name: "",
2226
- type: "uint256",
2227
- internalType: "uint256"
2228
- }
2229
- ],
2230
- stateMutability: "view"
2231
- },
2232
- {
2233
- type: "function",
2234
- name: "creator",
2235
- inputs: [
2236
- {
2237
- name: "_bToken",
2238
- type: "address",
2239
- internalType: "contract BToken"
2240
- }
2241
- ],
2242
- outputs: [
2243
- {
2244
- name: "",
2245
- type: "address",
2246
- internalType: "address"
2247
- }
2248
- ],
2249
- stateMutability: "view"
2250
- },
2251
- {
2252
- type: "function",
2253
- name: "creatorClaimable",
2254
- inputs: [
2255
- {
2256
- name: "_bToken",
2257
- type: "address",
2258
- internalType: "contract BToken"
2259
- }
2260
- ],
2261
- outputs: [
2262
- {
2263
- name: "",
2264
- type: "uint256",
2265
- internalType: "uint256"
2266
- }
2267
- ],
2268
- stateMutability: "view"
2269
- },
2270
- {
2271
- type: "function",
2272
- name: "creatorFeePct",
2273
- inputs: [
2274
- {
2275
- name: "_bToken",
2276
- type: "address",
2277
- internalType: "contract BToken"
2278
- }
2279
- ],
2280
- outputs: [
2281
- {
2282
- name: "",
2283
- type: "uint256",
2284
- internalType: "uint256"
2285
- }
2286
- ],
2287
- stateMutability: "view"
2288
- },
2289
- {
2290
- type: "function",
2291
- name: "creditAccount",
2292
- inputs: [
2293
- {
2294
- name: "_bToken",
2295
- type: "address",
2296
- internalType: "contract BToken"
2297
- },
2298
- {
2299
- name: "_user",
2300
- type: "address",
2301
- internalType: "address"
2302
- }
2303
- ],
2304
- outputs: [
2305
- {
2306
- name: "",
2307
- type: "uint256",
2308
- internalType: "uint256"
2309
- },
2310
- {
2311
- name: "",
2312
- type: "uint256",
2313
- internalType: "uint256"
2314
- }
2315
- ],
2316
- stateMutability: "view"
2317
- },
2318
- {
2319
- type: "function",
2320
- name: "defaultLiquidityFeePct",
2321
- inputs: [],
2322
- outputs: [
2323
- {
2324
- name: "",
2325
- type: "uint256",
2326
- internalType: "uint256"
2327
- }
2328
- ],
2329
- stateMutability: "view"
2330
- },
2331
- {
2332
- type: "function",
2333
- name: "defaultProtocolFeePct",
2334
- inputs: [],
2335
- outputs: [
2336
- {
2337
- name: "",
2338
- type: "uint256",
2339
- internalType: "uint256"
2340
- }
2341
- ],
2342
- stateMutability: "view"
2343
- },
2344
- {
2345
- type: "function",
2346
- name: "deployerProfile",
2347
- inputs: [
2348
- {
2349
- name: "_user",
2350
- type: "address",
2351
- internalType: "address"
2352
- }
2353
- ],
2354
- outputs: [
2355
- {
2356
- name: "",
2357
- type: "tuple",
2358
- internalType: "struct State.DeployerProfile",
2359
- components: [
2360
- {
2361
- name: "active",
2362
- type: "bool",
2363
- internalType: "bool"
2364
- },
2365
- {
2366
- name: "approvedCreditDeployer",
2367
- type: "bool",
2368
- internalType: "bool"
2369
- },
2370
- {
2371
- name: "pauser",
2372
- type: "bool",
2373
- internalType: "bool"
2374
- },
2375
- {
2376
- name: "protocolFeePct",
2377
- type: "uint64",
2378
- internalType: "uint64"
2379
- },
2380
- {
2381
- name: "liquidityFeePct",
2382
- type: "uint64",
2383
- internalType: "uint64"
2384
- }
2385
- ]
2386
- }
2387
- ],
2388
- stateMutability: "view"
2389
- },
2390
- {
2391
- type: "function",
2392
- name: "getBookPrice",
2393
- inputs: [
2394
- {
2395
- name: "_bToken",
2396
- type: "address",
2397
- internalType: "contract BToken"
2398
- }
2399
- ],
2400
- outputs: [
2401
- {
2402
- name: "",
2403
- type: "uint256",
2404
- internalType: "uint256"
2405
- }
2406
- ],
2407
- stateMutability: "view"
2408
- },
2409
- {
2410
- type: "function",
2411
- name: "getCirculatingSupply",
2412
- inputs: [
2413
- {
2414
- name: "_bToken",
2415
- type: "address",
2416
- internalType: "contract BToken"
2417
- }
2418
- ],
2419
- outputs: [
2420
- {
2421
- name: "",
2422
- type: "uint256",
2423
- internalType: "uint256"
2424
- }
2425
- ],
2426
- stateMutability: "view"
2427
- },
2428
- {
2429
- type: "function",
2430
- name: "getComponents",
2431
- inputs: [],
2432
- outputs: [
2433
- {
2434
- name: "components_",
2435
- type: "address[]",
2436
- internalType: "contract Component[]"
2437
- }
2438
- ],
2439
- stateMutability: "view"
2440
- },
2441
- {
2442
- type: "function",
2443
- name: "getMaker",
2444
- inputs: [
2445
- {
2446
- name: "_bToken",
2447
- type: "address",
2448
- internalType: "contract BToken"
2449
- }
2450
- ],
2451
- outputs: [
2452
- {
2453
- name: "",
2454
- type: "tuple",
2455
- internalType: "struct State.Maker",
2456
- components: [
2457
- {
2458
- name: "initialized",
2459
- type: "bool",
2460
- internalType: "bool"
2461
- },
2462
- {
2463
- name: "blvPrice",
2464
- type: "uint128",
2465
- internalType: "uint128"
2466
- },
2467
- {
2468
- name: "swapFee",
2469
- type: "uint128",
2470
- internalType: "uint128"
2471
- },
2472
- {
2473
- name: "maxCirc",
2474
- type: "uint128",
2475
- internalType: "uint128"
2476
- },
2477
- {
2478
- name: "maxReserves",
2479
- type: "uint128",
2480
- internalType: "uint128"
2481
- },
2482
- {
2483
- name: "convexityExp",
2484
- type: "uint128",
2485
- internalType: "uint128"
2486
- },
2487
- {
2488
- name: "lastInvariant",
2489
- type: "uint256",
2490
- internalType: "uint256"
2491
- }
2492
- ]
2493
- }
2494
- ],
2495
- stateMutability: "view"
2496
- },
2497
- {
2498
- type: "function",
2499
- name: "getQuoteState",
2500
- inputs: [
2501
- {
2502
- name: "_bToken",
2503
- type: "address",
2504
- internalType: "contract BToken"
2505
- }
2506
- ],
2507
- outputs: [
2508
- {
2509
- name: "state_",
2510
- type: "tuple",
2511
- internalType: "struct BLens.QuoteState",
2512
- components: [
2513
- {
2514
- name: "snapshotCurveParams",
2515
- type: "tuple",
2516
- internalType: "struct CurveParams",
2517
- components: [
2518
- {
2519
- name: "BLV",
2520
- type: "uint256",
2521
- internalType: "uint256"
2522
- },
2523
- {
2524
- name: "circ",
2525
- type: "uint256",
2526
- internalType: "uint256"
2527
- },
2528
- {
2529
- name: "supply",
2530
- type: "uint256",
2531
- internalType: "uint256"
2532
- },
2533
- {
2534
- name: "swapFee",
2535
- type: "uint256",
2536
- internalType: "uint256"
2537
- },
2538
- {
2539
- name: "reserves",
2540
- type: "uint256",
2541
- internalType: "uint256"
2542
- },
2543
- {
2544
- name: "totalSupply",
2545
- type: "uint256",
2546
- internalType: "uint256"
2547
- },
2548
- {
2549
- name: "convexityExp",
2550
- type: "uint256",
2551
- internalType: "uint256"
2552
- },
2553
- {
2554
- name: "lastInvariant",
2555
- type: "uint256",
2556
- internalType: "uint256"
2557
- }
2558
- ]
2559
- },
2560
- {
2561
- name: "quoteBlockBuyDeltaCirc",
2562
- type: "uint256",
2563
- internalType: "uint256"
2564
- },
2565
- {
2566
- name: "quoteBlockSellDeltaCirc",
2567
- type: "uint256",
2568
- internalType: "uint256"
2569
- },
2570
- {
2571
- name: "totalSupply",
2572
- type: "uint256",
2573
- internalType: "uint256"
2574
- },
2575
- {
2576
- name: "totalBTokens",
2577
- type: "uint256",
2578
- internalType: "uint256"
2579
- },
2580
- {
2581
- name: "totalReserves",
2582
- type: "uint256",
2583
- internalType: "uint256"
2584
- },
2585
- {
2586
- name: "reserveDecimals",
2587
- type: "uint8",
2588
- internalType: "uint8"
2589
- },
2590
- {
2591
- name: "liquidityFeePct",
2592
- type: "uint256",
2593
- internalType: "uint256"
2594
- },
2595
- {
2596
- name: "pendingSurplus",
2597
- type: "uint256",
2598
- internalType: "uint256"
2599
- },
2600
- {
2601
- name: "shouldSettlePendingSurplus",
2602
- type: "bool",
2603
- internalType: "bool"
2604
- },
2605
- {
2606
- name: "maxSellDelta",
2607
- type: "uint256",
2608
- internalType: "uint256"
2609
- },
2610
- {
2611
- name: "snapshotActivePrice",
2612
- type: "uint256",
2613
- internalType: "uint256"
2614
- }
2615
- ]
2616
- }
2617
- ],
2618
- stateMutability: "view"
2619
- },
2620
- {
2621
- type: "function",
2622
- name: "hasHook",
2623
- inputs: [
2624
- {
2625
- name: "_bToken",
2626
- type: "address",
2627
- internalType: "contract BToken"
2628
- }
2629
- ],
2630
- outputs: [
2631
- {
2632
- name: "",
2633
- type: "bool",
2634
- internalType: "bool"
2635
- }
2636
- ],
2637
- stateMutability: "view"
2638
- },
2639
- {
2640
- type: "function",
2641
- name: "isApprovedCreditDeployer",
2642
- inputs: [
2643
- {
2644
- name: "_user",
2645
- type: "address",
2646
- internalType: "address"
2647
- }
2648
- ],
2649
- outputs: [
2650
- {
2651
- name: "",
2652
- type: "bool",
2653
- internalType: "bool"
2654
- }
2655
- ],
2656
- stateMutability: "view"
2657
- },
2658
- {
2659
- type: "function",
2660
- name: "isLocked",
2661
- inputs: [],
2662
- outputs: [
2663
- {
2664
- name: "",
2665
- type: "bool",
2666
- internalType: "bool"
2667
- }
2668
- ],
2669
- stateMutability: "view"
2670
- },
2671
- {
2672
- type: "function",
2673
- name: "isPoolPaused",
2674
- inputs: [
2675
- {
2676
- name: "_bToken",
2677
- type: "address",
2678
- internalType: "contract BToken"
2679
- }
2680
- ],
2681
- outputs: [
2682
- {
2683
- name: "",
2684
- type: "bool",
2685
- internalType: "bool"
2686
- }
2687
- ],
2688
- stateMutability: "view"
2689
- },
2690
- {
2691
- type: "function",
2692
- name: "isProtocolPaused",
2693
- inputs: [],
2694
- outputs: [
2695
- {
2696
- name: "",
2697
- type: "bool",
2698
- internalType: "bool"
2699
- }
2700
- ],
2701
- stateMutability: "view"
2702
- },
2703
- {
2704
- type: "function",
2705
- name: "lastInvariant",
2706
- inputs: [
2707
- {
2708
- name: "_bToken",
2709
- type: "address",
2710
- internalType: "contract BToken"
2711
- }
2712
- ],
2713
- outputs: [
2714
- {
2715
- name: "",
2716
- type: "uint256",
2717
- internalType: "uint256"
2718
- }
2719
- ],
2720
- stateMutability: "view"
2721
- },
2722
- {
2723
- type: "function",
2724
- name: "lastUpdatedTimestamp",
2725
- inputs: [
2726
- {
2727
- name: "_bToken",
2728
- type: "address",
2729
- internalType: "contract BToken"
2730
- }
2731
- ],
2732
- outputs: [
2733
- {
2734
- name: "",
2735
- type: "uint256",
2736
- internalType: "uint256"
2737
- }
2738
- ],
2739
- stateMutability: "view"
2740
- },
2741
- {
2742
- type: "function",
2743
- name: "liquidityFeePct",
2744
- inputs: [
2745
- {
2746
- name: "_bToken",
2747
- type: "address",
2748
- internalType: "contract BToken"
2749
- }
2750
- ],
2751
- outputs: [
2752
- {
2753
- name: "",
2754
- type: "uint256",
2755
- internalType: "uint256"
2756
- }
2757
- ],
2758
- stateMutability: "view"
2759
- },
2760
- {
2761
- type: "function",
2762
- name: "originationFee",
2763
- inputs: [],
2764
- outputs: [
2765
- {
2766
- name: "",
2767
- type: "uint256",
2768
- internalType: "uint256"
2769
- }
2770
- ],
2771
- stateMutability: "view"
2772
- },
2773
- {
2774
- type: "function",
2775
- name: "pendingSurplus",
2776
- inputs: [
2777
- {
2778
- name: "_bToken",
2779
- type: "address",
2780
- internalType: "contract BToken"
2781
- }
2782
- ],
2783
- outputs: [
2784
- {
2785
- name: "",
2786
- type: "uint256",
2787
- internalType: "uint256"
2788
- }
2789
- ],
2790
- stateMutability: "view"
2791
- },
2792
- {
2793
- type: "function",
2794
- name: "pendingYield",
2795
- inputs: [
2796
- {
2797
- name: "_bToken",
2798
- type: "address",
2799
- internalType: "contract BToken"
2800
- }
2801
- ],
2802
- outputs: [
2803
- {
2804
- name: "",
2805
- type: "uint256",
2806
- internalType: "uint256"
2807
- }
2808
- ],
2809
- stateMutability: "view"
2810
- },
2811
- {
2812
- type: "function",
2813
- name: "poolFeeRecipient",
2814
- inputs: [
2815
- {
2816
- name: "_bToken",
2817
- type: "address",
2818
- internalType: "contract BToken"
2819
- }
2820
- ],
2821
- outputs: [
2822
- {
2823
- name: "",
2824
- type: "address",
2825
- internalType: "address"
2826
- }
2827
- ],
2828
- stateMutability: "view"
2829
- },
2830
- {
2831
- type: "function",
2832
- name: "poolFeeShare",
2833
- inputs: [
2834
- {
2835
- name: "_bToken",
2836
- type: "address",
2837
- internalType: "contract BToken"
2838
- }
2839
- ],
2840
- outputs: [
2841
- {
2842
- name: "creator_",
2843
- type: "uint256",
2844
- internalType: "uint256"
2845
- },
2846
- {
2847
- name: "staking_",
2848
- type: "uint256",
2849
- internalType: "uint256"
2850
- }
2851
- ],
2852
- stateMutability: "view"
2853
- },
2854
- {
2855
- type: "function",
2856
- name: "poolIdToBToken",
2857
- inputs: [
2858
- {
2859
- name: "_poolId",
2860
- type: "bytes32",
2861
- internalType: "PoolId"
2862
- }
2863
- ],
2864
- outputs: [
2865
- {
2866
- name: "",
2867
- type: "address",
2868
- internalType: "contract BToken"
2869
- }
2870
- ],
2871
- stateMutability: "view"
2872
- },
2873
- {
2874
- type: "function",
2875
- name: "poolKey",
2876
- inputs: [
2877
- {
2878
- name: "_bToken",
2879
- type: "address",
2880
- internalType: "contract BToken"
2881
- }
2882
- ],
2883
- outputs: [
2884
- {
2885
- name: "",
2886
- type: "tuple",
2887
- internalType: "struct PoolKey",
2888
- components: [
2889
- {
2890
- name: "currency0",
2891
- type: "address",
2892
- internalType: "Currency"
2893
- },
2894
- {
2895
- name: "currency1",
2896
- type: "address",
2897
- internalType: "Currency"
2898
- },
2899
- {
2900
- name: "fee",
2901
- type: "uint24",
2902
- internalType: "uint24"
2903
- },
2904
- {
2905
- name: "tickSpacing",
2906
- type: "int24",
2907
- internalType: "int24"
2908
- },
2909
- {
2910
- name: "hooks",
2911
- type: "address",
2912
- internalType: "contract IHooks"
2913
- }
2914
- ]
2915
- }
2916
- ],
2917
- stateMutability: "view"
2918
- },
2919
- {
2920
- type: "function",
2921
- name: "protocolClaimable",
2922
- inputs: [
2923
- {
2924
- name: "_bToken",
2925
- type: "address",
2926
- internalType: "contract BToken"
2927
- }
2928
- ],
2929
- outputs: [
2930
- {
2931
- name: "",
2932
- type: "uint256",
2933
- internalType: "uint256"
2934
- }
2935
- ],
2936
- stateMutability: "view"
2937
- },
2938
- {
2939
- type: "function",
2940
- name: "protocolFeePct",
2941
- inputs: [
2942
- {
2943
- name: "_bToken",
2944
- type: "address",
2945
- internalType: "contract BToken"
2946
- }
2947
- ],
2948
- outputs: [
2949
- {
2950
- name: "",
2951
- type: "uint256",
2952
- internalType: "uint256"
2953
- }
2954
- ],
2955
- stateMutability: "view"
2956
- },
2957
- {
2958
- type: "function",
2959
- name: "protocolFeeRecipient",
2960
- inputs: [],
2961
- outputs: [
2962
- {
2963
- name: "",
2964
- type: "address",
2965
- internalType: "address"
2966
- }
2967
- ],
2968
- stateMutability: "view"
2969
- },
2970
- {
2971
- type: "function",
2972
- name: "quoteLeverage",
2973
- inputs: [
2974
- {
2975
- name: "_bToken",
2976
- type: "address",
2977
- internalType: "contract BToken"
2978
- },
2979
- {
2980
- name: "_collateralIn",
2981
- type: "uint256",
2982
- internalType: "uint256"
2983
- },
2984
- {
2985
- name: "_leverageFactor",
2986
- type: "uint256",
2987
- internalType: "uint256"
2988
- }
2989
- ],
2990
- outputs: [
2991
- {
2992
- name: "targetCollateral_",
2993
- type: "uint256",
2994
- internalType: "uint256"
2995
- },
2996
- {
2997
- name: "maxSwapReservesIn_",
2998
- type: "uint256",
2999
- internalType: "uint256"
3000
- },
3001
- {
3002
- name: "expectedDebt_",
3003
- type: "uint256",
3004
- internalType: "uint256"
3005
- },
3006
- {
3007
- name: "slippage_",
3008
- type: "uint256",
3009
- internalType: "uint256"
3010
- }
3011
- ],
3012
- stateMutability: "view"
3013
- },
3014
- {
3015
- type: "function",
3016
- name: "reserve",
3017
- inputs: [
3018
- {
3019
- name: "_bToken",
3020
- type: "address",
3021
- internalType: "contract BToken"
3022
- }
3023
- ],
3024
- outputs: [
3025
- {
3026
- name: "",
3027
- type: "address",
3028
- internalType: "contract ERC20"
3029
- }
3030
- ],
3031
- stateMutability: "view"
3032
- },
3033
- {
3034
- type: "function",
3035
- name: "reserveHoldings",
3036
- inputs: [
3037
- {
3038
- name: "_reserve",
3039
- type: "address",
3040
- internalType: "contract ERC20"
3041
- }
3042
- ],
3043
- outputs: [
3044
- {
3045
- name: "",
3046
- type: "uint256",
3047
- internalType: "uint256"
3048
- }
3049
- ],
3050
- stateMutability: "view"
3051
- },
3052
- {
3053
- type: "function",
3054
- name: "settledReserves",
3055
- inputs: [
3056
- {
3057
- name: "_bToken",
3058
- type: "address",
3059
- internalType: "contract BToken"
3060
- }
3061
- ],
3062
- outputs: [
3063
- {
3064
- name: "",
3065
- type: "uint256",
3066
- internalType: "uint256"
3067
- }
3068
- ],
3069
- stateMutability: "view"
3070
- },
3071
- {
3072
- type: "function",
3073
- name: "stakedPosition",
3074
- inputs: [
3075
- {
3076
- name: "_bToken",
3077
- type: "address",
3078
- internalType: "contract BToken"
3079
- },
3080
- {
3081
- name: "_user",
3082
- type: "address",
3083
- internalType: "address"
3084
- }
3085
- ],
3086
- outputs: [
3087
- {
3088
- name: "",
3089
- type: "uint256",
3090
- internalType: "uint256"
3091
- },
3092
- {
3093
- name: "",
3094
- type: "uint256",
3095
- internalType: "uint256"
3096
- },
3097
- {
3098
- name: "",
3099
- type: "uint256",
3100
- internalType: "uint256"
3101
- },
3102
- {
3103
- name: "",
3104
- type: "uint256",
3105
- internalType: "uint256"
3106
- }
3107
- ],
3108
- stateMutability: "view"
3109
- },
3110
- {
3111
- type: "function",
3112
- name: "supportsInterface",
3113
- inputs: [
3114
- {
3115
- name: "_interfaceId",
3116
- type: "bytes4",
3117
- internalType: "bytes4"
3118
- }
3119
- ],
3120
- outputs: [
3121
- {
3122
- name: "",
3123
- type: "bool",
3124
- internalType: "bool"
3125
- }
3126
- ],
3127
- stateMutability: "pure"
3128
- },
3129
- {
3130
- type: "function",
3131
- name: "swapFee",
3132
- inputs: [
3133
- {
3134
- name: "_bToken",
3135
- type: "address",
3136
- internalType: "contract BToken"
3137
- }
3138
- ],
3139
- outputs: [
3140
- {
3141
- name: "",
3142
- type: "uint256",
3143
- internalType: "uint256"
3144
- }
3145
- ],
3146
- stateMutability: "view"
3147
- },
3148
- {
3149
- type: "function",
3150
- name: "timeToAdapt",
3151
- inputs: [],
3152
- outputs: [
3153
- {
3154
- name: "",
3155
- type: "uint256",
3156
- internalType: "uint256"
3157
- }
3158
- ],
3159
- stateMutability: "view"
3160
- },
3161
- {
3162
- type: "function",
3163
- name: "timeToDistribute",
3164
- inputs: [],
3165
- outputs: [
3166
- {
3167
- name: "",
3168
- type: "uint256",
3169
- internalType: "uint256"
3170
- }
3171
- ],
3172
- stateMutability: "view"
3173
- },
3174
- {
3175
- type: "function",
3176
- name: "tokensPerSecond",
3177
- inputs: [
3178
- {
3179
- name: "_bToken",
3180
- type: "address",
3181
- internalType: "contract BToken"
3182
- }
3183
- ],
3184
- outputs: [
3185
- {
3186
- name: "",
3187
- type: "uint256",
3188
- internalType: "uint256"
3189
- }
3190
- ],
3191
- stateMutability: "view"
3192
- },
3193
- {
3194
- type: "function",
3195
- name: "totalBTokens",
3196
- inputs: [
3197
- {
3198
- name: "_bToken",
3199
- type: "address",
3200
- internalType: "contract BToken"
3201
- }
3202
- ],
3203
- outputs: [
3204
- {
3205
- name: "",
3206
- type: "uint256",
3207
- internalType: "uint256"
3208
- }
3209
- ],
3210
- stateMutability: "view"
3211
- },
3212
- {
3213
- type: "function",
3214
- name: "totalCollateral",
3215
- inputs: [
3216
- {
3217
- name: "_bToken",
3218
- type: "address",
3219
- internalType: "contract BToken"
3220
- }
3221
- ],
3222
- outputs: [
3223
- {
3224
- name: "",
3225
- type: "uint256",
3226
- internalType: "uint256"
3227
- }
3228
- ],
3229
- stateMutability: "view"
3230
- },
3231
- {
3232
- type: "function",
3233
- name: "totalDebt",
3234
- inputs: [
3235
- {
3236
- name: "_bToken",
3237
- type: "address",
3238
- internalType: "contract BToken"
3239
- }
3240
- ],
3241
- outputs: [
3242
- {
3243
- name: "",
3244
- type: "uint256",
3245
- internalType: "uint256"
3246
- }
3247
- ],
3248
- stateMutability: "view"
3249
- },
3250
- {
3251
- type: "function",
3252
- name: "totalFeeShare",
3253
- inputs: [
3254
- {
3255
- name: "_bToken",
3256
- type: "address",
3257
- internalType: "contract BToken"
3258
- }
3259
- ],
3260
- outputs: [
3261
- {
3262
- name: "creator_",
3263
- type: "uint256",
3264
- internalType: "uint256"
3265
- },
3266
- {
3267
- name: "staking_",
3268
- type: "uint256",
3269
- internalType: "uint256"
3270
- },
3271
- {
3272
- name: "protocol_",
3273
- type: "uint256",
3274
- internalType: "uint256"
3275
- }
3276
- ],
3277
- stateMutability: "view"
3278
- },
3279
- {
3280
- type: "function",
3281
- name: "totalReserves",
3282
- inputs: [
3283
- {
3284
- name: "_bToken",
3285
- type: "address",
3286
- internalType: "contract BToken"
3287
- }
3288
- ],
3289
- outputs: [
3290
- {
3291
- name: "",
3292
- type: "uint256",
3293
- internalType: "uint256"
3294
- }
3295
- ],
3296
- stateMutability: "view"
3297
- },
3298
- {
3299
- type: "function",
3300
- name: "totalStaked",
3301
- inputs: [
3302
- {
3303
- name: "_bToken",
3304
- type: "address",
3305
- internalType: "contract BToken"
3306
- }
3307
- ],
3308
- outputs: [
3309
- {
3310
- name: "",
3311
- type: "uint256",
3312
- internalType: "uint256"
3313
- }
3314
- ],
3315
- stateMutability: "view"
3316
- },
3317
- {
3318
- type: "function",
3319
- name: "totalSupply",
3320
- inputs: [
3321
- {
3322
- name: "_bToken",
3323
- type: "address",
3324
- internalType: "contract BToken"
3325
- }
3326
- ],
3327
- outputs: [
3328
- {
3329
- name: "",
3330
- type: "uint256",
3331
- internalType: "uint256"
3332
- }
3333
- ],
3334
- stateMutability: "view"
3335
- },
3336
- {
3337
- type: "function",
3338
- name: "withdrawable",
3339
- inputs: [
3340
- {
3341
- name: "_bToken",
3342
- type: "address",
3343
- internalType: "contract BToken"
3344
- },
3345
- {
3346
- name: "_user",
3347
- type: "address",
3348
- internalType: "address"
3349
- }
3350
- ],
3351
- outputs: [
3352
- {
3353
- name: "",
3354
- type: "uint256",
3355
- internalType: "uint256"
3356
- }
3357
- ],
3358
- stateMutability: "view"
3359
- },
3360
- {
3361
- type: "error",
3362
- name: "BLens_InvalidLeverageFactor",
3363
- inputs: []
3364
- },
3365
- {
3366
- type: "error",
3367
- name: "Component_NotPermitted",
3368
- inputs: []
3369
- },
3370
- {
3371
- type: "error",
3372
- name: "InvalidConvexityExp",
3373
- inputs: []
3374
- },
3375
- {
3376
- type: "error",
3377
- name: "InvariantDecreased",
3378
- inputs: [
3379
- {
3380
- name: "prevInvariant",
3381
- type: "uint256",
3382
- internalType: "uint256"
3383
- },
3384
- {
3385
- name: "newInvariant",
3386
- type: "uint256",
3387
- internalType: "uint256"
3388
- }
3389
- ]
3390
- }
3391
- ];
1573
+ var bFactory = [{ "type": "function", "name": "LABEL", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "pure" }, { "type": "function", "name": "ROUTES", "inputs": [], "outputs": [{ "name": "routes_", "type": "bytes4[]", "internalType": "bytes4[]" }], "stateMutability": "pure" }, { "type": "function", "name": "VERSION", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "pure" }, { "type": "function", "name": "createBToken", "inputs": [{ "name": "_name", "type": "string", "internalType": "string" }, { "name": "_symbol", "type": "string", "internalType": "string" }, { "name": "_totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "_salt", "type": "bytes32", "internalType": "bytes32" }], "outputs": [{ "name": "bToken_", "type": "address", "internalType": "contract BToken" }], "stateMutability": "nonpayable" }, { "type": "function", "name": "createPool", "inputs": [{ "name": "params", "type": "tuple", "internalType": "struct BFactory.CreateParams", "components": [{ "name": "bToken", "type": "address", "internalType": "contract BToken" }, { "name": "initialPoolBTokens", "type": "uint256", "internalType": "uint256" }, { "name": "reserve", "type": "address", "internalType": "address" }, { "name": "initialPoolReserves", "type": "uint256", "internalType": "uint256" }, { "name": "initialActivePrice", "type": "uint256", "internalType": "uint256" }, { "name": "initialBLV", "type": "uint256", "internalType": "uint256" }, { "name": "creator", "type": "address", "internalType": "address" }, { "name": "feeRecipient", "type": "address", "internalType": "address" }, { "name": "creatorFeePct", "type": "uint256", "internalType": "uint256" }, { "name": "swapFeePct", "type": "uint256", "internalType": "uint256" }, { "name": "createHook", "type": "bool", "internalType": "bool" }, { "name": "claimMerkleRoot", "type": "bytes32", "internalType": "bytes32" }, { "name": "initialCollateral", "type": "uint256", "internalType": "uint256" }, { "name": "initialDebt", "type": "uint256", "internalType": "uint256" }] }], "outputs": [], "stateMutability": "payable" }, { "type": "function", "name": "createPoolFromInvariant", "inputs": [{ "name": "params", "type": "tuple", "internalType": "struct BFactory.CreateFromInvariantParams", "components": [{ "name": "bToken", "type": "address", "internalType": "contract BToken" }, { "name": "initialPoolBTokens", "type": "uint256", "internalType": "uint256" }, { "name": "reserve", "type": "address", "internalType": "address" }, { "name": "initialInvariant", "type": "uint256", "internalType": "uint256" }, { "name": "creator", "type": "address", "internalType": "address" }, { "name": "feeRecipient", "type": "address", "internalType": "address" }, { "name": "creatorFeePct", "type": "uint256", "internalType": "uint256" }, { "name": "swapFeePct", "type": "uint256", "internalType": "uint256" }, { "name": "createHook", "type": "bool", "internalType": "bool" }] }], "outputs": [], "stateMutability": "nonpayable" }, { "type": "function", "name": "precomputeBTokenAddress", "inputs": [{ "name": "_name", "type": "string", "internalType": "string" }, { "name": "_symbol", "type": "string", "internalType": "string" }, { "name": "_totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "_salt", "type": "bytes32", "internalType": "bytes32" }, { "name": "_deployer", "type": "address", "internalType": "address" }], "outputs": [{ "name": "computedAddress_", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "supportsInterface", "inputs": [{ "name": "_interfaceId", "type": "bytes4", "internalType": "bytes4" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "pure" }, { "type": "event", "name": "BTokenCreated", "inputs": [{ "name": "bTokenAddress", "type": "address", "indexed": false, "internalType": "contract BToken" }, { "name": "name", "type": "string", "indexed": false, "internalType": "string" }, { "name": "symbol", "type": "string", "indexed": false, "internalType": "string" }, { "name": "decimals", "type": "uint8", "indexed": false, "internalType": "uint8" }, { "name": "totalSupply", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "creator", "type": "address", "indexed": false, "internalType": "address" }], "anonymous": false }, { "type": "event", "name": "Initialized", "inputs": [{ "name": "bToken", "type": "address", "indexed": false, "internalType": "contract BToken" }, { "name": "activePrice", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "blvPrice", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "swapFeePct", "type": "uint256", "indexed": false, "internalType": "uint256" }], "anonymous": false }, { "type": "event", "name": "PoolCreated", "inputs": [{ "name": "bTokenAddress", "type": "address", "indexed": false, "internalType": "contract BToken" }, { "name": "reserveAddress", "type": "address", "indexed": false, "internalType": "address" }, { "name": "creator", "type": "address", "indexed": false, "internalType": "address" }, { "name": "feeRecipient", "type": "address", "indexed": false, "internalType": "address" }, { "name": "creatorFeePct", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "initialActivePrice", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "initialBlvPrice", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "totalReserves", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "totalBTokens", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "totalCollateral", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "totalDebt", "type": "uint256", "indexed": false, "internalType": "uint256" }, { "name": "poolId", "type": "bytes32", "indexed": false, "internalType": "bytes32" }], "anonymous": false }, { "type": "error", "name": "AlreadyInitialized", "inputs": [] }, { "type": "error", "name": "Component_NotPermitted", "inputs": [] }, { "type": "error", "name": "GuardLib_Paused", "inputs": [] }, { "type": "error", "name": "GuardLib_Reentrant", "inputs": [] }, { "type": "error", "name": "GuardLib_ReserveAccountingMismatch", "inputs": [] }, { "type": "error", "name": "InsolventInitialCreditPosition", "inputs": [] }, { "type": "error", "name": "InvalidActivePrice", "inputs": [] }, { "type": "error", "name": "InvalidBLVPrice", "inputs": [] }, { "type": "error", "name": "InvalidConvexityExp", "inputs": [] }, { "type": "error", "name": "InvalidConvexityExp", "inputs": [] }, { "type": "error", "name": "InvalidCreator", "inputs": [] }, { "type": "error", "name": "InvalidCreatorFee", "inputs": [] }, { "type": "error", "name": "InvalidDecimals", "inputs": [] }, { "type": "error", "name": "InvalidFeeRecipient", "inputs": [] }, { "type": "error", "name": "InvalidInitialCollateralOrDebt", "inputs": [] }, { "type": "error", "name": "InvalidName", "inputs": [] }, { "type": "error", "name": "InvalidParameters", "inputs": [] }, { "type": "error", "name": "InvalidPoolSupply", "inputs": [] }, { "type": "error", "name": "InvalidSalt", "inputs": [] }, { "type": "error", "name": "InvalidSwapFeePct", "inputs": [] }, { "type": "error", "name": "InvalidSymbol", "inputs": [] }, { "type": "error", "name": "InvariantDecreased", "inputs": [{ "name": "prevInvariant", "type": "uint256", "internalType": "uint256" }, { "name": "newInvariant", "type": "uint256", "internalType": "uint256" }] }, { "type": "error", "name": "InvariantTooLarge", "inputs": [] }, { "type": "error", "name": "InvariantTooSmall", "inputs": [] }, { "type": "error", "name": "NativeLib_AmountMismatch", "inputs": [] }, { "type": "error", "name": "NativeLib_NotWrapped", "inputs": [] }, { "type": "error", "name": "NotApprovedReserve", "inputs": [] }, { "type": "error", "name": "NotDeployer", "inputs": [] }, { "type": "error", "name": "PoolAlreadyInitialized", "inputs": [] }, { "type": "error", "name": "TotalSupplyTooHigh", "inputs": [] }, { "type": "error", "name": "TotalSupplyTooLow", "inputs": [] }, { "type": "error", "name": "UnauthorizedCreditPositionCreation", "inputs": [] }];
1574
+
1575
+ // ../contracts/abis/mercury/bLens.ts
1576
+ var bLens = [{ "type": "function", "name": "LABEL", "inputs": [], "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], "stateMutability": "view" }, { "type": "function", "name": "ROUTES", "inputs": [], "outputs": [{ "name": "routes_", "type": "bytes4[]", "internalType": "bytes4[]" }], "stateMutability": "pure" }, { "type": "function", "name": "VERSION", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "accumulator", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "activePrice", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "blvPrice", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "claimableYield", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "convexityExp", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "creator", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "creatorClaimable", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "creatorFeePct", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "creditAccount", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }, { "name": "_user", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }, { "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "defaultLiquidityFeePct", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "defaultProtocolFeePct", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "deployerProfile", "inputs": [{ "name": "_user", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct State.DeployerProfile", "components": [{ "name": "active", "type": "bool", "internalType": "bool" }, { "name": "approvedCreditDeployer", "type": "bool", "internalType": "bool" }, { "name": "pauser", "type": "bool", "internalType": "bool" }, { "name": "protocolFeePct", "type": "uint64", "internalType": "uint64" }, { "name": "liquidityFeePct", "type": "uint64", "internalType": "uint64" }, { "name": "approvedTokenRegistrar", "type": "bool", "internalType": "bool" }] }], "stateMutability": "view" }, { "type": "function", "name": "getBookPrice", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getCirculatingSupply", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "getComponents", "inputs": [], "outputs": [{ "name": "components_", "type": "address[]", "internalType": "contract Component[]" }], "stateMutability": "view" }, { "type": "function", "name": "getMaker", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct State.Maker", "components": [{ "name": "initialized", "type": "bool", "internalType": "bool" }, { "name": "blvPrice", "type": "uint128", "internalType": "uint128" }, { "name": "swapFee", "type": "uint128", "internalType": "uint128" }, { "name": "maxCirc", "type": "uint128", "internalType": "uint128" }, { "name": "maxReserves", "type": "uint128", "internalType": "uint128" }, { "name": "convexityExp", "type": "uint128", "internalType": "uint128" }, { "name": "lastInvariant", "type": "uint256", "internalType": "uint256" }] }], "stateMutability": "view" }, { "type": "function", "name": "getQuoteState", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "state_", "type": "tuple", "internalType": "struct BLens.QuoteState", "components": [{ "name": "snapshotCurveParams", "type": "tuple", "internalType": "struct CurveParams", "components": [{ "name": "BLV", "type": "uint256", "internalType": "uint256" }, { "name": "circ", "type": "uint256", "internalType": "uint256" }, { "name": "supply", "type": "uint256", "internalType": "uint256" }, { "name": "swapFee", "type": "uint256", "internalType": "uint256" }, { "name": "reserves", "type": "uint256", "internalType": "uint256" }, { "name": "totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "convexityExp", "type": "uint256", "internalType": "uint256" }, { "name": "lastInvariant", "type": "uint256", "internalType": "uint256" }] }, { "name": "quoteBlockBuyDeltaCirc", "type": "uint256", "internalType": "uint256" }, { "name": "quoteBlockSellDeltaCirc", "type": "uint256", "internalType": "uint256" }, { "name": "totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "totalBTokens", "type": "uint256", "internalType": "uint256" }, { "name": "totalReserves", "type": "uint256", "internalType": "uint256" }, { "name": "reserveDecimals", "type": "uint8", "internalType": "uint8" }, { "name": "liquidityFeePct", "type": "uint256", "internalType": "uint256" }, { "name": "pendingSurplus", "type": "uint256", "internalType": "uint256" }, { "name": "shouldSettlePendingSurplus", "type": "bool", "internalType": "bool" }, { "name": "maxSellDelta", "type": "uint256", "internalType": "uint256" }, { "name": "snapshotActivePrice", "type": "uint256", "internalType": "uint256" }] }], "stateMutability": "view" }, { "type": "function", "name": "hasHook", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "isApprovedCreditDeployer", "inputs": [{ "name": "_user", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "isLocked", "inputs": [], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "isPoolPaused", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "isProtocolPaused", "inputs": [], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "view" }, { "type": "function", "name": "lastInvariant", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "lastUpdatedTimestamp", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "liquidityFeePct", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "originationFee", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "pendingSurplus", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "pendingYield", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "poolFeeRecipient", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "poolFeeShare", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "creator_", "type": "uint256", "internalType": "uint256" }, { "name": "staking_", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "poolIdToBToken", "inputs": [{ "name": "_poolId", "type": "bytes32", "internalType": "PoolId" }], "outputs": [{ "name": "", "type": "address", "internalType": "contract BToken" }], "stateMutability": "view" }, { "type": "function", "name": "poolKey", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "tuple", "internalType": "struct PoolKey", "components": [{ "name": "currency0", "type": "address", "internalType": "Currency" }, { "name": "currency1", "type": "address", "internalType": "Currency" }, { "name": "fee", "type": "uint24", "internalType": "uint24" }, { "name": "tickSpacing", "type": "int24", "internalType": "int24" }, { "name": "hooks", "type": "address", "internalType": "contract IHooks" }] }], "stateMutability": "view" }, { "type": "function", "name": "previewInvariantForPrice", "inputs": [{ "name": "_launchPrice", "type": "uint256", "internalType": "uint256" }, { "name": "_totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "_bTokenDecimals", "type": "uint8", "internalType": "uint8" }], "outputs": [{ "name": "initialInvariant_", "type": "uint256", "internalType": "uint256" }], "stateMutability": "pure" }, { "type": "function", "name": "previewInvariantInitPrice", "inputs": [{ "name": "_initialInvariant", "type": "uint256", "internalType": "uint256" }, { "name": "_totalSupply", "type": "uint256", "internalType": "uint256" }, { "name": "_bTokenDecimals", "type": "uint8", "internalType": "uint8" }], "outputs": [{ "name": "launchPrice_", "type": "uint256", "internalType": "uint256" }], "stateMutability": "pure" }, { "type": "function", "name": "protocolClaimable", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "protocolFeePct", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "protocolFeeRecipient", "inputs": [], "outputs": [{ "name": "", "type": "address", "internalType": "address" }], "stateMutability": "view" }, { "type": "function", "name": "quoteLeverage", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }, { "name": "_collateralIn", "type": "uint256", "internalType": "uint256" }, { "name": "_leverageFactor", "type": "uint256", "internalType": "uint256" }], "outputs": [{ "name": "targetCollateral_", "type": "uint256", "internalType": "uint256" }, { "name": "maxSwapReservesIn_", "type": "uint256", "internalType": "uint256" }, { "name": "expectedDebt_", "type": "uint256", "internalType": "uint256" }, { "name": "slippage_", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "reserve", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "address", "internalType": "contract ERC20" }], "stateMutability": "view" }, { "type": "function", "name": "reserveHoldings", "inputs": [{ "name": "_reserve", "type": "address", "internalType": "contract ERC20" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "settledReserves", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "stakedPosition", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }, { "name": "_user", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }, { "name": "", "type": "uint256", "internalType": "uint256" }, { "name": "", "type": "uint256", "internalType": "uint256" }, { "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "supportsInterface", "inputs": [{ "name": "_interfaceId", "type": "bytes4", "internalType": "bytes4" }], "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], "stateMutability": "pure" }, { "type": "function", "name": "swapFee", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "timeToAdapt", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "timeToDistribute", "inputs": [], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "tokensPerSecond", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalBTokens", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalCollateral", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalDebt", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalFeeShare", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "creator_", "type": "uint256", "internalType": "uint256" }, { "name": "staking_", "type": "uint256", "internalType": "uint256" }, { "name": "protocol_", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalReserves", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalStaked", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "totalSupply", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "function", "name": "withdrawable", "inputs": [{ "name": "_bToken", "type": "address", "internalType": "contract BToken" }, { "name": "_user", "type": "address", "internalType": "address" }], "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], "stateMutability": "view" }, { "type": "error", "name": "BLens_InvalidLeverageFactor", "inputs": [] }, { "type": "error", "name": "BLens_UnrepresentableLaunchPrice", "inputs": [] }, { "type": "error", "name": "Component_NotPermitted", "inputs": [] }, { "type": "error", "name": "InvalidConvexityExp", "inputs": [] }, { "type": "error", "name": "InvariantDecreased", "inputs": [{ "name": "prevInvariant", "type": "uint256", "internalType": "uint256" }, { "name": "newInvariant", "type": "uint256", "internalType": "uint256" }] }];
3392
1577
 
3393
1578
  // ../contracts/abis/mercury/bStaking.ts
3394
1579
  var bStaking = [
@@ -4649,6 +2834,223 @@ var ContractFactory = class {
4649
2834
 
4650
2835
  // ../contracts/index.ts
4651
2836
  var supportedChainIds = Object.keys(addressBook_default).map(Number);
2837
+ function encodeBaseLaunchCalls(input) {
2838
+ return [
2839
+ {
2840
+ to: input.relay,
2841
+ data: encodeFunctionData({
2842
+ abi: mercuryAbis.bFactory,
2843
+ functionName: "createBToken",
2844
+ args: [input.name, input.symbol, input.totalSupply, input.salt]
2845
+ })
2846
+ },
2847
+ {
2848
+ to: input.bToken,
2849
+ data: encodeFunctionData({
2850
+ abi: externalAbis.erc20,
2851
+ functionName: "approve",
2852
+ args: [input.relay, input.bTokenApprovalAmount]
2853
+ })
2854
+ }
2855
+ ];
2856
+ }
2857
+ function encodeZrpLaunchCalls(input) {
2858
+ return [
2859
+ ...encodeBaseLaunchCalls({
2860
+ ...input,
2861
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2862
+ }),
2863
+ {
2864
+ to: input.relay,
2865
+ data: encodeFunctionData({
2866
+ abi: mercuryAbis.bFactory,
2867
+ functionName: "createPoolFromInvariant",
2868
+ args: [input.params]
2869
+ })
2870
+ }
2871
+ ];
2872
+ }
2873
+ function encodeStandardLaunchCalls(input) {
2874
+ return [
2875
+ ...encodeBaseLaunchCalls({
2876
+ ...input,
2877
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2878
+ }),
2879
+ {
2880
+ to: input.reserve,
2881
+ data: encodeFunctionData({
2882
+ abi: externalAbis.erc20,
2883
+ functionName: "approve",
2884
+ args: [input.relay, input.params.initialPoolReserves]
2885
+ })
2886
+ },
2887
+ {
2888
+ to: input.relay,
2889
+ data: encodeFunctionData({
2890
+ abi: mercuryAbis.bFactory,
2891
+ functionName: "createPool",
2892
+ args: [input.params]
2893
+ })
2894
+ }
2895
+ ];
2896
+ }
2897
+
2898
+ // src/launch/constants.ts
2899
+ var WAD = 10n ** 18n;
2900
+ var ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
2901
+ var DEFAULT_SWAP_FEE_PCT = WAD / 100n;
2902
+ var MIN_SWAP_FEE_PCT = 1500000000000000n;
2903
+ var MAX_SWAP_FEE_PCT = WAD / 2n;
2904
+ var MIN_TOTAL_SUPPLY = 10000n * WAD;
2905
+ var MAX_TOTAL_SUPPLY = 20282409603651670423947251286015n;
2906
+ var MIN_INVARIANT = 3n * WAD;
2907
+
2908
+ // src/launch/validate.ts
2909
+ function normalizeSalt(salt) {
2910
+ if (!salt) return ZERO_BYTES32;
2911
+ if (!/^0x[a-fA-F0-9]{64}$/.test(salt)) {
2912
+ throw new Error("salt must be a bytes32 hex string");
2913
+ }
2914
+ return salt;
2915
+ }
2916
+ function validateAddress(address, label) {
2917
+ if (!isAddress(address)) throw new Error(`${label} must be a valid address`);
2918
+ }
2919
+ function validateTokenText(name, symbol) {
2920
+ if (name.trim().length === 0) throw new Error("name is required");
2921
+ if (symbol.trim().length === 0) throw new Error("symbol is required");
2922
+ if (new TextEncoder().encode(name).length > 30) {
2923
+ throw new Error("name exceeds 30 bytes");
2924
+ }
2925
+ if (new TextEncoder().encode(symbol).length > 30) {
2926
+ throw new Error("symbol exceeds 30 bytes");
2927
+ }
2928
+ }
2929
+ function validateDecimals(decimals, label) {
2930
+ if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18) {
2931
+ throw new Error(`${label} must be an integer between 0 and 18`);
2932
+ }
2933
+ }
2934
+ function resolveLaunchDefaults(input) {
2935
+ const mode = input.mode ?? "zrp";
2936
+ if (mode !== "zrp" && mode !== "standard") {
2937
+ throw new Error("mode must be zrp or standard");
2938
+ }
2939
+ validateTokenText(input.name, input.symbol);
2940
+ validateAddress(input.relay, "relay");
2941
+ validateAddress(input.bToken, "bToken");
2942
+ validateAddress(input.reserve, "reserve");
2943
+ validateAddress(input.creator, "creator");
2944
+ validateDecimals(input.reserveDecimals ?? 18, "reserveDecimals");
2945
+ const feeRecipient = input.feeRecipient ?? input.creator;
2946
+ validateAddress(feeRecipient, "feeRecipient");
2947
+ if (input.totalSupply < MIN_TOTAL_SUPPLY) {
2948
+ throw new Error("totalSupply is below the protocol minimum");
2949
+ }
2950
+ if (input.totalSupply > MAX_TOTAL_SUPPLY) {
2951
+ throw new Error("totalSupply exceeds the protocol maximum");
2952
+ }
2953
+ if (input.initialPoolBTokens <= 0n) {
2954
+ throw new Error("initialPoolBTokens must be greater than zero");
2955
+ }
2956
+ if (input.initialPoolBTokens > input.totalSupply) {
2957
+ throw new Error("initialPoolBTokens cannot exceed totalSupply");
2958
+ }
2959
+ const swapFeePct = input.swapFeePct ?? DEFAULT_SWAP_FEE_PCT;
2960
+ if (swapFeePct < MIN_SWAP_FEE_PCT || swapFeePct > MAX_SWAP_FEE_PCT) {
2961
+ throw new Error("swapFeePct is outside protocol bounds");
2962
+ }
2963
+ if (input.creatorFeePct < 0n || input.creatorFeePct > WAD) {
2964
+ throw new Error("creatorFeePct must be between 0 and 1e18");
2965
+ }
2966
+ if (mode === "zrp") {
2967
+ if (input.initialPoolBTokens !== input.totalSupply) {
2968
+ throw new Error("zrp launches require all BTokens in the pool");
2969
+ }
2970
+ if ((input.initialPoolReserves ?? 0n) !== 0n) {
2971
+ throw new Error("zrp launches require zero initial reserves");
2972
+ }
2973
+ } else {
2974
+ if ((input.initialPoolReserves ?? 0n) <= 0n) {
2975
+ throw new Error("standard launches require initialPoolReserves");
2976
+ }
2977
+ if (input.initialPoolBTokens >= input.totalSupply) {
2978
+ throw new Error("standard launches require circulating supply");
2979
+ }
2980
+ }
2981
+ return { mode, swapFeePct, feeRecipient };
2982
+ }
2983
+
2984
+ // src/launch/calls.ts
2985
+ function buildLaunchCalls(input) {
2986
+ const salt = normalizeSalt(input.salt);
2987
+ const { mode, swapFeePct, feeRecipient } = resolveLaunchDefaults(input);
2988
+ if (mode === "zrp") {
2989
+ const params2 = {
2990
+ bToken: input.bToken,
2991
+ initialPoolBTokens: input.initialPoolBTokens,
2992
+ reserve: input.reserve,
2993
+ initialInvariant: MIN_INVARIANT,
2994
+ creator: input.creator,
2995
+ feeRecipient,
2996
+ creatorFeePct: input.creatorFeePct,
2997
+ swapFeePct,
2998
+ createHook: true
2999
+ };
3000
+ return encodeZrpLaunchCalls({
3001
+ relay: input.relay,
3002
+ bToken: input.bToken,
3003
+ name: input.name,
3004
+ symbol: input.symbol,
3005
+ totalSupply: input.totalSupply,
3006
+ salt,
3007
+ params: params2
3008
+ });
3009
+ }
3010
+ const initialPoolReserves = input.initialPoolReserves ?? 0n;
3011
+ const circulatingSupply = input.totalSupply - input.initialPoolBTokens;
3012
+ const reservesWad = toWad(initialPoolReserves, input.reserveDecimals ?? 18);
3013
+ const circulatingWad = toWad(circulatingSupply, 18);
3014
+ const bookPrice = divWad(reservesWad, circulatingWad);
3015
+ const initialActivePrice = bookPrice + 1n;
3016
+ const initialBLV = 0n;
3017
+ const params = {
3018
+ bToken: input.bToken,
3019
+ initialPoolBTokens: input.initialPoolBTokens,
3020
+ reserve: input.reserve,
3021
+ initialPoolReserves,
3022
+ initialActivePrice,
3023
+ initialBLV,
3024
+ creator: input.creator,
3025
+ feeRecipient,
3026
+ creatorFeePct: input.creatorFeePct,
3027
+ swapFeePct,
3028
+ createHook: true,
3029
+ claimMerkleRoot: ZERO_BYTES32,
3030
+ initialCollateral: 0n,
3031
+ initialDebt: 0n
3032
+ };
3033
+ return encodeStandardLaunchCalls({
3034
+ relay: input.relay,
3035
+ bToken: input.bToken,
3036
+ reserve: input.reserve,
3037
+ name: input.name,
3038
+ symbol: input.symbol,
3039
+ totalSupply: input.totalSupply,
3040
+ salt,
3041
+ params
3042
+ });
3043
+ }
3044
+ function toWad(amount, decimals) {
3045
+ return amount * 10n ** BigInt(18 - decimals);
3046
+ }
3047
+ function divWad(numerator, denominator) {
3048
+ return numerator * WAD / denominator;
3049
+ }
3050
+ function validateLaunchCallInput(input) {
3051
+ normalizeSalt(input.salt);
3052
+ resolveLaunchDefaults(input);
3053
+ }
4652
3054
  var SDKError = class extends Error {
4653
3055
  kind = "unknown";
4654
3056
  component;
@@ -4834,11 +3236,15 @@ function valueForNative(useNative, amount) {
4834
3236
  }
4835
3237
 
4836
3238
  // src/baseline-sdk.ts
3239
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
4837
3240
  var BaselineSDK = class _BaselineSDK {
4838
3241
  publicClient;
4839
3242
  walletClient;
4840
3243
  config;
4841
3244
  readFactory;
3245
+ calls = {
3246
+ launch: (input, opts) => this.launchCalls(input, opts)
3247
+ };
4842
3248
  getAccount(opts) {
4843
3249
  const account = opts?.account ?? this.walletClient?.account?.address;
4844
3250
  if (!account) {
@@ -4916,6 +3322,59 @@ var BaselineSDK = class _BaselineSDK {
4916
3322
  });
4917
3323
  return { hash };
4918
3324
  }
3325
+ async createPoolFromInvariant(params, opts) {
3326
+ const account = this.getAccount(opts);
3327
+ const hash = await simulateAndWrite({
3328
+ publicClient: this.publicClient,
3329
+ walletClient: this.walletClient,
3330
+ address: this.proxy,
3331
+ abi: mercuryAbis.bFactory,
3332
+ functionName: "createPoolFromInvariant",
3333
+ args: [params],
3334
+ account,
3335
+ confirmations: opts?.confirmations,
3336
+ onSimulateError: opts?.onSimulateError
3337
+ });
3338
+ return { hash };
3339
+ }
3340
+ async precomputeBTokenAddress(input) {
3341
+ const bToken = await this.publicClient.readContract({
3342
+ address: this.proxy,
3343
+ abi: mercuryAbis.bFactory,
3344
+ functionName: "precomputeBTokenAddress",
3345
+ args: [
3346
+ input.name,
3347
+ input.symbol,
3348
+ input.totalSupply,
3349
+ input.salt,
3350
+ input.deployer
3351
+ ]
3352
+ });
3353
+ return bToken;
3354
+ }
3355
+ async launchCalls(input, opts) {
3356
+ const account = this.getAccount(opts);
3357
+ const salt = input.salt ?? ZERO_BYTES32;
3358
+ validateLaunchCallInput({
3359
+ ...input,
3360
+ relay: this.proxy,
3361
+ bToken: "0x0000000000000000000000000000000000000000",
3362
+ salt
3363
+ });
3364
+ const bToken = await this.precomputeBTokenAddress({
3365
+ name: input.name,
3366
+ symbol: input.symbol,
3367
+ totalSupply: input.totalSupply,
3368
+ salt,
3369
+ deployer: account
3370
+ });
3371
+ return buildLaunchCalls({
3372
+ ...input,
3373
+ relay: this.proxy,
3374
+ bToken,
3375
+ salt
3376
+ });
3377
+ }
4919
3378
  // ---------- Swap quotes ----------
4920
3379
  async quoteBuyExactIn(bToken, reservesIn) {
4921
3380
  const [tokensOut, fee, slippage] = await this.publicClient.readContract({
@@ -5274,6 +3733,118 @@ var BaselineSDK = class _BaselineSDK {
5274
3733
  });
5275
3734
  }
5276
3735
  // ---------- Lens queries ----------
3736
+ async getBTokenInfo(bToken) {
3737
+ const bytecode = await this.publicClient.getBytecode({ address: bToken });
3738
+ const hasBytecode = !!bytecode && bytecode !== "0x";
3739
+ const results = await this.publicClient.multicall({
3740
+ allowFailure: true,
3741
+ contracts: [
3742
+ { address: bToken, abi: externalAbis.erc20, functionName: "name" },
3743
+ { address: bToken, abi: externalAbis.erc20, functionName: "symbol" },
3744
+ { address: bToken, abi: externalAbis.erc20, functionName: "decimals" },
3745
+ {
3746
+ address: bToken,
3747
+ abi: externalAbis.erc20,
3748
+ functionName: "totalSupply"
3749
+ },
3750
+ {
3751
+ address: this.proxy,
3752
+ abi: mercuryAbis.bLens,
3753
+ functionName: "reserve",
3754
+ args: [bToken]
3755
+ },
3756
+ {
3757
+ address: this.proxy,
3758
+ abi: mercuryAbis.bLens,
3759
+ functionName: "creator",
3760
+ args: [bToken]
3761
+ },
3762
+ {
3763
+ address: this.proxy,
3764
+ abi: mercuryAbis.bLens,
3765
+ functionName: "poolFeeRecipient",
3766
+ args: [bToken]
3767
+ },
3768
+ {
3769
+ address: this.proxy,
3770
+ abi: mercuryAbis.bLens,
3771
+ functionName: "creatorFeePct",
3772
+ args: [bToken]
3773
+ },
3774
+ {
3775
+ address: this.proxy,
3776
+ abi: mercuryAbis.bLens,
3777
+ functionName: "swapFee",
3778
+ args: [bToken]
3779
+ },
3780
+ {
3781
+ address: this.proxy,
3782
+ abi: mercuryAbis.bLens,
3783
+ functionName: "totalBTokens",
3784
+ args: [bToken]
3785
+ },
3786
+ {
3787
+ address: this.proxy,
3788
+ abi: mercuryAbis.bLens,
3789
+ functionName: "totalReserves",
3790
+ args: [bToken]
3791
+ },
3792
+ {
3793
+ address: this.proxy,
3794
+ abi: mercuryAbis.bLens,
3795
+ functionName: "getMaker",
3796
+ args: [bToken]
3797
+ },
3798
+ {
3799
+ address: this.proxy,
3800
+ abi: mercuryAbis.bLens,
3801
+ functionName: "getQuoteState",
3802
+ args: [bToken]
3803
+ }
3804
+ ]
3805
+ });
3806
+ const result = (index) => {
3807
+ const item = results[index];
3808
+ return item?.status === "success" ? item.result : void 0;
3809
+ };
3810
+ const name = result(0);
3811
+ const symbol = result(1);
3812
+ const decimals = result(2);
3813
+ const totalSupply = result(3);
3814
+ const reserve = result(4);
3815
+ const creator = result(5);
3816
+ const poolFeeRecipient = result(6);
3817
+ const creatorFeePct = result(7);
3818
+ const swapFee = result(8);
3819
+ const totalBTokens = result(9);
3820
+ const totalReserves = result(10);
3821
+ const maker = normalizeMaker(result(11));
3822
+ const reserveDecimals = normalizeQuoteState(
3823
+ result(12)
3824
+ )?.reserveDecimals;
3825
+ const hasBaselineState = reserve !== void 0 && reserve.toLowerCase() !== ZERO_ADDRESS && maker !== void 0;
3826
+ const status = !hasBytecode ? "not_deployed" : !hasBaselineState ? "contract_only" : maker.initialized ? "initialized" : "baseline_uninitialized";
3827
+ return {
3828
+ chainId: this.chainId,
3829
+ relay: this.proxy,
3830
+ bToken,
3831
+ status,
3832
+ bytecode: hasBytecode,
3833
+ name,
3834
+ symbol,
3835
+ decimals,
3836
+ totalSupply,
3837
+ reserve,
3838
+ reserveDecimals,
3839
+ creator,
3840
+ poolFeeRecipient,
3841
+ creatorFeePct,
3842
+ swapFee,
3843
+ totalBTokens,
3844
+ totalReserves,
3845
+ maker
3846
+ };
3847
+ }
5277
3848
  async getReserve(bToken) {
5278
3849
  const reserve = await this.publicClient.readContract({
5279
3850
  address: this.proxy,
@@ -5307,5 +3878,40 @@ var BaselineSDK = class _BaselineSDK {
5307
3878
  };
5308
3879
  }
5309
3880
  };
3881
+ function normalizeMaker(value) {
3882
+ if (!value) return void 0;
3883
+ const get = (key, index) => Array.isArray(value) ? value[index] : value[key];
3884
+ const initialized = get("initialized", 0);
3885
+ const blvPrice = get("blvPrice", 1);
3886
+ const swapFee = get("swapFee", 2);
3887
+ const maxCirc = get("maxCirc", 3);
3888
+ const maxReserves = get("maxReserves", 4);
3889
+ const convexityExp = get("convexityExp", 5);
3890
+ const lastInvariant = get("lastInvariant", 6);
3891
+ if (typeof initialized !== "boolean" || typeof blvPrice !== "bigint" || typeof swapFee !== "bigint" || typeof maxCirc !== "bigint" || typeof maxReserves !== "bigint" || typeof convexityExp !== "bigint" || typeof lastInvariant !== "bigint") {
3892
+ return void 0;
3893
+ }
3894
+ return {
3895
+ initialized,
3896
+ blvPrice,
3897
+ swapFee,
3898
+ maxCirc,
3899
+ maxReserves,
3900
+ convexityExp,
3901
+ lastInvariant
3902
+ };
3903
+ }
3904
+ function normalizeQuoteState(value) {
3905
+ if (!value) return void 0;
3906
+ const reserveDecimals = Array.isArray(value) ? value[6] : value.reserveDecimals;
3907
+ return typeof reserveDecimals === "number" ? { reserveDecimals } : void 0;
3908
+ }
3909
+ function serializeCalls(calls) {
3910
+ return calls.map((call) => ({
3911
+ to: call.to,
3912
+ data: call.data,
3913
+ value: toHex(call.value ?? 0n)
3914
+ }));
3915
+ }
5310
3916
 
5311
- export { BaselineSDK, SDKError, supportedChainIds };
3917
+ export { BaselineSDK, SDKError, mercuryAbis as abis, serializeCalls, supportedChainIds };