@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.cjs CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  var viem = require('viem');
4
4
  var chains = require('viem/chains');
5
+ var actions = require('viem/actions');
5
6
 
6
- // ../contracts/abis/external/chainlinkOracle.ts
7
+ var __defProp = Object.defineProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
7
12
 
8
13
  // ../contracts/abis/external/erc20.ts
9
14
  var erc20 = [
@@ -1545,1853 +1550,38 @@ var bCredit = [
1545
1550
  inputs: []
1546
1551
  },
1547
1552
  {
1548
- type: "error",
1549
- name: "GuardLib_Paused",
1550
- inputs: []
1551
- },
1552
- {
1553
- type: "error",
1554
- name: "GuardLib_Reentrant",
1555
- inputs: []
1556
- },
1557
- {
1558
- type: "error",
1559
- name: "GuardLib_ReserveAccountingMismatch",
1560
- inputs: []
1561
- },
1562
- {
1563
- type: "error",
1564
- name: "NativeLib_AmountMismatch",
1565
- inputs: []
1566
- },
1567
- {
1568
- type: "error",
1569
- name: "NativeLib_NotWrapped",
1570
- inputs: []
1571
- }
1572
- ];
1573
-
1574
- // ../contracts/abis/mercury/bFactory.ts
1575
- var bFactory = [
1576
- {
1577
- type: "function",
1578
- name: "LABEL",
1579
- inputs: [],
1580
- outputs: [
1581
- {
1582
- name: "",
1583
- type: "bytes32",
1584
- internalType: "bytes32"
1585
- }
1586
- ],
1587
- stateMutability: "pure"
1588
- },
1589
- {
1590
- type: "function",
1591
- name: "ROUTES",
1592
- inputs: [],
1593
- outputs: [
1594
- {
1595
- name: "routes_",
1596
- type: "bytes4[]",
1597
- internalType: "bytes4[]"
1598
- }
1599
- ],
1600
- stateMutability: "pure"
1601
- },
1602
- {
1603
- type: "function",
1604
- name: "VERSION",
1605
- inputs: [],
1606
- outputs: [
1607
- {
1608
- name: "",
1609
- type: "uint256",
1610
- internalType: "uint256"
1611
- }
1612
- ],
1613
- stateMutability: "pure"
1614
- },
1615
- {
1616
- type: "function",
1617
- name: "createBToken",
1618
- inputs: [
1619
- {
1620
- name: "_name",
1621
- type: "string",
1622
- internalType: "string"
1623
- },
1624
- {
1625
- name: "_symbol",
1626
- type: "string",
1627
- internalType: "string"
1628
- },
1629
- {
1630
- name: "_totalSupply",
1631
- type: "uint256",
1632
- internalType: "uint256"
1633
- },
1634
- {
1635
- name: "_salt",
1636
- type: "bytes32",
1637
- internalType: "bytes32"
1638
- }
1639
- ],
1640
- outputs: [
1641
- {
1642
- name: "bToken_",
1643
- type: "address",
1644
- internalType: "contract BToken"
1645
- }
1646
- ],
1647
- stateMutability: "nonpayable"
1648
- },
1649
- {
1650
- type: "function",
1651
- name: "createPool",
1652
- inputs: [
1653
- {
1654
- name: "params",
1655
- type: "tuple",
1656
- internalType: "struct BFactory.CreateParams",
1657
- components: [
1658
- {
1659
- name: "bToken",
1660
- type: "address",
1661
- internalType: "contract BToken"
1662
- },
1663
- {
1664
- name: "initialPoolBTokens",
1665
- type: "uint256",
1666
- internalType: "uint256"
1667
- },
1668
- {
1669
- name: "reserve",
1670
- type: "address",
1671
- internalType: "address"
1672
- },
1673
- {
1674
- name: "initialPoolReserves",
1675
- type: "uint256",
1676
- internalType: "uint256"
1677
- },
1678
- {
1679
- name: "initialActivePrice",
1680
- type: "uint256",
1681
- internalType: "uint256"
1682
- },
1683
- {
1684
- name: "initialBLV",
1685
- type: "uint256",
1686
- internalType: "uint256"
1687
- },
1688
- {
1689
- name: "creator",
1690
- type: "address",
1691
- internalType: "address"
1692
- },
1693
- {
1694
- name: "feeRecipient",
1695
- type: "address",
1696
- internalType: "address"
1697
- },
1698
- {
1699
- name: "creatorFeePct",
1700
- type: "uint256",
1701
- internalType: "uint256"
1702
- },
1703
- {
1704
- name: "swapFeePct",
1705
- type: "uint256",
1706
- internalType: "uint256"
1707
- },
1708
- {
1709
- name: "createHook",
1710
- type: "bool",
1711
- internalType: "bool"
1712
- },
1713
- {
1714
- name: "claimMerkleRoot",
1715
- type: "bytes32",
1716
- internalType: "bytes32"
1717
- },
1718
- {
1719
- name: "initialCollateral",
1720
- type: "uint256",
1721
- internalType: "uint256"
1722
- },
1723
- {
1724
- name: "initialDebt",
1725
- type: "uint256",
1726
- internalType: "uint256"
1727
- }
1728
- ]
1729
- }
1730
- ],
1731
- outputs: [],
1732
- stateMutability: "payable"
1733
- },
1734
- {
1735
- type: "function",
1736
- name: "precomputeBTokenAddress",
1737
- inputs: [
1738
- {
1739
- name: "_name",
1740
- type: "string",
1741
- internalType: "string"
1742
- },
1743
- {
1744
- name: "_symbol",
1745
- type: "string",
1746
- internalType: "string"
1747
- },
1748
- {
1749
- name: "_totalSupply",
1750
- type: "uint256",
1751
- internalType: "uint256"
1752
- },
1753
- {
1754
- name: "_salt",
1755
- type: "bytes32",
1756
- internalType: "bytes32"
1757
- },
1758
- {
1759
- name: "_deployer",
1760
- type: "address",
1761
- internalType: "address"
1762
- }
1763
- ],
1764
- outputs: [
1765
- {
1766
- name: "computedAddress_",
1767
- type: "address",
1768
- internalType: "address"
1769
- }
1770
- ],
1771
- stateMutability: "view"
1772
- },
1773
- {
1774
- type: "function",
1775
- name: "supportsInterface",
1776
- inputs: [
1777
- {
1778
- name: "_interfaceId",
1779
- type: "bytes4",
1780
- internalType: "bytes4"
1781
- }
1782
- ],
1783
- outputs: [
1784
- {
1785
- name: "",
1786
- type: "bool",
1787
- internalType: "bool"
1788
- }
1789
- ],
1790
- stateMutability: "pure"
1791
- },
1792
- {
1793
- type: "event",
1794
- name: "BTokenCreated",
1795
- inputs: [
1796
- {
1797
- name: "bTokenAddress",
1798
- type: "address",
1799
- indexed: false,
1800
- internalType: "contract BToken"
1801
- },
1802
- {
1803
- name: "name",
1804
- type: "string",
1805
- indexed: false,
1806
- internalType: "string"
1807
- },
1808
- {
1809
- name: "symbol",
1810
- type: "string",
1811
- indexed: false,
1812
- internalType: "string"
1813
- },
1814
- {
1815
- name: "decimals",
1816
- type: "uint8",
1817
- indexed: false,
1818
- internalType: "uint8"
1819
- },
1820
- {
1821
- name: "totalSupply",
1822
- type: "uint256",
1823
- indexed: false,
1824
- internalType: "uint256"
1825
- },
1826
- {
1827
- name: "creator",
1828
- type: "address",
1829
- indexed: false,
1830
- internalType: "address"
1831
- }
1832
- ],
1833
- anonymous: false
1834
- },
1835
- {
1836
- type: "event",
1837
- name: "Initialized",
1838
- inputs: [
1839
- {
1840
- name: "bToken",
1841
- type: "address",
1842
- indexed: false,
1843
- internalType: "contract BToken"
1844
- },
1845
- {
1846
- name: "activePrice",
1847
- type: "uint256",
1848
- indexed: false,
1849
- internalType: "uint256"
1850
- },
1851
- {
1852
- name: "blvPrice",
1853
- type: "uint256",
1854
- indexed: false,
1855
- internalType: "uint256"
1856
- },
1857
- {
1858
- name: "swapFeePct",
1859
- type: "uint256",
1860
- indexed: false,
1861
- internalType: "uint256"
1862
- }
1863
- ],
1864
- anonymous: false
1865
- },
1866
- {
1867
- type: "event",
1868
- name: "PoolCreated",
1869
- inputs: [
1870
- {
1871
- name: "bTokenAddress",
1872
- type: "address",
1873
- indexed: false,
1874
- internalType: "contract BToken"
1875
- },
1876
- {
1877
- name: "reserveAddress",
1878
- type: "address",
1879
- indexed: false,
1880
- internalType: "address"
1881
- },
1882
- {
1883
- name: "creator",
1884
- type: "address",
1885
- indexed: false,
1886
- internalType: "address"
1887
- },
1888
- {
1889
- name: "feeRecipient",
1890
- type: "address",
1891
- indexed: false,
1892
- internalType: "address"
1893
- },
1894
- {
1895
- name: "creatorFeePct",
1896
- type: "uint256",
1897
- indexed: false,
1898
- internalType: "uint256"
1899
- },
1900
- {
1901
- name: "initialActivePrice",
1902
- type: "uint256",
1903
- indexed: false,
1904
- internalType: "uint256"
1905
- },
1906
- {
1907
- name: "initialBlvPrice",
1908
- type: "uint256",
1909
- indexed: false,
1910
- internalType: "uint256"
1911
- },
1912
- {
1913
- name: "totalReserves",
1914
- type: "uint256",
1915
- indexed: false,
1916
- internalType: "uint256"
1917
- },
1918
- {
1919
- name: "totalBTokens",
1920
- type: "uint256",
1921
- indexed: false,
1922
- internalType: "uint256"
1923
- },
1924
- {
1925
- name: "totalCollateral",
1926
- type: "uint256",
1927
- indexed: false,
1928
- internalType: "uint256"
1929
- },
1930
- {
1931
- name: "totalDebt",
1932
- type: "uint256",
1933
- indexed: false,
1934
- internalType: "uint256"
1935
- },
1936
- {
1937
- name: "poolId",
1938
- type: "bytes32",
1939
- indexed: false,
1940
- internalType: "bytes32"
1941
- }
1942
- ],
1943
- anonymous: false
1944
- },
1945
- {
1946
- type: "error",
1947
- name: "AlreadyInitialized",
1948
- inputs: []
1949
- },
1950
- {
1951
- type: "error",
1952
- name: "Component_NotPermitted",
1953
- inputs: []
1954
- },
1955
- {
1956
- type: "error",
1957
- name: "GuardLib_Paused",
1958
- inputs: []
1959
- },
1960
- {
1961
- type: "error",
1962
- name: "GuardLib_Reentrant",
1963
- inputs: []
1964
- },
1965
- {
1966
- type: "error",
1967
- name: "GuardLib_ReserveAccountingMismatch",
1968
- inputs: []
1969
- },
1970
- {
1971
- type: "error",
1972
- name: "InsolventInitialCreditPosition",
1973
- inputs: []
1974
- },
1975
- {
1976
- type: "error",
1977
- name: "InvalidActivePrice",
1978
- inputs: []
1979
- },
1980
- {
1981
- type: "error",
1982
- name: "InvalidBLVPrice",
1983
- inputs: []
1984
- },
1985
- {
1986
- type: "error",
1987
- name: "InvalidConvexityExp",
1988
- inputs: []
1989
- },
1990
- {
1991
- type: "error",
1992
- name: "InvalidConvexityExp",
1993
- inputs: []
1994
- },
1995
- {
1996
- type: "error",
1997
- name: "InvalidCreator",
1998
- inputs: []
1999
- },
2000
- {
2001
- type: "error",
2002
- name: "InvalidCreatorFee",
2003
- inputs: []
2004
- },
2005
- {
2006
- type: "error",
2007
- name: "InvalidFeeRecipient",
2008
- inputs: []
2009
- },
2010
- {
2011
- type: "error",
2012
- name: "InvalidInitialCollateralOrDebt",
2013
- inputs: []
2014
- },
2015
- {
2016
- type: "error",
2017
- name: "InvalidName",
2018
- inputs: []
2019
- },
2020
- {
2021
- type: "error",
2022
- name: "InvalidPoolSupply",
2023
- inputs: []
2024
- },
2025
- {
2026
- type: "error",
2027
- name: "InvalidSalt",
2028
- inputs: []
2029
- },
2030
- {
2031
- type: "error",
2032
- name: "InvalidSwapFeePct",
2033
- inputs: []
2034
- },
2035
- {
2036
- type: "error",
2037
- name: "InvalidSymbol",
2038
- inputs: []
2039
- },
2040
- {
2041
- type: "error",
2042
- name: "InvariantDecreased",
2043
- inputs: [
2044
- {
2045
- name: "prevInvariant",
2046
- type: "uint256",
2047
- internalType: "uint256"
2048
- },
2049
- {
2050
- name: "newInvariant",
2051
- type: "uint256",
2052
- internalType: "uint256"
2053
- }
2054
- ]
2055
- },
2056
- {
2057
- type: "error",
2058
- name: "NativeLib_AmountMismatch",
2059
- inputs: []
2060
- },
2061
- {
2062
- type: "error",
2063
- name: "NativeLib_NotWrapped",
2064
- inputs: []
2065
- },
2066
- {
2067
- type: "error",
2068
- name: "NotApprovedReserve",
2069
- inputs: []
2070
- },
2071
- {
2072
- type: "error",
2073
- name: "NotDeployer",
2074
- inputs: []
2075
- },
2076
- {
2077
- type: "error",
2078
- name: "PoolAlreadyInitialized",
2079
- inputs: []
2080
- },
2081
- {
2082
- type: "error",
2083
- name: "TotalSupplyTooHigh",
2084
- inputs: []
2085
- },
2086
- {
2087
- type: "error",
2088
- name: "TotalSupplyTooLow",
2089
- inputs: []
2090
- },
2091
- {
2092
- type: "error",
2093
- name: "UnauthorizedCreditPositionCreation",
2094
- inputs: []
2095
- }
2096
- ];
2097
-
2098
- // ../contracts/abis/mercury/bLens.ts
2099
- var bLens = [
2100
- {
2101
- type: "function",
2102
- name: "LABEL",
2103
- inputs: [],
2104
- outputs: [
2105
- {
2106
- name: "",
2107
- type: "bytes32",
2108
- internalType: "bytes32"
2109
- }
2110
- ],
2111
- stateMutability: "view"
2112
- },
2113
- {
2114
- type: "function",
2115
- name: "ROUTES",
2116
- inputs: [],
2117
- outputs: [
2118
- {
2119
- name: "routes_",
2120
- type: "bytes4[]",
2121
- internalType: "bytes4[]"
2122
- }
2123
- ],
2124
- stateMutability: "pure"
2125
- },
2126
- {
2127
- type: "function",
2128
- name: "VERSION",
2129
- inputs: [],
2130
- outputs: [
2131
- {
2132
- name: "",
2133
- type: "uint256",
2134
- internalType: "uint256"
2135
- }
2136
- ],
2137
- stateMutability: "view"
2138
- },
2139
- {
2140
- type: "function",
2141
- name: "accumulator",
2142
- inputs: [
2143
- {
2144
- name: "_bToken",
2145
- type: "address",
2146
- internalType: "contract BToken"
2147
- }
2148
- ],
2149
- outputs: [
2150
- {
2151
- name: "",
2152
- type: "uint256",
2153
- internalType: "uint256"
2154
- }
2155
- ],
2156
- stateMutability: "view"
2157
- },
2158
- {
2159
- type: "function",
2160
- name: "activePrice",
2161
- inputs: [
2162
- {
2163
- name: "_bToken",
2164
- type: "address",
2165
- internalType: "contract BToken"
2166
- }
2167
- ],
2168
- outputs: [
2169
- {
2170
- name: "",
2171
- type: "uint256",
2172
- internalType: "uint256"
2173
- }
2174
- ],
2175
- stateMutability: "view"
2176
- },
2177
- {
2178
- type: "function",
2179
- name: "blvPrice",
2180
- inputs: [
2181
- {
2182
- name: "_bToken",
2183
- type: "address",
2184
- internalType: "contract BToken"
2185
- }
2186
- ],
2187
- outputs: [
2188
- {
2189
- name: "",
2190
- type: "uint256",
2191
- internalType: "uint256"
2192
- }
2193
- ],
2194
- stateMutability: "view"
2195
- },
2196
- {
2197
- type: "function",
2198
- name: "claimableYield",
2199
- inputs: [
2200
- {
2201
- name: "_bToken",
2202
- type: "address",
2203
- internalType: "contract BToken"
2204
- }
2205
- ],
2206
- outputs: [
2207
- {
2208
- name: "",
2209
- type: "uint256",
2210
- internalType: "uint256"
2211
- }
2212
- ],
2213
- stateMutability: "view"
2214
- },
2215
- {
2216
- type: "function",
2217
- name: "convexityExp",
2218
- inputs: [
2219
- {
2220
- name: "_bToken",
2221
- type: "address",
2222
- internalType: "contract BToken"
2223
- }
2224
- ],
2225
- outputs: [
2226
- {
2227
- name: "",
2228
- type: "uint256",
2229
- internalType: "uint256"
2230
- }
2231
- ],
2232
- stateMutability: "view"
2233
- },
2234
- {
2235
- type: "function",
2236
- name: "creator",
2237
- inputs: [
2238
- {
2239
- name: "_bToken",
2240
- type: "address",
2241
- internalType: "contract BToken"
2242
- }
2243
- ],
2244
- outputs: [
2245
- {
2246
- name: "",
2247
- type: "address",
2248
- internalType: "address"
2249
- }
2250
- ],
2251
- stateMutability: "view"
2252
- },
2253
- {
2254
- type: "function",
2255
- name: "creatorClaimable",
2256
- inputs: [
2257
- {
2258
- name: "_bToken",
2259
- type: "address",
2260
- internalType: "contract BToken"
2261
- }
2262
- ],
2263
- outputs: [
2264
- {
2265
- name: "",
2266
- type: "uint256",
2267
- internalType: "uint256"
2268
- }
2269
- ],
2270
- stateMutability: "view"
2271
- },
2272
- {
2273
- type: "function",
2274
- name: "creatorFeePct",
2275
- inputs: [
2276
- {
2277
- name: "_bToken",
2278
- type: "address",
2279
- internalType: "contract BToken"
2280
- }
2281
- ],
2282
- outputs: [
2283
- {
2284
- name: "",
2285
- type: "uint256",
2286
- internalType: "uint256"
2287
- }
2288
- ],
2289
- stateMutability: "view"
2290
- },
2291
- {
2292
- type: "function",
2293
- name: "creditAccount",
2294
- inputs: [
2295
- {
2296
- name: "_bToken",
2297
- type: "address",
2298
- internalType: "contract BToken"
2299
- },
2300
- {
2301
- name: "_user",
2302
- type: "address",
2303
- internalType: "address"
2304
- }
2305
- ],
2306
- outputs: [
2307
- {
2308
- name: "",
2309
- type: "uint256",
2310
- internalType: "uint256"
2311
- },
2312
- {
2313
- name: "",
2314
- type: "uint256",
2315
- internalType: "uint256"
2316
- }
2317
- ],
2318
- stateMutability: "view"
2319
- },
2320
- {
2321
- type: "function",
2322
- name: "defaultLiquidityFeePct",
2323
- inputs: [],
2324
- outputs: [
2325
- {
2326
- name: "",
2327
- type: "uint256",
2328
- internalType: "uint256"
2329
- }
2330
- ],
2331
- stateMutability: "view"
2332
- },
2333
- {
2334
- type: "function",
2335
- name: "defaultProtocolFeePct",
2336
- inputs: [],
2337
- outputs: [
2338
- {
2339
- name: "",
2340
- type: "uint256",
2341
- internalType: "uint256"
2342
- }
2343
- ],
2344
- stateMutability: "view"
2345
- },
2346
- {
2347
- type: "function",
2348
- name: "deployerProfile",
2349
- inputs: [
2350
- {
2351
- name: "_user",
2352
- type: "address",
2353
- internalType: "address"
2354
- }
2355
- ],
2356
- outputs: [
2357
- {
2358
- name: "",
2359
- type: "tuple",
2360
- internalType: "struct State.DeployerProfile",
2361
- components: [
2362
- {
2363
- name: "active",
2364
- type: "bool",
2365
- internalType: "bool"
2366
- },
2367
- {
2368
- name: "approvedCreditDeployer",
2369
- type: "bool",
2370
- internalType: "bool"
2371
- },
2372
- {
2373
- name: "pauser",
2374
- type: "bool",
2375
- internalType: "bool"
2376
- },
2377
- {
2378
- name: "protocolFeePct",
2379
- type: "uint64",
2380
- internalType: "uint64"
2381
- },
2382
- {
2383
- name: "liquidityFeePct",
2384
- type: "uint64",
2385
- internalType: "uint64"
2386
- }
2387
- ]
2388
- }
2389
- ],
2390
- stateMutability: "view"
2391
- },
2392
- {
2393
- type: "function",
2394
- name: "getBookPrice",
2395
- inputs: [
2396
- {
2397
- name: "_bToken",
2398
- type: "address",
2399
- internalType: "contract BToken"
2400
- }
2401
- ],
2402
- outputs: [
2403
- {
2404
- name: "",
2405
- type: "uint256",
2406
- internalType: "uint256"
2407
- }
2408
- ],
2409
- stateMutability: "view"
2410
- },
2411
- {
2412
- type: "function",
2413
- name: "getCirculatingSupply",
2414
- inputs: [
2415
- {
2416
- name: "_bToken",
2417
- type: "address",
2418
- internalType: "contract BToken"
2419
- }
2420
- ],
2421
- outputs: [
2422
- {
2423
- name: "",
2424
- type: "uint256",
2425
- internalType: "uint256"
2426
- }
2427
- ],
2428
- stateMutability: "view"
2429
- },
2430
- {
2431
- type: "function",
2432
- name: "getComponents",
2433
- inputs: [],
2434
- outputs: [
2435
- {
2436
- name: "components_",
2437
- type: "address[]",
2438
- internalType: "contract Component[]"
2439
- }
2440
- ],
2441
- stateMutability: "view"
2442
- },
2443
- {
2444
- type: "function",
2445
- name: "getMaker",
2446
- inputs: [
2447
- {
2448
- name: "_bToken",
2449
- type: "address",
2450
- internalType: "contract BToken"
2451
- }
2452
- ],
2453
- outputs: [
2454
- {
2455
- name: "",
2456
- type: "tuple",
2457
- internalType: "struct State.Maker",
2458
- components: [
2459
- {
2460
- name: "initialized",
2461
- type: "bool",
2462
- internalType: "bool"
2463
- },
2464
- {
2465
- name: "blvPrice",
2466
- type: "uint128",
2467
- internalType: "uint128"
2468
- },
2469
- {
2470
- name: "swapFee",
2471
- type: "uint128",
2472
- internalType: "uint128"
2473
- },
2474
- {
2475
- name: "maxCirc",
2476
- type: "uint128",
2477
- internalType: "uint128"
2478
- },
2479
- {
2480
- name: "maxReserves",
2481
- type: "uint128",
2482
- internalType: "uint128"
2483
- },
2484
- {
2485
- name: "convexityExp",
2486
- type: "uint128",
2487
- internalType: "uint128"
2488
- },
2489
- {
2490
- name: "lastInvariant",
2491
- type: "uint256",
2492
- internalType: "uint256"
2493
- }
2494
- ]
2495
- }
2496
- ],
2497
- stateMutability: "view"
2498
- },
2499
- {
2500
- type: "function",
2501
- name: "getQuoteState",
2502
- inputs: [
2503
- {
2504
- name: "_bToken",
2505
- type: "address",
2506
- internalType: "contract BToken"
2507
- }
2508
- ],
2509
- outputs: [
2510
- {
2511
- name: "state_",
2512
- type: "tuple",
2513
- internalType: "struct BLens.QuoteState",
2514
- components: [
2515
- {
2516
- name: "snapshotCurveParams",
2517
- type: "tuple",
2518
- internalType: "struct CurveParams",
2519
- components: [
2520
- {
2521
- name: "BLV",
2522
- type: "uint256",
2523
- internalType: "uint256"
2524
- },
2525
- {
2526
- name: "circ",
2527
- type: "uint256",
2528
- internalType: "uint256"
2529
- },
2530
- {
2531
- name: "supply",
2532
- type: "uint256",
2533
- internalType: "uint256"
2534
- },
2535
- {
2536
- name: "swapFee",
2537
- type: "uint256",
2538
- internalType: "uint256"
2539
- },
2540
- {
2541
- name: "reserves",
2542
- type: "uint256",
2543
- internalType: "uint256"
2544
- },
2545
- {
2546
- name: "totalSupply",
2547
- type: "uint256",
2548
- internalType: "uint256"
2549
- },
2550
- {
2551
- name: "convexityExp",
2552
- type: "uint256",
2553
- internalType: "uint256"
2554
- },
2555
- {
2556
- name: "lastInvariant",
2557
- type: "uint256",
2558
- internalType: "uint256"
2559
- }
2560
- ]
2561
- },
2562
- {
2563
- name: "quoteBlockBuyDeltaCirc",
2564
- type: "uint256",
2565
- internalType: "uint256"
2566
- },
2567
- {
2568
- name: "quoteBlockSellDeltaCirc",
2569
- type: "uint256",
2570
- internalType: "uint256"
2571
- },
2572
- {
2573
- name: "totalSupply",
2574
- type: "uint256",
2575
- internalType: "uint256"
2576
- },
2577
- {
2578
- name: "totalBTokens",
2579
- type: "uint256",
2580
- internalType: "uint256"
2581
- },
2582
- {
2583
- name: "totalReserves",
2584
- type: "uint256",
2585
- internalType: "uint256"
2586
- },
2587
- {
2588
- name: "reserveDecimals",
2589
- type: "uint8",
2590
- internalType: "uint8"
2591
- },
2592
- {
2593
- name: "liquidityFeePct",
2594
- type: "uint256",
2595
- internalType: "uint256"
2596
- },
2597
- {
2598
- name: "pendingSurplus",
2599
- type: "uint256",
2600
- internalType: "uint256"
2601
- },
2602
- {
2603
- name: "shouldSettlePendingSurplus",
2604
- type: "bool",
2605
- internalType: "bool"
2606
- },
2607
- {
2608
- name: "maxSellDelta",
2609
- type: "uint256",
2610
- internalType: "uint256"
2611
- },
2612
- {
2613
- name: "snapshotActivePrice",
2614
- type: "uint256",
2615
- internalType: "uint256"
2616
- }
2617
- ]
2618
- }
2619
- ],
2620
- stateMutability: "view"
2621
- },
2622
- {
2623
- type: "function",
2624
- name: "hasHook",
2625
- inputs: [
2626
- {
2627
- name: "_bToken",
2628
- type: "address",
2629
- internalType: "contract BToken"
2630
- }
2631
- ],
2632
- outputs: [
2633
- {
2634
- name: "",
2635
- type: "bool",
2636
- internalType: "bool"
2637
- }
2638
- ],
2639
- stateMutability: "view"
2640
- },
2641
- {
2642
- type: "function",
2643
- name: "isApprovedCreditDeployer",
2644
- inputs: [
2645
- {
2646
- name: "_user",
2647
- type: "address",
2648
- internalType: "address"
2649
- }
2650
- ],
2651
- outputs: [
2652
- {
2653
- name: "",
2654
- type: "bool",
2655
- internalType: "bool"
2656
- }
2657
- ],
2658
- stateMutability: "view"
2659
- },
2660
- {
2661
- type: "function",
2662
- name: "isLocked",
2663
- inputs: [],
2664
- outputs: [
2665
- {
2666
- name: "",
2667
- type: "bool",
2668
- internalType: "bool"
2669
- }
2670
- ],
2671
- stateMutability: "view"
2672
- },
2673
- {
2674
- type: "function",
2675
- name: "isPoolPaused",
2676
- inputs: [
2677
- {
2678
- name: "_bToken",
2679
- type: "address",
2680
- internalType: "contract BToken"
2681
- }
2682
- ],
2683
- outputs: [
2684
- {
2685
- name: "",
2686
- type: "bool",
2687
- internalType: "bool"
2688
- }
2689
- ],
2690
- stateMutability: "view"
2691
- },
2692
- {
2693
- type: "function",
2694
- name: "isProtocolPaused",
2695
- inputs: [],
2696
- outputs: [
2697
- {
2698
- name: "",
2699
- type: "bool",
2700
- internalType: "bool"
2701
- }
2702
- ],
2703
- stateMutability: "view"
2704
- },
2705
- {
2706
- type: "function",
2707
- name: "lastInvariant",
2708
- inputs: [
2709
- {
2710
- name: "_bToken",
2711
- type: "address",
2712
- internalType: "contract BToken"
2713
- }
2714
- ],
2715
- outputs: [
2716
- {
2717
- name: "",
2718
- type: "uint256",
2719
- internalType: "uint256"
2720
- }
2721
- ],
2722
- stateMutability: "view"
2723
- },
2724
- {
2725
- type: "function",
2726
- name: "lastUpdatedTimestamp",
2727
- inputs: [
2728
- {
2729
- name: "_bToken",
2730
- type: "address",
2731
- internalType: "contract BToken"
2732
- }
2733
- ],
2734
- outputs: [
2735
- {
2736
- name: "",
2737
- type: "uint256",
2738
- internalType: "uint256"
2739
- }
2740
- ],
2741
- stateMutability: "view"
2742
- },
2743
- {
2744
- type: "function",
2745
- name: "liquidityFeePct",
2746
- inputs: [
2747
- {
2748
- name: "_bToken",
2749
- type: "address",
2750
- internalType: "contract BToken"
2751
- }
2752
- ],
2753
- outputs: [
2754
- {
2755
- name: "",
2756
- type: "uint256",
2757
- internalType: "uint256"
2758
- }
2759
- ],
2760
- stateMutability: "view"
2761
- },
2762
- {
2763
- type: "function",
2764
- name: "originationFee",
2765
- inputs: [],
2766
- outputs: [
2767
- {
2768
- name: "",
2769
- type: "uint256",
2770
- internalType: "uint256"
2771
- }
2772
- ],
2773
- stateMutability: "view"
2774
- },
2775
- {
2776
- type: "function",
2777
- name: "pendingSurplus",
2778
- inputs: [
2779
- {
2780
- name: "_bToken",
2781
- type: "address",
2782
- internalType: "contract BToken"
2783
- }
2784
- ],
2785
- outputs: [
2786
- {
2787
- name: "",
2788
- type: "uint256",
2789
- internalType: "uint256"
2790
- }
2791
- ],
2792
- stateMutability: "view"
2793
- },
2794
- {
2795
- type: "function",
2796
- name: "pendingYield",
2797
- inputs: [
2798
- {
2799
- name: "_bToken",
2800
- type: "address",
2801
- internalType: "contract BToken"
2802
- }
2803
- ],
2804
- outputs: [
2805
- {
2806
- name: "",
2807
- type: "uint256",
2808
- internalType: "uint256"
2809
- }
2810
- ],
2811
- stateMutability: "view"
2812
- },
2813
- {
2814
- type: "function",
2815
- name: "poolFeeRecipient",
2816
- inputs: [
2817
- {
2818
- name: "_bToken",
2819
- type: "address",
2820
- internalType: "contract BToken"
2821
- }
2822
- ],
2823
- outputs: [
2824
- {
2825
- name: "",
2826
- type: "address",
2827
- internalType: "address"
2828
- }
2829
- ],
2830
- stateMutability: "view"
2831
- },
2832
- {
2833
- type: "function",
2834
- name: "poolFeeShare",
2835
- inputs: [
2836
- {
2837
- name: "_bToken",
2838
- type: "address",
2839
- internalType: "contract BToken"
2840
- }
2841
- ],
2842
- outputs: [
2843
- {
2844
- name: "creator_",
2845
- type: "uint256",
2846
- internalType: "uint256"
2847
- },
2848
- {
2849
- name: "staking_",
2850
- type: "uint256",
2851
- internalType: "uint256"
2852
- }
2853
- ],
2854
- stateMutability: "view"
2855
- },
2856
- {
2857
- type: "function",
2858
- name: "poolIdToBToken",
2859
- inputs: [
2860
- {
2861
- name: "_poolId",
2862
- type: "bytes32",
2863
- internalType: "PoolId"
2864
- }
2865
- ],
2866
- outputs: [
2867
- {
2868
- name: "",
2869
- type: "address",
2870
- internalType: "contract BToken"
2871
- }
2872
- ],
2873
- stateMutability: "view"
2874
- },
2875
- {
2876
- type: "function",
2877
- name: "poolKey",
2878
- inputs: [
2879
- {
2880
- name: "_bToken",
2881
- type: "address",
2882
- internalType: "contract BToken"
2883
- }
2884
- ],
2885
- outputs: [
2886
- {
2887
- name: "",
2888
- type: "tuple",
2889
- internalType: "struct PoolKey",
2890
- components: [
2891
- {
2892
- name: "currency0",
2893
- type: "address",
2894
- internalType: "Currency"
2895
- },
2896
- {
2897
- name: "currency1",
2898
- type: "address",
2899
- internalType: "Currency"
2900
- },
2901
- {
2902
- name: "fee",
2903
- type: "uint24",
2904
- internalType: "uint24"
2905
- },
2906
- {
2907
- name: "tickSpacing",
2908
- type: "int24",
2909
- internalType: "int24"
2910
- },
2911
- {
2912
- name: "hooks",
2913
- type: "address",
2914
- internalType: "contract IHooks"
2915
- }
2916
- ]
2917
- }
2918
- ],
2919
- stateMutability: "view"
2920
- },
2921
- {
2922
- type: "function",
2923
- name: "protocolClaimable",
2924
- inputs: [
2925
- {
2926
- name: "_bToken",
2927
- type: "address",
2928
- internalType: "contract BToken"
2929
- }
2930
- ],
2931
- outputs: [
2932
- {
2933
- name: "",
2934
- type: "uint256",
2935
- internalType: "uint256"
2936
- }
2937
- ],
2938
- stateMutability: "view"
2939
- },
2940
- {
2941
- type: "function",
2942
- name: "protocolFeePct",
2943
- inputs: [
2944
- {
2945
- name: "_bToken",
2946
- type: "address",
2947
- internalType: "contract BToken"
2948
- }
2949
- ],
2950
- outputs: [
2951
- {
2952
- name: "",
2953
- type: "uint256",
2954
- internalType: "uint256"
2955
- }
2956
- ],
2957
- stateMutability: "view"
2958
- },
2959
- {
2960
- type: "function",
2961
- name: "protocolFeeRecipient",
2962
- inputs: [],
2963
- outputs: [
2964
- {
2965
- name: "",
2966
- type: "address",
2967
- internalType: "address"
2968
- }
2969
- ],
2970
- stateMutability: "view"
2971
- },
2972
- {
2973
- type: "function",
2974
- name: "quoteLeverage",
2975
- inputs: [
2976
- {
2977
- name: "_bToken",
2978
- type: "address",
2979
- internalType: "contract BToken"
2980
- },
2981
- {
2982
- name: "_collateralIn",
2983
- type: "uint256",
2984
- internalType: "uint256"
2985
- },
2986
- {
2987
- name: "_leverageFactor",
2988
- type: "uint256",
2989
- internalType: "uint256"
2990
- }
2991
- ],
2992
- outputs: [
2993
- {
2994
- name: "targetCollateral_",
2995
- type: "uint256",
2996
- internalType: "uint256"
2997
- },
2998
- {
2999
- name: "maxSwapReservesIn_",
3000
- type: "uint256",
3001
- internalType: "uint256"
3002
- },
3003
- {
3004
- name: "expectedDebt_",
3005
- type: "uint256",
3006
- internalType: "uint256"
3007
- },
3008
- {
3009
- name: "slippage_",
3010
- type: "uint256",
3011
- internalType: "uint256"
3012
- }
3013
- ],
3014
- stateMutability: "view"
3015
- },
3016
- {
3017
- type: "function",
3018
- name: "reserve",
3019
- inputs: [
3020
- {
3021
- name: "_bToken",
3022
- type: "address",
3023
- internalType: "contract BToken"
3024
- }
3025
- ],
3026
- outputs: [
3027
- {
3028
- name: "",
3029
- type: "address",
3030
- internalType: "contract ERC20"
3031
- }
3032
- ],
3033
- stateMutability: "view"
3034
- },
3035
- {
3036
- type: "function",
3037
- name: "reserveHoldings",
3038
- inputs: [
3039
- {
3040
- name: "_reserve",
3041
- type: "address",
3042
- internalType: "contract ERC20"
3043
- }
3044
- ],
3045
- outputs: [
3046
- {
3047
- name: "",
3048
- type: "uint256",
3049
- internalType: "uint256"
3050
- }
3051
- ],
3052
- stateMutability: "view"
3053
- },
3054
- {
3055
- type: "function",
3056
- name: "settledReserves",
3057
- inputs: [
3058
- {
3059
- name: "_bToken",
3060
- type: "address",
3061
- internalType: "contract BToken"
3062
- }
3063
- ],
3064
- outputs: [
3065
- {
3066
- name: "",
3067
- type: "uint256",
3068
- internalType: "uint256"
3069
- }
3070
- ],
3071
- stateMutability: "view"
3072
- },
3073
- {
3074
- type: "function",
3075
- name: "stakedPosition",
3076
- inputs: [
3077
- {
3078
- name: "_bToken",
3079
- type: "address",
3080
- internalType: "contract BToken"
3081
- },
3082
- {
3083
- name: "_user",
3084
- type: "address",
3085
- internalType: "address"
3086
- }
3087
- ],
3088
- outputs: [
3089
- {
3090
- name: "",
3091
- type: "uint256",
3092
- internalType: "uint256"
3093
- },
3094
- {
3095
- name: "",
3096
- type: "uint256",
3097
- internalType: "uint256"
3098
- },
3099
- {
3100
- name: "",
3101
- type: "uint256",
3102
- internalType: "uint256"
3103
- },
3104
- {
3105
- name: "",
3106
- type: "uint256",
3107
- internalType: "uint256"
3108
- }
3109
- ],
3110
- stateMutability: "view"
3111
- },
3112
- {
3113
- type: "function",
3114
- name: "supportsInterface",
3115
- inputs: [
3116
- {
3117
- name: "_interfaceId",
3118
- type: "bytes4",
3119
- internalType: "bytes4"
3120
- }
3121
- ],
3122
- outputs: [
3123
- {
3124
- name: "",
3125
- type: "bool",
3126
- internalType: "bool"
3127
- }
3128
- ],
3129
- stateMutability: "pure"
3130
- },
3131
- {
3132
- type: "function",
3133
- name: "swapFee",
3134
- inputs: [
3135
- {
3136
- name: "_bToken",
3137
- type: "address",
3138
- internalType: "contract BToken"
3139
- }
3140
- ],
3141
- outputs: [
3142
- {
3143
- name: "",
3144
- type: "uint256",
3145
- internalType: "uint256"
3146
- }
3147
- ],
3148
- stateMutability: "view"
3149
- },
3150
- {
3151
- type: "function",
3152
- name: "timeToAdapt",
3153
- inputs: [],
3154
- outputs: [
3155
- {
3156
- name: "",
3157
- type: "uint256",
3158
- internalType: "uint256"
3159
- }
3160
- ],
3161
- stateMutability: "view"
3162
- },
3163
- {
3164
- type: "function",
3165
- name: "timeToDistribute",
3166
- inputs: [],
3167
- outputs: [
3168
- {
3169
- name: "",
3170
- type: "uint256",
3171
- internalType: "uint256"
3172
- }
3173
- ],
3174
- stateMutability: "view"
3175
- },
3176
- {
3177
- type: "function",
3178
- name: "tokensPerSecond",
3179
- inputs: [
3180
- {
3181
- name: "_bToken",
3182
- type: "address",
3183
- internalType: "contract BToken"
3184
- }
3185
- ],
3186
- outputs: [
3187
- {
3188
- name: "",
3189
- type: "uint256",
3190
- internalType: "uint256"
3191
- }
3192
- ],
3193
- stateMutability: "view"
3194
- },
3195
- {
3196
- type: "function",
3197
- name: "totalBTokens",
3198
- inputs: [
3199
- {
3200
- name: "_bToken",
3201
- type: "address",
3202
- internalType: "contract BToken"
3203
- }
3204
- ],
3205
- outputs: [
3206
- {
3207
- name: "",
3208
- type: "uint256",
3209
- internalType: "uint256"
3210
- }
3211
- ],
3212
- stateMutability: "view"
3213
- },
3214
- {
3215
- type: "function",
3216
- name: "totalCollateral",
3217
- inputs: [
3218
- {
3219
- name: "_bToken",
3220
- type: "address",
3221
- internalType: "contract BToken"
3222
- }
3223
- ],
3224
- outputs: [
3225
- {
3226
- name: "",
3227
- type: "uint256",
3228
- internalType: "uint256"
3229
- }
3230
- ],
3231
- stateMutability: "view"
3232
- },
3233
- {
3234
- type: "function",
3235
- name: "totalDebt",
3236
- inputs: [
3237
- {
3238
- name: "_bToken",
3239
- type: "address",
3240
- internalType: "contract BToken"
3241
- }
3242
- ],
3243
- outputs: [
3244
- {
3245
- name: "",
3246
- type: "uint256",
3247
- internalType: "uint256"
3248
- }
3249
- ],
3250
- stateMutability: "view"
3251
- },
3252
- {
3253
- type: "function",
3254
- name: "totalFeeShare",
3255
- inputs: [
3256
- {
3257
- name: "_bToken",
3258
- type: "address",
3259
- internalType: "contract BToken"
3260
- }
3261
- ],
3262
- outputs: [
3263
- {
3264
- name: "creator_",
3265
- type: "uint256",
3266
- internalType: "uint256"
3267
- },
3268
- {
3269
- name: "staking_",
3270
- type: "uint256",
3271
- internalType: "uint256"
3272
- },
3273
- {
3274
- name: "protocol_",
3275
- type: "uint256",
3276
- internalType: "uint256"
3277
- }
3278
- ],
3279
- stateMutability: "view"
3280
- },
3281
- {
3282
- type: "function",
3283
- name: "totalReserves",
3284
- inputs: [
3285
- {
3286
- name: "_bToken",
3287
- type: "address",
3288
- internalType: "contract BToken"
3289
- }
3290
- ],
3291
- outputs: [
3292
- {
3293
- name: "",
3294
- type: "uint256",
3295
- internalType: "uint256"
3296
- }
3297
- ],
3298
- stateMutability: "view"
3299
- },
3300
- {
3301
- type: "function",
3302
- name: "totalStaked",
3303
- inputs: [
3304
- {
3305
- name: "_bToken",
3306
- type: "address",
3307
- internalType: "contract BToken"
3308
- }
3309
- ],
3310
- outputs: [
3311
- {
3312
- name: "",
3313
- type: "uint256",
3314
- internalType: "uint256"
3315
- }
3316
- ],
3317
- stateMutability: "view"
3318
- },
3319
- {
3320
- type: "function",
3321
- name: "totalSupply",
3322
- inputs: [
3323
- {
3324
- name: "_bToken",
3325
- type: "address",
3326
- internalType: "contract BToken"
3327
- }
3328
- ],
3329
- outputs: [
3330
- {
3331
- name: "",
3332
- type: "uint256",
3333
- internalType: "uint256"
3334
- }
3335
- ],
3336
- stateMutability: "view"
3337
- },
3338
- {
3339
- type: "function",
3340
- name: "withdrawable",
3341
- inputs: [
3342
- {
3343
- name: "_bToken",
3344
- type: "address",
3345
- internalType: "contract BToken"
3346
- },
3347
- {
3348
- name: "_user",
3349
- type: "address",
3350
- internalType: "address"
3351
- }
3352
- ],
3353
- outputs: [
3354
- {
3355
- name: "",
3356
- type: "uint256",
3357
- internalType: "uint256"
3358
- }
3359
- ],
3360
- stateMutability: "view"
1553
+ type: "error",
1554
+ name: "GuardLib_Paused",
1555
+ inputs: []
3361
1556
  },
3362
1557
  {
3363
1558
  type: "error",
3364
- name: "BLens_InvalidLeverageFactor",
1559
+ name: "GuardLib_Reentrant",
3365
1560
  inputs: []
3366
1561
  },
3367
1562
  {
3368
1563
  type: "error",
3369
- name: "Component_NotPermitted",
1564
+ name: "GuardLib_ReserveAccountingMismatch",
3370
1565
  inputs: []
3371
1566
  },
3372
1567
  {
3373
1568
  type: "error",
3374
- name: "InvalidConvexityExp",
1569
+ name: "NativeLib_AmountMismatch",
3375
1570
  inputs: []
3376
1571
  },
3377
1572
  {
3378
1573
  type: "error",
3379
- name: "InvariantDecreased",
3380
- inputs: [
3381
- {
3382
- name: "prevInvariant",
3383
- type: "uint256",
3384
- internalType: "uint256"
3385
- },
3386
- {
3387
- name: "newInvariant",
3388
- type: "uint256",
3389
- internalType: "uint256"
3390
- }
3391
- ]
1574
+ name: "NativeLib_NotWrapped",
1575
+ inputs: []
3392
1576
  }
3393
1577
  ];
