timelock-sdk 0.0.25 → 0.0.27

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.d.ts CHANGED
@@ -285,7 +285,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
285
285
  __typename: "MintOptionEvent";
286
286
  transactionHash: string;
287
287
  } | null;
288
- }[] | undefined, Error>>;
288
+ }[], Error>>;
289
289
  fetchStatus: _tanstack_query_core0.FetchStatus;
290
290
  promise: Promise<{
291
291
  id: bigint;
@@ -314,7 +314,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
314
314
  __typename: "MintOptionEvent";
315
315
  transactionHash: string;
316
316
  } | null;
317
- }[] | undefined>;
317
+ }[]>;
318
318
  data: {
319
319
  id: bigint;
320
320
  marketAddr: Address;
@@ -393,7 +393,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
393
393
  __typename: "MintOptionEvent";
394
394
  transactionHash: string;
395
395
  } | null;
396
- }[] | undefined, Error>>;
396
+ }[], Error>>;
397
397
  fetchStatus: _tanstack_query_core0.FetchStatus;
398
398
  promise: Promise<{
399
399
  id: bigint;
@@ -422,7 +422,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
422
422
  __typename: "MintOptionEvent";
423
423
  transactionHash: string;
424
424
  } | null;
425
- }[] | undefined>;
425
+ }[]>;
426
426
  data: {
427
427
  id: bigint;
428
428
  marketAddr: Address;
@@ -501,7 +501,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
501
501
  __typename: "MintOptionEvent";
502
502
  transactionHash: string;
503
503
  } | null;
504
- }[] | undefined, Error>>;
504
+ }[], Error>>;
505
505
  fetchStatus: _tanstack_query_core0.FetchStatus;
506
506
  promise: Promise<{
507
507
  id: bigint;
@@ -530,7 +530,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
530
530
  __typename: "MintOptionEvent";
531
531
  transactionHash: string;
532
532
  } | null;
533
- }[] | undefined>;
533
+ }[]>;
534
534
  data: {
535
535
  id: bigint;
536
536
  marketAddr: Address;
@@ -609,7 +609,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
609
609
  __typename: "MintOptionEvent";
610
610
  transactionHash: string;
611
611
  } | null;
612
- }[] | undefined, Error>>;
612
+ }[], Error>>;
613
613
  fetchStatus: _tanstack_query_core0.FetchStatus;
614
614
  promise: Promise<{
615
615
  id: bigint;
@@ -638,7 +638,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
638
638
  __typename: "MintOptionEvent";
639
639
  transactionHash: string;
640
640
  } | null;
641
- }[] | undefined>;
641
+ }[]>;
642
642
  data: {
643
643
  id: bigint;
644
644
  marketAddr: Address;
@@ -717,7 +717,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
717
717
  __typename: "MintOptionEvent";
718
718
  transactionHash: string;
719
719
  } | null;
720
- }[] | undefined, Error>>;
720
+ }[], Error>>;
721
721
  fetchStatus: _tanstack_query_core0.FetchStatus;
722
722
  promise: Promise<{
723
723
  id: bigint;
@@ -746,7 +746,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
746
746
  __typename: "MintOptionEvent";
747
747
  transactionHash: string;
748
748
  } | null;
749
- }[] | undefined>;
749
+ }[]>;
750
750
  data: {
751
751
  id: bigint;
752
752
  marketAddr: Address;
@@ -825,7 +825,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
825
825
  __typename: "MintOptionEvent";
826
826
  transactionHash: string;
827
827
  } | null;
828
- }[] | undefined, Error>>;
828
+ }[], Error>>;
829
829
  fetchStatus: _tanstack_query_core0.FetchStatus;
