@baseline-markets/sdk 1.0.2 → 1.2.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,7 +1,12 @@
1
- import { getContract, BaseError, UserRejectedRequestError, InsufficientFundsError, ContractFunctionRevertedError, HttpRequestError, WebSocketRequestError, SocketClosedError, TimeoutError, decodeErrorResult } from 'viem';
2
- import { baseSepolia, base, mainnet } from 'viem/chains';
1
+ import { toHex, isAddress, decodeFunctionResult, encodeFunctionData, getContract, BaseError, UserRejectedRequestError, InsufficientFundsError, ContractFunctionRevertedError, HttpRequestError, WebSocketRequestError, SocketClosedError, TimeoutError, decodeErrorResult } from 'viem';
2
+ import { hyperEvm, baseSepolia, base, mainnet } from 'viem/chains';
3
+ import { sendCalls, waitForCallsStatus } from 'viem/actions';
3
4
 
4
- // ../contracts/abis/external/chainlinkOracle.ts
5
+ var __defProp = Object.defineProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
5
10
 
6
11
  // ../contracts/abis/external/erc20.ts
7
12
  var erc20 = [
@@ -1543,1853 +1548,38 @@ var bCredit = [
1543
1548
  inputs: []
1544
1549
  },
1545
1550
  {
1546
- type: "error",
1547
- name: "GuardLib_Paused",
1548
- inputs: []
1549
- },
1550
- {
1551
- type: "error",
1552
- name: "GuardLib_Reentrant",
1553
- inputs: []
1554
- },
1555
- {
1556
- type: "error",
1557
- name: "GuardLib_ReserveAccountingMismatch",
1558
- inputs: []
1559
- },
1560
- {
1561
- type: "error",
1562
- name: "NativeLib_AmountMismatch",
1563
- inputs: []
1564
- },
1565
- {
1566
- type: "error",
1567
- name: "NativeLib_NotWrapped",
1568
- inputs: []
1569
- }
1570
- ];
1571
-
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"
1551
+ type: "error",
1552
+ name: "GuardLib_Paused",
1553
+ inputs: []
3359
1554
  },
3360
1555
  {
3361
1556
  type: "error",
3362
- name: "BLens_InvalidLeverageFactor",
1557
+ name: "GuardLib_Reentrant",
3363
1558
  inputs: []
3364
1559
  },
3365
1560
  {
3366
1561
  type: "error",
3367
- name: "Component_NotPermitted",
1562
+ name: "GuardLib_ReserveAccountingMismatch",
3368
1563
  inputs: []
3369
1564
  },
3370
1565
  {
3371
1566
  type: "error",
3372
- name: "InvalidConvexityExp",
1567
+ name: "NativeLib_AmountMismatch",
3373
1568
  inputs: []
3374
1569
  },
3375
1570
  {
3376
1571
  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
- ]
1572
+ name: "NativeLib_NotWrapped",
1573
+ inputs: []
3390
1574
  }
3391
1575
  ];
3392
1576
 
1577
+ // ../contracts/abis/mercury/bFactory.ts
1578
+ 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": [] }];
1579
+
1580
+ // ../contracts/abis/mercury/bLens.ts
1581
+ 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" }] }];
1582
+
3393
1583
  // ../contracts/abis/mercury/bStaking.ts