3394
1578
 
1579
+ // ../contracts/abis/mercury/bFactory.ts
1580
+ 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": [] }];
1581
+
1582
+ // ../contracts/abis/mercury/bLens.ts
1583
+ 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" }] }];
1584
+
3395
1585
  // ../contracts/abis/mercury/bStaking.ts
3396
1586
  var bStaking = [
3397
1587
  {
@@ -4557,6 +2747,8 @@ var externalAbis = {
4557
2747
  [chains.base.id]: {
4558
2748
  },
4559
2749
  [chains.baseSepolia.id]: {
2750
+ },
2751
+ [chains.hyperEvm.id]: {
4560
2752
  }
4561
2753
  });
4562
2754
  ({
@@ -4565,6 +2757,8 @@ var externalAbis = {
4565
2757
  [chains.base.id]: {
4566
2758
  },
4567
2759
  [chains.baseSepolia.id]: {
2760
+ },
2761
+ [chains.hyperEvm.id]: {
4568
2762
  }
4569
2763
  });
4570
2764
  var relayAddress = "0xc81Fd894C0acE037d133aF4886550aC8133568E8";
@@ -4580,6 +2774,10 @@ var addressBook_default = {
4580
2774
  [chains.baseSepolia.id]: {
4581
2775
  address: relayAddress,
4582
2776
  block: 40585325
2777
+ },
2778
+ [chains.hyperEvm.id]: {
2779
+ address: relayAddress,
2780
+ block: 37892152
4583
2781
  }
4584
2782
  };
4585
2783
  var ContractFactory = class {
@@ -4651,6 +2849,427 @@ var ContractFactory = class {
4651
2849
 
4652
2850
  // ../contracts/index.ts
4653
2851
  var supportedChainIds = Object.keys(addressBook_default).map(Number);
2852
+
2853
+ // src/calls/index.ts
2854
+ var calls_exports = {};
2855
+ __export(calls_exports, {
2856
+ MAX_UINT256: () => MAX_UINT256,
2857
+ WAD: () => WAD,
2858
+ ZERO_BYTES32: () => ZERO_BYTES32,
2859
+ approvalCalls: () => approvalCalls,
2860
+ buildLaunchCalls: () => buildLaunchCalls,
2861
+ createCallsApi: () => createCallsApi,
2862
+ encodeStandardLaunchCalls: () => encodeStandardLaunchCalls,
2863
+ encodeZrpLaunchCalls: () => encodeZrpLaunchCalls,
2864
+ serializeCalls: () => serializeCalls,
2865
+ simulateCalls: () => simulateCalls,
2866
+ validateLaunchCallInput: () => validateLaunchCallInput
2867
+ });
2868
+
2869
+ // src/utils/native.ts
2870
+ function shouldUseNative(explicit, config) {
2871
+ return explicit ?? !!config?.defaultUseNative;
2872
+ }
2873
+ function valueForNative(useNative, amount) {
2874
+ return useNative ? amount : void 0;
2875
+ }
2876
+ async function simulateCalls(publicClient, calls, opts) {
2877
+ const simulation = await publicClient.simulateCalls({
2878
+ account: opts?.account,
2879
+ calls
2880
+ });
2881
+ if (simulation.results.length !== calls.length) {
2882
+ throw new Error(
2883
+ `Call simulation returned ${simulation.results.length} results for ${calls.length} calls`
2884
+ );
2885
+ }
2886
+ return simulation.results.map((result, index) => {
2887
+ if (!result) {
2888
+ throw new Error(`Call simulation ${index} did not return a result`);
2889
+ }
2890
+ if (result.status === "failure") throw result.error;
2891
+ const call = calls[index];
2892
+ if (!call?.decode) return result.data;
2893
+ return call.decode(result.data);
2894
+ });
2895
+ }
2896
+ function contractCall(input) {
2897
+ return {
2898
+ to: input.to,
2899
+ data: viem.encodeFunctionData({
2900
+ abi: input.abi,
2901
+ functionName: input.functionName,
2902
+ args: input.args
2903
+ }),
2904
+ value: input.value,
2905
+ decode: (data) => {
2906
+ const result = viem.decodeFunctionResult({
2907
+ abi: input.abi,
2908
+ functionName: input.functionName,
2909
+ data
2910
+ });
2911
+ return input.mapResult ? input.mapResult(result) : result;
2912
+ }
2913
+ };
2914
+ }
2915
+ function serializeCalls(calls) {
2916
+ return calls.map((call) => ({
2917
+ to: call.to,
2918
+ data: call.data,
2919
+ value: viem.toHex(call.value ?? 0n)
2920
+ }));
2921
+ }
2922
+ var WAD = 10n ** 18n;
2923
+ var ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
2924
+ var DEFAULT_SWAP_FEE_PCT = WAD / 100n;
2925
+ var MIN_SWAP_FEE_PCT = 1500000000000000n;
2926
+ var MAX_SWAP_FEE_PCT = WAD / 2n;
2927
+ var MIN_TOTAL_SUPPLY = 10000n * WAD;
2928
+ var MAX_TOTAL_SUPPLY = 20282409603651670423947251286015n;
2929
+ var MIN_INVARIANT = 3n * WAD;
2930
+ function encodeBaseLaunchCalls(input) {
2931
+ return [
2932
+ contractCall({
2933
+ to: input.relay,
2934
+ abi: mercuryAbis.bFactory,
2935
+ functionName: "createBToken",
2936
+ args: [input.name, input.symbol, input.totalSupply, input.salt]
2937
+ }),
2938
+ contractCall({
2939
+ to: input.bToken,
2940
+ abi: externalAbis.erc20,
2941
+ functionName: "approve",
2942
+ args: [input.relay, input.bTokenApprovalAmount]
2943
+ })
2944
+ ];
2945
+ }
2946
+ function encodeZrpLaunchCalls(input) {
2947
+ return [
2948
+ ...encodeBaseLaunchCalls({
2949
+ ...input,
2950
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2951
+ }),
2952
+ contractCall({
2953
+ to: input.relay,
2954
+ abi: mercuryAbis.bFactory,
2955
+ functionName: "createPoolFromInvariant",
2956
+ args: [input.params]
2957
+ })
2958
+ ];
2959
+ }
2960
+ function encodeStandardLaunchCalls(input) {
2961
+ return [
2962
+ ...encodeBaseLaunchCalls({
2963
+ ...input,
2964
+ bTokenApprovalAmount: input.params.initialPoolBTokens
2965
+ }),
2966
+ contractCall({
2967
+ to: input.reserve,
2968
+ abi: externalAbis.erc20,
2969
+ functionName: "approve",
2970
+ args: [input.relay, input.params.initialPoolReserves]
2971
+ }),
2972
+ contractCall({
2973
+ to: input.relay,
2974
+ abi: mercuryAbis.bFactory,
2975
+ functionName: "createPool",
2976
+ args: [input.params]
2977
+ })
2978
+ ];
2979
+ }
2980
+ function buildLaunchCalls(input) {
2981
+ const salt = normalizeSalt(input.salt);
2982
+ const { mode, swapFeePct, feeRecipient } = resolveLaunchDefaults(input);
2983
+ if (mode === "zrp") {
2984
+ const params2 = {
2985
+ bToken: input.bToken,
2986
+ initialPoolBTokens: input.initialPoolBTokens,
2987
+ reserve: input.reserve,
2988
+ initialInvariant: MIN_INVARIANT,
2989
+ creator: input.creator,
2990
+ feeRecipient,
2991
+ creatorFeePct: input.creatorFeePct,
2992
+ swapFeePct,
2993
+ createHook: true
2994
+ };
2995
+ return encodeZrpLaunchCalls({
2996
+ relay: input.relay,
2997
+ bToken: input.bToken,
2998
+ name: input.name,
2999
+ symbol: input.symbol,
3000
+ totalSupply: input.totalSupply,
3001
+ salt,
3002
+ params: params2
3003
+ });
3004
+ }
3005
+ const initialPoolReserves = input.initialPoolReserves ?? 0n;
3006
+ const circulatingSupply = input.totalSupply - input.initialPoolBTokens;
3007
+ const reservesWad = toWad(initialPoolReserves, input.reserveDecimals ?? 18);
3008
+ const circulatingWad = toWad(circulatingSupply, 18);
3009
+ const bookPrice = divWad(reservesWad, circulatingWad);
3010
+ const params = {
3011
+ bToken: input.bToken,
3012
+ initialPoolBTokens: input.initialPoolBTokens,
3013
+ reserve: input.reserve,
3014
+ initialPoolReserves,
3015
+ initialActivePrice: bookPrice + 1n,
3016
+ initialBLV: 0n,
3017
+ creator: input.creator,
3018
+ feeRecipient,
3019
+ creatorFeePct: input.creatorFeePct,
3020
+ swapFeePct,
3021
+ createHook: true,
3022
+ claimMerkleRoot: ZERO_BYTES32,
3023
+ initialCollateral: 0n,
3024
+ initialDebt: 0n
3025
+ };
3026
+ return encodeStandardLaunchCalls({
3027
+ relay: input.relay,
3028
+ bToken: input.bToken,
3029
+ reserve: input.reserve,
3030
+ name: input.name,
3031
+ symbol: input.symbol,
3032
+ totalSupply: input.totalSupply,
3033
+ salt,
3034
+ params
3035
+ });
3036
+ }
3037
+ function validateLaunchCallInput(input) {
3038
+ normalizeSalt(input.salt);
3039
+ resolveLaunchDefaults(input);
3040
+ }
3041
+ function normalizeSalt(salt) {
3042
+ if (!salt) return ZERO_BYTES32;
3043
+ if (!/^0x[a-fA-F0-9]{64}$/.test(salt)) {
3044
+ throw new Error("salt must be a bytes32 hex string");
3045
+ }
3046
+ return salt;
3047
+ }
3048
+ function resolveLaunchDefaults(input) {
3049
+ const mode = input.mode ?? "zrp";
3050
+ if (mode !== "zrp" && mode !== "standard") {
3051
+ throw new Error("mode must be zrp or standard");
3052
+ }
3053
+ validateTokenText(input.name, input.symbol);
3054
+ validateAddress(input.relay, "relay");
3055
+ validateAddress(input.bToken, "bToken");
3056
+ validateAddress(input.reserve, "reserve");
3057
+ validateAddress(input.creator, "creator");
3058
+ validateDecimals(input.reserveDecimals ?? 18, "reserveDecimals");
3059
+ const feeRecipient = input.feeRecipient ?? input.creator;
3060
+ validateAddress(feeRecipient, "feeRecipient");
3061
+ if (input.totalSupply < MIN_TOTAL_SUPPLY) {
3062
+ throw new Error("totalSupply is below the protocol minimum");
3063
+ }
3064
+ if (input.totalSupply > MAX_TOTAL_SUPPLY) {
3065
+ throw new Error("totalSupply exceeds the protocol maximum");
3066
+ }
3067
+ if (input.initialPoolBTokens <= 0n) {
3068
+ throw new Error("initialPoolBTokens must be greater than zero");
3069
+ }
3070
+ if (input.initialPoolBTokens > input.totalSupply) {
3071
+ throw new Error("initialPoolBTokens cannot exceed totalSupply");
3072
+ }
3073
+ const swapFeePct = input.swapFeePct ?? DEFAULT_SWAP_FEE_PCT;
3074
+ if (swapFeePct < MIN_SWAP_FEE_PCT || swapFeePct > MAX_SWAP_FEE_PCT) {
3075
+ throw new Error("swapFeePct is outside protocol bounds");
3076
+ }
3077
+ if (input.creatorFeePct < 0n || input.creatorFeePct > WAD) {
3078
+ throw new Error("creatorFeePct must be between 0 and 1e18");
3079
+ }
3080
+ if (mode === "zrp") {
3081
+ if (input.initialPoolBTokens !== input.totalSupply) {
3082
+ throw new Error("zrp launches require all BTokens in the pool");
3083
+ }
3084
+ if ((input.initialPoolReserves ?? 0n) !== 0n) {
3085
+ throw new Error("zrp launches require zero initial reserves");
3086
+ }
3087
+ } else {
3088
+ if ((input.initialPoolReserves ?? 0n) <= 0n) {
3089
+ throw new Error("standard launches require initialPoolReserves");
3090
+ }
3091
+ if (input.initialPoolBTokens >= input.totalSupply) {
3092
+ throw new Error("standard launches require circulating supply");
3093
+ }
3094
+ }
3095
+ return { mode, swapFeePct, feeRecipient };
3096
+ }
3097
+ function validateAddress(address, label) {
3098
+ if (!viem.isAddress(address)) throw new Error(`${label} must be a valid address`);
3099
+ }
3100
+ function validateTokenText(name, symbol) {
3101
+ if (name.trim().length === 0) throw new Error("name is required");
3102
+ if (symbol.trim().length === 0) throw new Error("symbol is required");
3103
+ if (new TextEncoder().encode(name).length > 30) {
3104
+ throw new Error("name exceeds 30 bytes");
3105
+ }
3106
+ if (new TextEncoder().encode(symbol).length > 30) {
3107
+ throw new Error("symbol exceeds 30 bytes");
3108
+ }
3109
+ }
3110
+ function validateDecimals(decimals, label) {
3111
+ if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18) {
3112
+ throw new Error(`${label} must be an integer between 0 and 18`);
3113
+ }
3114
+ }
3115
+ function toWad(amount, decimals) {
3116
+ return amount * 10n ** BigInt(18 - decimals);
3117
+ }
3118
+ function divWad(numerator, denominator) {
3119
+ return numerator * WAD / denominator;
3120
+ }
3121
+
3122
+ // src/calls/index.ts
3123
+ var MAX_UINT256 = 2n ** 256n - 1n;
3124
+ function createCallsApi(input) {
3125
+ const relay = () => input.getRelay();
3126
+ return {
3127
+ launch: input.launch,
3128
+ factory: {
3129
+ createBToken: (name, symbol, totalSupply, salt) => contractCall({
3130
+ to: relay(),
3131
+ abi: mercuryAbis.bFactory,
3132
+ functionName: "createBToken",
3133
+ args: [name, symbol, totalSupply, salt]
3134
+ }),
3135
+ createPool: (params) => contractCall({
3136
+ to: relay(),
3137
+ abi: mercuryAbis.bFactory,
3138
+ functionName: "createPool",
3139
+ args: [params]
3140
+ }),
3141
+ createPoolFromInvariant: (params) => contractCall({
3142
+ to: relay(),
3143
+ abi: mercuryAbis.bFactory,
3144
+ functionName: "createPoolFromInvariant",
3145
+ args: [params]
3146
+ })
3147
+ },
3148
+ swap: {
3149
+ buyTokensExactOut: (bToken, amountOut, limitAmount, opts) => contractCall({
3150
+ to: relay(),
3151
+ abi: mercuryAbis.bSwap,
3152
+ functionName: "buyTokensExactOut",
3153
+ args: [bToken, amountOut, limitAmount],
3154
+ value: valueForNative(
3155
+ shouldUseNative(opts?.useNative, input.getConfig()),
3156
+ limitAmount
3157
+ )
3158
+ }),
3159
+ buyTokensExactIn: (bToken, amountIn, limitAmount) => contractCall({
3160
+ to: relay(),
3161
+ abi: mercuryAbis.bSwap,
3162
+ functionName: "buyTokensExactIn",
3163
+ args: [bToken, amountIn, limitAmount]
3164
+ }),
3165
+ sellTokensExactIn: (bToken, amountIn, limitAmount) => contractCall({
3166
+ to: relay(),
3167
+ abi: mercuryAbis.bSwap,
3168
+ functionName: "sellTokensExactIn",
3169
+ args: [bToken, amountIn, limitAmount]
3170
+ }),
3171
+ sellTokensExactOut: (bToken, amountOut, limitAmount) => contractCall({
3172
+ to: relay(),
3173
+ abi: mercuryAbis.bSwap,
3174
+ functionName: "sellTokensExactOut",
3175
+ args: [bToken, amountOut, limitAmount]
3176
+ })
3177
+ },
3178
+ staking: {
3179
+ deposit: (bToken, user, amount) => contractCall({
3180
+ to: relay(),
3181
+ abi: mercuryAbis.bStaking,
3182
+ functionName: "deposit",
3183
+ args: [bToken, user, amount]
3184
+ }),
3185
+ withdraw: (bToken, amount) => contractCall({
3186
+ to: relay(),
3187
+ abi: mercuryAbis.bStaking,
3188
+ functionName: "withdraw",
3189
+ args: [bToken, amount]
3190
+ }),
3191
+ claim: (bToken, user, asNative = false) => contractCall({
3192
+ to: relay(),
3193
+ abi: mercuryAbis.bStaking,
3194
+ functionName: "claim",
3195
+ args: [bToken, user, asNative]
3196
+ })
3197
+ },
3198
+ credit: {
3199
+ borrow: (bToken, amount, recipient, opts) => contractCall({
3200
+ to: relay(),
3201
+ abi: mercuryAbis.bCredit,
3202
+ functionName: opts?.outputNative ? "borrowNative" : "borrow",
3203
+ args: [bToken, amount, recipient]
3204
+ }),
3205
+ repay: (bToken, reservesIn, recipient, opts) => {
3206
+ const useNative = shouldUseNative(opts?.useNative, input.getConfig());
3207
+ return contractCall({
3208
+ to: relay(),
3209
+ abi: mercuryAbis.bCredit,
3210
+ functionName: useNative ? "repayWithNative" : "repay",
3211
+ args: useNative ? [bToken, recipient] : [bToken, reservesIn, recipient],
3212
+ value: useNative ? reservesIn : void 0
3213
+ });
3214
+ },
3215
+ leverage: (bToken, totalCollateral, collateralIn, maxSwapReservesIn) => contractCall({
3216
+ to: relay(),
3217
+ abi: mercuryAbis.bCredit,
3218
+ functionName: "leverage",
3219
+ args: [bToken, totalCollateral, collateralIn, maxSwapReservesIn]
3220
+ }),
3221
+ deleverage: (bToken, collateralToSell, minSwapReservesOut) => contractCall({
3222
+ to: relay(),
3223
+ abi: mercuryAbis.bCredit,
3224
+ functionName: "deleverage",
3225
+ args: [bToken, collateralToSell, minSwapReservesOut],
3226
+ mapResult: ([collateralRedeemed, debtRepaid, refund]) => ({
3227
+ collateralRedeemed,
3228
+ debtRepaid,
3229
+ refund
3230
+ })
3231
+ })
3232
+ },
3233
+ approval: {
3234
+ approve: (token, spender, amount) => contractCall({
3235
+ to: token,
3236
+ abi: externalAbis.erc20,
3237
+ functionName: "approve",
3238
+ args: [spender, amount]
3239
+ }),
3240
+ ensure: async (token, spender, required, opts) => {
3241
+ const owner = opts?.owner ?? input.getAccount();
3242
+ const policy = opts?.policy ?? input.getConfig()?.approvals ?? "infinite";
3243
+ const currentAllowance = await input.getAllowance(
3244
+ token,
3245
+ owner,
3246
+ spender
3247
+ );
3248
+ return approvalCalls({
3249
+ token,
3250
+ spender,
3251
+ required,
3252
+ currentAllowance,
3253
+ policy
3254
+ });
3255
+ }
3256
+ }
3257
+ };
3258
+ }
3259
+ function approvalCalls(input) {
3260
+ if (input.currentAllowance >= input.required) return [];
3261
+ return [
3262
+ contractCall({
3263
+ to: input.token,
3264
+ abi: externalAbis.erc20,
3265
+ functionName: "approve",
3266
+ args: [
3267
+ input.spender,
3268
+ input.policy === "infinite" ? MAX_UINT256 : input.required
3269
+ ]
3270
+ })
3271
+ ];
3272
+ }
4654
3273
  var SDKError = class extends Error {
4655
3274
  kind = "unknown";
4656
3275
  component;
@@ -4743,6 +3362,17 @@ async function requireWallet(wallet) {
4743
3362
  });
4744
3363
  return wallet;
4745
3364
  }
3365
+ function resolveWriteAccount(wallet, sender) {
3366
+ const walletAccount = wallet.account;
3367
+ if (!walletAccount) return sender;
3368
+ if (walletAccount.address.toLowerCase() !== sender.toLowerCase()) {
3369
+ throw new SDKError(
3370
+ `Wallet account ${walletAccount.address} cannot sign for requested account ${sender}`,
3371
+ { kind: "wallet" }
3372
+ );
3373
+ }
3374
+ return walletAccount;
3375
+ }
4746
3376
  async function simulateAndWrite({
4747
3377
  publicClient,
4748
3378
  walletClient,
@@ -4771,7 +3401,82 @@ async function simulateAndWrite({
4771
3401
  account: sender,
4772
3402
  value
4773
3403
  });
4774
- const hash = await wallet.writeContract(simulation.request);
3404
+ const hash = await wallet.writeContract({
3405
+ ...simulation.request,
3406
+ account: resolveWriteAccount(wallet, sender)
3407
+ });
3408
+ if (confirmations) {
3409
+ const receipt = await publicClient.waitForTransactionReceipt({
3410
+ hash,
3411
+ confirmations
3412
+ });
3413
+ if (receipt.status === "reverted") {
3414
+ throw new SDKError("Transaction reverted on-chain", {
3415
+ kind: "reverted",
3416
+ cause: { hash, receipt }
3417
+ });
3418
+ }
3419
+ }
3420
+ return hash;
3421
+ } catch (e) {
3422
+ onSimulateError?.(e);
3423
+ throw classifyTxError(e);
3424
+ }
3425
+ }
3426
+ async function executeCalls({
3427
+ publicClient,
3428
+ walletClient,
3429
+ calls,
3430
+ account,
3431
+ confirmations,
3432
+ onSimulateError
3433
+ }) {
3434
+ const wallet = await requireWallet(walletClient);
3435
+ const sender = account ?? wallet.account?.address;
3436
+ if (!sender) {
3437
+ throw new SDKError(
3438
+ "No account provided and wallet missing default account",
3439
+ {
3440
+ kind: "wallet"
3441
+ }
3442
+ );
3443
+ }
3444
+ if (calls.length === 0) {
3445
+ throw new SDKError("At least one call is required", { kind: "unknown" });
3446
+ }
3447
+ try {
3448
+ const simulation = await publicClient.simulateCalls({
3449
+ account: sender,
3450
+ calls
3451
+ });
3452
+ for (const [index, result] of simulation.results.entries()) {
3453
+ if (!result) {
3454
+ throw new SDKError(`Call simulation ${index} did not return a result`);
3455
+ }
3456
+ if (result.status === "failure") {
3457
+ const error = classifyTxError(result.error);
3458
+ if (error.kind === "unknown" && result.error instanceof Error) {
3459
+ throw new SDKError(result.error.message, {
3460
+ kind: "reverted",
3461
+ cause: result.error
3462
+ });
3463
+ }
3464
+ throw error;
3465
+ }
3466
+ }
3467
+ const { id } = await actions.sendCalls(wallet, {
3468
+ account: resolveWriteAccount(wallet, sender),
3469
+ calls,
3470
+ experimental_fallback: true
3471
+ });
3472
+ const status = await actions.waitForCallsStatus(wallet, {
3473
+ id,
3474
+ throwOnFailure: true
3475
+ });
3476
+ const hash = status.receipts?.[0]?.transactionHash;
3477
+ if (!hash) {
3478
+ throw new SDKError("Calls bundle did not return a transaction hash");
3479
+ }
4775
3480
  if (confirmations) {
4776
3481
  const receipt = await publicClient.waitForTransactionReceipt({
4777
3482
  hash,
@@ -4806,41 +3511,21 @@ async function getAllowance(client, token, owner, spender) {
4806
3511
  });
4807
3512
  return allowance;
4808
3513
  }
4809
- async function ensureAllowance(params) {
4810
- const current = await getAllowance(
4811
- params.publicClient,
4812
- params.token,
4813
- params.owner,
4814
- params.spender
4815
- );
4816
- if (current >= params.required) return;
4817
- const amount = params.policy === "infinite" ? 2n ** 256n - 1n : params.required;
4818
- await simulateAndWrite({
4819
- publicClient: params.publicClient,
4820
- walletClient: params.walletClient,
4821
- address: params.token,
4822
- abi: externalAbis.erc20,
4823
- functionName: "approve",
4824
- args: [params.spender, amount],
4825
- account: params.owner,
4826
- confirmations: params.confirmations
4827
- });
4828
- }
4829
-
4830
- // src/utils/native.ts
4831
- function shouldUseNative(explicit, config) {
4832
- return explicit ?? !!config?.defaultUseNative;
4833
- }
4834
- function valueForNative(useNative, amount) {
4835
- return useNative ? amount : void 0;
4836
- }
4837
3514
 
4838
3515
  // src/baseline-sdk.ts
3516
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
4839
3517
  var BaselineSDK = class _BaselineSDK {
4840
3518
  publicClient;
4841
3519
  walletClient;
4842
3520
  config;
4843
3521
  readFactory;
3522
+ calls = createCallsApi({
3523
+ getRelay: () => this.proxy,
3524
+ getConfig: () => this.config,
3525
+ getAccount: () => this.getAccount(),
3526
+ getAllowance: (token, owner, spender) => this.getAllowance(token, owner, spender),
3527
+ launch: (input, opts) => this.launchCalls(input, opts)
3528
+ });
4844
3529
  getAccount(opts) {
4845
3530
  const account = opts?.account ?? this.walletClient?.account?.address;
4846
3531
  if (!account) {
@@ -4891,7 +3576,10 @@ var BaselineSDK = class _BaselineSDK {
4891
3576
  account
4892
3577
  });
4893
3578
  const wallet = this.requireWallet();
4894
- const hash = await wallet.writeContract(request);
3579
+ const hash = await wallet.writeContract({
3580
+ ...request,
3581
+ account: resolveWriteAccount(wallet, account)
3582
+ });
4895
3583
  if (opts?.confirmations)
4896
3584
  await this.publicClient.waitForTransactionReceipt({
4897
3585
  hash,
@@ -4918,6 +3606,59 @@ var BaselineSDK = class _BaselineSDK {
4918
3606
  });
4919
3607
  return { hash };
4920
3608
  }
3609
+ async createPoolFromInvariant(params, opts) {
3610
+ const account = this.getAccount(opts);
3611
+ const hash = await simulateAndWrite({
3612
+ publicClient: this.publicClient,
3613
+ walletClient: this.walletClient,
3614
+ address: this.proxy,
3615
+ abi: mercuryAbis.bFactory,
3616
+ functionName: "createPoolFromInvariant",
3617
+ args: [params],
3618
+ account,
3619
+ confirmations: opts?.confirmations,
3620
+ onSimulateError: opts?.onSimulateError
3621
+ });
3622
+ return { hash };
3623
+ }
3624
+ async precomputeBTokenAddress(input) {
3625
+ const bToken = await this.publicClient.readContract({
3626
+ address: this.proxy,
3627
+ abi: mercuryAbis.bFactory,
3628
+ functionName: "precomputeBTokenAddress",
3629
+ args: [
3630
+ input.name,
3631
+ input.symbol,
3632
+ input.totalSupply,
3633
+ input.salt,
3634
+ input.deployer
3635
+ ]
3636
+ });
3637
+ return bToken;
3638
+ }
3639
+ async launchCalls(input, opts) {
3640
+ const account = this.getAccount(opts);
3641
+ const salt = input.salt ?? ZERO_BYTES32;
3642
+ validateLaunchCallInput({
3643
+ ...input,
3644
+ relay: this.proxy,
3645
+ bToken: "0x0000000000000000000000000000000000000000",
3646
+ salt
3647
+ });
3648
+ const bToken = opts?.precomputedBToken ?? await this.precomputeBTokenAddress({
3649
+ name: input.name,
3650
+ symbol: input.symbol,
3651
+ totalSupply: input.totalSupply,
3652
+ salt,
3653
+ deployer: account
3654
+ });
3655
+ return buildLaunchCalls({
3656
+ ...input,
3657
+ relay: this.proxy,
3658
+ bToken,
3659
+ salt
3660
+ });
3661
+ }
4921
3662
  // ---------- Swap quotes ----------
4922
3663
  async quoteBuyExactIn(bToken, reservesIn) {
4923
3664
  const [tokensOut, fee, slippage] = await this.publicClient.readContract({
@@ -4957,18 +3698,22 @@ var BaselineSDK = class _BaselineSDK {
4957
3698
  }
4958
3699
  // ---------- Swap execution ----------
4959
3700
  async buyTokensExactOut(bToken, amountOut, limitAmount, opts) {
4960
- const useNative = shouldUseNative(opts?.useNative, this.config);
4961
3701
  const account = this.getAccount(opts);
4962
- const value = valueForNative(useNative, limitAmount);
3702
+ const call = this.calls.swap.buyTokensExactOut(
3703
+ bToken,
3704
+ amountOut,
3705
+ limitAmount,
3706
+ opts
3707
+ );
4963
3708
  return simulateAndWrite({
4964
3709
  publicClient: this.publicClient,
4965
3710
  walletClient: this.walletClient,
4966
- address: this.proxy,
3711
+ address: call.to,
4967
3712
  abi: mercuryAbis.bSwap,
4968
3713
  functionName: "buyTokensExactOut",
4969
3714
  args: [bToken, amountOut, limitAmount],
4970
3715
  account,
4971
- value,
3716
+ value: call.value,
4972
3717
  confirmations: opts?.confirmations,
4973
3718
  onSimulateError: opts?.onSimulateError
4974
3719
  });
@@ -5033,23 +3778,20 @@ var BaselineSDK = class _BaselineSDK {
5033
3778
  }
5034
3779
  async withdraw(bToken, amount, opts) {
5035
3780
  const account = this.getAccount(opts);
5036
- return simulateAndWrite({
3781
+ return executeCalls({
5037
3782
  publicClient: this.publicClient,
5038
3783
  walletClient: this.walletClient,
5039
- address: this.proxy,
5040
- abi: mercuryAbis.bStaking,
5041
- functionName: "withdraw",
5042
- args: [bToken, amount],
3784
+ calls: [this.calls.staking.withdraw(bToken, amount)],
5043
3785
  account,
5044
3786
  confirmations: opts?.confirmations,
5045
3787
  onSimulateError: opts?.onSimulateError
5046
3788
  });
5047
3789
  }
5048
3790
  async claim(bToken, opts) {
5049
- const wallet = this.requireWallet();
5050
3791
  const account = this.getAccount(opts);
5051
3792
  const user = opts?.user ?? account;
5052
3793
  const asNative = opts?.asNative ?? false;
3794
+ const wallet = this.requireWallet();
5053
3795
  try {
5054
3796
  const { result, request } = await this.publicClient.simulateContract({
5055
3797
  address: this.proxy,
@@ -5058,7 +3800,10 @@ var BaselineSDK = class _BaselineSDK {
5058
3800
  args: [bToken, user, asNative],
5059
3801
  account
5060
3802
  });
5061
- const hash = await wallet.writeContract(request);
3803
+ const hash = await wallet.writeContract({
3804
+ ...request,
3805
+ account: resolveWriteAccount(wallet, account)
3806
+ });
5062
3807
  if (opts?.confirmations)
5063
3808
  await this.publicClient.waitForTransactionReceipt({
5064
3809
  hash,
@@ -5109,13 +3854,12 @@ var BaselineSDK = class _BaselineSDK {
5109
3854
  }
5110
3855
  async borrow(bToken, amount, recipient, opts) {
5111
3856
  const account = this.getAccount(opts);
5112
- const functionName = opts?.outputNative ? "borrowNative" : "borrow";
5113
3857
  return simulateAndWrite({
5114
3858
  publicClient: this.publicClient,
5115
3859
  walletClient: this.walletClient,
5116
3860
  address: this.proxy,
5117
3861
  abi: mercuryAbis.bCredit,
5118
- functionName,
3862
+ functionName: opts?.outputNative ? "borrowNative" : "borrow",
5119
3863
  args: [bToken, amount, recipient],
5120
3864
  account,
5121
3865
  confirmations: opts?.confirmations,
@@ -5123,20 +3867,18 @@ var BaselineSDK = class _BaselineSDK {
5123
3867
  });
5124
3868
  }
5125
3869
  async repay(bToken, reservesIn, recipient, opts) {
5126
- const useNative = shouldUseNative(opts?.useNative, this.config);
5127
3870
  const account = this.getAccount(opts);
5128
- const functionName = useNative ? "repayWithNative" : "repay";
5129
- const args = useNative ? [bToken, recipient] : [bToken, reservesIn, recipient];
5130
- const value = valueForNative(useNative, reservesIn);
3871
+ const call = this.calls.credit.repay(bToken, reservesIn, recipient, opts);
3872
+ const useNative = shouldUseNative(opts?.useNative, this.config);
5131
3873
  return simulateAndWrite({
5132
3874
  publicClient: this.publicClient,
5133
3875
  walletClient: this.walletClient,
5134
- address: this.proxy,
3876
+ address: call.to,
5135
3877
  abi: mercuryAbis.bCredit,
5136
- functionName,
5137
- args,
3878
+ functionName: useNative ? "repayWithNative" : "repay",
3879
+ args: useNative ? [bToken, recipient] : [bToken, reservesIn, recipient],
5138
3880
  account,
5139
- value,
3881
+ value: call.value,
5140
3882
  confirmations: opts?.confirmations,
5141
3883
  onSimulateError: opts?.onSimulateError
5142
3884
  });
@@ -5225,6 +3967,15 @@ var BaselineSDK = class _BaselineSDK {
5225
3967
  userAccumulator
5226
3968
  };
5227
3969
  }
3970
+ async getEarned(bToken, user) {
3971
+ const earned = await this.publicClient.readContract({
3972
+ address: this.proxy,
3973
+ abi: mercuryAbis.bStaking,
3974
+ functionName: "getEarned",
3975
+ args: [bToken, user]
3976
+ });
3977
+ return earned;
3978
+ }
5228
3979
  async getCreditAccount(bToken, user) {
5229
3980
  const [collateral, debt] = await this.publicClient.readContract({
5230
3981
  address: this.proxy,
@@ -5264,18 +4015,131 @@ var BaselineSDK = class _BaselineSDK {
5264
4015
  async ensureApproval(token, spender, required, opts) {
5265
4016
  const account = this.getAccount(opts);
5266
4017
  const policy = opts?.policy ?? this.config?.approvals ?? "infinite";
5267
- await ensureAllowance({
5268
- publicClient: this.publicClient,
5269
- walletClient: this.walletClient,
5270
- token,
4018
+ const calls = await this.calls.approval.ensure(token, spender, required, {
5271
4019
  owner: account,
5272
- spender,
5273
- required,
5274
- policy,
5275
- confirmations: opts?.confirmations
4020
+ policy
5276
4021
  });
4022
+ const [call] = calls;
4023
+ if (!call) return;
4024
+ const amount = policy === "infinite" ? 2n ** 256n - 1n : required;
4025
+ await this.approve(token, spender, amount, opts);
5277
4026
  }
5278
4027
  // ---------- Lens queries ----------
4028
+ async getBTokenInfo(bToken) {
4029
+ const results = await this.publicClient.multicall({
4030
+ allowFailure: true,
4031
+ contracts: [
4032
+ { address: bToken, abi: externalAbis.erc20, functionName: "name" },
4033
+ { address: bToken, abi: externalAbis.erc20, functionName: "symbol" },
4034
+ { address: bToken, abi: externalAbis.erc20, functionName: "decimals" },
4035
+ {
4036
+ address: bToken,
4037
+ abi: externalAbis.erc20,
4038
+ functionName: "totalSupply"
4039
+ },
4040
+ {
4041
+ address: this.proxy,
4042
+ abi: mercuryAbis.bLens,
4043
+ functionName: "reserve",
4044
+ args: [bToken]
4045
+ },
4046
+ {
4047
+ address: this.proxy,
4048
+ abi: mercuryAbis.bLens,
4049
+ functionName: "creator",
4050
+ args: [bToken]
4051
+ },
4052
+ {
4053
+ address: this.proxy,
4054
+ abi: mercuryAbis.bLens,
4055
+ functionName: "poolFeeRecipient",
4056
+ args: [bToken]
4057
+ },
4058
+ {
4059
+ address: this.proxy,
4060
+ abi: mercuryAbis.bLens,
4061
+ functionName: "creatorFeePct",
4062
+ args: [bToken]
4063
+ },
4064
+ {
4065
+ address: this.proxy,
4066
+ abi: mercuryAbis.bLens,
4067
+ functionName: "swapFee",
4068
+ args: [bToken]
4069
+ },
4070
+ {
4071
+ address: this.proxy,
4072
+ abi: mercuryAbis.bLens,
4073
+ functionName: "totalBTokens",
4074
+ args: [bToken]
4075
+ },
4076
+ {
4077
+ address: this.proxy,
4078
+ abi: mercuryAbis.bLens,
4079
+ functionName: "totalReserves",
4080
+ args: [bToken]
4081
+ },
4082
+ {
4083
+ address: this.proxy,
4084
+ abi: mercuryAbis.bLens,
4085
+ functionName: "getMaker",
4086
+ args: [bToken]
4087
+ },
4088
+ {
4089
+ address: this.proxy,
4090
+ abi: mercuryAbis.bLens,
4091
+ functionName: "getQuoteState",
4092
+ args: [bToken]
4093
+ }
4094
+ ]
4095
+ });
4096
+ const result = (index) => {
4097
+ const item = results[index];
4098
+ return item?.status === "success" ? item.result : void 0;
4099
+ };
4100
+ const name = result(0);
4101
+ const symbol = result(1);
4102
+ const decimals = result(2);
4103
+ const totalSupply = result(3);
4104
+ const reserve = result(4);
4105
+ const creator = result(5);
4106
+ const poolFeeRecipient = result(6);
4107
+ const creatorFeePct = result(7);
4108
+ const swapFee = result(8);
4109
+ const totalBTokens = result(9);
4110
+ const totalReserves = result(10);
4111
+ const maker = normalizeMaker(result(11));
4112
+ const reserveDecimals = normalizeQuoteState(
4113
+ result(12)
4114
+ )?.reserveDecimals;
4115
+ return {
4116
+ chainId: this.chainId,
4117
+ relay: this.proxy,
4118
+ bToken,
4119
+ name,
4120
+ symbol,
4121
+ decimals,
4122
+ totalSupply,
4123
+ reserve,
4124
+ reserveDecimals,
4125
+ creator,
4126
+ poolFeeRecipient,
4127
+ creatorFeePct,
4128
+ swapFee,
4129
+ totalBTokens,
4130
+ totalReserves,
4131
+ maker
4132
+ };
4133
+ }
4134
+ async getBTokenStatus(bToken, info) {
4135
+ const bytecode = await this.publicClient.getCode({ address: bToken });
4136
+ const hasBytecode = !!bytecode && bytecode !== "0x";
4137
+ const tokenInfo = info ?? await this.getBTokenInfo(bToken);
4138
+ const hasBaselineState = tokenInfo.reserve !== void 0 && tokenInfo.reserve.toLowerCase() !== ZERO_ADDRESS && tokenInfo.maker !== void 0;
4139
+ const maker = tokenInfo.maker;
4140
+ const status = !hasBytecode ? "not_deployed" : !hasBaselineState ? "contract_only" : maker?.initialized ? "initialized" : "baseline_uninitialized";
4141
+ return { status, bytecode: hasBytecode };
4142
+ }
5279
4143
  async getReserve(bToken) {
5280
4144
  const reserve = await this.publicClient.readContract({
5281
4145
  address: this.proxy,
@@ -5309,8 +4173,57 @@ var BaselineSDK = class _BaselineSDK {
5309
4173
  };
5310
4174
  }
5311
4175
  };
4176
+ function normalizeMaker(value) {
4177
+ if (!value) return void 0;
4178
+ const get = (key, index) => Array.isArray(value) ? value[index] : value[key];
4179
+ const initialized = get("initialized", 0);
4180
+ const blvPrice = get("blvPrice", 1);
4181
+ const swapFee = get("swapFee", 2);
4182
+ const maxCirc = get("maxCirc", 3);
4183
+ const maxReserves = get("maxReserves", 4);
4184
+ const convexityExp = get("convexityExp", 5);
4185
+ const lastInvariant = get("lastInvariant", 6);
4186
+ if (typeof initialized !== "boolean" || typeof blvPrice !== "bigint" || typeof swapFee !== "bigint" || typeof maxCirc !== "bigint" || typeof maxReserves !== "bigint" || typeof convexityExp !== "bigint" || typeof lastInvariant !== "bigint") {
4187
+ return void 0;
4188
+ }
4189
+ return {
4190
+ initialized,
4191
+ blvPrice,
4192
+ swapFee,
4193
+ maxCirc,
4194
+ maxReserves,
4195
+ convexityExp,
4196
+ lastInvariant
4197
+ };
4198
+ }
4199
+ function normalizeQuoteState(value) {
4200
+ if (!value) return void 0;
4201
+ const reserveDecimals = Array.isArray(value) ? value[6] : value.reserveDecimals;
4202
+ return typeof reserveDecimals === "number" ? { reserveDecimals } : void 0;
4203
+ }
4204
+
4205
+ // src/utils/slippage.ts
4206
+ function maxInWithSlippage(amountIn, slippageBps) {
4207
+ if (slippageBps < 0) throw new Error("slippageBps must be >= 0");
4208
+ return amountIn * BigInt(1e4 + slippageBps) / 10000n;
4209
+ }
4210
+ function minOutWithSlippage(amountOut, slippageBps) {
4211
+ if (slippageBps < 0) throw new Error("slippageBps must be >= 0");
4212
+ const numerator = amountOut * 10000n;
4213
+ const denom = BigInt(1e4 + slippageBps);
4214
+ return numerator / denom;
4215
+ }
4216
+
4217
+ // index.ts
4218
+ var abis = mercuryAbis;
4219
+ var supportedChainIds2 = supportedChainIds;
5312
4220
 
5313
4221
  exports.BaselineSDK = BaselineSDK;
5314
4222
  exports.SDKError = SDKError;
5315
- exports.abis = mercuryAbis;
5316
- exports.supportedChainIds = supportedChainIds;
4223
+ exports.abis = abis;
4224
+ exports.calls = calls_exports;
4225
+ exports.maxInWithSlippage = maxInWithSlippage;
4226
+ exports.minOutWithSlippage = minOutWithSlippage;
4227
+ exports.serializeCalls = serializeCalls;
4228
+ exports.simulateCalls = simulateCalls;
4229
+ exports.supportedChainIds = supportedChainIds2;