830
830
  promise: Promise<{
831
831
  id: bigint;
@@ -854,7 +854,7 @@ declare const useUserOptions: (user?: string, active?: boolean) => {
854
854
  __typename: "MintOptionEvent";
855
855
  transactionHash: string;
856
856
  } | null;
857
- }[] | undefined>;
857
+ }[]>;
858
858
  data: {
859
859
  id: bigint;
860
860
  marketAddr: Address;
@@ -934,7 +934,7 @@ declare const useActiveUserOptions: (user?: string) => {
934
934
  __typename: "MintOptionEvent";
935
935
  transactionHash: string;
936
936
  } | null;
937
- }[] | undefined, Error>>;
937
+ }[], Error>>;
938
938
  fetchStatus: _tanstack_query_core0.FetchStatus;
939
939
  promise: Promise<{
940
940
  id: bigint;
@@ -963,7 +963,7 @@ declare const useActiveUserOptions: (user?: string) => {
963
963
  __typename: "MintOptionEvent";
964
964
  transactionHash: string;
965
965
  } | null;
966
- }[] | undefined>;
966
+ }[]>;
967
967
  data: {
968
968
  id: bigint;
969
969
  marketAddr: Address;
@@ -1042,7 +1042,7 @@ declare const useActiveUserOptions: (user?: string) => {
1042
1042
  __typename: "MintOptionEvent";
1043
1043
  transactionHash: string;
1044
1044
  } | null;
1045
- }[] | undefined, Error>>;
1045
+ }[], Error>>;
1046
1046
  fetchStatus: _tanstack_query_core0.FetchStatus;
1047
1047
  promise: Promise<{
1048
1048
  id: bigint;
@@ -1071,7 +1071,7 @@ declare const useActiveUserOptions: (user?: string) => {
1071
1071
  __typename: "MintOptionEvent";
1072
1072
  transactionHash: string;
1073
1073
  } | null;
1074
- }[] | undefined>;
1074
+ }[]>;
1075
1075
  data: {
1076
1076
  id: bigint;
1077
1077
  marketAddr: Address;
@@ -1150,7 +1150,7 @@ declare const useActiveUserOptions: (user?: string) => {
1150
1150
  __typename: "MintOptionEvent";
1151
1151
  transactionHash: string;
1152
1152
  } | null;
1153
- }[] | undefined, Error>>;
1153
+ }[], Error>>;
1154
1154
  fetchStatus: _tanstack_query_core0.FetchStatus;
1155
1155
  promise: Promise<{
1156
1156
  id: bigint;
@@ -1179,7 +1179,7 @@ declare const useActiveUserOptions: (user?: string) => {
1179
1179
  __typename: "MintOptionEvent";
1180
1180
  transactionHash: string;
1181
1181
  } | null;
1182
- }[] | undefined>;
1182
+ }[]>;
1183
1183
  data: {
1184
1184
  id: bigint;
1185
1185
  marketAddr: Address;
@@ -1258,7 +1258,7 @@ declare const useActiveUserOptions: (user?: string) => {
1258
1258
  __typename: "MintOptionEvent";
1259
1259
  transactionHash: string;
1260
1260
  } | null;
1261
- }[] | undefined, Error>>;
1261
+ }[], Error>>;
1262
1262
  fetchStatus: _tanstack_query_core0.FetchStatus;
1263
1263
  promise: Promise<{
1264
1264
  id: bigint;
@@ -1287,7 +1287,7 @@ declare const useActiveUserOptions: (user?: string) => {
1287
1287
  __typename: "MintOptionEvent";
1288
1288
  transactionHash: string;
1289
1289
  } | null;
1290
- }[] | undefined>;
1290
+ }[]>;
1291
1291
  data: {
1292
1292
  id: bigint;
1293
1293
  marketAddr: Address;
@@ -1366,7 +1366,7 @@ declare const useActiveUserOptions: (user?: string) => {
1366
1366
  __typename: "MintOptionEvent";
1367
1367
  transactionHash: string;
1368
1368
  } | null;
1369
- }[] | undefined, Error>>;
1369
+ }[], Error>>;
1370
1370
  fetchStatus: _tanstack_query_core0.FetchStatus;
