timelock-sdk 0.0.61 → 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/client.cjs +73 -8
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +602 -119
- package/dist/client.d.ts +612 -129
- package/dist/client.js +73 -9
- package/dist/client.js.map +1 -1
- package/dist/{index-CE9Z8aoZ.d.ts → index-BIkdgG3y.d.ts} +92 -92
- package/dist/package.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -23,12 +23,17 @@ __tanstack_react_query = require_numberUtils.__toESM(__tanstack_react_query);
|
|
|
23
23
|
const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
24
24
|
query GetActiveUserOptions($user: String!) {
|
|
25
25
|
UserOption(
|
|
26
|
-
where: {
|
|
26
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: false}}
|
|
27
27
|
limit: 1000
|
|
28
28
|
) {
|
|
29
29
|
id
|
|
30
30
|
optionId
|
|
31
|
-
|
|
31
|
+
owner {
|
|
32
|
+
address
|
|
33
|
+
}
|
|
34
|
+
market {
|
|
35
|
+
address
|
|
36
|
+
}
|
|
32
37
|
exerciseEvents {
|
|
33
38
|
transactionHash
|
|
34
39
|
}
|
|
@@ -46,7 +51,6 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
|
46
51
|
premium
|
|
47
52
|
protocolFee
|
|
48
53
|
realizedPayout
|
|
49
|
-
marketAddr
|
|
50
54
|
liquiditiesAtOpen
|
|
51
55
|
liquiditiesCurrent
|
|
52
56
|
positionSizeAtOpen
|
|
@@ -58,12 +62,17 @@ const GetActiveUserOptionsDocument = graphql_tag.default`
|
|
|
58
62
|
const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
59
63
|
query GetClosedUserOptions($user: String!) {
|
|
60
64
|
UserOption(
|
|
61
|
-
where: {
|
|
65
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: true}}
|
|
62
66
|
limit: 1000
|
|
63
67
|
) {
|
|
64
68
|
id
|
|
65
69
|
optionId
|
|
66
|
-
|
|
70
|
+
owner {
|
|
71
|
+
address
|
|
72
|
+
}
|
|
73
|
+
market {
|
|
74
|
+
address
|
|
75
|
+
}
|
|
67
76
|
exerciseEvents {
|
|
68
77
|
transactionHash
|
|
69
78
|
}
|
|
@@ -81,7 +90,6 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
|
81
90
|
premium
|
|
82
91
|
protocolFee
|
|
83
92
|
realizedPayout
|
|
84
|
-
marketAddr
|
|
85
93
|
liquiditiesAtOpen
|
|
86
94
|
liquiditiesCurrent
|
|
87
95
|
positionSizeAtOpen
|
|
@@ -92,8 +100,9 @@ const GetClosedUserOptionsDocument = graphql_tag.default`
|
|
|
92
100
|
`;
|
|
93
101
|
const GetMarketDataDocument = graphql_tag.default`
|
|
94
102
|
query GetMarketData($marketAddr: String!) {
|
|
95
|
-
TimelockMarket(where: {
|
|
103
|
+
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
96
104
|
id
|
|
105
|
+
address
|
|
97
106
|
optionsCount
|
|
98
107
|
tradersCount
|
|
99
108
|
vault
|
|
@@ -111,6 +120,27 @@ const GetMarketDataDocument = graphql_tag.default`
|
|
|
111
120
|
}
|
|
112
121
|
}
|
|
113
122
|
`;
|
|
123
|
+
const GetUserMarketOperatorsDocument = graphql_tag.default`
|
|
124
|
+
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
125
|
+
UserMarketOperator(
|
|
126
|
+
where: {
|
|
127
|
+
user: {address: {_eq: $userAddr}}
|
|
128
|
+
market: {address: {_eq: $marketAddr}}
|
|
129
|
+
}
|
|
130
|
+
limit: 1000
|
|
131
|
+
) {
|
|
132
|
+
id
|
|
133
|
+
operator {
|
|
134
|
+
address
|
|
135
|
+
}
|
|
136
|
+
canExtend
|
|
137
|
+
canExercise
|
|
138
|
+
canTransfer
|
|
139
|
+
canMint
|
|
140
|
+
spendingApproval
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
114
144
|
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
115
145
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
116
146
|
return {
|
|
@@ -146,6 +176,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
146
176
|
},
|
|
147
177
|
signal
|
|
148
178
|
}), "GetMarketData", "query", variables);
|
|
179
|
+
},
|
|
180
|
+
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
181
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
182
|
+
document: GetUserMarketOperatorsDocument,
|
|
183
|
+
variables,
|
|
184
|
+
requestHeaders: {
|
|
185
|
+
...requestHeaders,
|
|
186
|
+
...wrappedRequestHeaders
|
|
187
|
+
},
|
|
188
|
+
signal
|
|
189
|
+
}), "GetUserMarketOperators", "query", variables);
|
|
149
190
|
}
|
|
150
191
|
};
|
|
151
192
|
}
|
|
@@ -534,7 +575,8 @@ const useUserOptions = (user, active = false) => {
|
|
|
534
575
|
return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
|
|
535
576
|
...option,
|
|
536
577
|
optionId: BigInt(option.optionId),
|
|
537
|
-
marketAddr: option.
|
|
578
|
+
marketAddr: option.market.address,
|
|
579
|
+
ownerAddr: option.owner.address,
|
|
538
580
|
optionType: option.optionType,
|
|
539
581
|
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
540
582
|
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
@@ -614,6 +656,28 @@ const useExtendOption = (marketAddr) => {
|
|
|
614
656
|
};
|
|
615
657
|
};
|
|
616
658
|
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/hooks/market/useUserOperators.ts
|
|
661
|
+
const useUserOperators = (userAddr, marketAddr) => {
|
|
662
|
+
const { graphqlClient } = useTimelockConfig();
|
|
663
|
+
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
664
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
665
|
+
queryFn: async () => {
|
|
666
|
+
if (!userAddr || !marketAddr) return void 0;
|
|
667
|
+
return (await graphqlClient.GetUserMarketOperators({
|
|
668
|
+
userAddr: userAddr.toLowerCase(),
|
|
669
|
+
marketAddr: marketAddr.toLowerCase()
|
|
670
|
+
})).UserMarketOperator.map((operator) => ({
|
|
671
|
+
...operator,
|
|
672
|
+
spendingApproval: BigInt(operator.spendingApproval),
|
|
673
|
+
operatorAddr: operator.operator.address.toLowerCase()
|
|
674
|
+
}));
|
|
675
|
+
},
|
|
676
|
+
enabled: !!marketAddr && !!graphqlClient
|
|
677
|
+
});
|
|
678
|
+
return data || {};
|
|
679
|
+
};
|
|
680
|
+
|
|
617
681
|
//#endregion
|
|
618
682
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
619
683
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -1007,6 +1071,7 @@ exports.usePoolData = usePoolData;
|
|
|
1007
1071
|
exports.usePriceAtTick = usePriceAtTick;
|
|
1008
1072
|
exports.usePriceHistory = usePriceHistory;
|
|
1009
1073
|
exports.useTimelockConfig = useTimelockConfig;
|
|
1074
|
+
exports.useUserOperators = useUserOperators;
|
|
1010
1075
|
exports.useVaultData = useVaultData;
|
|
1011
1076
|
exports.useVaultTVL = useVaultTVL;
|
|
1012
1077
|
//# sourceMappingURL=client.cjs.map
|