timelock-sdk 0.0.60 → 0.0.62
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/abis.cjs +1 -1
- package/dist/abis.d.cts +1 -1
- package/dist/abis.d.ts +1 -1
- package/dist/abis.js +1 -1
- package/dist/client.cjs +76 -10
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +548 -65
- package/dist/client.d.ts +607 -124
- package/dist/client.js +76 -11
- package/dist/client.js.map +1 -1
- package/dist/{index-Ct8jAxHT.d.ts → index-BIkdgG3y.d.ts} +2 -2
- package/dist/{index-DgBdLHRl.d.cts → index-CDYUCwzA.d.cts} +2 -2
- package/dist/{numberUtils-DaQ_5dq6.cjs → numberUtils-CmVB4kX7.cjs} +2 -2
- package/dist/{numberUtils-DaQ_5dq6.cjs.map → numberUtils-CmVB4kX7.cjs.map} +1 -1
- package/dist/{numberUtils-DYkWKQ5v.js → numberUtils-Dd7vdmeQ.js} +2 -2
- package/dist/{numberUtils-DYkWKQ5v.js.map → numberUtils-Dd7vdmeQ.js.map} +1 -1
- package/dist/{optionsMarket-C5z_ZrhG.cjs → optionsMarket-D192aXEZ.cjs} +43 -17
- package/dist/{optionsMarket-C5z_ZrhG.cjs.map → optionsMarket-D192aXEZ.cjs.map} +1 -1
- package/dist/{optionsMarket-BW3qSfsm.js → optionsMarket-DD4CWMqv.js} +43 -17
- package/dist/{optionsMarket-BW3qSfsm.js.map → optionsMarket-DD4CWMqv.js.map} +1 -1
- package/dist/package.cjs +2 -2
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/dist/{uniswapMathLens-DS1i63oR.d.ts → uniswapMathLens-D3iSMTdz.d.cts} +35 -16
- package/dist/{uniswapMathLens-Dd_BqyEk.d.cts → uniswapMathLens-Ddy91uWa.d.ts} +35 -16
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-
|
|
5
|
-
import { C as token1ToToken0, D as getUniswapMathLens, E as getTimelockMarket, O as timelockLenses, S as token0ToToken1, T as getTimelockLens, b as roundTickDown, d as wrapPrice, h as getPriceAtTick, k as uniswapMathLenses, l as wrapAmount, m as PRICE_PRECISION, w as getErc20, y as liquiditiesToAmounts } from "./numberUtils-
|
|
4
|
+
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-DD4CWMqv.js";
|
|
5
|
+
import { C as token1ToToken0, D as getUniswapMathLens, E as getTimelockMarket, O as timelockLenses, S as token0ToToken1, T as getTimelockLens, b as roundTickDown, d as wrapPrice, h as getPriceAtTick, k as uniswapMathLenses, l as wrapAmount, m as PRICE_PRECISION, w as getErc20, y as liquiditiesToAmounts } from "./numberUtils-Dd7vdmeQ.js";
|
|
6
6
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
|
|
7
7
|
import { encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useMemo } from "react";
|
|
@@ -16,12 +16,17 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
16
16
|
const GetActiveUserOptionsDocument = gql`
|
|
17
17
|
query GetActiveUserOptions($user: String!) {
|
|
18
18
|
UserOption(
|
|
19
|
-
where: {
|
|
19
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: false}}
|
|
20
20
|
limit: 1000
|
|
21
21
|
) {
|
|
22
22
|
id
|
|
23
23
|
optionId
|
|
24
|
-
|
|
24
|
+
owner {
|
|
25
|
+
address
|
|
26
|
+
}
|
|
27
|
+
market {
|
|
28
|
+
address
|
|
29
|
+
}
|
|
25
30
|
exerciseEvents {
|
|
26
31
|
transactionHash
|
|
27
32
|
}
|
|
@@ -39,7 +44,6 @@ const GetActiveUserOptionsDocument = gql`
|
|
|
39
44
|
premium
|
|
40
45
|
protocolFee
|
|
41
46
|
realizedPayout
|
|
42
|
-
marketAddr
|
|
43
47
|
liquiditiesAtOpen
|
|
44
48
|
liquiditiesCurrent
|
|
45
49
|
positionSizeAtOpen
|
|
@@ -51,12 +55,17 @@ const GetActiveUserOptionsDocument = gql`
|
|
|
51
55
|
const GetClosedUserOptionsDocument = gql`
|
|
52
56
|
query GetClosedUserOptions($user: String!) {
|
|
53
57
|
UserOption(
|
|
54
|
-
where: {
|
|
58
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: true}}
|
|
55
59
|
limit: 1000
|
|
56
60
|
) {
|
|
57
61
|
id
|
|
58
62
|
optionId
|
|
59
|
-
|
|
63
|
+
owner {
|
|
64
|
+
address
|
|
65
|
+
}
|
|
66
|
+
market {
|
|
67
|
+
address
|
|
68
|
+
}
|
|
60
69
|
exerciseEvents {
|
|
61
70
|
transactionHash
|
|
62
71
|
}
|
|
@@ -74,7 +83,6 @@ const GetClosedUserOptionsDocument = gql`
|
|
|
74
83
|
premium
|
|
75
84
|
protocolFee
|
|
76
85
|
realizedPayout
|
|
77
|
-
marketAddr
|
|
78
86
|
liquiditiesAtOpen
|
|
79
87
|
liquiditiesCurrent
|
|
80
88
|
positionSizeAtOpen
|
|
@@ -85,8 +93,9 @@ const GetClosedUserOptionsDocument = gql`
|
|
|
85
93
|
`;
|
|
86
94
|
const GetMarketDataDocument = gql`
|
|
87
95
|
query GetMarketData($marketAddr: String!) {
|
|
88
|
-
TimelockMarket(where: {
|
|
96
|
+
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
89
97
|
id
|
|
98
|
+
address
|
|
90
99
|
optionsCount
|
|
91
100
|
tradersCount
|
|
92
101
|
vault
|
|
@@ -104,6 +113,27 @@ const GetMarketDataDocument = gql`
|
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
`;
|
|
116
|
+
const GetUserMarketOperatorsDocument = gql`
|
|
117
|
+
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
118
|
+
UserMarketOperator(
|
|
119
|
+
where: {
|
|
120
|
+
user: {address: {_eq: $userAddr}}
|
|
121
|
+
market: {address: {_eq: $marketAddr}}
|
|
122
|
+
}
|
|
123
|
+
limit: 1000
|
|
124
|
+
) {
|
|
125
|
+
id
|
|
126
|
+
operator {
|
|
127
|
+
address
|
|
128
|
+
}
|
|
129
|
+
canExtend
|
|
130
|
+
canExercise
|
|
131
|
+
canTransfer
|
|
132
|
+
canMint
|
|
133
|
+
spendingApproval
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
107
137
|
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
108
138
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
109
139
|
return {
|
|
@@ -139,6 +169,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
139
169
|
},
|
|
140
170
|
signal
|
|
141
171
|
}), "GetMarketData", "query", variables);
|
|
172
|
+
},
|
|
173
|
+
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
174
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
175
|
+
document: GetUserMarketOperatorsDocument,
|
|
176
|
+
variables,
|
|
177
|
+
requestHeaders: {
|
|
178
|
+
...requestHeaders,
|
|
179
|
+
...wrappedRequestHeaders
|
|
180
|
+
},
|
|
181
|
+
signal
|
|
182
|
+
}), "GetUserMarketOperators", "query", variables);
|
|
142
183
|
}
|
|
143
184
|
};
|
|
144
185
|
}
|
|
@@ -404,6 +445,7 @@ const useMintOption = (marketAddr) => {
|
|
|
404
445
|
abi: optionsMarketAbi,
|
|
405
446
|
functionName: "mintOption",
|
|
406
447
|
args: [
|
|
448
|
+
address,
|
|
407
449
|
optionType === "CALL" ? 0 : 1,
|
|
408
450
|
amount,
|
|
409
451
|
strikeTick,
|
|
@@ -526,7 +568,8 @@ const useUserOptions = (user, active = false) => {
|
|
|
526
568
|
return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
|
|
527
569
|
...option,
|
|
528
570
|
optionId: BigInt(option.optionId),
|
|
529
|
-
marketAddr: option.
|
|
571
|
+
marketAddr: option.market.address,
|
|
572
|
+
ownerAddr: option.owner.address,
|
|
530
573
|
optionType: option.optionType,
|
|
531
574
|
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
532
575
|
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
@@ -606,6 +649,28 @@ const useExtendOption = (marketAddr) => {
|
|
|
606
649
|
};
|
|
607
650
|
};
|
|
608
651
|
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/hooks/market/useUserOperators.ts
|
|
654
|
+
const useUserOperators = (userAddr, marketAddr) => {
|
|
655
|
+
const { graphqlClient } = useTimelockConfig();
|
|
656
|
+
const { data } = useQuery({
|
|
657
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
658
|
+
queryFn: async () => {
|
|
659
|
+
if (!userAddr || !marketAddr) return void 0;
|
|
660
|
+
return (await graphqlClient.GetUserMarketOperators({
|
|
661
|
+
userAddr: userAddr.toLowerCase(),
|
|
662
|
+
marketAddr: marketAddr.toLowerCase()
|
|
663
|
+
})).UserMarketOperator.map((operator) => ({
|
|
664
|
+
...operator,
|
|
665
|
+
spendingApproval: BigInt(operator.spendingApproval),
|
|
666
|
+
operatorAddr: operator.operator.address.toLowerCase()
|
|
667
|
+
}));
|
|
668
|
+
},
|
|
669
|
+
enabled: !!marketAddr && !!graphqlClient
|
|
670
|
+
});
|
|
671
|
+
return data || {};
|
|
672
|
+
};
|
|
673
|
+
|
|
609
674
|
//#endregion
|
|
610
675
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
611
676
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -977,5 +1042,5 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
977
1042
|
};
|
|
978
1043
|
|
|
979
1044
|
//#endregion
|
|
980
|
-
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useVaultData, useVaultTVL };
|
|
1045
|
+
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
981
1046
|
//# sourceMappingURL=client.js.map
|