1371
1371
  promise: Promise<{
1372
1372
  id: bigint;
@@ -1395,7 +1395,7 @@ declare const useActiveUserOptions: (user?: string) => {
1395
1395
  __typename: "MintOptionEvent";
1396
1396
  transactionHash: string;
1397
1397
  } | null;
1398
- }[] | undefined>;
1398
+ }[]>;
1399
1399
  data: {
1400
1400
  id: bigint;
1401
1401
  marketAddr: Address;
@@ -1474,7 +1474,7 @@ declare const useActiveUserOptions: (user?: string) => {
1474
1474
  __typename: "MintOptionEvent";
1475
1475
  transactionHash: string;
1476
1476
  } | null;
1477
- }[] | undefined, Error>>;
1477
+ }[], Error>>;
1478
1478
  fetchStatus: _tanstack_query_core0.FetchStatus;
1479
1479
  promise: Promise<{
1480
1480
  id: bigint;
@@ -1503,7 +1503,7 @@ declare const useActiveUserOptions: (user?: string) => {
1503
1503
  __typename: "MintOptionEvent";
1504
1504
  transactionHash: string;
1505
1505
  } | null;
1506
- }[] | undefined>;
1506
+ }[]>;
1507
1507
  data: {
1508
1508
  id: bigint;
1509
1509
  marketAddr: Address;
@@ -1583,7 +1583,7 @@ declare const useClosedUserOptions: (user?: string) => {
1583
1583
  __typename: "MintOptionEvent";
1584
1584
  transactionHash: string;
1585
1585
  } | null;
1586
- }[] | undefined, Error>>;
1586
+ }[], Error>>;
1587
1587
  fetchStatus: _tanstack_query_core0.FetchStatus;
1588
1588
  promise: Promise<{
1589
1589
  id: bigint;
@@ -1612,7 +1612,7 @@ declare const useClosedUserOptions: (user?: string) => {
1612
1612
  __typename: "MintOptionEvent";
1613
1613
  transactionHash: string;
1614
1614
  } | null;
1615
- }[] | undefined>;
1615
+ }[]>;
1616
1616
  data: {
1617
1617
  id: bigint;
1618
1618
  marketAddr: Address;
@@ -1691,7 +1691,7 @@ declare const useClosedUserOptions: (user?: string) => {
1691
1691
  __typename: "MintOptionEvent";
1692
1692
  transactionHash: string;
1693
1693
  } | null;
1694
- }[] | undefined, Error>>;
1694
+ }[], Error>>;
1695
1695
  fetchStatus: _tanstack_query_core0.FetchStatus;
1696
1696
  promise: Promise<{
1697
1697
  id: bigint;
@@ -1720,7 +1720,7 @@ declare const useClosedUserOptions: (user?: string) => {
1720
1720
  __typename: "MintOptionEvent";
1721
1721
  transactionHash: string;
1722
1722
  } | null;
1723
- }[] | undefined>;
1723
+ }[]>;
1724
1724
  data: {
1725
1725
  id: bigint;
1726
1726
  marketAddr: Address;
@@ -1799,7 +1799,7 @@ declare const useClosedUserOptions: (user?: string) => {
1799
1799
  __typename: "MintOptionEvent";
1800
1800
  transactionHash: string;
1801
1801
  } | null;
1802
- }[] | undefined, Error>>;
1802
+ }[], Error>>;
1803
1803
  fetchStatus: _tanstack_query_core0.FetchStatus;
