timelock-sdk 0.0.153 → 0.0.154

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/client.js CHANGED
@@ -1,15 +1,15 @@
1
1
  'use client';
2
2
 
3
3
 
4
- import { i as erc20Abi$1, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-C83iT_EM.js";
5
- import { A as token1ToToken0, B as swappers, D as roundTick, F as getStateView, H as statelessStateViewAbi, I as getTimelockLens, L as getTimelockMarket, N as getPriceHistory, O as token0ToToken1, P as getErc20, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0AtTick, k as token0ToToken1AtTick, m as wrapPrice, r as EMPTY_ARRAY, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick } from "./optionUtils-DJ8kTxc_.js";
4
+ import { i as erc20Abi$1, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-Bs6Pf2pL.js";
5
+ import { A as token1ToToken0, B as swappers, D as roundTick, F as getStateView, H as statelessStateViewAbi, I as getTimelockLens, L as getTimelockMarket, N as getPriceHistory, O as token0ToToken1, P as getErc20, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0AtTick, k as token0ToToken1AtTick, m as wrapPrice, r as EMPTY_ARRAY, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick } from "./optionUtils-mVijJiqG.js";
6
6
  import { t as singleOwnerVaultAbi } from "./singleOwnerVault-BJyEs_D_.js";
7
7
  import { encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
8
8
  import React, { createContext, useContext, useEffect, useMemo } from "react";
9
9
  import { GraphQLClient, RequestOptions } from "graphql-request";
10
10
  import gql from "graphql-tag";
11
11
  import { waitForTransactionReceipt } from "viem/actions";
12
- import { useChainId, useClient, useConnection, useReadContract, useSignMessage, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
12
+ import { useChainId, useClient, useConnection, usePublicClient, useReadContract, useSignMessage, useWaitForTransactionReceipt, useWriteContract } from "wagmi";
13
13
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
14
14
  import { z } from "zod";
15
15
 
@@ -1517,5 +1517,670 @@ const useVaultTVL = (vaultAddr) => {
1517
1517
  };
1518
1518
 
1519
1519
  //#endregion
1520
- export { TimelockProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePerpsOperator, usePoolData, usePriceAtSqrtPriceX96, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useTokenBalance, useTokenData, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
1520
+ //#region src/hooks/guardian/useGuardianGlobalState.ts
1521
+ const useGuardianGlobalState = (guardianAddr) => {
1522
+ const { timelockLens } = useLens();
1523
+ const { data, ...rest } = useReadContract({
1524
+ address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
1525
+ abi: lensAbi,
1526
+ functionName: "getGlobalGuardianState",
1527
+ args: guardianAddr ? [guardianAddr] : void 0
1528
+ });
1529
+ return {
1530
+ data: data || {},
1531
+ ...rest
1532
+ };
1533
+ };
1534
+
1535
+ //#endregion
1536
+ //#region src/abis/guardian.ts
1537
+ const guardianAbi = [
1538
+ {
1539
+ type: "constructor",
1540
+ inputs: [],
1541
+ stateMutability: "nonpayable"
1542
+ },
1543
+ {
1544
+ type: "function",
1545
+ name: "DEFAULT_ADMIN_ROLE",
1546
+ inputs: [],
1547
+ outputs: [{
1548
+ name: "",
1549
+ type: "bytes32",
1550
+ internalType: "bytes32"
1551
+ }],
1552
+ stateMutability: "view"
1553
+ },
1554
+ {
1555
+ type: "function",
1556
+ name: "MIN_WITHDRAW_INTERVAL",
1557
+ inputs: [],
1558
+ outputs: [{
1559
+ name: "",
1560
+ type: "uint256",
1561
+ internalType: "uint256"
1562
+ }],
1563
+ stateMutability: "view"
1564
+ },
1565
+ {
1566
+ type: "function",
1567
+ name: "PAUSER_ROLE",
1568
+ inputs: [],
1569
+ outputs: [{
1570
+ name: "",
1571
+ type: "bytes32",
1572
+ internalType: "bytes32"
1573
+ }],
1574
+ stateMutability: "view"
1575
+ },
1576
+ {
1577
+ type: "function",
1578
+ name: "allowBurn",
1579
+ inputs: [{
1580
+ name: "vault",
1581
+ type: "address",
1582
+ internalType: "address"
1583
+ }],
1584
+ outputs: [{
1585
+ name: "",
1586
+ type: "bool",
1587
+ internalType: "bool"
1588
+ }],
1589
+ stateMutability: "view"
1590
+ },
1591
+ {
1592
+ type: "function",
1593
+ name: "allowEmergencyMarketWithdraw",
1594
+ inputs: [{
1595
+ name: "market",
1596
+ type: "address",
1597
+ internalType: "address"
1598
+ }],
1599
+ outputs: [{
1600
+ name: "",
1601
+ type: "bool",
1602
+ internalType: "bool"
1603
+ }],
1604
+ stateMutability: "view"
1605
+ },
1606
+ {
1607
+ type: "function",
1608
+ name: "allowEmergencyVaultWithdraw",
1609
+ inputs: [{
1610
+ name: "vault",
1611
+ type: "address",
1612
+ internalType: "address"
1613
+ }],
1614
+ outputs: [{
1615
+ name: "",
1616
+ type: "bool",
1617
+ internalType: "bool"
1618
+ }],
1619
+ stateMutability: "view"
1620
+ },
1621
+ {
1622
+ type: "function",
1623
+ name: "allowMint",
1624
+ inputs: [{
1625
+ name: "vault",
1626
+ type: "address",
1627
+ internalType: "address"
1628
+ }],
1629
+ outputs: [{
1630
+ name: "",
1631
+ type: "bool",
1632
+ internalType: "bool"
1633
+ }],
1634
+ stateMutability: "view"
1635
+ },
1636
+ {
1637
+ type: "function",
1638
+ name: "allowTrade",
1639
+ inputs: [
1640
+ {
1641
+ name: "market",
1642
+ type: "address",
1643
+ internalType: "address"
1644
+ },
1645
+ {
1646
+ name: "owner",
1647
+ type: "address",
1648
+ internalType: "address"
1649
+ },
1650
+ {
1651
+ name: "sender",
1652
+ type: "address",
1653
+ internalType: "address"
1654
+ }
1655
+ ],
1656
+ outputs: [{
1657
+ name: "",
1658
+ type: "bool",
1659
+ internalType: "bool"
1660
+ }],
1661
+ stateMutability: "view"
1662
+ },
1663
+ {
1664
+ type: "function",
1665
+ name: "getRoleAdmin",
1666
+ inputs: [{
1667
+ name: "role",
1668
+ type: "bytes32",
1669
+ internalType: "bytes32"
1670
+ }],
1671
+ outputs: [{
1672
+ name: "",
1673
+ type: "bytes32",
1674
+ internalType: "bytes32"
1675
+ }],
1676
+ stateMutability: "view"
1677
+ },
1678
+ {
1679
+ type: "function",
1680
+ name: "globalBurnPaused",
1681
+ inputs: [],
1682
+ outputs: [{
1683
+ name: "paused",
1684
+ type: "bool",
1685
+ internalType: "bool"
1686
+ }, {
1687
+ name: "updatedAt",
1688
+ type: "uint64",
1689
+ internalType: "uint64"
1690
+ }],
1691
+ stateMutability: "view"
1692
+ },
1693
+ {
1694
+ type: "function",
1695
+ name: "globalMintPaused",
1696
+ inputs: [],
1697
+ outputs: [{
1698
+ name: "paused",
1699
+ type: "bool",
1700
+ internalType: "bool"
1701
+ }, {
1702
+ name: "updatedAt",
1703
+ type: "uint64",
1704
+ internalType: "uint64"
1705
+ }],
1706
+ stateMutability: "view"
1707
+ },
1708
+ {
1709
+ type: "function",
1710
+ name: "globalTradingPaused",
1711
+ inputs: [],
1712
+ outputs: [{
1713
+ name: "paused",
1714
+ type: "bool",
1715
+ internalType: "bool"
1716
+ }, {
1717
+ name: "updatedAt",
1718
+ type: "uint64",
1719
+ internalType: "uint64"
1720
+ }],
1721
+ stateMutability: "view"
1722
+ },
1723
+ {
1724
+ type: "function",
1725
+ name: "grantRole",
1726
+ inputs: [{
1727
+ name: "role",
1728
+ type: "bytes32",
1729
+ internalType: "bytes32"
1730
+ }, {
1731
+ name: "account",
1732
+ type: "address",
1733
+ internalType: "address"
1734
+ }],
1735
+ outputs: [],
1736
+ stateMutability: "nonpayable"
1737
+ },
1738
+ {
1739
+ type: "function",
1740
+ name: "hasRole",
1741
+ inputs: [{
1742
+ name: "role",
1743
+ type: "bytes32",
1744
+ internalType: "bytes32"
1745
+ }, {
1746
+ name: "account",
1747
+ type: "address",
1748
+ internalType: "address"
1749
+ }],
1750
+ outputs: [{
1751
+ name: "",
1752
+ type: "bool",
1753
+ internalType: "bool"
1754
+ }],
1755
+ stateMutability: "view"
1756
+ },
1757
+ {
1758
+ type: "function",
1759
+ name: "marketTradingPaused",
1760
+ inputs: [{
1761
+ name: "",
1762
+ type: "address",
1763
+ internalType: "address"
1764
+ }],
1765
+ outputs: [{
1766
+ name: "paused",
1767
+ type: "bool",
1768
+ internalType: "bool"
1769
+ }, {
1770
+ name: "updatedAt",
1771
+ type: "uint64",
1772
+ internalType: "uint64"
1773
+ }],
1774
+ stateMutability: "view"
1775
+ },
1776
+ {
1777
+ type: "function",
1778
+ name: "operatorsPaused",
1779
+ inputs: [{
1780
+ name: "",
1781
+ type: "address",
1782
+ internalType: "address"
1783
+ }],
1784
+ outputs: [{
1785
+ name: "paused",
1786
+ type: "bool",
1787
+ internalType: "bool"
1788
+ }, {
1789
+ name: "updatedAt",
1790
+ type: "uint64",
1791
+ internalType: "uint64"
1792
+ }],
1793
+ stateMutability: "view"
1794
+ },
1795
+ {
1796
+ type: "function",
1797
+ name: "pauseGlobal",
1798
+ inputs: [
1799
+ {
1800
+ name: "mintPaused",
1801
+ type: "bool",
1802
+ internalType: "bool"
1803
+ },
1804
+ {
1805
+ name: "burnPaused",
1806
+ type: "bool",
1807
+ internalType: "bool"
1808
+ },
1809
+ {
1810
+ name: "TradingPaused",
1811
+ type: "bool",
1812
+ internalType: "bool"
1813
+ }
1814
+ ],
1815
+ outputs: [],
1816
+ stateMutability: "nonpayable"
1817
+ },
1818
+ {
1819
+ type: "function",
1820
+ name: "pauseMarket",
1821
+ inputs: [{
1822
+ name: "market",
1823
+ type: "address",
1824
+ internalType: "address"
1825
+ }, {
1826
+ name: "TradingPaused",
1827
+ type: "bool",
1828
+ internalType: "bool"
1829
+ }],
1830
+ outputs: [],
1831
+ stateMutability: "nonpayable"
1832
+ },
1833
+ {
1834
+ type: "function",
1835
+ name: "pauseOperator",
1836
+ inputs: [{
1837
+ name: "operator",
1838
+ type: "address",
1839
+ internalType: "address"
1840
+ }, {
1841
+ name: "paused",
1842
+ type: "bool",
1843
+ internalType: "bool"
1844
+ }],
1845
+ outputs: [],
1846
+ stateMutability: "nonpayable"
1847
+ },
1848
+ {
1849
+ type: "function",
1850
+ name: "pauseVault",
1851
+ inputs: [
1852
+ {
1853
+ name: "vault",
1854
+ type: "address",
1855
+ internalType: "address"
1856
+ },
1857
+ {
1858
+ name: "mintPaused",
1859
+ type: "bool",
1860
+ internalType: "bool"
1861
+ },
1862
+ {
1863
+ name: "burnPaused",
1864
+ type: "bool",
1865
+ internalType: "bool"
1866
+ }
1867
+ ],
1868
+ outputs: [],
1869
+ stateMutability: "nonpayable"
1870
+ },
1871
+ {
1872
+ type: "function",
1873
+ name: "renounceRole",
1874
+ inputs: [{
1875
+ name: "role",
1876
+ type: "bytes32",
1877
+ internalType: "bytes32"
1878
+ }, {
1879
+ name: "callerConfirmation",
1880
+ type: "address",
1881
+ internalType: "address"
1882
+ }],
1883
+ outputs: [],
1884
+ stateMutability: "nonpayable"
1885
+ },
1886
+ {
1887
+ type: "function",
1888
+ name: "revokeRole",
1889
+ inputs: [{
1890
+ name: "role",
1891
+ type: "bytes32",
1892
+ internalType: "bytes32"
1893
+ }, {
1894
+ name: "account",
1895
+ type: "address",
1896
+ internalType: "address"
1897
+ }],
1898
+ outputs: [],
1899
+ stateMutability: "nonpayable"
1900
+ },
1901
+ {
1902
+ type: "function",
1903
+ name: "supportsInterface",
1904
+ inputs: [{
1905
+ name: "interfaceId",
1906
+ type: "bytes4",
1907
+ internalType: "bytes4"
1908
+ }],
1909
+ outputs: [{
1910
+ name: "",
1911
+ type: "bool",
1912
+ internalType: "bool"
1913
+ }],
1914
+ stateMutability: "view"
1915
+ },
1916
+ {
1917
+ type: "function",
1918
+ name: "vaultBurnPaused",
1919
+ inputs: [{
1920
+ name: "",
1921
+ type: "address",
1922
+ internalType: "address"
1923
+ }],
1924
+ outputs: [{
1925
+ name: "paused",
1926
+ type: "bool",
1927
+ internalType: "bool"
1928
+ }, {
1929
+ name: "updatedAt",
1930
+ type: "uint64",
1931
+ internalType: "uint64"
1932
+ }],
1933
+ stateMutability: "view"
1934
+ },
1935
+ {
1936
+ type: "function",
1937
+ name: "vaultMintPaused",
1938
+ inputs: [{
1939
+ name: "",
1940
+ type: "address",
1941
+ internalType: "address"
1942
+ }],
1943
+ outputs: [{
1944
+ name: "paused",
1945
+ type: "bool",
1946
+ internalType: "bool"
1947
+ }, {
1948
+ name: "updatedAt",
1949
+ type: "uint64",
1950
+ internalType: "uint64"
1951
+ }],
1952
+ stateMutability: "view"
1953
+ },
1954
+ {
1955
+ type: "event",
1956
+ name: "PauseGlobal",
1957
+ inputs: [
1958
+ {
1959
+ name: "mintPaused",
1960
+ type: "bool",
1961
+ indexed: false,
1962
+ internalType: "bool"
1963
+ },
1964
+ {
1965
+ name: "burnPaused",
1966
+ type: "bool",
1967
+ indexed: false,
1968
+ internalType: "bool"
1969
+ },
1970
+ {
1971
+ name: "TradingPaused",
1972
+ type: "bool",
1973
+ indexed: false,
1974
+ internalType: "bool"
1975
+ }
1976
+ ],
1977
+ anonymous: false
1978
+ },
1979
+ {
1980
+ type: "event",
1981
+ name: "PauseMarket",
1982
+ inputs: [{
1983
+ name: "market",
1984
+ type: "address",
1985
+ indexed: true,
1986
+ internalType: "address"
1987
+ }, {
1988
+ name: "paused",
1989
+ type: "bool",
1990
+ indexed: false,
1991
+ internalType: "bool"
1992
+ }],
1993
+ anonymous: false
1994
+ },
1995
+ {
1996
+ type: "event",
1997
+ name: "PauseOperator",
1998
+ inputs: [{
1999
+ name: "operator",
2000
+ type: "address",
2001
+ indexed: true,
2002
+ internalType: "address"
2003
+ }, {
2004
+ name: "paused",
2005
+ type: "bool",
2006
+ indexed: false,
2007
+ internalType: "bool"
2008
+ }],
2009
+ anonymous: false
2010
+ },
2011
+ {
2012
+ type: "event",
2013
+ name: "PauseVault",
2014
+ inputs: [
2015
+ {
2016
+ name: "vault",
2017
+ type: "address",
2018
+ indexed: true,
2019
+ internalType: "address"
2020
+ },
2021
+ {
2022
+ name: "mintPaused",
2023
+ type: "bool",
2024
+ indexed: false,
2025
+ internalType: "bool"
2026
+ },
2027
+ {
2028
+ name: "burnPaused",
2029
+ type: "bool",
2030
+ indexed: false,
2031
+ internalType: "bool"
2032
+ }
2033
+ ],
2034
+ anonymous: false
2035
+ },
2036
+ {
2037
+ type: "event",
2038
+ name: "RoleAdminChanged",
2039
+ inputs: [
2040
+ {
2041
+ name: "role",
2042
+ type: "bytes32",
2043
+ indexed: true,
2044
+ internalType: "bytes32"
2045
+ },
2046
+ {
2047
+ name: "previousAdminRole",
2048
+ type: "bytes32",
2049
+ indexed: true,
2050
+ internalType: "bytes32"
2051
+ },
2052
+ {
2053
+ name: "newAdminRole",
2054
+ type: "bytes32",
2055
+ indexed: true,
2056
+ internalType: "bytes32"
2057
+ }
2058
+ ],
2059
+ anonymous: false
2060
+ },
2061
+ {
2062
+ type: "event",
2063
+ name: "RoleGranted",
2064
+ inputs: [
2065
+ {
2066
+ name: "role",
2067
+ type: "bytes32",
2068
+ indexed: true,
2069
+ internalType: "bytes32"
2070
+ },
2071
+ {
2072
+ name: "account",
2073
+ type: "address",
2074
+ indexed: true,
2075
+ internalType: "address"
2076
+ },
2077
+ {
2078
+ name: "sender",
2079
+ type: "address",
2080
+ indexed: true,
2081
+ internalType: "address"
2082
+ }
2083
+ ],
2084
+ anonymous: false
2085
+ },
2086
+ {
2087
+ type: "event",
2088
+ name: "RoleRevoked",
2089
+ inputs: [
2090
+ {
2091
+ name: "role",
2092
+ type: "bytes32",
2093
+ indexed: true,
2094
+ internalType: "bytes32"
2095
+ },
2096
+ {
2097
+ name: "account",
2098
+ type: "address",
2099
+ indexed: true,
2100
+ internalType: "address"
2101
+ },
2102
+ {
2103
+ name: "sender",
2104
+ type: "address",
2105
+ indexed: true,
2106
+ internalType: "address"
2107
+ }
2108
+ ],
2109
+ anonymous: false
2110
+ },
2111
+ {
2112
+ type: "error",
2113
+ name: "AccessControlBadConfirmation",
2114
+ inputs: []
2115
+ },
2116
+ {
2117
+ type: "error",
2118
+ name: "AccessControlUnauthorizedAccount",
2119
+ inputs: [{
2120
+ name: "account",
2121
+ type: "address",
2122
+ internalType: "address"
2123
+ }, {
2124
+ name: "neededRole",
2125
+ type: "bytes32",
2126
+ internalType: "bytes32"
2127
+ }]
2128
+ }
2129
+ ];
2130
+
2131
+ //#endregion
2132
+ //#region src/hooks/guardian/usePauseGlobalTrading.ts
2133
+ const usePauseGlobalTrading = ({ marketAddr }) => {
2134
+ const { guardian } = useMarketData(marketAddr);
2135
+ const { data: { globalBurnPaused, globalMintPaused }, refetch } = useGuardianGlobalState(guardian);
2136
+ const publicClient = usePublicClient();
2137
+ const { writeContractAsync, ...rest } = useWriteContract();
2138
+ const pauseGlobalTrading = async (paused) => {
2139
+ if (!marketAddr) throw new Error("Market address is required");
2140
+ if (!guardian) throw new Error("Could not load guardian address");
2141
+ if (!globalMintPaused || !globalBurnPaused) throw new Error("Could not load global mint or burn paused state");
2142
+ if (!publicClient) throw new Error("Could not load public client");
2143
+ const hash = await writeContractAsync({
2144
+ address: guardian,
2145
+ abi: guardianAbi,
2146
+ functionName: "pauseGlobal",
2147
+ args: [
2148
+ globalMintPaused.paused,
2149
+ globalBurnPaused.paused,
2150
+ paused
2151
+ ]
2152
+ });
2153
+ await publicClient.waitForTransactionReceipt({ hash });
2154
+ refetch();
2155
+ return hash;
2156
+ };
2157
+ return {
2158
+ pauseGlobalTrading,
2159
+ ...rest
2160
+ };
2161
+ };
2162
+
2163
+ //#endregion
2164
+ //#region src/hooks/guardian/usePauseMarketTrading.ts
2165
+ const usePauseMarketTrading = ({ marketAddr }) => {
2166
+ const { guardian } = useMarketData(marketAddr);
2167
+ const { writeContractAsync, ...rest } = useWriteContract();
2168
+ const pauseMarketTrading = async (paused) => {
2169
+ if (!marketAddr) throw new Error("Market address is required");
2170
+ if (!guardian) throw new Error("Could not load guardian address");
2171
+ return await writeContractAsync({
2172
+ address: guardian,
2173
+ abi: guardianAbi,
2174
+ functionName: "pauseMarket",
2175
+ args: [marketAddr, paused]
2176
+ });
2177
+ };
2178
+ return {
2179
+ pauseMarketTrading,
2180
+ ...rest
2181
+ };
2182
+ };
2183
+
2184
+ //#endregion
2185
+ export { TimelockProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useGuardianGlobalState, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionTimeline, usePauseGlobalTrading, usePauseMarketTrading, usePerpsOperator, usePoolData, usePriceAtSqrtPriceX96, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useTokenBalance, useTokenData, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
1521
2186
  //# sourceMappingURL=client.js.map