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.js
CHANGED
|
@@ -23,12 +23,6 @@ const UserOptionFieldsFragmentDoc = gql`
|
|
|
23
23
|
market {
|
|
24
24
|
address
|
|
25
25
|
}
|
|
26
|
-
exerciseEvents {
|
|
27
|
-
transactionHash
|
|
28
|
-
}
|
|
29
|
-
mintEvent {
|
|
30
|
-
transactionHash
|
|
31
|
-
}
|
|
32
26
|
optionType
|
|
33
27
|
strikeTick
|
|
34
28
|
entryTick
|
|
@@ -142,6 +136,66 @@ const GetUserMarketOperatorsDocument = gql`
|
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
`;
|
|
139
|
+
const GetOptionEventsDocument = gql`
|
|
140
|
+
query GetOptionEvents($marketAddr: String!, $optionId: numeric!) {
|
|
141
|
+
MintOptionEvent(
|
|
142
|
+
where: {
|
|
143
|
+
option: {
|
|
144
|
+
optionId: {_eq: $optionId}
|
|
145
|
+
market: {address: {_eq: $marketAddr}}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
limit: 1000
|
|
149
|
+
) {
|
|
150
|
+
id
|
|
151
|
+
optionType
|
|
152
|
+
strikeTick
|
|
153
|
+
currentTick
|
|
154
|
+
expiresAt
|
|
155
|
+
premium
|
|
156
|
+
protocolFee
|
|
157
|
+
liquidities
|
|
158
|
+
timestamp
|
|
159
|
+
blockNumber
|
|
160
|
+
transactionHash
|
|
161
|
+
}
|
|
162
|
+
ExerciseOptionEvent(
|
|
163
|
+
where: {
|
|
164
|
+
option: {
|
|
165
|
+
market: {address: {_eq: $marketAddr}}
|
|
166
|
+
optionId: {_eq: $optionId}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
limit: 1000
|
|
170
|
+
) {
|
|
171
|
+
id
|
|
172
|
+
liquidities
|
|
173
|
+
currentTick
|
|
174
|
+
payout
|
|
175
|
+
timestamp
|
|
176
|
+
blockNumber
|
|
177
|
+
transactionHash
|
|
178
|
+
}
|
|
179
|
+
ExtendOptionEvent(
|
|
180
|
+
where: {
|
|
181
|
+
option: {
|
|
182
|
+
market: {address: {_eq: $marketAddr}}
|
|
183
|
+
optionId: {_eq: $optionId}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
limit: 1000
|
|
187
|
+
) {
|
|
188
|
+
id
|
|
189
|
+
premium
|
|
190
|
+
protocolFee
|
|
191
|
+
currentTick
|
|
192
|
+
addedDuration
|
|
193
|
+
timestamp
|
|
194
|
+
blockNumber
|
|
195
|
+
transactionHash
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
145
199
|
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
146
200
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
147
201
|
return {
|
|
@@ -210,6 +264,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
210
264
|
},
|
|
211
265
|
signal
|
|
212
266
|
}), "GetUserMarketOperators", "query", variables);
|
|
267
|
+
},
|
|
268
|
+
GetOptionEvents(variables, requestHeaders, signal) {
|
|
269
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
270
|
+
document: GetOptionEventsDocument,
|
|
271
|
+
variables,
|
|
272
|
+
requestHeaders: {
|
|
273
|
+
...requestHeaders,
|
|
274
|
+
...wrappedRequestHeaders
|
|
275
|
+
},
|
|
276
|
+
signal
|
|
277
|
+
}), "GetOptionEvents", "query", variables);
|
|
213
278
|
}
|
|
214
279
|
};
|
|
215
280
|
}
|
|
@@ -715,6 +780,78 @@ const useSetOperatorPerms = (marketAddr) => {
|
|
|
715
780
|
return useMutation({ mutationFn: setOperatorPerms });
|
|
716
781
|
};
|
|
717
782
|
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/hooks/market/useOptionTimeline.ts
|
|
785
|
+
const useOptionTimeline = (marketAddr, optionId) => {
|
|
786
|
+
const { graphqlClient } = useTimelockConfig();
|
|
787
|
+
const normalizedMarketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
|
|
788
|
+
const { data,...rest } = useQuery({
|
|
789
|
+
queryKey: [
|
|
790
|
+
"optionTimeline",
|
|
791
|
+
normalizedMarketAddr || "--",
|
|
792
|
+
(optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
|
|
793
|
+
],
|
|
794
|
+
queryFn: async () => {
|
|
795
|
+
if (!graphqlClient || !normalizedMarketAddr || optionId === void 0) return [];
|
|
796
|
+
const result = await graphqlClient.GetOptionEvents({
|
|
797
|
+
marketAddr: normalizedMarketAddr,
|
|
798
|
+
optionId: optionId.toString()
|
|
799
|
+
});
|
|
800
|
+
const mintEvents = result.MintOptionEvent.map((event) => ({
|
|
801
|
+
id: event.id,
|
|
802
|
+
optionType: event.optionType,
|
|
803
|
+
strikeTick: event.strikeTick,
|
|
804
|
+
currentTick: event.currentTick,
|
|
805
|
+
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
806
|
+
premium: BigInt(event.premium),
|
|
807
|
+
protocolFee: BigInt(event.protocolFee),
|
|
808
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
809
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
810
|
+
blockNumber: BigInt(event.blockNumber),
|
|
811
|
+
transactionHash: event.transactionHash
|
|
812
|
+
}));
|
|
813
|
+
const exerciseEvents = result.ExerciseOptionEvent.map((event) => ({
|
|
814
|
+
id: event.id,
|
|
815
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
816
|
+
currentTick: event.currentTick,
|
|
817
|
+
payout: BigInt(event.payout),
|
|
818
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
819
|
+
blockNumber: BigInt(event.blockNumber),
|
|
820
|
+
transactionHash: event.transactionHash
|
|
821
|
+
}));
|
|
822
|
+
const extendEvents = result.ExtendOptionEvent.map((event) => ({
|
|
823
|
+
id: event.id,
|
|
824
|
+
premium: BigInt(event.premium),
|
|
825
|
+
protocolFee: BigInt(event.protocolFee),
|
|
826
|
+
currentTick: event.currentTick,
|
|
827
|
+
addedDuration: BigInt(event.addedDuration),
|
|
828
|
+
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
829
|
+
blockNumber: BigInt(event.blockNumber),
|
|
830
|
+
transactionHash: event.transactionHash
|
|
831
|
+
}));
|
|
832
|
+
return [
|
|
833
|
+
...mintEvents.map((data$1) => ({
|
|
834
|
+
type: "mint",
|
|
835
|
+
data: data$1
|
|
836
|
+
})),
|
|
837
|
+
...exerciseEvents.map((data$1) => ({
|
|
838
|
+
type: "exercise",
|
|
839
|
+
data: data$1
|
|
840
|
+
})),
|
|
841
|
+
...extendEvents.map((data$1) => ({
|
|
842
|
+
type: "extend",
|
|
843
|
+
data: data$1
|
|
844
|
+
}))
|
|
845
|
+
].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
|
|
846
|
+
},
|
|
847
|
+
enabled: !!normalizedMarketAddr && optionId !== void 0 && !!graphqlClient
|
|
848
|
+
});
|
|
849
|
+
return {
|
|
850
|
+
data: data || [],
|
|
851
|
+
...rest
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
|
|
718
855
|
//#endregion
|
|
719
856
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
720
857
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -1086,5 +1223,5 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
1086
1223
|
};
|
|
1087
1224
|
|
|
1088
1225
|
//#endregion
|
|
1089
|
-
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
1226
|
+
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, useOptionTimeline, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
1090
1227
|
//# sourceMappingURL=client.js.map
|