timelock-sdk 0.0.74 → 0.0.76
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 +189 -198
- package/dist/client.d.ts +122 -131
- package/dist/client.js +109 -72
- package/dist/client.js.map +1 -1
- package/dist/{index-C-uDgfkL.d.cts → index-CFBcBY1K.d.cts} +92 -92
- package/dist/{index-BdBPLPWm.d.ts → index-CdkTrz02.d.ts} +92 -92
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +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,25 @@ 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();
|
|
568
|
+
marketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
|
|
538
569
|
const { data,...rest } = useQuery({
|
|
539
570
|
queryKey: [
|
|
540
571
|
"userOptions",
|
|
541
|
-
|
|
572
|
+
userAddr || "--",
|
|
542
573
|
active
|
|
543
574
|
],
|
|
544
575
|
queryFn: async () => {
|
|
545
|
-
if (!graphqlClient || !
|
|
546
|
-
return (active ?
|
|
576
|
+
if (!graphqlClient || !userAddr || !marketAddr) return [];
|
|
577
|
+
return (await (marketAddr === "*" ? active ? graphqlClient.GetActiveUserOptions({ userAddr }) : graphqlClient.GetClosedUserOptions({ userAddr }) : active ? graphqlClient.GetActiveUserOptionsByMarket({
|
|
578
|
+
userAddr,
|
|
579
|
+
marketAddr
|
|
580
|
+
}) : graphqlClient.GetClosedUserOptionsByMarket({
|
|
581
|
+
userAddr,
|
|
582
|
+
marketAddr
|
|
583
|
+
}))).UserOption.map((option) => ({
|
|
547
584
|
...option,
|
|
548
585
|
optionId: BigInt(option.optionId),
|
|
549
586
|
marketAddr: option.market.address,
|
|
@@ -562,18 +599,18 @@ const useUserOptions = (user, active = false) => {
|
|
|
562
599
|
entryPrice: BigInt(option.entryPrice)
|
|
563
600
|
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
564
601
|
},
|
|
565
|
-
enabled: !!
|
|
602
|
+
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
566
603
|
});
|
|
567
604
|
return {
|
|
568
605
|
data: data || [],
|
|
569
606
|
...rest
|
|
570
607
|
};
|
|
571
608
|
};
|
|
572
|
-
const useActiveUserOptions = (
|
|
573
|
-
return useUserOptions(
|
|
609
|
+
const useActiveUserOptions = (userAddr, marketAddr) => {
|
|
610
|
+
return useUserOptions(userAddr, marketAddr, true);
|
|
574
611
|
};
|
|
575
|
-
const useClosedUserOptions = (
|
|
576
|
-
return useUserOptions(
|
|
612
|
+
const useClosedUserOptions = (userAddr, marketAddr) => {
|
|
613
|
+
return useUserOptions(userAddr, marketAddr, false);
|
|
577
614
|
};
|
|
578
615
|
|
|
579
616
|
//#endregion
|