timelock-sdk 0.0.76 → 0.0.78
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 +144 -6
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +962 -509
- package/dist/client.d.ts +1016 -563
- package/dist/client.js +144 -7
- package/dist/client.js.map +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -30,12 +30,6 @@ const UserOptionFieldsFragmentDoc = graphql_tag.default`
|
|
|
30
30
|
market {
|
|
31
31
|
address
|
|
32
32
|
}
|
|
33
|
-
exerciseEvents {
|
|
34
|
-
transactionHash
|
|
35
|
-
}
|
|
36
|
-
mintEvent {
|
|
37
|
-
transactionHash
|
|
38
|
-
}
|
|
39
33
|
optionType
|
|
40
34
|
strikeTick
|
|
41
35
|
entryTick
|
|
@@ -149,6 +143,66 @@ const GetUserMarketOperatorsDocument = graphql_tag.default`
|
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
`;
|
|
146
|
+
const GetOptionEventsDocument = graphql_tag.default`
|
|
147
|
+
query GetOptionEvents($marketAddr: String!, $optionId: numeric!) {
|
|
148
|
+
MintOptionEvent(
|
|
149
|
+
where: {
|
|
150
|
+
option: {
|
|
151
|
+
optionId: {_eq: $optionId}
|
|
152
|
+
market: {address: {_eq: $marketAddr}}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
limit: 1000
|
|
156
|
+
) {
|
|
157
|
+
id
|
|
158
|
+
optionType
|
|
159
|
+
strikeTick
|
|
160
|
+
currentTick
|
|
161
|
+
expiresAt
|
|
162
|
+
premium
|
|
163
|
+
protocolFee
|
|
164
|
+
liquidities
|
|
165
|
+
timestamp
|
|
166
|
+
blockNumber
|
|
167
|
+
transactionHash
|
|
168
|
+
}
|
|
169
|
+
ExerciseOptionEvent(
|
|
170
|
+
where: {
|
|
171
|
+
option: {
|
|
172
|
+
market: {address: {_eq: $marketAddr}}
|
|
173
|
+
optionId: {_eq: $optionId}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
limit: 1000
|
|
177
|
+
) {
|
|
178
|
+
id
|
|
179
|
+
liquidities
|
|
180
|
+
currentTick
|
|
181
|
+
payout
|
|
182
|
+
timestamp
|
|
183
|
+
blockNumber
|
|
184
|
+
transactionHash
|
|
185
|
+
}
|
|
186
|
+
ExtendOptionEvent(
|
|
187
|
+
where: {
|
|
188
|
+
option: {
|
|
189
|
+
market: {address: {_eq: $marketAddr}}
|
|
190
|
+
optionId: {_eq: $optionId}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
limit: 1000
|
|
194
|
+
) {
|
|
195
|
+
id
|
|
196
|
+
premium
|
|
197
|
+
protocolFee
|
|
198
|
+
currentTick
|
|
199
|
+
addedDuration
|
|
200
|
+
timestamp
|
|
201
|
+
blockNumber
|
|
202
|
+
transactionHash
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`;
|
|
152
206
|
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
153
207
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
154
208
|
return {
|
|
@@ -217,6 +271,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
217
271
|
},
|
|
218
272
|
signal
|
|
219
273
|
}), "GetUserMarketOperators", "query", variables);
|
|
274
|
+
},
|
|
275
|
+
GetOptionEvents(variables, requestHeaders, signal) {
|
|
276
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
277
|
+
document: GetOptionEventsDocument,
|
|
278
|
+
variables,
|
|
279
|
+
requestHeaders: {
|
|
280
|
+
...requestHeaders,
|
|
281
|
+
...wrappedRequestHeaders
|
|
282
|
+
},
|
|
283
|
+
signal
|
|
284
|
+
}), "GetOptionEvents", "query", variables);
|
|
220
285
|
}
|
|
221
286
|
};
|
|
222
287
|
}
|
|
@@ -722,6 +787,78 @@ const useSetOperatorPerms = (marketAddr) => {
|
|
|
722
787
|
return (0, __tanstack_react_query.useMutation)({ mutationFn: setOperatorPerms });
|
|
723
788
|
};
|
|
724
789
|
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/hooks/market/useOptionTimeline.ts
|
|
792
|
+
const useOptionTimeline = (marketAddr, optionId) => {
|
|
793
|
+
const { graphqlClient } = useTimelockConfig();
|
|
794
|
+
const normalizedMarketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
|
|
795
|
+
const { data,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
796
|
+
queryKey: [
|
|
797
|
+
"optionTimeline",
|
|
798
|
+
normalizedMarketAddr || "--",
|
|
799
|
+
(optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
|
|
800
|
+
],
|
|
801
|
+
queryFn: async () => {
|
|
802
|
+
if (!graphqlClient || !normalizedMarketAddr || optionId === void 0) return [];
|
|
803
|
+
const result = await graphqlClient.GetOptionEvents({
|
|
804
|
+
marketAddr: normalizedMarketAddr,
|
|
805
|
+
optionId: optionId.toString()
|
|
806
|
+
});
|
|
807
|
+
const mintEvents = result.MintOptionEvent.map((event) => ({
|
|
808
|
+
id: event.id,
|
|
809
|
+
optionType: event.optionType,
|
|
810
|
+
strikeTick: event.strikeTick,
|
|
811
|
+
currentTick: event.currentTick,
|
|
812
|
+
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
813
|
+
premium: BigInt(event.premium),
|
|
814
|
+
protocolFee: BigInt(event.protocolFee),
|
|
815
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
816
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
817
|
+
blockNumber: BigInt(event.blockNumber),
|
|
818
|
+
transactionHash: event.transactionHash
|
|
819
|
+
}));
|
|
820
|
+
const exerciseEvents = result.ExerciseOptionEvent.map((event) => ({
|
|
821
|
+
id: event.id,
|
|
822
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
823
|
+
currentTick: event.currentTick,
|
|
824
|
+
payout: BigInt(event.payout),
|
|
825
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
826
|
+
blockNumber: BigInt(event.blockNumber),
|
|
827
|
+
transactionHash: event.transactionHash
|
|
828
|
+
}));
|
|
829
|
+
const extendEvents = result.ExtendOptionEvent.map((event) => ({
|
|
830
|
+
id: event.id,
|
|
831
|
+
premium: BigInt(event.premium),
|
|
832
|
+
protocolFee: BigInt(event.protocolFee),
|
|
833
|
+
currentTick: event.currentTick,
|
|
834
|
+
addedDuration: BigInt(event.addedDuration),
|
|
835
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
836
|
+
blockNumber: BigInt(event.blockNumber),
|
|
837
|
+
transactionHash: event.transactionHash
|
|
838
|
+
}));
|
|
839
|
+
return [
|
|
840
|
+
...mintEvents.map((data$1) => ({
|
|
841
|
+
type: "mint",
|
|
842
|
+
data: data$1
|
|
843
|
+
})),
|
|
844
|
+
...exerciseEvents.map((data$1) => ({
|
|
845
|
+
type: "exercise",
|
|
846
|
+
data: data$1
|
|
847
|
+
})),
|
|
848
|
+
...extendEvents.map((data$1) => ({
|
|
849
|
+
type: "extend",
|
|
850
|
+
data: data$1
|
|
851
|
+
}))
|
|
852
|
+
].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
|
|
853
|
+
},
|
|
854
|
+
enabled: !!normalizedMarketAddr && optionId !== void 0 && !!graphqlClient
|
|
855
|
+
});
|
|
856
|
+
return {
|
|
857
|
+
data: data || [],
|
|
858
|
+
...rest
|
|
859
|
+
};
|
|
860
|
+
};
|
|
861
|
+
|
|
725
862
|
//#endregion
|
|
726
863
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
727
864
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -1112,6 +1249,7 @@ exports.useMintLiquidity = useMintLiquidity;
|
|
|
1112
1249
|
exports.useMintOption = useMintOption;
|
|
1113
1250
|
exports.useOptionPnl = useOptionPnl;
|
|
1114
1251
|
exports.useOptionPremium = useOptionPremium;
|
|
1252
|
+
exports.useOptionTimeline = useOptionTimeline;
|
|
1115
1253
|
exports.usePoolData = usePoolData;
|
|
1116
1254
|
exports.usePriceAtTick = usePriceAtTick;
|
|
1117
1255
|
exports.usePriceHistory = usePriceHistory;
|