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.js
CHANGED
|
@@ -16,12 +16,17 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
16
16
|
const GetActiveUserOptionsDocument = gql`
|
|
17
17
|
query GetActiveUserOptions($user: String!) {
|
|
18
18
|
UserOption(
|
|
19
|
-
where: {
|
|
19
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: false}}
|
|
20
20
|
limit: 1000
|
|
21
21
|
) {
|
|
22
22
|
id
|
|
23
23
|
optionId
|
|
24
|
-
|
|
24
|
+
owner {
|
|
25
|
+
address
|
|
26
|
+
}
|
|
27
|
+
market {
|
|
28
|
+
address
|
|
29
|
+
}
|
|
25
30
|
exerciseEvents {
|
|
26
31
|
transactionHash
|
|
27
32
|
}
|
|
@@ -39,7 +44,6 @@ const GetActiveUserOptionsDocument = gql`
|
|
|
39
44
|
premium
|
|
40
45
|
protocolFee
|
|
41
46
|
realizedPayout
|
|
42
|
-
marketAddr
|
|
43
47
|
liquiditiesAtOpen
|
|
44
48
|
liquiditiesCurrent
|
|
45
49
|
positionSizeAtOpen
|
|
@@ -51,12 +55,17 @@ const GetActiveUserOptionsDocument = gql`
|
|
|
51
55
|
const GetClosedUserOptionsDocument = gql`
|
|
52
56
|
query GetClosedUserOptions($user: String!) {
|
|
53
57
|
UserOption(
|
|
54
|
-
where: {
|
|
58
|
+
where: {owner: {address: {_eq: $user}}, fullyExercised: {_eq: true}}
|
|
55
59
|
limit: 1000
|
|
56
60
|
) {
|
|
57
61
|
id
|
|
58
62
|
optionId
|
|
59
|
-
|
|
63
|
+
owner {
|
|
64
|
+
address
|
|
65
|
+
}
|
|
66
|
+
market {
|
|
67
|
+
address
|
|
68
|
+
}
|
|
60
69
|
exerciseEvents {
|
|
61
70
|
transactionHash
|
|
62
71
|
}
|
|
@@ -74,7 +83,6 @@ const GetClosedUserOptionsDocument = gql`
|
|
|
74
83
|
premium
|
|
75
84
|
protocolFee
|
|
76
85
|
realizedPayout
|
|
77
|
-
marketAddr
|
|
78
86
|
liquiditiesAtOpen
|
|
79
87
|
liquiditiesCurrent
|
|
80
88
|
positionSizeAtOpen
|
|
@@ -85,8 +93,9 @@ const GetClosedUserOptionsDocument = gql`
|
|
|
85
93
|
`;
|
|
86
94
|
const GetMarketDataDocument = gql`
|
|
87
95
|
query GetMarketData($marketAddr: String!) {
|
|
88
|
-
TimelockMarket(where: {
|
|
96
|
+
TimelockMarket(where: {address: {_eq: $marketAddr}}, limit: 1) {
|
|
89
97
|
id
|
|
98
|
+
address
|
|
90
99
|
optionsCount
|
|
91
100
|
tradersCount
|
|
92
101
|
vault
|
|
@@ -104,6 +113,27 @@ const GetMarketDataDocument = gql`
|
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
`;
|
|
116
|
+
const GetUserMarketOperatorsDocument = gql`
|
|
117
|
+
query GetUserMarketOperators($userAddr: String!, $marketAddr: String!) {
|
|
118
|
+
UserMarketOperator(
|
|
119
|
+
where: {
|
|
120
|
+
user: {address: {_eq: $userAddr}}
|
|
121
|
+
market: {address: {_eq: $marketAddr}}
|
|
122
|
+
}
|
|
123
|
+
limit: 1000
|
|
124
|
+
) {
|
|
125
|
+
id
|
|
126
|
+
operator {
|
|
127
|
+
address
|
|
128
|
+
}
|
|
129
|
+
canExtend
|
|
130
|
+
canExercise
|
|
131
|
+
canTransfer
|
|
132
|
+
canMint
|
|
133
|
+
spendingApproval
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
107
137
|
const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
108
138
|
function getSdk(client, withWrapper = defaultWrapper) {
|
|
109
139
|
return {
|
|
@@ -139,6 +169,17 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
139
169
|
},
|
|
140
170
|
signal
|
|
141
171
|
}), "GetMarketData", "query", variables);
|
|
172
|
+
},
|
|
173
|
+
GetUserMarketOperators(variables, requestHeaders, signal) {
|
|
174
|
+
return withWrapper((wrappedRequestHeaders) => client.request({
|
|
175
|
+
document: GetUserMarketOperatorsDocument,
|
|
176
|
+
variables,
|
|
177
|
+
requestHeaders: {
|
|
178
|
+
...requestHeaders,
|
|
179
|
+
...wrappedRequestHeaders
|
|
180
|
+
},
|
|
181
|
+
signal
|
|
182
|
+
}), "GetUserMarketOperators", "query", variables);
|
|
142
183
|
}
|
|
143
184
|
};
|
|
144
185
|
}
|
|
@@ -527,7 +568,8 @@ const useUserOptions = (user, active = false) => {
|
|
|
527
568
|
return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
|
|
528
569
|
...option,
|
|
529
570
|
optionId: BigInt(option.optionId),
|
|
530
|
-
marketAddr: option.
|
|
571
|
+
marketAddr: option.market.address,
|
|
572
|
+
ownerAddr: option.owner.address,
|
|
531
573
|
optionType: option.optionType,
|
|
532
574
|
createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
|
|
533
575
|
expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
|
|
@@ -607,6 +649,28 @@ const useExtendOption = (marketAddr) => {
|
|
|
607
649
|
};
|
|
608
650
|
};
|
|
609
651
|
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/hooks/market/useUserOperators.ts
|
|
654
|
+
const useUserOperators = (userAddr, marketAddr) => {
|
|
655
|
+
const { graphqlClient } = useTimelockConfig();
|
|
656
|
+
const { data } = useQuery({
|
|
657
|
+
queryKey: ["marketData", marketAddr || "--"],
|
|
658
|
+
queryFn: async () => {
|
|
659
|
+
if (!userAddr || !marketAddr) return void 0;
|
|
660
|
+
return (await graphqlClient.GetUserMarketOperators({
|
|
661
|
+
userAddr: userAddr.toLowerCase(),
|
|
662
|
+
marketAddr: marketAddr.toLowerCase()
|
|
663
|
+
})).UserMarketOperator.map((operator) => ({
|
|
664
|
+
...operator,
|
|
665
|
+
spendingApproval: BigInt(operator.spendingApproval),
|
|
666
|
+
operatorAddr: operator.operator.address.toLowerCase()
|
|
667
|
+
}));
|
|
668
|
+
},
|
|
669
|
+
enabled: !!marketAddr && !!graphqlClient
|
|
670
|
+
});
|
|
671
|
+
return data || {};
|
|
672
|
+
};
|
|
673
|
+
|
|
610
674
|
//#endregion
|
|
611
675
|
//#region src/hooks/pool/usePriceAtTick.ts
|
|
612
676
|
const usePriceAtTick = (tick, poolAddr) => {
|
|
@@ -978,5 +1042,5 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
978
1042
|
};
|
|
979
1043
|
|
|
980
1044
|
//#endregion
|
|
981
|
-
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useVaultData, useVaultTVL };
|
|
1045
|
+
export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
|
982
1046
|
//# sourceMappingURL=client.js.map
|