1804
1804
  promise: Promise<{
1805
1805
  id: bigint;
@@ -1828,7 +1828,7 @@ declare const useClosedUserOptions: (user?: string) => {
1828
1828
  __typename: "MintOptionEvent";
1829
1829
  transactionHash: string;
1830
1830
  } | null;
1831
- }[] | undefined>;
1831
+ }[]>;
1832
1832
  data: {
1833
1833
  id: bigint;
1834
1834
  marketAddr: Address;
@@ -1907,7 +1907,7 @@ declare const useClosedUserOptions: (user?: string) => {
1907
1907
  __typename: "MintOptionEvent";
1908
1908
  transactionHash: string;
1909
1909
  } | null;
1910
- }[] | undefined, Error>>;
1910
+ }[], Error>>;
1911
1911
  fetchStatus: _tanstack_query_core0.FetchStatus;
1912
1912
  promise: Promise<{
1913
1913
  id: bigint;
@@ -1936,7 +1936,7 @@ declare const useClosedUserOptions: (user?: string) => {
1936
1936
  __typename: "MintOptionEvent";
1937
1937
  transactionHash: string;
1938
1938
  } | null;
1939
- }[] | undefined>;
1939
+ }[]>;
1940
1940
  data: {
1941
1941
  id: bigint;
1942
1942
  marketAddr: Address;
@@ -2015,7 +2015,7 @@ declare const useClosedUserOptions: (user?: string) => {
2015
2015
  __typename: "MintOptionEvent";
2016
2016
  transactionHash: string;
2017
2017
  } | null;
2018
- }[] | undefined, Error>>;
2018
+ }[], Error>>;
2019
2019
  fetchStatus: _tanstack_query_core0.FetchStatus;
2020
2020
  promise: Promise<{
2021
2021
  id: bigint;
@@ -2044,7 +2044,7 @@ declare const useClosedUserOptions: (user?: string) => {
2044
2044
  __typename: "MintOptionEvent";
2045
2045
  transactionHash: string;
2046
2046
  } | null;
2047
- }[] | undefined>;
2047
+ }[]>;
2048
2048
  data: {
2049
2049
  id: bigint;
2050
2050
  marketAddr: Address;
@@ -2123,7 +2123,7 @@ declare const useClosedUserOptions: (user?: string) => {
2123
2123
  __typename: "MintOptionEvent";
2124
2124
  transactionHash: string;
2125
2125
  } | null;
2126
- }[] | undefined, Error>>;
2126
+ }[], Error>>;
2127
2127
  fetchStatus: _tanstack_query_core0.FetchStatus;
