timelock-sdk 0.0.61 → 0.0.63
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 +80 -8
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +985 -119
- package/dist/client.d.ts +993 -127
- package/dist/client.js +80 -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,35 @@ 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,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
664
|
+
queryKey: [
|
|
665
|
+
"userOperators",
|
|
666
|
+
userAddr || "--",
|
|
667
|
+
marketAddr || "--"
|
|
668
|
+
],
|
|
669
|
+
queryFn: async () => {
|
|
670
|
+
if (!userAddr || !marketAddr) return void 0;
|
|
671
|
+
return (await graphqlClient.GetUserMarketOperators({
|
|
672
|
+
userAddr: userAddr.toLowerCase(),
|
|
673
|
+
marketAddr: marketAddr.toLowerCase()
|
|
674
|
+
})).UserMarketOperator.map((operator) => ({
|
|
675
|
+
...operator,
|
|
676
|
+
spendingApproval: BigInt(operator.spendingApproval),
|
|
677
|
+
operatorAddr: operator.operator.address.toLowerCase()
|
|
678
|
+
}));
|
|
679
|
+
},
|
|
680
|
+
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
681
|
+
});
|
|
682
|
+
return {
|
|
683
|
+
...rest,
|
|
684
|
+
data: data || {}
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
|
|
617
688
|
//#endregion
|
|
618
689
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
619
690
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -1007,6 +1078,7 @@ exports.usePoolData = usePoolData;
|
|
|
1007
1078
|
exports.usePriceAtTick = usePriceAtTick;
|
|
1008
1079
|
exports.usePriceHistory = usePriceHistory;
|
|
1009
1080
|
exports.useTimelockConfig = useTimelockConfig;
|
|
1081
|
+
exports.useUserOperators = useUserOperators;
|
|
1010
1082
|
exports.useVaultData = useVaultData;
|
|
1011
1083
|
exports.useVaultTVL = useVaultTVL;
|
|
1012
1084
|
//# sourceMappingURL=client.cjs.map
|