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.cjs
CHANGED
|
@@ -20,83 +20,91 @@ let __tanstack_react_query = require("@tanstack/react-query");
|
|
|
20
20
|
__tanstack_react_query = require_numberUtils.__toESM(__tanstack_react_query);
|
|
21
21
|
|
|
22
22
|
//#region src/generated/graphql.ts
|
|
23
|
+
const UserOptionFieldsFragmentDoc = graphql_tag.default`
|
|
24
|
+
fragment UserOptionFields on UserOption {
|
|
25
|
+
id
|
|
26
|
+
optionId
|
|
27
|
+
owner {
|
|
28
|
+
address
|
|
29
|
+
}
|
|
30
|
+
market {
|
|
31
|
+
address
|
|
32
|
+
}
|
|
33
|
+
exerciseEvents {
|
|
34
|
+
transactionHash
|
|
35
|
+
}
|
|
36
|
+
mintEvent {
|
|
37
|
+
transactionHash
|
|
38
|
+
}
|
|
39
|
+
optionType
|
|
40
|
+
strikeTick
|
|
41
|
+
entryTick
|
|
42
|
+
startTick
|
|
43
|
+
strikePrice
|
|
44
|
+
entryPrice
|
|
45
|
+
expiresAt
|
|
46
|
+
createdAt
|
|
47
|
+
premium
|
|
48
|
+
protocolFee
|
|
49
|
+
realizedPayout
|
|
50
|
+
liquiditiesAtOpen
|
|
51
|
+
liquiditiesCurrent
|
|
52
|
+
positionSizeAtOpen
|
|
53
|
+
positionSizeCurrent
|
|
54
|
+
fullyExercised
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
23
57
|
const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
24
|
-
query GetActiveUserOptions($
|
|
58
|
+
query GetActiveUserOptions($userAddr: String!) {
|
|
25
59
|
UserOption(
|
|
26
|
-
where: {owner: {address: {_eq: $
|
|
60
|
+
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: false}}
|
|
27
61
|
limit: 1000
|
|
28
62
|
) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
transactionHash
|
|
63
|
+
...UserOptionFields
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
${UserOptionFieldsFragmentDoc}
|
|
67
|
+
`;
|
|
68
|
+
const GetActiveUserOptionsByMarketDocument = graphql_tag.default`
|
|
69
|
+
query GetActiveUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
70
|
+
UserOption(
|
|
71
|
+
where: {
|
|
72
|
+
owner: {address: {_eq: $userAddr}}
|
|
73
|
+
fullyExercised: {_eq: false}
|
|
74
|
+
market: {address: {_eq: $marketAddr}}
|
|
42
75
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
startTick
|
|
47
|
-
strikePrice
|
|
48
|
-
entryPrice
|
|
49
|
-
expiresAt
|
|
50
|
-
createdAt
|
|
51
|
-
premium
|
|
52
|
-
protocolFee
|
|
53
|
-
realizedPayout
|
|
54
|
-
liquiditiesAtOpen
|
|
55
|
-
liquiditiesCurrent
|
|
56
|
-
positionSizeAtOpen
|
|
57
|
-
positionSizeCurrent
|
|
58
|
-
fullyExercised
|
|
76
|
+
limit: 1000
|
|
77
|
+
) {
|
|
78
|
+
...UserOptionFields
|
|
59
79
|
}
|
|
60
80
|
}
|
|
81
|
+
${UserOptionFieldsFragmentDoc}
|
|
61
82
|
`;
|
|
62
83
|
const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
63
|
-
query GetClosedUserOptions($
|
|
84
|
+
query GetClosedUserOptions($userAddr: String!) {
|
|
64
85
|
UserOption(
|
|
65
|
-
where: {owner: {address: {_eq: $
|
|
86
|
+
where: {owner: {address: {_eq: $userAddr}}, fullyExercised: {_eq: true}}
|
|
66
87
|
limit: 1000
|
|
67
88
|
) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
transactionHash
|
|
89
|
+
...UserOptionFields
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
${UserOptionFieldsFragmentDoc}
|
|
93
|
+
`;
|
|
94
|
+
const GetClosedUserOptionsByMarketDocument = graphql_tag.default`
|
|
95
|
+
query GetClosedUserOptionsByMarket($userAddr: String!, $marketAddr: String!) {
|
|
96
|
+
UserOption(
|
|
97
|
+
where: {
|
|
98
|
+
owner: {address: {_eq: $userAddr}}
|
|
99
|
+
fullyExercised: {_eq: true}
|
|
100
|
+
market: {address: {_eq: $marketAddr}}
|
|
81
101
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
startTick
|
|
86
|
-
strikePrice
|
|
87
|
-
entryPrice
|
|
88
|
-
expiresAt
|
|
89
|
-
createdAt
|
|
90
|
-
premium
|
|
91
|
-
protocolFee
|
|
92
|
-
realizedPayout
|
|
93
|
-
liquiditiesAtOpen
|
|
94
|
-
liquiditiesCurrent
|
|
95
|
-
positionSizeAtOpen
|
|
96
|
-
positionSizeCurrent
|
|
97
|
-
fullyExercised
|
|
102
|
+
limit: 1000
|
|
103
|
+
) {
|
|
104
|
+
...UserOptionFields
|
|
98
105
|
}
|
|
99
106
|
}
|
|
107
|
+
${UserOptionFieldsFragmentDoc}
|
|
100
108
|
`;
|
|
101
109
|
const GetMarketDataDocument = graphql_tag.default`
|
|
102
110
|
query GetMarketData($marketAddr: String!) {
|
|
@@ -155,6 +163,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
155
163
|
signal
|
|
156
164
|
}), "GetActiveUserOptions", "query", variables);
|
|
157
165
|
},
|
|
166
|
+
GetActiveUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
167
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
168
|
+
document: GetActiveUserOptionsByMarketDocument,
|
|
169
|
+
variables,
|
|
170
|
+
requestHeaders: {
|
|
171
|
+
...requestHeaders,
|
|
172
|
+
...wrappedRequestHeaders
|
|
173
|
+
},
|
|
174
|
+
signal
|
|
175
|
+
}), "GetActiveUserOptionsByMarket", "query", variables);
|
|
176
|
+
},
|
|
158
177
|
GetClosedUserOptions(variables, requestHeaders, signal) {
|
|
159
178
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
160
179
|
document: GetClosedUserOptionsDocument,
|
|
@@ -166,6 +185,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
166
185
|
signal
|
|
167
186
|
}), "GetClosedUserOptions", "query", variables);
|
|
168
187
|
},
|
|
188
|
+
GetClosedUserOptionsByMarket(variables, requestHeaders, signal) {
|
|
189
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
190
|
+
document: GetClosedUserOptionsByMarketDocument,
|
|
191
|
+
variables,
|
|
192
|
+
requestHeaders: {
|
|
193
|
+
...requestHeaders,
|
|
194
|
+
...wrappedRequestHeaders
|
|
195
|
+
},
|
|
196
|
+
signal
|
|
197
|
+
}), "GetClosedUserOptionsByMarket", "query", variables);
|
|
198
|
+
},
|
|
169
199
|
GetMarketData(variables, requestHeaders, signal) {
|
|
170
200
|
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
171
201
|
document: GetMarketDataDocument,
|
|
@@ -539,18 +569,24 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, r
|
|
|
539
569
|
|
|
540
570
|
//#endregion
|
|
541
571
|
//#region src/hooks/market/useUserOptions.ts
|
|
542
|
-
const useUserOptions = (
|
|
572
|
+
const useUserOptions = (userAddr, marketAddr, active = false) => {
|
|
543
573
|
const { graphqlClient } = useTimelockConfig();
|
|
544
|
-
|
|
574
|
+
userAddr = userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase();
|
|
545
575
|
const { data,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
546
576
|
queryKey: [
|
|
547
577
|
"userOptions",
|
|
548
|
-
|
|
578
|
+
userAddr || "--",
|
|
549
579
|
active
|
|
550
580
|
],
|
|
551
581
|
queryFn: async () => {
|
|
552
|
-
if (!graphqlClient || !
|
|
553
|
-
return (active ?
|
|
582
|
+
if (!graphqlClient || !userAddr || !marketAddr) return [];
|
|
583
|
+
return (await (marketAddr === "*" ? active ? graphqlClient.GetActiveUserOptions({ userAddr }) : graphqlClient.GetClosedUserOptions({ userAddr }) : active ? graphqlClient.GetActiveUserOptionsByMarket({
|
|
584
|
+
userAddr,
|
|
585
|
+
marketAddr
|
|
586
|
+
}) : graphqlClient.GetClosedUserOptionsByMarket({
|
|
587
|
+
userAddr,
|
|
588
|
+
marketAddr
|
|
589
|
+
}))).UserOption.map((option) => ({
|
|
554
590
|
...option,
|
|
555
591
|
optionId: BigInt(option.optionId),
|
|
556
592
|
marketAddr: option.market.address,
|
|
@@ -569,18 +605,18 @@ const useUserOptions = (user, active = false) => {
|
|
|
569
605
|
entryPrice: BigInt(option.entryPrice)
|
|
570
606
|
})).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
571
607
|
},
|
|
572
|
-
enabled: !!
|
|
608
|
+
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
573
609
|
});
|
|
574
610
|
return {
|
|
575
611
|
data: data || [],
|
|
576
612
|
...rest
|
|
577
613
|
};
|
|
578
614
|
};
|
|
579
|
-
const useActiveUserOptions = (
|
|
580
|
-
return useUserOptions(
|
|
615
|
+
const useActiveUserOptions = (userAddr, marketAddr) => {
|
|
616
|
+
return useUserOptions(userAddr, marketAddr, true);
|
|
581
617
|
};
|
|
582
|
-
const useClosedUserOptions = (
|
|
583
|
-
return useUserOptions(
|
|
618
|
+
const useClosedUserOptions = (userAddr, marketAddr) => {
|
|
619
|
+
return useUserOptions(userAddr, marketAddr, false);
|
|
584
620
|
};
|
|
585
621
|
|
|
586
622
|
//#endregion
|
|
@@ -1059,6 +1095,7 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
1059
1095
|
exports.TimelockMarketProvider = TimelockMarketProvider;
|
|
1060
1096
|
exports.batchGetAmountsFromLiquidity = batchGetAmountsFromLiquidity;
|
|
1061
1097
|
exports.useActiveUserOptions = useActiveUserOptions;
|
|
1098
|
+
exports.useApproval = useApproval;
|
|
1062
1099
|
exports.useBurnLiquidity = useBurnLiquidity;
|
|
1063
1100
|
exports.useClosedUserOptions = useClosedUserOptions;
|
|
1064
1101
|
exports.useCurrentMarket = useCurrentMarket;
|