2128
2128
  promise: Promise<{
2129
2129
  id: bigint;
@@ -2152,7 +2152,7 @@ declare const useClosedUserOptions: (user?: string) => {
2152
2152
  __typename: "MintOptionEvent";
2153
2153
  transactionHash: string;
2154
2154
  } | null;
2155
- }[] | undefined>;
2155
+ }[]>;
2156
2156
  data: {
2157
2157
  id: bigint;
2158
2158
  marketAddr: Address;
package/dist/client.js CHANGED
@@ -172,20 +172,21 @@ const useTimelockConfig = () => {
172
172
 
173
173
  //#endregion
174
174
  //#region src/hooks/market/useMarketData.ts
175
+ const selectMarket = (data) => ({
176
+ ...data.TimelockMarket[0],
177
+ pool: data.TimelockMarket[0].pool,
178
+ vault: data.TimelockMarket[0].vault,
179
+ optionAsset: data.TimelockMarket[0].optionAsset,
180
+ payoutAsset: data.TimelockMarket[0].payoutAsset,
181
+ optionsCount: BigInt(data.TimelockMarket[0].optionsCount),
182
+ tradersCount: BigInt(data.TimelockMarket[0].tradersCount)
183
+ });
175
184
  const useMarketData = (marketAddr) => {
176
185
  const { graphqlClient } = useTimelockConfig();
177
186
  const { data } = useQuery({
178
187
  queryKey: ["marketData", marketAddr || "--"],
179
188
  queryFn: () => graphqlClient.GetMarketData({ marketAddr: marketAddr.toLowerCase() }),
180
- select: (data$1) => ({
181
- ...data$1.TimelockMarket[0],
182
- pool: data$1.TimelockMarket[0].pool,
183
- vault: data$1.TimelockMarket[0].vault,
184
- optionAsset: data$1.TimelockMarket[0].optionAsset,
185
- payoutAsset: data$1.TimelockMarket[0].payoutAsset,
186
- optionsCount: BigInt(data$1.TimelockMarket[0].optionsCount),
187
- tradersCount: BigInt(data$1.TimelockMarket[0].tradersCount)
188
- }),
189
+ select: selectMarket,
189
190
  enabled: !!marketAddr && !!graphqlClient
190
191
  });
191
192
  return data || {};
@@ -434,38 +435,39 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration) => {
434
435
 
435
436
  //#endregion
436
437
  //#region src/hooks/market/useUserOptions.ts
438
+ const selectOptions = (data) => {
439
+ if (!(data === null || data === void 0 ? void 0 : data.UserOption)) return [];
440
+ return data.UserOption.map((option) => ({
441
+ ...option,
442
+ id: BigInt(option.id),
443
+ marketAddr: option.marketAddr,
444
+ optionType: option.optionType,
445
+ createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
446
+ expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
447
+ premiumPaid: BigInt(option.premiumPaid),
448
+ realizedPayout: BigInt(option.realizedPayout),
449
+ liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
450
+ liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
451
+ positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
452
+ positionSizeCurrent: BigInt(option.positionSizeCurrent),
453
+ strikePrice: BigInt(option.strikePrice),
454
+ entryPrice: BigInt(option.entryPrice)
455
+ })).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
456
+ };
437
457
  const useUserOptions = (user, active = false) => {
438
458
  const { graphqlClient } = useTimelockConfig();
439
- const { data: options,...rest } = useQuery({
459
+ const { data,...rest } = useQuery({
440
460
  queryKey: [
441
461
  "userTrades",
442
462
  user || "--",
443
463
  active
444
464
  ],
445
465
  queryFn: () => active ? graphqlClient === null || graphqlClient === void 0 ? void 0 : graphqlClient.GetActiveUserOptions({ user: user.toLowerCase() }) : graphqlClient === null || graphqlClient === void 0 ? void 0 : graphqlClient.GetClosedUserOptions({ user: user.toLowerCase() }),
446
- select: (data) => {
447
- var _data$UserOption;
448
- return data === null || data === void 0 || (_data$UserOption = data.UserOption) === null || _data$UserOption === void 0 ? void 0 : _data$UserOption.map((option) => ({
449
- ...option,
450
- id: BigInt(option.id),
451
- marketAddr: option.marketAddr,
452
- optionType: option.optionType,
453
- createdAt: /* @__PURE__ */ new Date(Number(option.createdAt) * 1e3),
454
- expiresAt: /* @__PURE__ */ new Date(Number(option.expiresAt) * 1e3),
455
- premiumPaid: BigInt(option.premiumPaid),
456
- realizedPayout: BigInt(option.realizedPayout),
457
- liquiditiesAtOpen: option.liquiditiesAtOpen.map((liquidity) => BigInt(liquidity)),
458
- liquiditiesCurrent: option.liquiditiesCurrent.map((liquidity) => BigInt(liquidity)),
459
- positionSizeAtOpen: BigInt(option.positionSizeAtOpen),
460
- positionSizeCurrent: BigInt(option.positionSizeCurrent),
461
- strikePrice: BigInt(option.strikePrice),
462
- entryPrice: BigInt(option.entryPrice)
463
- }));
464
- },
466
+ select: selectOptions,
465
467
  enabled: !!user && !!graphqlClient
466
468
  });
467
469
  return {
468
- data: useMemo(() => (options === null || options === void 0 ? void 0 : options.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())) || [], [options]),
470
+ data: data || [],
469
471
  ...rest
470
472
  };
471
473
  };