3394
1584
  var bStaking = [
3395
1585
  {
@@ -4555,6 +2745,8 @@ var externalAbis = {
4555
2745
  [base.id]: {
4556
2746
  },
4557
2747
  [baseSepolia.id]: {
2748
+ },
2749
+ [hyperEvm.id]: {
4558
2750
  }
4559
2751
  });
4560
2752
  ({
@@ -4563,6 +2755,8 @@ var externalAbis = {
4563
2755
  [base.id]: {
4564
2756
  },
4565
2757
  [baseSepolia.id]: {
2758
+ },
2759
+ [hyperEvm.id]: {
4566
2760
  }
4567
2761
  });
4568
2762
  var relayAddress = "0xc81Fd894C0acE037d133aF4886550aC8133568E8";
@@ -4578,6 +2772,10 @@ var addressBook_default = {
4578
2772
  [baseSepolia.id]: {
4579
2773
  address: relayAddress,
4580
2774
  block: 40585325
2775
+ },
2776
+ [hyperEvm.id]: {
2777
+ address: relayAddress,
2778
+ block: 37892152
4581
2779
  }
4582
2780
  };
4583
2781
  var ContractFactory = class {
@@ -4649,6 +2847,427 @@ var ContractFactory = class {
4649
2847
 
4650
2848
  // ../contracts/index.ts
4651
2849
  var supportedChainIds = Object.keys(addressBook_default).map(Number);
2850
+
2851
+ // src/calls/index.ts
2852
+ var calls_exports = {};
2853
+ __export(calls_exports, {
2854
+ MAX_UINT256: () => MAX_UINT256,
2855
+ WAD: () => WAD,
2856
+ ZERO_BYTES32: () => ZERO_BYTES32,
2857
+ approvalCalls: () => approvalCalls,
2858
+ buildLaunchCalls: () => buildLaunchCalls,
2859
+ createCallsApi: () => createCallsApi,
2860
+ encodeStandardLaunchCalls: () => encodeStandardLaunchCalls,
2861
+ encodeZrpLaunchCalls: () => encodeZrpLaunchCalls,
2862
+ serializeCalls: () => serializeCalls,
2863
+ simulateCalls: () => simulateCalls,
2864
+ validateLaunchCallInput: () => validateLaunchCallInput
2865
+ });
2866
+
2867
+ // src/utils/native.ts
2868
+ function shouldUseNative(explicit, config) {
2869
+ return explicit ?? !!config?.defaultUseNative;
2870
+ }
2871
+ function valueForNative(useNative, amount) {
2872
+ return useNative ? amount : void 0;
2873
+ }
2874
+ async function simulateCalls(publicClient, calls, opts) {
2875
+ const simulation = await publicClient.simulateCalls({
2876
+ account: opts?.account,
2877
+ calls
2878
+ });
2879
+ if (simulation.results.length !== calls.length) {
2880
+ throw new Error(
2881
+ `Call simulation returned ${simulation.results.length} results for ${calls.length} calls`
2882
+ );
2883
+ }
2884
+ return simulation.results.map((result, index) => {
2885
+ if (!result) {
2886
+ throw new Error(`Call simulation ${index} did not return a result`);
2887
+ }
2888
+ if (result.status === "failure") throw result.error;
2889
+ const call = calls[index];
2890
+ if (!call?.decode) return result.data;
2891
+ return call.decode(result.data);
2892
+ });
2893
+ }
2894
+ function contractCall(input) {
2895
+ return {
2896
+ to: input.to,
2897
+ data: encodeFunctionData({
2898
+ abi: input.abi,
2899
+ functionName: input.functionName,
2900
+ args: input.args
2901
+ }),
2902
+ value: input.value,
2903
+ decode: (data) => {
2904
+ const result = decodeFunctionResult({
2905
+ abi: input.abi,
2906
+ functionName: input.functionName,
2907
+ data
2908
+ });
2909
+ return input.mapResult ? input.mapResult(result) : result;
2910
+ }
2911
+ };
2912
+ }
2913
+ function serializeCalls(calls) {
2914
+ return calls.map((call) => ({
2915
+ to: call.to,
2916
+ data: call.data,
2917
+ value: toHex(call.value ?? 0n)
2918
+ }));
2919
+ }
2920
+ var WAD = 10n ** 18n;
2921
+ var ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
2922
+ var DEFAULT_SWAP_FEE_PCT = WAD / 100n;
2923
+ var MIN_SWAP_FEE_PCT = 1500000000000000n;
2924
+ var MAX_SWAP_FEE_PCT = WAD / 2n;
2925
+ var MIN_TOTAL_SUPPLY = 10000n * WAD;
2926
+ var MAX_TOTAL_SUPPLY = 20282409603651670423947251286015n;
2927
+ var MIN_INVARIANT = 3n * WAD;
2928
+ function encodeBaseLaunchCalls(input) {
2929
+ return [
2930
+ contractCall({
2931
+ to: input.relay,
2932
+ abi: mercuryAbis.bFactory,
2933
+ functionName: "createBToken",
2934
+ args: [input.name, input.symbol, input.totalSupply, input.salt]
2935
+ }),
2936
+ contractCall({
2937
+ to: input.bToken,
2938
+ abi: externalAbis.erc20,
2939
+ functionName: "approve",
2940
+ args: [input.relay, input.bTokenApprovalAmount]
2941
+ })
2942
+ ];
2943
+ }
2944
+ function encodeZrpLaunchCalls(input) {
2945
+ return [
2946
+ ...encodeBaseLaunchCalls({
2947
+ ...input,
2948
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2949
+ }),
2950
+ contractCall({
2951
+ to: input.relay,
2952
+ abi: mercuryAbis.bFactory,
2953
+ functionName: "createPoolFromInvariant",
2954
+ args: [input.params]
2955
+ })
2956
+ ];
2957
+ }
2958
+ function encodeStandardLaunchCalls(input) {
2959
+ return [
2960
+ ...encodeBaseLaunchCalls({
2961
+ ...input,
2962
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2963
+ }),
2964
+ contractCall({
2965
+ to: input.reserve,
2966
+ abi: externalAbis.erc20,
2967
+ functionName: "approve",
2968
+ args: [input.relay, input.params.initialPoolReserves]
2969
+ }),
2970
+ contractCall({
2971
+ to: input.relay,
2972
+ abi: mercuryAbis.bFactory,
2973
+ functionName: "createPool",
2974
+ args: [input.params]
2975
+ })
2976
+ ];
2977
+ }
2978
+ function buildLaunchCalls(input) {
2979
+ const salt = normalizeSalt(input.salt);
2980
+ const { mode, swapFeePct, feeRecipient } = resolveLaunchDefaults(input);
2981
+ if (mode === "zrp") {
2982
+ const params2 = {
2983
+ bToken: input.bToken,
2984
+ initialPoolBTokens: input.initialPoolBTokens,
2985
+ reserve: input.reserve,
2986
+ initialInvariant: MIN_INVARIANT,
2987
+ creator: input.creator,
2988
+ feeRecipient,
2989
+ creatorFeePct: input.creatorFeePct,
2990
+ swapFeePct,
2991
+ createHook: true
2992
+ };
2993
+ return encodeZrpLaunchCalls({
2994
+ relay: input.relay,
2995
+ bToken: input.bToken,
2996
+ name: input.name,
2997
+ symbol: input.symbol,
2998
+ totalSupply: input.totalSupply,
2999
+ salt,
3000
+ params: params2
3001
+ });
3002
+ }
3003
+ const initialPoolReserves = input.initialPoolReserves ?? 0n;
3004
+ const circulatingSupply = input.totalSupply - input.initialPoolBTokens;
3005
+ const reservesWad = toWad(initialPoolReserves, input.reserveDecimals ?? 18);
3006
+ const circulatingWad = toWad(circulatingSupply, 18);
3007
+ const bookPrice = divWad(reservesWad, circulatingWad);
3008
+ const params = {
3009
+ bToken: input.bToken,
3010
+ initialPoolBTokens: input.initialPoolBTokens,
3011
+ reserve: input.reserve,
3012
+ initialPoolReserves,
3013
+ initialActivePrice: bookPrice + 1n,
3014
+ initialBLV: 0n,
3015
+ creator: input.creator,
3016
+ feeRecipient,
3017
+ creatorFeePct: input.creatorFeePct,
3018
+ swapFeePct,
3019
+ createHook: true,
3020
+ claimMerkleRoot: ZERO_BYTES32,
3021
+ initialCollateral: 0n,
3022
+ initialDebt: 0n
3023
+ };
3024
+ return encodeStandardLaunchCalls({
3025
+ relay: input.relay,
3026
+ bToken: input.bToken,
3027
+ reserve: input.reserve,
3028
+ name: input.name,
3029
+ symbol: input.symbol,
3030
+ totalSupply: input.totalSupply,
3031
+ salt,
3032
+ params
3033
+ });
3034
+ }
3035
+ function validateLaunchCallInput(input) {
3036
+ normalizeSalt(input.salt);
3037
+ resolveLaunchDefaults(input);
3038
+ }
3039
+ function normalizeSalt(salt) {
3040
+ if (!salt) return ZERO_BYTES32;
3041
+ if (!/^0x[a-fA-F0-9]{64}$/.test(salt)) {
3042
+ throw new Error("salt must be a bytes32 hex string");
3043
+ }
3044
+ return salt;
3045
+ }
3046
+ function resolveLaunchDefaults(input) {
3047
+ const mode = input.mode ?? "zrp";
3048
+ if (mode !== "zrp" && mode !== "standard") {
3049
+ throw new Error("mode must be zrp or standard");
3050
+ }
3051
+ validateTokenText(input.name, input.symbol);
3052
+ validateAddress(input.relay, "relay");
3053
+ validateAddress(input.bToken, "bToken");
3054
+ validateAddress(input.reserve, "reserve");
3055
+ validateAddress(input.creator, "creator");
3056
+ validateDecimals(input.reserveDecimals ?? 18, "reserveDecimals");
3057
+ const feeRecipient = input.feeRecipient ?? input.creator;
3058
+ validateAddress(feeRecipient, "feeRecipient");
3059
+ if (input.totalSupply < MIN_TOTAL_SUPPLY) {
3060
+ throw new Error("totalSupply is below the protocol minimum");
3061
+ }
3062
+ if (input.totalSupply > MAX_TOTAL_SUPPLY) {
3063
+ throw new Error("totalSupply exceeds the protocol maximum");
3064
+ }
3065
+ if (input.initialPoolBTokens <= 0n) {
3066
+ throw new Error("initialPoolBTokens must be greater than zero");
3067
+ }
3068
+ if (input.initialPoolBTokens > input.totalSupply) {
3069
+ throw new Error("initialPoolBTokens cannot exceed totalSupply");
3070
+ }
3071
+ const swapFeePct = input.swapFeePct ?? DEFAULT_SWAP_FEE_PCT;
3072
+ if (swapFeePct < MIN_SWAP_FEE_PCT || swapFeePct > MAX_SWAP_FEE_PCT) {
3073
+ throw new Error("swapFeePct is outside protocol bounds");
3074
+ }
3075
+ if (input.creatorFeePct < 0n || input.creatorFeePct > WAD) {
3076
+ throw new Error("creatorFeePct must be between 0 and 1e18");
3077
+ }
3078
+ if (mode === "zrp") {
3079
+ if (input.initialPoolBTokens !== input.totalSupply) {
3080
+ throw new Error("zrp launches require all BTokens in the pool");
3081
+ }
3082
+ if ((input.initialPoolReserves ?? 0n) !== 0n) {
3083
+ throw new Error("zrp launches require zero initial reserves");
3084
+ }
3085
+ } else {
3086
+ if ((input.initialPoolReserves ?? 0n) <= 0n) {
3087
+ throw new Error("standard launches require initialPoolReserves");
3088
+ }
3089
+ if (input.initialPoolBTokens >= input.totalSupply) {
3090
+ throw new Error("standard launches require circulating supply");
3091
+ }
3092
+ }
3093
+ return { mode, swapFeePct, feeRecipient };
3094
+ }
3095
+ function validateAddress(address, label) {
3096
+ if (!isAddress(address)) throw new Error(`${label} must be a valid address`);
3097
+ }
3098
+ function validateTokenText(name, symbol) {
3099
+ if (name.trim().length === 0) throw new Error("name is required");
3100
+ if (symbol.trim().length === 0) throw new Error("symbol is required");
3101
+ if (new TextEncoder().encode(name).length > 30) {
3102
+ throw new Error("name exceeds 30 bytes");
3103
+ }
3104
+ if (new TextEncoder().encode(symbol).length > 30) {
3105
+ throw new Error("symbol exceeds 30 bytes");
3106
+ }
3107
+ }
3108
+ function validateDecimals(decimals, label) {
3109
+ if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18) {
3110
+ throw new Error(`${label} must be an integer between 0 and 18`);
3111
+ }
3112
+ }
3113
+ function toWad(amount, decimals) {
3114
+ return amount * 10n ** BigInt(18 - decimals);
3115
+ }
3116
+ function divWad(numerator, denominator) {
3117
+ return numerator * WAD / denominator;
3118
+ }
3119
+
3120
+ // src/calls/index.ts
3121
+ var MAX_UINT256 = 2n ** 256n - 1n;
3122
+ function createCallsApi(input) {
3123
+ const relay = () => input.getRelay();
3124
+ return {
3125
+ launch: input.launch,
3126
+ factory: {
3127
+ createBToken: (name, symbol, totalSupply, salt) => contractCall({
3128
+ to: relay(),
3129
+ abi: mercuryAbis.bFactory,
3130
+ functionName: "createBToken",
3131
+ args: [name, symbol, totalSupply, salt]
3132
+ }),
3133
+ createPool: (params) => contractCall({
3134
+ to: relay(),
3135
+ abi: mercuryAbis.bFactory,
3136
+ functionName: "createPool",
3137
+ args: [params]
3138
+ }),
3139
+ createPoolFromInvariant: (params) => contractCall({
3140
+ to: relay(),
3141
+ abi: mercuryAbis.bFactory,
3142
+ functionName: "createPoolFromInvariant",
3143
+ args: [params]
3144
+ })
3145
+ },
3146
+ swap: {
3147
+ buyTokensExactOut: (bToken, amountOut, limitAmount, opts) => contractCall({
3148
+ to: relay(),
3149
+ abi: mercuryAbis.bSwap,
3150
+ functionName: "buyTokensExactOut",
3151
+ args: [bToken, amountOut, limitAmount],
3152
+ value: valueForNative(
3153
+ shouldUseNative(opts?.useNative, input.getConfig()),
3154
+ limitAmount
3155
+ )
3156
+ }),
3157
+ buyTokensExactIn: (bToken, amountIn, limitAmount) => contractCall({
3158
+ to: relay(),
3159
+ abi: mercuryAbis.bSwap,
3160
+ functionName: "buyTokensExactIn",
3161
+ args: [bToken, amountIn, limitAmount]
3162
+ }),
3163
+ sellTokensExactIn: (bToken, amountIn, limitAmount) => contractCall({
3164
+ to: relay(),
3165
+ abi: mercuryAbis.bSwap,
3166
+ functionName: "sellTokensExactIn",
3167
+ args: [bToken, amountIn, limitAmount]
3168
+ }),
3169
+ sellTokensExactOut: (bToken, amountOut, limitAmount) => contractCall({
3170
+ to: relay(),
3171
+ abi: mercuryAbis.bSwap,
3172
+ functionName: "sellTokensExactOut",
3173
+ args: [bToken, amountOut, limitAmount]
3174
+ })
3175
+ },
3176
+ staking: {
3177
+ deposit: (bToken, user, amount) => contractCall({
3178
+ to: relay(),
3179
+ abi: mercuryAbis.bStaking,
3180
+ functionName: "deposit",
3181
+ args: [bToken, user, amount]
3182
+ }),
3183
+ withdraw: (bToken, amount) => contractCall({
3184
+ to: relay(),
3185
+ abi: mercuryAbis.bStaking,
3186
+ functionName: "withdraw",
3187
+ args: [bToken, amount]
3188
+ }),
3189
+ claim: (bToken, user, asNative = false) => contractCall({
3190
+ to: relay(),
3191
+ abi: mercuryAbis.bStaking,
3192
+ functionName: "claim",
3193
+ args: [bToken, user, asNative]
3194
+ })
3195
+ },
3196
+ credit: {
3197
+ borrow: (bToken, amount, recipient, opts) => contractCall({
3198
+ to: relay(),
3199
+ abi: mercuryAbis.bCredit,
3200
+ functionName: opts?.outputNative ? "borrowNative" : "borrow",
3201
+ args: [bToken, amount, recipient]
3202
+ }),
3203
+ repay: (bToken, reservesIn, recipient, opts) => {
3204
+ const useNative = shouldUseNative(opts?.useNative, input.getConfig());
3205
+ return contractCall({
3206
+ to: relay(),
3207
+ abi: mercuryAbis.bCredit,
3208
+ functionName: useNative ? "repayWithNative" : "repay",
3209
+ args: useNative ? [bToken, recipient] : [bToken, reservesIn, recipient],
3210
+ value: useNative ? reservesIn : void 0
3211
+ });
3212
+ },
3213
+ leverage: (bToken, totalCollateral, collateralIn, maxSwapReservesIn) => contractCall({
3214
+ to: relay(),
3215
+ abi: mercuryAbis.bCredit,
3216
+ functionName: "leverage",
3217
+ args: [bToken, totalCollateral, collateralIn, maxSwapReservesIn]
3218
+ }),
3219
+ deleverage: (bToken, collateralToSell, minSwapReservesOut) => contractCall({
3220
+ to: relay(),
3221
+ abi: mercuryAbis.bCredit,
3222
+ functionName: "deleverage",
3223
+ args: [bToken, collateralToSell, minSwapReservesOut],
3224
+ mapResult: ([collateralRedeemed, debtRepaid, refund]) => ({
3225
+ collateralRedeemed,
3226
+ debtRepaid,
3227
+ refund
3228
+ })
3229
+ })
3230
+ },
3231
+ approval: {
3232
+ approve: (token, spender, amount) => contractCall({
3233
+ to: token,
3234
+ abi: externalAbis.erc20,
3235
+ functionName: "approve",
3236
+ args: [spender, amount]
3237
+ }),
3238
+ ensure: async (token, spender, required, opts) => {
3239
+ const owner = opts?.owner ?? input.getAccount();
3240
+ const policy = opts?.policy ?? input.getConfig()?.approvals ?? "infinite";
3241
+ const currentAllowance = await input.getAllowance(
3242
+ token,
3243
+ owner,
3244
+ spender
3245
+ );
3246
+ return approvalCalls({
3247
+ token,
3248
+ spender,
3249
+ required,
3250
+ currentAllowance,
3251
+ policy
3252
+ });
3253
+ }
3254
+ }
3255
+ };
3256
+ }
3257
+ function approvalCalls(input) {
3258
+ if (input.currentAllowance >= input.required) return [];
3259
+ return [
3260
+ contractCall({
3261
+ to: input.token,
3262
+ abi: externalAbis.erc20,
3263
+ functionName: "approve",
3264
+ args: [
3265
+ input.spender,
3266
+ input.policy === "infinite" ? MAX_UINT256 : input.required
3267
+ ]
3268
+ })
3269
+ ];
3270
+ }
4652
3271
  var SDKError = class extends Error {
4653
3272
  kind = "unknown";
4654
3273
  component;
@@ -4741,6 +3360,17 @@ async function requireWallet(wallet) {
4741
3360
  });
4742
3361
  return wallet;
4743
3362
  }
3363
+ function resolveWriteAccount(wallet, sender) {
3364
+ const walletAccount = wallet.account;
3365
+ if (!walletAccount) return sender;
3366
+ if (walletAccount.address.toLowerCase() !== sender.toLowerCase()) {
3367
+ throw new SDKError(
3368
+ `Wallet account ${walletAccount.address} cannot sign for requested account ${sender}`,
3369
+ { kind: "wallet" }
3370
+ );
3371
+ }
3372
+ return walletAccount;
3373
+ }
4744
3374
  async function simulateAndWrite({
4745
3375
  publicClient,
4746
3376
  walletClient,
@@ -4769,7 +3399,82 @@ async function simulateAndWrite({
4769
3399
  account: sender,
4770
3400
  value
4771
3401
  });
4772
- const hash = await wallet.writeContract(simulation.request);
3402
+ const hash = await wallet.writeContract({
3403
+ ...simulation.request,
3404
+ account: resolveWriteAccount(wallet, sender)
3405
+ });
3406
+ if (confirmations) {
3407
+ const receipt = await publicClient.waitForTransactionReceipt({
3408
+ hash,
3409
+ confirmations
3410
+ });
3411
+ if (receipt.status === "reverted") {
3412
+ throw new SDKError("Transaction reverted on-chain", {
3413
+ kind: "reverted",
3414
+ cause: { hash, receipt }
3415
+ });
3416
+ }
3417
+ }
3418
+ return hash;
3419
+ } catch (e) {
3420
+ onSimulateError?.(e);
3421
+ throw classifyTxError(e);
3422
+ }
3423
+ }
3424
+ async function executeCalls({
3425
+ publicClient,
3426
+ walletClient,
3427
+ calls,
3428
+ account,
3429
+ confirmations,
3430
+ onSimulateError
3431
+ }) {
3432
+ const wallet = await requireWallet(walletClient);
3433
+ const sender = account ?? wallet.account?.address;
3434
+ if (!sender) {
3435
+ throw new SDKError(
3436
+ "No account provided and wallet missing default account",
3437
+ {
3438
+ kind: "wallet"
3439
+ }
3440
+ );
3441
+ }
3442
+ if (calls.length === 0) {
3443
+ throw new SDKError("At least one call is required", { kind: "unknown" });
3444
+ }
3445
+ try {
3446
+ const simulation = await publicClient.simulateCalls({
3447
+ account: sender,
3448
+ calls
3449
+ });
3450
+ for (const [index, result] of simulation.results.entries()) {
3451
+ if (!result) {
3452
+ throw new SDKError(`Call simulation ${index} did not return a result`);
3453
+ }
3454
+ if (result.status === "failure") {
3455
+ const error = classifyTxError(result.error);
3456
+ if (error.kind === "unknown" && result.error instanceof Error) {
3457
+ throw new SDKError(result.error.message, {
3458
+ kind: "reverted",
3459
+ cause: result.error
3460
+ });
3461
+ }
3462
+ throw error;
3463
+ }
3464
+ }
3465
+ const { id } = await sendCalls(wallet, {
3466
+ account: resolveWriteAccount(wallet, sender),
3467
+ calls,
3468
+ experimental_fallback: true
3469
+ });
3470
+ const status = await waitForCallsStatus(wallet, {
3471
+ id,
3472
+ throwOnFailure: true
3473
+ });
3474
+ const hash = status.receipts?.[0]?.transactionHash;
3475
+ if (!hash) {
3476
+ throw new SDKError("Calls bundle did not return a transaction hash");
3477
+ }
4773
3478
  if (confirmations) {
4774
3479
  const receipt = await publicClient.waitForTransactionReceipt({
4775
3480
  hash,
@@ -4804,41 +3509,21 @@ async function getAllowance(client, token, owner, spender) {
4804
3509
  });
4805
3510
  return allowance;
4806
3511
  }
4807
- async function ensureAllowance(params) {
4808
- const current = await getAllowance(
4809
- params.publicClient,
4810
- params.token,
4811
- params.owner,
4812
- params.spender
4813
- );
4814
- if (current >= params.required) return;
4815
- const amount = params.policy === "infinite" ? 2n ** 256n - 1n : params.required;
4816
- await simulateAndWrite({
4817
- publicClient: params.publicClient,
4818
- walletClient: params.walletClient,
4819
- address: params.token,
4820
- abi: externalAbis.erc20,
4821
- functionName: "approve",
4822
- args: [params.spender, amount],
4823
- account: params.owner,
4824
- confirmations: params.confirmations
4825
- });
4826
- }
4827
-
4828
- // src/utils/native.ts
4829
- function shouldUseNative(explicit, config) {
4830
- return explicit ?? !!config?.defaultUseNative;
4831
- }
4832
- function valueForNative(useNative, amount) {
4833
- return useNative ? amount : void 0;
4834
- }
4835
3512
 
4836
3513
  // src/baseline-sdk.ts
3514
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
4837
3515
  var BaselineSDK = class _BaselineSDK {
4838
3516
  publicClient;
4839
3517
  walletClient;
4840
3518
  config;
4841
3519
  readFactory;
3520
+ calls = createCallsApi({
3521
+ getRelay: () => this.proxy,
3522
+ getConfig: () => this.config,
3523
+ getAccount: () => this.getAccount(),
3524
+ getAllowance: (token, owner, spender) => this.getAllowance(token, owner, spender),
3525
+ launch: (input, opts) => this.launchCalls(input, opts)
3526
+ });
4842
3527
  getAccount(opts) {
4843
3528
  const account = opts?.account ?? this.walletClient?.account?.address;
4844
3529
  if (!account) {
@@ -4889,7 +3574,10 @@ var BaselineSDK = class _BaselineSDK {
4889
3574
  account
4890
3575
  });
4891
3576
  const wallet = this.requireWallet();
4892
- const hash = await wallet.writeContract(request);
3577
+ const hash = await wallet.writeContract({
3578
+ ...request,
3579
+ account: resolveWriteAccount(wallet, account)
3580
+ });
4893
3581
  if (opts?.confirmations)
4894
3582
  await this.publicClient.waitForTransactionReceipt({
4895
3583
  hash,
@@ -4916,6 +3604,59 @@ var BaselineSDK = class _BaselineSDK {
4916
3604
  });
4917
3605
  return { hash };
4918
3606
  }
3607
+ async createPoolFromInvariant(params, opts) {
3608
+ const account = this.getAccount(opts);
3609
+ const hash = await simulateAndWrite({
3610
+ publicClient: this.publicClient,
3611
+ walletClient: this.walletClient,
3612
+ address: this.proxy,
3613
+ abi: mercuryAbis.bFactory,
3614
+ functionName: "createPoolFromInvariant",
3615
+ args: [params],
3616
+ account,
3617
+ confirmations: opts?.confirmations,
3618
+ onSimulateError: opts?.onSimulateError
3619
+ });
3620
+ return { hash };
3621
+ }
3622
+ async precomputeBTokenAddress(input) {
3623
+ const bToken = await this.publicClient.readContract({
3624
+ address: this.proxy,
3625
+ abi: mercuryAbis.bFactory,
3626
+ functionName: "precomputeBTokenAddress",
3627
+ args: [
3628
+ input.name,
3629
+ input.symbol,
3630
+ input.totalSupply,
3631
+ input.salt,
3632
+ input.deployer
3633
+ ]
3634
+ });
3635
+ return bToken;
3636
+ }
3637
+ async launchCalls(input, opts) {
3638
+ const account = this.getAccount(opts);
3639
+ const salt = input.salt ?? ZERO_BYTES32;
3640
+ validateLaunchCallInput({
3641
+ ...input,
3642
+ relay: this.proxy,
3643
+ bToken: "0x0000000000000000000000000000000000000000",
3644
+ salt
3645
+ });
3646
+ const bToken = opts?.precomputedBToken ?? await this.precomputeBTokenAddress({
3647
+ name: input.name,
3648
+ symbol: input.symbol,
3649
+ totalSupply: input.totalSupply,
3650
+ salt,
3651
+ deployer: account
3652
+ });
3653
+ return buildLaunchCalls({
3654
+ ...input,
3655
+ relay: this.proxy,
3656
+ bToken,
3657
+ salt
3658
+ });
3659
+ }
4919
3660
  // ---------- Swap quotes ----------
4920
3661
  async quoteBuyExactIn(bToken, reservesIn) {
4921
3662
  const [tokensOut, fee, slippage] = await this.publicClient.readContract({
@@ -4955,18 +3696,22 @@ var BaselineSDK = class _BaselineSDK {
4955
3696
  }
4956
3697
  // ---------- Swap execution ----------
4957
3698
  async buyTokensExactOut(bToken, amountOut, limitAmount, opts) {
4958
- const useNative = shouldUseNative(opts?.useNative, this.config);
4959
3699
  const account = this.getAccount(opts);
4960
- const value = valueForNative(useNative, limitAmount);
3700
+ const call = this.calls.swap.buyTokensExactOut(
3701
+ bToken,
3702
+ amountOut,
3703
+ limitAmount,
3704
+ opts
3705
+ );
4961
3706
  return simulateAndWrite({
4962
3707
  publicClient: this.publicClient,
4963
3708
  walletClient: this.walletClient,
4964
- address: this.proxy,
3709
+ address: call.to,
4965
3710
  abi: mercuryAbis.bSwap,
4966
3711
  functionName: "buyTokensExactOut",
4967
3712
  args: [bToken, amountOut, limitAmount],
4968
3713
  account,
4969
- value,
3714
+ value: call.value,
4970
3715
  confirmations: opts?.confirmations,
4971
3716
  onSimulateError: opts?.onSimulateError
4972
3717
  });
@@ -5031,23 +3776,20 @@ var BaselineSDK = class _BaselineSDK {
5031
3776
  }
5032
3777
  async withdraw(bToken, amount, opts) {
5033
3778
  const account = this.getAccount(opts);
5034
- return simulateAndWrite({
3779
+ return executeCalls({
5035
3780
  publicClient: this.publicClient,
5036
3781
  walletClient: this.walletClient,
5037
- address: this.proxy,
5038
- abi: mercuryAbis.bStaking,
5039
- functionName: "withdraw",
5040
- args: [bToken, amount],
3782
+ calls: [this.calls.staking.withdraw(bToken, amount)],
5041
3783
  account,
5042
3784
  confirmations: opts?.confirmations,
5043
3785
  onSimulateError: opts?.onSimulateError
5044
3786
  });
5045
3787
  }
5046
3788
  async claim(bToken, opts) {
5047
- const wallet = this.requireWallet();
5048
3789
  const account = this.getAccount(opts);
5049
3790
  const user = opts?.user ?? account;
5050
3791
  const asNative = opts?.asNative ?? false;
3792
+ const wallet = this.requireWallet();
5051
3793
  try {
5052
3794
  const { result, request } = await this.publicClient.simulateContract({
5053
3795
  address: this.proxy,
@@ -5056,7 +3798,10 @@ var BaselineSDK = class _BaselineSDK {
5056
3798
  args: [bToken, user, asNative],
5057
3799
  account
5058
3800
  });
5059
- const hash = await wallet.writeContract(request);
3801
+ const hash = await wallet.writeContract({
3802
+ ...request,
3803
+ account: resolveWriteAccount(wallet, account)
3804
+ });
5060
3805
  if (opts?.confirmations)
5061
3806
  await this.publicClient.waitForTransactionReceipt({
5062
3807
  hash,
@@ -5107,13 +3852,12 @@ var BaselineSDK = class _BaselineSDK {
5107
3852
  }
5108
3853
  async borrow(bToken, amount, recipient, opts) {
5109
3854
  const account = this.getAccount(opts);
5110
- const functionName = opts?.outputNative ? "borrowNative" : "borrow";
5111
3855
  return simulateAndWrite({
5112
3856
  publicClient: this.publicClient,
5113
3857
  walletClient: this.walletClient,
5114
3858
  address: this.proxy,
5115
3859
  abi: mercuryAbis.bCredit,
5116
- functionName,
3860
+ functionName: opts?.outputNative ? "borrowNative" : "borrow",
5117
3861
  args: [bToken, amount, recipient],
5118
3862
  account,
5119
3863
  confirmations: opts?.confirmations,
@@ -5121,20 +3865,18 @@ var BaselineSDK = class _BaselineSDK {
5121
3865
  });
5122
3866
  }
5123
3867
  async repay(bToken, reservesIn, recipient, opts) {
5124
- const useNative = shouldUseNative(opts?.useNative, this.config);
5125
3868
  const account = this.getAccount(opts);
5126
- const functionName = useNative ? "repayWithNative" : "repay";
5127
- const args = useNative ? [bToken, recipient] : [bToken, reservesIn, recipient];
5128
- const value = valueForNative(useNative, reservesIn);
3869
+ const call = this.calls.credit.repay(bToken, reservesIn, recipient, opts);
3870
+ const useNative = shouldUseNative(opts?.useNative, this.config);
5129
3871
  return simulateAndWrite({
5130
3872
  publicClient: this.publicClient,
5131
3873
  walletClient: this.walletClient,
5132
- address: this.proxy,
3874
+ address: call.to,
5133
3875
  abi: mercuryAbis.bCredit,
5134
- functionName,
5135
- args,
3876
+ functionName: useNative ? "repayWithNative" : "repay",
3877
+ args: useNative ? [bToken, recipient] : [bToken, reservesIn, recipient],
5136
3878
  account,
5137
- value,
3879
+ value: call.value,
5138
3880
  confirmations: opts?.confirmations,
5139
3881
  onSimulateError: opts?.onSimulateError
5140
3882
  });
@@ -5223,6 +3965,15 @@ var BaselineSDK = class _BaselineSDK {
5223
3965
  userAccumulator
5224
3966
  };
5225
3967
  }
3968
+ async getEarned(bToken, user) {
3969
+ const earned = await this.publicClient.readContract({
3970
+ address: this.proxy,
3971
+ abi: mercuryAbis.bStaking,
3972
+ functionName: "getEarned",
3973
+ args: [bToken, user]
3974
+ });
3975
+ return earned;
3976
+ }
5226
3977
  async getCreditAccount(bToken, user) {
5227
3978
  const [collateral, debt] = await this.publicClient.readContract({
5228
3979
  address: this.proxy,
@@ -5262,18 +4013,131 @@ var BaselineSDK = class _BaselineSDK {
5262
4013
  async ensureApproval(token, spender, required, opts) {
5263
4014
  const account = this.getAccount(opts);
5264
4015
  const policy = opts?.policy ?? this.config?.approvals ?? "infinite";
5265
- await ensureAllowance({
5266
- publicClient: this.publicClient,
5267
- walletClient: this.walletClient,
5268
- token,
4016
+ const calls = await this.calls.approval.ensure(token, spender, required, {
5269
4017
  owner: account,
5270
- spender,
5271
- required,
5272
- policy,
5273
- confirmations: opts?.confirmations
4018
+ policy
5274
4019
  });
4020
+ const [call] = calls;
4021
+ if (!call) return;
4022
+ const amount = policy === "infinite" ? 2n ** 256n - 1n : required;
4023
+ await this.approve(token, spender, amount, opts);
5275
4024
  }
5276
4025
  // ---------- Lens queries ----------
4026
+ async getBTokenInfo(bToken) {
4027
+ const results = await this.publicClient.multicall({
4028
+ allowFailure: true,
4029
+ contracts: [
4030
+ { address: bToken, abi: externalAbis.erc20, functionName: "name" },
4031
+ { address: bToken, abi: externalAbis.erc20, functionName: "symbol" },
4032
+ { address: bToken, abi: externalAbis.erc20, functionName: "decimals" },
4033
+ {
4034
+ address: bToken,
4035
+ abi: externalAbis.erc20,
4036
+ functionName: "totalSupply"
4037
+ },
4038
+ {
4039
+ address: this.proxy,
4040
+ abi: mercuryAbis.bLens,
4041
+ functionName: "reserve",
4042
+ args: [bToken]
4043
+ },
4044
+ {
4045
+ address: this.proxy,
4046
+ abi: mercuryAbis.bLens,
4047
+ functionName: "creator",
4048
+ args: [bToken]
4049
+ },
4050
+ {
4051
+ address: this.proxy,
4052
+ abi: mercuryAbis.bLens,
4053
+ functionName: "poolFeeRecipient",
4054
+ args: [bToken]
4055
+ },
4056
+ {
4057
+ address: this.proxy,
4058
+ abi: mercuryAbis.bLens,
4059
+ functionName: "creatorFeePct",
4060
+ args: [bToken]
4061
+ },
4062
+ {
4063
+ address: this.proxy,
4064
+ abi: mercuryAbis.bLens,
4065
+ functionName: "swapFee",
4066
+ args: [bToken]
4067
+ },
4068
+ {
4069
+ address: this.proxy,
4070
+ abi: mercuryAbis.bLens,
4071
+ functionName: "totalBTokens",
4072
+ args: [bToken]
4073
+ },
4074
+ {
4075
+ address: this.proxy,
4076
+ abi: mercuryAbis.bLens,
4077
+ functionName: "totalReserves",
4078
+ args: [bToken]
4079
+ },
4080
+ {
4081
+ address: this.proxy,
4082
+ abi: mercuryAbis.bLens,
4083
+ functionName: "getMaker",
4084
+ args: [bToken]
4085
+ },
4086
+ {
4087
+ address: this.proxy,
4088
+ abi: mercuryAbis.bLens,
4089
+ functionName: "getQuoteState",
4090
+ args: [bToken]
4091
+ }
4092
+ ]
4093
+ });
4094
+ const result = (index) => {
4095
+ const item = results[index];
4096
+ return item?.status === "success" ? item.result : void 0;
4097
+ };
4098
+ const name = result(0);
4099
+ const symbol = result(1);
4100
+ const decimals = result(2);
4101
+ const totalSupply = result(3);
4102
+ const reserve = result(4);
4103
+ const creator = result(5);
4104
+ const poolFeeRecipient = result(6);
4105
+ const creatorFeePct = result(7);
4106
+ const swapFee = result(8);
4107
+ const totalBTokens = result(9);
4108
+ const totalReserves = result(10);
4109
+ const maker = normalizeMaker(result(11));
4110
+ const reserveDecimals = normalizeQuoteState(
4111
+ result(12)
4112
+ )?.reserveDecimals;
4113
+ return {
4114
+ chainId: this.chainId,
4115
+ relay: this.proxy,
4116
+ bToken,
4117
+ name,
4118
+ symbol,
4119
+ decimals,
4120
+ totalSupply,
4121
+ reserve,
4122
+ reserveDecimals,
4123
+ creator,
4124
+ poolFeeRecipient,
4125
+ creatorFeePct,
4126
+ swapFee,
4127
+ totalBTokens,
4128
+ totalReserves,
4129
+ maker
4130
+ };
4131
+ }
4132
+ async getBTokenStatus(bToken, info) {
4133
+ const bytecode = await this.publicClient.getCode({ address: bToken });
4134
+ const hasBytecode = !!bytecode && bytecode !== "0x";
4135
+ const tokenInfo = info ?? await this.getBTokenInfo(bToken);
4136
+ const hasBaselineState = tokenInfo.reserve !== void 0 && tokenInfo.reserve.toLowerCase() !== ZERO_ADDRESS && tokenInfo.maker !== void 0;
4137
+ const maker = tokenInfo.maker;
4138
+ const status = !hasBytecode ? "not_deployed" : !hasBaselineState ? "contract_only" : maker?.initialized ? "initialized" : "baseline_uninitialized";
4139
+ return { status, bytecode: hasBytecode };
4140
+ }
5277
4141
  async getReserve(bToken) {
5278
4142
  const reserve = await this.publicClient.readContract({
5279
4143
  address: this.proxy,
@@ -5307,5 +4171,49 @@ var BaselineSDK = class _BaselineSDK {
5307
4171
  };
5308
4172
  }
5309
4173
  };
4174
+ function normalizeMaker(value) {
4175
+ if (!value) return void 0;
4176
+ const get = (key, index) => Array.isArray(value) ? value[index] : value[key];
4177
+ const initialized = get("initialized", 0);
4178
+ const blvPrice = get("blvPrice", 1);
4179
+ const swapFee = get("swapFee", 2);
4180
+ const maxCirc = get("maxCirc", 3);
4181
+ const maxReserves = get("maxReserves", 4);
4182
+ const convexityExp = get("convexityExp", 5);
4183
+ const lastInvariant = get("lastInvariant", 6);
4184
+ if (typeof initialized !== "boolean" || typeof blvPrice !== "bigint" || typeof swapFee !== "bigint" || typeof maxCirc !== "bigint" || typeof maxReserves !== "bigint" || typeof convexityExp !== "bigint" || typeof lastInvariant !== "bigint") {
4185
+ return void 0;
4186
+ }
4187
+ return {
4188
+ initialized,
4189
+ blvPrice,
4190
+ swapFee,
4191
+ maxCirc,
4192
+ maxReserves,
4193
+ convexityExp,
4194
+ lastInvariant
4195
+ };
4196
+ }
4197
+ function normalizeQuoteState(value) {
4198
+ if (!value) return void 0;
4199
+ const reserveDecimals = Array.isArray(value) ? value[6] : value.reserveDecimals;
4200
+ return typeof reserveDecimals === "number" ? { reserveDecimals } : void 0;
4201
+ }
4202
+
4203
+ // src/utils/slippage.ts
4204
+ function maxInWithSlippage(amountIn, slippageBps) {
4205
+ if (slippageBps < 0) throw new Error("slippageBps must be >= 0");
4206
+ return amountIn * BigInt(1e4 + slippageBps) / 10000n;
4207
+ }
4208
+ function minOutWithSlippage(amountOut, slippageBps) {
4209
+ if (slippageBps < 0) throw new Error("slippageBps must be >= 0");
4210
+ const numerator = amountOut * 10000n;
4211
+ const denom = BigInt(1e4 + slippageBps);
4212
+ return numerator / denom;
4213
+ }
4214
+
4215
+ // index.ts
4216
+ var abis = mercuryAbis;
4217
+ var supportedChainIds2 = supportedChainIds;
5310
4218
 
5311
- export { BaselineSDK, SDKError, mercuryAbis as abis, supportedChainIds };
4219
+ export { BaselineSDK, SDKError, abis, calls_exports as calls, maxInWithSlippage, minOutWithSlippage, serializeCalls, simulateCalls, supportedChainIds2 as supportedChainIds };