timelock-sdk 0.0.73 → 0.0.75
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.cjs +109 -72
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +144 -144
- package/dist/client.d.ts +131 -131
- package/dist/client.js +109 -73
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -13,83 +13,91 @@ import { waitForTransactionReceipt } from "viem/actions";
|
|
|
13
13
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
14
14
|
|
|
15
15
|
//#region src/generated/graphql.ts
|
|
16
|
+
const UserOptionFieldsFragmentDoc = gql`
|
|
17
|
+
fragment UserOptionFields on UserOption {
|
|
18
|
+
id
|
|
19
|
+
optionId
|
|
20
|
+
owner {
|
|
21
|
+
address
|
|
22
|
+
}
|
|
23
|
+
market {
|
|
24
|
+
address
|
|
25
|
+
}
|
|
26
|
+
exerciseEvents {
|
|
27
|
+
transactionHash
|
|
28
|
+
}
|
|
29
|
+
mintEvent {
|
|
30
|
+
transactionHash
|
|
31
|
+
}
|
|
32
|
+
optionType
|
|
33
|
+
strikeTick
|
|
34
|
+
entryTick
|
|
35
|
+
startTick
|
|
36
|
+
strikePrice
|
|
37
|
+
entryPrice
|
|
38
|
+
expiresAt
|
|
39
|
+
createdAt
|
|
40
|
+
premium
|
|
41
|
+
protocolFee
|
|
42
|
+
realizedPayout
|
|
43
|
+
liquiditiesAtOpen
|
|
44
|
+
liquiditiesCurrent
|
|
45
|
+
positionSizeAtOpen
|
|
46
|
+
positionSizeCurrent
|
|
47
|
+
fullyExercised
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
16
50
|
const GetActiveUserOptionsDocument = gql`
|
|
17
|
-
query GetActiveUserOptions($
|
|
51
|
+
query GetActiveUserOptions($userAddr: String!) {
|
|
18
52
|
UserOption(
|
|
19
|
-
where: {owner: {address: {_eq: $
|
|
53
|
+
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: false}}
|
|
20
54
|
limit: 1000
|
|
21
55
|
) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
transactionHash
|
|
56
|
+
...UserOptionFields
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
${UserOptionFieldsFragmentDoc}
|
|
60
|
+
`;
|
|
61
|
+
const GetActiveUserOptionsByMarketDocument = gql`
|
|
62
|
+
query GetActiveUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
63
|
+
UserOption(
|
|
64
|
+
where: {
|
|
65
|
+
owner: {address: {_eq: $userAddr}}
|
|
66
|
+
fullyExercised: {_eq: false}
|
|
67
|
+
market: {address: {_eq: $marketAddr}}
|
|
35
68
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
startTick
|
|
40
|
-
strikePrice
|
|
41
|
-
entryPrice
|
|
42
|
-
expiresAt
|
|
43
|
-
createdAt
|
|
44
|
-
premium
|
|
45
|
-
protocolFee
|
|
46
|
-
realizedPayout
|
|
47
|
-
liquiditiesAtOpen
|
|
48
|
-
liquiditiesCurrent
|
|
49
|
-
positionSizeAtOpen
|
|
50
|
-
positionSizeCurrent
|
|
51
|
-
fullyExercised
|
|
69
|
+
limit: 1000
|
|
70
|
+
) {
|
|
71
|
+
...UserOptionFields
|
|
52
72
|
}
|
|
53
73
|
}
|
|
74
|
+
${UserOptionFieldsFragmentDoc}
|
|
54
75
|
`;
|
|
55
76
|
const GetClosedUserOptionsDocument = gql`
|
|
56
|
-
query GetClosedUserOptions($
|
|
77
|
+
query GetClosedUserOptions($userAddr: String!) {
|
|
57
78
|
UserOption(
|
|
58
|
-
where: {owner: {address: {_eq: $
|
|
79
|
+
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: true}}
|
|
59
80
|
limit: 1000
|
|
60
81
|
) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
transactionHash
|
|
82
|
+
...UserOptionFields
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
${UserOptionFieldsFragmentDoc}
|
|
86
|
+
`;
|
|
87
|
+
const GetClosedUserOptionsByMarketDocument = gql`
|
|
88
|
+
query GetClosedUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
89
|
+
UserOption(
|
|
90
|
+
where: {
|
|
91
|
+
owner: {address: {_eq: $userAddr}}
|
|
92
|
+
fullyExercised: {_eq: true}
|
|
93
|
+
market: {address: {_eq: $marketAddr}}
|
|
74
94
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
startTick
|
|
79
|
-
strikePrice
|
|
80
|
-
entryPrice
|
|
81
|
-
expiresAt
|
|
82
|
-
createdAt
|
|
83
|
-
premium
|
|
84
|
-
protocolFee
|
|
85
|
-
realizedPayout
|
|
86
|
-
liquiditiesAtOpen
|
|
87
|
-
liquiditiesCurrent
|
|
88
|
-
positionSizeAtOpen
|
|
89
|
-
positionSizeCurrent
|
|
90
|
-
fullyExercised
|
|
95
|
+
limit: 1000
|
|
96
|
+
) {
|
|
97
|
+
...UserOptionFields
|
|
91
98
|
}
|
|
92
99
|
}
|
|
100
|
+
${UserOptionFieldsFragmentDoc}
|
|
93
101
|
`;
|
|
94
102
|
const GetMarketDataDocument = gql`
|
|
95
103
|
query GetMarketData($marketAddr: String!) {
|
|
@@ -148,6 +156,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
148
156
|
signal
|
|
149
157
|
}), "GetActiveUserOptions", "query", variables);
|
|
150
158
|
},
|
|
159
|
+
GetActiveUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
160
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
161
|
+
document: GetActiveUserOptionsByMarketDocument,
|
|
162
|
+
variables,
|
|
163
|
+
requestHeaders: {
|
|
164
|
+
...requestHeaders,
|
|
165
|
+
...wrappedRequestHeaders
|
|
166
|
+
},
|
|
167
|
+
signal
|
|
168
|
+
}), "GetActiveUserOptionsByMarket", "query", variables);
|
|
169
|
+
},
|
|
151
170
|
GetClosedUserOptions(variables, requestHeaders, signal) {
|
|
152
171
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
153
172
|
document: GetClosedUserOptionsDocument,
|
|
@@ -159,6 +178,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
159
178
|
signal
|
|
160
179
|
}), "GetClosedUserOptions", "query", variables);
|
|
161
180
|
},
|
|
181
|
+
GetClosedUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
182
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
183
|
+
document: GetClosedUserOptionsByMarketDocument,
|
|
184
|
+
variables,
|
|
185
|
+
requestHeaders: {
|
|
186
|
+
...requestHeaders,
|
|
187
|
+
...wrappedRequestHeaders
|
|
188
|
+
},
|
|
189
|
+
signal
|
|
190
|
+
}), "GetClosedUserOptionsByMarket", "query", variables);
|
|
191
|
+
},
|
|
162
192
|
GetMarketData(variables, requestHeaders, signal) {
|
|
163
193
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
164
194
|
document: GetMarketDataDocument,
|
|
@@ -532,18 +562,24 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, r
|
|
|
532
562
|
|
|
533
563
|
//#endregion
|
|
534
564
|
//#region src/hooks/market/useUserOptions.ts
|
|
535
|
-
const useUserOptions = (
|
|
565
|
+
const useUserOptions = (userAddr, marketAddr, active = false) => {
|
|
536
566
|
const { graphqlClient } = useTimelockConfig();
|
|
537
|
-
|
|
567
|
+
userAddr = userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase();
|
|
538
568
|
const { data,...rest } = useQuery({
|
|
539
569
|
queryKey: [
|
|
540
570
|
"userOptions",
|
|
541
|
-
|
|
571
|
+
userAddr || "--",
|
|
542
572
|
active
|
|
543
573
|
],
|
|
544
574
|
queryFn: async () => {
|
|
545
|
-
if (!graphqlClient || !
|
|
546
|
-
return (active ?
|
|
575
|
+
if (!graphqlClient || !userAddr || !marketAddr) return [];
|
|
576
|
+
return (await (marketAddr === "*" ? active ? graphqlClient.GetActiveUserOptions({ userAddr }) : graphqlClient.GetClosedUserOptions({ userAddr }) : active ? graphqlClient.GetActiveUserOptionsByMarket({
|
|
577
|
+
userAddr,
|
|
578
|
+
marketAddr
|
|
579
|
+
}) : graphqlClient.GetClosedUserOptionsByMarket({
|
|
580
|
+
userAddr,
|
|
581
|
+
marketAddr
|
|
582
|
+
}))).UserOption.map((option) => ({
|
|
547
583
|
...option,
|
|
548
584
|
optionId: BigInt(option.optionId),
|
|
549
585
|
marketAddr: option.market.address,
|
|
@@ -562,18 +598,18 @@ const useUserOptions = (user, active = false) => {
|
|
|
562
598
|
entryPrice: BigInt(option.entryPrice)
|
|
563
599
|
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
564
600
|
},
|
|
565
|
-
enabled: !!
|
|
601
|
+
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
566
602
|
});
|
|
567
603
|
return {
|
|
568
604
|
data: data || [],
|
|
569
605
|
...rest
|
|
570
606
|
};
|
|
571
607
|
};
|
|
572
|
-
const useActiveUserOptions = (
|
|
573
|
-
return useUserOptions(
|
|
608
|
+
const useActiveUserOptions = (userAddr, marketAddr) => {
|
|
609
|
+
return useUserOptions(userAddr, marketAddr, true);
|
|
574
610
|
};
|
|
575
|
-
const useClosedUserOptions = (
|
|
576
|
-
return useUserOptions(
|
|
611
|
+
const useClosedUserOptions = (userAddr, marketAddr) => {
|
|
612
|
+
return useUserOptions(userAddr, marketAddr, false);
|
|
577
613
|
};
|
|
578
614
|
|
|
579
615
|
//#endregion
|
|
@@ -1049,5 +1085,5 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
1049
1085
|
};
|
|
1050
1086
|
|
|
1051
1087
|
//#endregion
|
|
1052
|
-
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
1088
|
+
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
1053
1089
|
//# sourceMappingURL=client.js.map
|