timelock-sdk 0.0.9 → 0.0.11
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 +21 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +94 -82
- package/dist/client.d.ts +90 -78
- package/dist/client.js +23 -3
- package/dist/client.js.map +1 -1
- package/dist/{index-sG69Fv-T.d.ts → index-CnVjbZPl.d.ts} +124 -121
- package/dist/{index-DDAsERk2.d.cts → index-tyVRQhLR.d.cts} +17 -14
- package/dist/numberUtils-DB5N1e6G.js.map +1 -1
- package/dist/numberUtils-DRGhFDHZ.cjs.map +1 -1
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Amount, TimelockMarket, TimelockVault, UniswapMathLens, UniswapPool } from "./index-
|
|
2
|
-
import * as
|
|
1
|
+
import { Amount, TimelockMarket, TimelockMarketData, TimelockVault, UniswapMathLens, UniswapPool } from "./index-CnVjbZPl.js";
|
|
2
|
+
import * as viem382 from "viem";
|
|
3
3
|
import { Address } from "viem";
|
|
4
4
|
import React, { ReactNode } from "react";
|
|
5
5
|
import { GraphQLClient } from "graphql-request";
|
|
6
|
+
import { NonUndefinedGuard } from "@tanstack/react-query";
|
|
6
7
|
import "graphql";
|
|
7
8
|
import * as _wagmi_core0 from "@wagmi/core";
|
|
8
9
|
import * as _tanstack_query_core0 from "@tanstack/query-core";
|
|
@@ -120,25 +121,30 @@ type GetClosedUserOptionsQuery = {
|
|
|
120
121
|
} | null;
|
|
121
122
|
}>;
|
|
122
123
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type TimelockMarketData = Required<ReturnType<typeof useMarketData>>;
|
|
126
|
-
declare const useMarketData: (market?: Address | TimelockMarket) => Partial<{
|
|
127
|
-
optionAssetIsToken0: boolean;
|
|
128
|
-
vault: `0x${string}`;
|
|
129
|
-
pool: `0x${string}`;
|
|
130
|
-
optionAsset: `0x${string}`;
|
|
131
|
-
payoutAsset: `0x${string}`;
|
|
132
|
-
optionAssetDecimals: number;
|
|
133
|
-
payoutAssetDecimals: number;
|
|
134
|
-
optionAssetSymbol: string;
|
|
135
|
-
payoutAssetSymbol: string;
|
|
136
|
-
optionAssetName: string;
|
|
137
|
-
payoutAssetName: string;
|
|
138
|
-
optionsCount: bigint;
|
|
139
|
-
} & {
|
|
140
|
-
address: Address;
|
|
124
|
+
type GetMarketDataQueryVariables = Exact<{
|
|
125
|
+
marketAddr: Scalars['String']['input'];
|
|
141
126
|
}>;
|
|
127
|
+
type GetMarketDataQuery = {
|
|
128
|
+
__typename: 'query_root';
|
|
129
|
+
TimelockMarket: Array<{
|
|
130
|
+
__typename: 'TimelockMarket';
|
|
131
|
+
id: string;
|
|
132
|
+
optionsCount: any;
|
|
133
|
+
tradersCount: any;
|
|
134
|
+
vault: string;
|
|
135
|
+
pool: string;
|
|
136
|
+
tickSpacing: number;
|
|
137
|
+
optionAssetIsToken0: boolean;
|
|
138
|
+
optionAsset: string;
|
|
139
|
+
payoutAsset: string;
|
|
140
|
+
optionAssetDecimals: number;
|
|
141
|
+
payoutAssetDecimals: number;
|
|
142
|
+
optionAssetSymbol: string;
|
|
143
|
+
payoutAssetSymbol: string;
|
|
144
|
+
optionAssetName: string;
|
|
145
|
+
payoutAssetName: string;
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
142
148
|
//#endregion
|
|
143
149
|
//#region src/providers/TimelockMarketProvider.d.ts
|
|
144
150
|
declare const TimelockMarketProvider: ({
|
|
@@ -150,22 +156,7 @@ declare const TimelockMarketProvider: ({
|
|
|
150
156
|
marketData?: Partial<TimelockMarketData>;
|
|
151
157
|
envioGraphqlUrl?: string;
|
|
152
158
|
}) => React.JSX.Element;
|
|
153
|
-
declare const useCurrentMarket: () => Partial<
|
|
154
|
-
optionAssetIsToken0: boolean;
|
|
155
|
-
vault: `0x${string}`;
|
|
156
|
-
pool: `0x${string}`;
|
|
157
|
-
optionAsset: `0x${string}`;
|
|
158
|
-
payoutAsset: `0x${string}`;
|
|
159
|
-
optionAssetDecimals: number;
|
|
160
|
-
payoutAssetDecimals: number;
|
|
161
|
-
optionAssetSymbol: string;
|
|
162
|
-
payoutAssetSymbol: string;
|
|
163
|
-
optionAssetName: string;
|
|
164
|
-
payoutAssetName: string;
|
|
165
|
-
optionsCount: bigint;
|
|
166
|
-
} & {
|
|
167
|
-
address: Address;
|
|
168
|
-
}>>>;
|
|
159
|
+
declare const useCurrentMarket: () => Partial<TimelockMarketData>;
|
|
169
160
|
declare const useTimelockConfig: () => {
|
|
170
161
|
lensAddr: `0x${string}` | undefined;
|
|
171
162
|
uniswapMathLensAddr: `0x${string}` | undefined;
|
|
@@ -173,6 +164,7 @@ declare const useTimelockConfig: () => {
|
|
|
173
164
|
graphqlClient: {
|
|
174
165
|
GetActiveUserOptions(variables: GetActiveUserOptionsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetActiveUserOptionsQuery>;
|
|
175
166
|
GetClosedUserOptions(variables: GetClosedUserOptionsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetClosedUserOptionsQuery>;
|
|
167
|
+
GetMarketData(variables: GetMarketDataQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMarketDataQuery>;
|
|
176
168
|
} | undefined;
|
|
177
169
|
};
|
|
178
170
|
//#endregion
|
|
@@ -187,6 +179,26 @@ declare const useExerciseOption: (market?: Address | TimelockMarket) => {
|
|
|
187
179
|
isLoading: boolean;
|
|
188
180
|
};
|
|
189
181
|
//#endregion
|
|
182
|
+
//#region src/hooks/market/useMarketData.d.ts
|
|
183
|
+
declare const useMarketData: (market?: Address | TimelockMarket) => Partial<NonUndefinedGuard<{
|
|
184
|
+
pool: Address;
|
|
185
|
+
vault: Address;
|
|
186
|
+
optionAsset: Address;
|
|
187
|
+
payoutAsset: Address;
|
|
188
|
+
optionsCount: bigint;
|
|
189
|
+
tradersCount: bigint;
|
|
190
|
+
__typename: "TimelockMarket";
|
|
191
|
+
id: string;
|
|
192
|
+
tickSpacing: number;
|
|
193
|
+
optionAssetIsToken0: boolean;
|
|
194
|
+
optionAssetDecimals: number;
|
|
195
|
+
payoutAssetDecimals: number;
|
|
196
|
+
optionAssetSymbol: string;
|
|
197
|
+
payoutAssetSymbol: string;
|
|
198
|
+
optionAssetName: string;
|
|
199
|
+
payoutAssetName: string;
|
|
200
|
+
} | undefined>>;
|
|
201
|
+
//#endregion
|
|
190
202
|
//#region src/hooks/market/useMaxPositionSize.d.ts
|
|
191
203
|
declare const useMaxPositionSize: (market: Address | TimelockMarket | undefined, strikeTick?: number, maxBorrowableRange?: number) => {
|
|
192
204
|
maxCallSize: Amount | undefined;
|
|
@@ -205,7 +217,7 @@ declare const useMintOption: (market?: Address | TimelockMarket) => {
|
|
|
205
217
|
isLoading: boolean;
|
|
206
218
|
};
|
|
207
219
|
//#endregion
|
|
208
|
-
//#region src/hooks/market/
|
|
220
|
+
//#region src/hooks/market/useOptionPnl.d.ts
|
|
209
221
|
declare const useOptionPnl: (optionData: {
|
|
210
222
|
marketAddr: Address;
|
|
211
223
|
optionType: "CALL" | "PUT";
|
|
@@ -2292,14 +2304,14 @@ declare const useVaultTVL: (vault?: Address | TimelockVault) => {
|
|
|
2292
2304
|
totalAmount1: Amount | undefined;
|
|
2293
2305
|
borrowedAmount0: Amount | undefined;
|
|
2294
2306
|
borrowedAmount1: Amount | undefined;
|
|
2295
|
-
refetch: (options?: _tanstack_query_core0.RefetchOptions) => Promise<_tanstack_query_core0.QueryObserverResult<readonly [bigint, bigint, bigint, bigint, bigint, bigint],
|
|
2307
|
+
refetch: (options?: _tanstack_query_core0.RefetchOptions) => Promise<_tanstack_query_core0.QueryObserverResult<readonly [bigint, bigint, bigint, bigint, bigint, bigint], viem382.ReadContractErrorType>>;
|
|
2296
2308
|
};
|
|
2297
2309
|
//#endregion
|
|
2298
2310
|
//#region src/hooks/useLens.d.ts
|
|
2299
2311
|
declare const useLens: () => {
|
|
2300
2312
|
uniswapLens: {
|
|
2301
2313
|
read: {
|
|
2302
|
-
batchGetAmount0ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
2314
|
+
batchGetAmount0ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
2303
2315
|
readonly type: "function";
|
|
2304
2316
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
2305
2317
|
readonly inputs: readonly [{
|
|
@@ -2920,7 +2932,7 @@ declare const useLens: () => {
|
|
|
2920
2932
|
}];
|
|
2921
2933
|
readonly stateMutability: "pure";
|
|
2922
2934
|
}], "batchGetAmount0ForLiquidity", readonly [readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
2923
|
-
batchGetAmount0ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?:
|
|
2935
|
+
batchGetAmount0ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
2924
2936
|
readonly type: "function";
|
|
2925
2937
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
2926
2938
|
readonly inputs: readonly [{
|
|
@@ -3541,7 +3553,7 @@ declare const useLens: () => {
|
|
|
3541
3553
|
}];
|
|
3542
3554
|
readonly stateMutability: "pure";
|
|
3543
3555
|
}], "batchGetAmount0ForLiquidityTicks", readonly [readonly number[], readonly number[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
3544
|
-
batchGetAmount1ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
3556
|
+
batchGetAmount1ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
3545
3557
|
readonly type: "function";
|
|
3546
3558
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
3547
3559
|
readonly inputs: readonly [{
|
|
@@ -4162,7 +4174,7 @@ declare const useLens: () => {
|
|
|
4162
4174
|
}];
|
|
4163
4175
|
readonly stateMutability: "pure";
|
|
4164
4176
|
}], "batchGetAmount1ForLiquidity", readonly [readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
4165
|
-
batchGetAmount1ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?:
|
|
4177
|
+
batchGetAmount1ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
4166
4178
|
readonly type: "function";
|
|
4167
4179
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
4168
4180
|
readonly inputs: readonly [{
|
|
@@ -4783,7 +4795,7 @@ declare const useLens: () => {
|
|
|
4783
4795
|
}];
|
|
4784
4796
|
readonly stateMutability: "pure";
|
|
4785
4797
|
}], "batchGetAmount1ForLiquidityTicks", readonly [readonly number[], readonly number[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
4786
|
-
batchGetAmountsForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
4798
|
+
batchGetAmountsForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
4787
4799
|
readonly type: "function";
|
|
4788
4800
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
4789
4801
|
readonly inputs: readonly [{
|
|
@@ -5404,7 +5416,7 @@ declare const useLens: () => {
|
|
|
5404
5416
|
}];
|
|
5405
5417
|
readonly stateMutability: "pure";
|
|
5406
5418
|
}], "batchGetAmountsForLiquidity", readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [readonly bigint[], readonly bigint[]]>;
|
|
5407
|
-
batchGetAmountsForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[]], options?:
|
|
5419
|
+
batchGetAmountsForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
5408
5420
|
readonly type: "function";
|
|
5409
5421
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
5410
5422
|
readonly inputs: readonly [{
|
|
@@ -6025,7 +6037,7 @@ declare const useLens: () => {
|
|
|
6025
6037
|
}];
|
|
6026
6038
|
readonly stateMutability: "pure";
|
|
6027
6039
|
}], "batchGetAmountsForLiquidityTicks", readonly [readonly number[], readonly number[], readonly number[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [readonly bigint[], readonly bigint[]]>;
|
|
6028
|
-
batchGetLiquidityForAmount0: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
6040
|
+
batchGetLiquidityForAmount0: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
6029
6041
|
readonly type: "function";
|
|
6030
6042
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
6031
6043
|
readonly inputs: readonly [{
|
|
@@ -6646,7 +6658,7 @@ declare const useLens: () => {
|
|
|
6646
6658
|
}];
|
|
6647
6659
|
readonly stateMutability: "pure";
|
|
6648
6660
|
}], "batchGetLiquidityForAmount0", readonly [readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
6649
|
-
batchGetLiquidityForAmount0Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?:
|
|
6661
|
+
batchGetLiquidityForAmount0Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
6650
6662
|
readonly type: "function";
|
|
6651
6663
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
6652
6664
|
readonly inputs: readonly [{
|
|
@@ -7267,7 +7279,7 @@ declare const useLens: () => {
|
|
|
7267
7279
|
}];
|
|
7268
7280
|
readonly stateMutability: "pure";
|
|
7269
7281
|
}], "batchGetLiquidityForAmount0Ticks", readonly [readonly number[], readonly number[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
7270
|
-
batchGetLiquidityForAmount1: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
7282
|
+
batchGetLiquidityForAmount1: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
7271
7283
|
readonly type: "function";
|
|
7272
7284
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
7273
7285
|
readonly inputs: readonly [{
|
|
@@ -7888,7 +7900,7 @@ declare const useLens: () => {
|
|
|
7888
7900
|
}];
|
|
7889
7901
|
readonly stateMutability: "pure";
|
|
7890
7902
|
}], "batchGetLiquidityForAmount1", readonly [readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
7891
|
-
batchGetLiquidityForAmount1Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?:
|
|
7903
|
+
batchGetLiquidityForAmount1Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
7892
7904
|
readonly type: "function";
|
|
7893
7905
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
7894
7906
|
readonly inputs: readonly [{
|
|
@@ -8509,7 +8521,7 @@ declare const useLens: () => {
|
|
|
8509
8521
|
}];
|
|
8510
8522
|
readonly stateMutability: "pure";
|
|
8511
8523
|
}], "batchGetLiquidityForAmount1Ticks", readonly [readonly number[], readonly number[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
8512
|
-
batchGetLiquidityForAmounts: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
8524
|
+
batchGetLiquidityForAmounts: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
8513
8525
|
readonly type: "function";
|
|
8514
8526
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
8515
8527
|
readonly inputs: readonly [{
|
|
@@ -9130,7 +9142,7 @@ declare const useLens: () => {
|
|
|
9130
9142
|
}];
|
|
9131
9143
|
readonly stateMutability: "pure";
|
|
9132
9144
|
}], "batchGetLiquidityForAmounts", readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
9133
|
-
batchGetLiquidityForAmountsTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[], readonly bigint[]], options?:
|
|
9145
|
+
batchGetLiquidityForAmountsTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
9134
9146
|
readonly type: "function";
|
|
9135
9147
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
9136
9148
|
readonly inputs: readonly [{
|
|
@@ -9751,7 +9763,7 @@ declare const useLens: () => {
|
|
|
9751
9763
|
}];
|
|
9752
9764
|
readonly stateMutability: "pure";
|
|
9753
9765
|
}], "batchGetLiquidityForAmountsTicks", readonly [readonly number[], readonly number[], readonly number[], readonly bigint[], readonly bigint[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
9754
|
-
batchGetPriceAtTick: (args: readonly [readonly number[]], options?:
|
|
9766
|
+
batchGetPriceAtTick: (args: readonly [readonly number[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
9755
9767
|
readonly type: "function";
|
|
9756
9768
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
9757
9769
|
readonly inputs: readonly [{
|
|
@@ -10372,7 +10384,7 @@ declare const useLens: () => {
|
|
|
10372
10384
|
}];
|
|
10373
10385
|
readonly stateMutability: "pure";
|
|
10374
10386
|
}], "batchGetPriceAtTick", readonly [readonly number[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
10375
|
-
getAmount0ForLiquidity: (args: readonly [bigint, bigint, bigint], options?:
|
|
10387
|
+
getAmount0ForLiquidity: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
10376
10388
|
readonly type: "function";
|
|
10377
10389
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
10378
10390
|
readonly inputs: readonly [{
|
|
@@ -10993,7 +11005,7 @@ declare const useLens: () => {
|
|
|
10993
11005
|
}];
|
|
10994
11006
|
readonly stateMutability: "pure";
|
|
10995
11007
|
}], "getAmount0ForLiquidity", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
10996
|
-
getAmount0ForLiquidityTicks: (args: readonly [number, number, bigint], options?:
|
|
11008
|
+
getAmount0ForLiquidityTicks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
10997
11009
|
readonly type: "function";
|
|
10998
11010
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
10999
11011
|
readonly inputs: readonly [{
|
|
@@ -11614,7 +11626,7 @@ declare const useLens: () => {
|
|
|
11614
11626
|
}];
|
|
11615
11627
|
readonly stateMutability: "pure";
|
|
11616
11628
|
}], "getAmount0ForLiquidityTicks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
11617
|
-
getAmount1ForLiquidity: (args: readonly [bigint, bigint, bigint], options?:
|
|
11629
|
+
getAmount1ForLiquidity: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
11618
11630
|
readonly type: "function";
|
|
11619
11631
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
11620
11632
|
readonly inputs: readonly [{
|
|
@@ -12235,7 +12247,7 @@ declare const useLens: () => {
|
|
|
12235
12247
|
}];
|
|
12236
12248
|
readonly stateMutability: "pure";
|
|
12237
12249
|
}], "getAmount1ForLiquidity", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
12238
|
-
getAmount1ForLiquidityTicks: (args: readonly [number, number, bigint], options?:
|
|
12250
|
+
getAmount1ForLiquidityTicks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
12239
12251
|
readonly type: "function";
|
|
12240
12252
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
12241
12253
|
readonly inputs: readonly [{
|
|
@@ -12856,7 +12868,7 @@ declare const useLens: () => {
|
|
|
12856
12868
|
}];
|
|
12857
12869
|
readonly stateMutability: "pure";
|
|
12858
12870
|
}], "getAmount1ForLiquidityTicks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
12859
|
-
getAmountsForLiquidity: (args: readonly [bigint, bigint, bigint, bigint], options?:
|
|
12871
|
+
getAmountsForLiquidity: (args: readonly [bigint, bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
12860
12872
|
readonly type: "function";
|
|
12861
12873
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
12862
12874
|
readonly inputs: readonly [{
|
|
@@ -13477,7 +13489,7 @@ declare const useLens: () => {
|
|
|
13477
13489
|
}];
|
|
13478
13490
|
readonly stateMutability: "pure";
|
|
13479
13491
|
}], "getAmountsForLiquidity", readonly [bigint, bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
13480
|
-
getAmountsForLiquidityTicks: (args: readonly [number, number, number, bigint], options?:
|
|
13492
|
+
getAmountsForLiquidityTicks: (args: readonly [number, number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
13481
13493
|
readonly type: "function";
|
|
13482
13494
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
13483
13495
|
readonly inputs: readonly [{
|
|
@@ -14098,7 +14110,7 @@ declare const useLens: () => {
|
|
|
14098
14110
|
}];
|
|
14099
14111
|
readonly stateMutability: "pure";
|
|
14100
14112
|
}], "getAmountsForLiquidityTicks", readonly [number, number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
14101
|
-
getLiquidityForAmount0: (args: readonly [bigint, bigint, bigint], options?:
|
|
14113
|
+
getLiquidityForAmount0: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
14102
14114
|
readonly type: "function";
|
|
14103
14115
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
14104
14116
|
readonly inputs: readonly [{
|
|
@@ -14719,7 +14731,7 @@ declare const useLens: () => {
|
|
|
14719
14731
|
}];
|
|
14720
14732
|
readonly stateMutability: "pure";
|
|
14721
14733
|
}], "getLiquidityForAmount0", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
14722
|
-
getLiquidityForAmount0Ticks: (args: readonly [number, number, bigint], options?:
|
|
14734
|
+
getLiquidityForAmount0Ticks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
14723
14735
|
readonly type: "function";
|
|
14724
14736
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
14725
14737
|
readonly inputs: readonly [{
|
|
@@ -15340,7 +15352,7 @@ declare const useLens: () => {
|
|
|
15340
15352
|
}];
|
|
15341
15353
|
readonly stateMutability: "pure";
|
|
15342
15354
|
}], "getLiquidityForAmount0Ticks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
15343
|
-
getLiquidityForAmount1: (args: readonly [bigint, bigint, bigint], options?:
|
|
15355
|
+
getLiquidityForAmount1: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
15344
15356
|
readonly type: "function";
|
|
15345
15357
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
15346
15358
|
readonly inputs: readonly [{
|
|
@@ -15961,7 +15973,7 @@ declare const useLens: () => {
|
|
|
15961
15973
|
}];
|
|
15962
15974
|
readonly stateMutability: "pure";
|
|
15963
15975
|
}], "getLiquidityForAmount1", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
15964
|
-
getLiquidityForAmount1Ticks: (args: readonly [number, number, bigint], options?:
|
|
15976
|
+
getLiquidityForAmount1Ticks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
15965
15977
|
readonly type: "function";
|
|
15966
15978
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
15967
15979
|
readonly inputs: readonly [{
|
|
@@ -16582,7 +16594,7 @@ declare const useLens: () => {
|
|
|
16582
16594
|
}];
|
|
16583
16595
|
readonly stateMutability: "pure";
|
|
16584
16596
|
}], "getLiquidityForAmount1Ticks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
16585
|
-
getLiquidityForAmounts: (args: readonly [bigint, bigint, bigint, bigint, bigint], options?:
|
|
16597
|
+
getLiquidityForAmounts: (args: readonly [bigint, bigint, bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
16586
16598
|
readonly type: "function";
|
|
16587
16599
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
16588
16600
|
readonly inputs: readonly [{
|
|
@@ -17203,7 +17215,7 @@ declare const useLens: () => {
|
|
|
17203
17215
|
}];
|
|
17204
17216
|
readonly stateMutability: "pure";
|
|
17205
17217
|
}], "getLiquidityForAmounts", readonly [bigint, bigint, bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
17206
|
-
getLiquidityForAmountsTicks: (args: readonly [number, number, number, bigint, bigint], options?:
|
|
17218
|
+
getLiquidityForAmountsTicks: (args: readonly [number, number, number, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
17207
17219
|
readonly type: "function";
|
|
17208
17220
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
17209
17221
|
readonly inputs: readonly [{
|
|
@@ -17824,7 +17836,7 @@ declare const useLens: () => {
|
|
|
17824
17836
|
}];
|
|
17825
17837
|
readonly stateMutability: "pure";
|
|
17826
17838
|
}], "getLiquidityForAmountsTicks", readonly [number, number, number, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
17827
|
-
getPriceAtTick: (args: readonly [number], options?:
|
|
17839
|
+
getPriceAtTick: (args: readonly [number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
17828
17840
|
readonly type: "function";
|
|
17829
17841
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
17830
17842
|
readonly inputs: readonly [{
|
|
@@ -19071,7 +19083,7 @@ declare const useLens: () => {
|
|
|
19071
19083
|
} | undefined;
|
|
19072
19084
|
timelockLens: {
|
|
19073
19085
|
read: {
|
|
19074
|
-
batchGetRefTick: (args: readonly [`0x${string}`, readonly number[]], options?:
|
|
19086
|
+
batchGetRefTick: (args: readonly [`0x${string}`, readonly number[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
19075
19087
|
readonly type: "function";
|
|
19076
19088
|
readonly name: "batchGetRefTick";
|
|
19077
19089
|
readonly inputs: readonly [{
|
|
@@ -19773,7 +19785,7 @@ declare const useLens: () => {
|
|
|
19773
19785
|
}];
|
|
19774
19786
|
readonly stateMutability: "view";
|
|
19775
19787
|
}], "batchGetRefTick", readonly [`0x${string}`, readonly number[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly number[]>;
|
|
19776
|
-
getAllBlocks: (args: readonly [`0x${string}`], options?:
|
|
19788
|
+
getAllBlocks: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
19777
19789
|
readonly type: "function";
|
|
19778
19790
|
readonly name: "batchGetRefTick";
|
|
19779
19791
|
readonly inputs: readonly [{
|
|
@@ -20485,7 +20497,7 @@ declare const useLens: () => {
|
|
|
20485
20497
|
borrowedAmount0: bigint;
|
|
20486
20498
|
borrowedAmount1: bigint;
|
|
20487
20499
|
}[]>;
|
|
20488
|
-
getExpiredOptions: (args: readonly [`0x${string}`, bigint, bigint], options?:
|
|
20500
|
+
getExpiredOptions: (args: readonly [`0x${string}`, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
20489
20501
|
readonly type: "function";
|
|
20490
20502
|
readonly name: "batchGetRefTick";
|
|
20491
20503
|
readonly inputs: readonly [{
|
|
@@ -21206,7 +21218,7 @@ declare const useLens: () => {
|
|
|
21206
21218
|
createdAt: bigint;
|
|
21207
21219
|
liquidities: readonly bigint[];
|
|
21208
21220
|
}[], bigint, boolean]>;
|
|
21209
|
-
getLiquidityAtTick: (args: readonly [`0x${string}`, number], options?:
|
|
21221
|
+
getLiquidityAtTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
21210
21222
|
readonly type: "function";
|
|
21211
21223
|
readonly name: "batchGetRefTick";
|
|
21212
21224
|
readonly inputs: readonly [{
|
|
@@ -21908,7 +21920,7 @@ declare const useLens: () => {
|
|
|
21908
21920
|
}];
|
|
21909
21921
|
readonly stateMutability: "view";
|
|
21910
21922
|
}], "getLiquidityAtTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
21911
|
-
getMarketData: (args: readonly [`0x${string}`], options?:
|
|
21923
|
+
getMarketData: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
21912
21924
|
readonly type: "function";
|
|
21913
21925
|
readonly name: "batchGetRefTick";
|
|
21914
21926
|
readonly inputs: readonly [{
|
|
@@ -22623,7 +22635,7 @@ declare const useLens: () => {
|
|
|
22623
22635
|
payoutAssetName: string;
|
|
22624
22636
|
optionsCount: bigint;
|
|
22625
22637
|
}>;
|
|
22626
|
-
getMaxPositionSize: (args: readonly [`0x${string}`, number, number], options?:
|
|
22638
|
+
getMaxPositionSize: (args: readonly [`0x${string}`, number, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
22627
22639
|
readonly type: "function";
|
|
22628
22640
|
readonly name: "batchGetRefTick";
|
|
22629
22641
|
readonly inputs: readonly [{
|
|
@@ -23325,7 +23337,7 @@ declare const useLens: () => {
|
|
|
23325
23337
|
}];
|
|
23326
23338
|
readonly stateMutability: "view";
|
|
23327
23339
|
}], "getMaxPositionSize", readonly [`0x${string}`, number, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
23328
|
-
getMaxPositionSizeAtCurrentTick: (args: readonly [`0x${string}`, number], options?:
|
|
23340
|
+
getMaxPositionSizeAtCurrentTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
23329
23341
|
readonly type: "function";
|
|
23330
23342
|
readonly name: "batchGetRefTick";
|
|
23331
23343
|
readonly inputs: readonly [{
|
|
@@ -24027,7 +24039,7 @@ declare const useLens: () => {
|
|
|
24027
24039
|
}];
|
|
24028
24040
|
readonly stateMutability: "view";
|
|
24029
24041
|
}], "getMaxPositionSizeAtCurrentTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
24030
|
-
getOptionData: (args: readonly [`0x${string}`, bigint], options?:
|
|
24042
|
+
getOptionData: (args: readonly [`0x${string}`, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
24031
24043
|
readonly type: "function";
|
|
24032
24044
|
readonly name: "batchGetRefTick";
|
|
24033
24045
|
readonly inputs: readonly [{
|
|
@@ -24748,7 +24760,7 @@ declare const useLens: () => {
|
|
|
24748
24760
|
createdAt: bigint;
|
|
24749
24761
|
liquidities: readonly bigint[];
|
|
24750
24762
|
}>;
|
|
24751
|
-
getOptionsData: (args: readonly [`0x${string}`, readonly bigint[]], options?:
|
|
24763
|
+
getOptionsData: (args: readonly [`0x${string}`, readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
24752
24764
|
readonly type: "function";
|
|
24753
24765
|
readonly name: "batchGetRefTick";
|
|
24754
24766
|
readonly inputs: readonly [{
|
|
@@ -25469,7 +25481,7 @@ declare const useLens: () => {
|
|
|
25469
25481
|
createdAt: bigint;
|
|
25470
25482
|
liquidities: readonly bigint[];
|
|
25471
25483
|
}[]>;
|
|
25472
|
-
getPoolData: (args: readonly [`0x${string}`], options?:
|
|
25484
|
+
getPoolData: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
25473
25485
|
readonly type: "function";
|
|
25474
25486
|
readonly name: "batchGetRefTick";
|
|
25475
25487
|
readonly inputs: readonly [{
|
|
@@ -26182,7 +26194,7 @@ declare const useLens: () => {
|
|
|
26182
26194
|
tickSpacing: number;
|
|
26183
26195
|
fee: number;
|
|
26184
26196
|
}>;
|
|
26185
|
-
getRefTick: (args: readonly [`0x${string}`, number], options?:
|
|
26197
|
+
getRefTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
26186
26198
|
readonly type: "function";
|
|
26187
26199
|
readonly name: "batchGetRefTick";
|
|
26188
26200
|
readonly inputs: readonly [{
|
|
@@ -26884,7 +26896,7 @@ declare const useLens: () => {
|
|
|
26884
26896
|
}];
|
|
26885
26897
|
readonly stateMutability: "view";
|
|
26886
26898
|
}], "getRefTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<number>;
|
|
26887
|
-
getUserOptions: (args: readonly [`0x${string}`, `0x${string}`, bigint, bigint], options?:
|
|
26899
|
+
getUserOptions: (args: readonly [`0x${string}`, `0x${string}`, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
26888
26900
|
readonly type: "function";
|
|
26889
26901
|
readonly name: "batchGetRefTick";
|
|
26890
26902
|
readonly inputs: readonly [{
|
|
@@ -27605,7 +27617,7 @@ declare const useLens: () => {
|
|
|
27605
27617
|
createdAt: bigint;
|
|
27606
27618
|
liquidities: readonly bigint[];
|
|
27607
27619
|
}[], bigint, boolean]>;
|
|
27608
|
-
getVaultTVL: (args: readonly [`0x${string}`], options?:
|
|
27620
|
+
getVaultTVL: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
27609
27621
|
readonly type: "function";
|
|
27610
27622
|
readonly name: "batchGetRefTick";
|
|
27611
27623
|
readonly inputs: readonly [{
|
|
@@ -29014,5 +29026,5 @@ declare const useLens: () => {
|
|
|
29014
29026
|
} | undefined;
|
|
29015
29027
|
};
|
|
29016
29028
|
//#endregion
|
|
29017
|
-
export { LiquidityBlockData, OptionData,
|
|
29029
|
+
export { LiquidityBlockData, OptionData, TimelockMarketProvider, UniswapPoolData, batchGetAmountsFromLiquidity, getCurrentTick, useActiveUserOptions, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, useTimelockConfig, useVaultData, useVaultTVL };
|
|
29018
29030
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{getErc20 as e,getPriceAtTick as t,getTimelockLens as n,getTimelockMarket as r,getUniswapMathLens as i,getUniswapPool as a,lensAbi as o,optionsMarketAbi as s,roundTickDown as c,roundTickUp as l,singleOwnerVaultAbi as u,timelockLenses as d,token0ToToken1 as f,token1ToToken0 as p,uniswapMathLenses as m,wrapAmount as h,wrapPrice as g}from"./numberUtils-DB5N1e6G.js";import{encodeFunctionData as _,erc20Abi as v,maxUint256 as y}from"viem";import b,{createContext as x,useContext as S,useMemo as C}from"react";import{useAccount as w,useChainId as T,useClient as E,useReadContract as D,useWaitForTransactionReceipt as O,useWriteContract as k}from"wagmi";import{GraphQLClient as
|
|
1
|
+
"use client";import{getErc20 as e,getPriceAtTick as t,getTimelockLens as n,getTimelockMarket as r,getUniswapMathLens as i,getUniswapPool as a,lensAbi as o,optionsMarketAbi as s,roundTickDown as c,roundTickUp as l,singleOwnerVaultAbi as u,timelockLenses as d,token0ToToken1 as f,token1ToToken0 as p,uniswapMathLenses as m,wrapAmount as h,wrapPrice as g}from"./numberUtils-DB5N1e6G.js";import{encodeFunctionData as _,erc20Abi as v,maxUint256 as y}from"viem";import b,{createContext as x,useContext as S,useMemo as C}from"react";import{useAccount as w,useChainId as T,useClient as E,useReadContract as D,useWaitForTransactionReceipt as O,useWriteContract as k}from"wagmi";import{GraphQLClient as ee}from"graphql-request";import A from"graphql-tag";import{waitForTransactionReceipt as j}from"viem/actions";import{useQuery as M}from"@tanstack/react-query";const N=A`
|
|
2
2
|
query GetActiveUserOptions($user: String!) {
|
|
3
3
|
UserOption(
|
|
4
4
|
where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: false}}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
fullyExercised
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
`,
|
|
32
|
+
`,P=A`
|
|
33
33
|
query GetClosedUserOptions($user: String!) {
|
|
34
34
|
UserOption(
|
|
35
35
|
where: {ownerAddr: {_eq: $user}, fullyExercised: {_eq: true}}
|
|
@@ -60,5 +60,25 @@
|
|
|
60
60
|
fullyExercised
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
`,I=(e,t,n,r)=>e();function L(e,t=I){return{GetActiveUserOptions(n,r,i){return t(t=>e.request({document:P,variables:n,requestHeaders:{...r,...t},signal:i}),`GetActiveUserOptions`,`query`,n)},GetClosedUserOptions(n,r,i){return t(t=>e.request({document:F,variables:n,requestHeaders:{...r,...t},signal:i}),`GetClosedUserOptions`,`query`,n)}}}const R=x(void 0),z=({children:e,marketData:t,envioGraphqlUrl:n})=>{let r=T(),i=d[r],a=m[r];return b.createElement(R.Provider,{value:{marketData:t||{},lensAddr:i,uniswapMathLensAddr:a,envioGraphqlUrl:n}},e)},B=()=>{let e=S(R);if(e===void 0)throw Error(`useCurrentMarket must be used within a TimelockMarketProvider`);return e.marketData},V=()=>{let e=S(R);if(e===void 0)throw Error(`useConfig must be used within a TimelockMarketProvider`);return{lensAddr:e.lensAddr,uniswapMathLensAddr:e.uniswapMathLensAddr,envioGraphqlUrl:e.envioGraphqlUrl,graphqlClient:e.envioGraphqlUrl?L(new A(e.envioGraphqlUrl)):void 0}},H=()=>{let e=E(),t=e?n(e):void 0;return{uniswapLens:e?i(e):void 0,timelockLens:t}},U=e=>{let{timelockLens:t}=H(),n=E(),r=typeof e==`string`?e:e==null?void 0:e.address,{data:i}=D({address:t==null?void 0:t.address,abi:o,functionName:`getMarketData`,args:r?[r]:void 0,query:{enabled:r!==void 0}});return!i||!r||!n?{}:{...i,address:r}},W=e=>{let{vault:t}=U(e),n=E(),{data:r}=D({address:t,abi:u,functionName:`lowestTick`}),{writeContractAsync:i,data:a,isPending:o,error:c}=k(),{isLoading:l,isSuccess:d}=O({hash:a}),f=typeof e==`string`?e:e==null?void 0:e.address;return{exerciseOption:async(e,t)=>{if(!n)throw Error(`Wallet not connected`);if(r===void 0||!f)throw Error(`Lowest tick lower not available`);let a=await i({address:f,abi:s,functionName:`exerciseOption`,args:[e,t,0n,r]});return await M(n,{hash:a}),a},hash:a,isPending:o,isConfirming:l,isSuccess:d,error:c,isLoading:o||l}},G=(e,t,n=100)=>{let{timelockLens:r}=H(),{optionAssetDecimals:i}=U(e),a=typeof e==`string`?e:e==null?void 0:e.address,{data:s,refetch:c}=D({address:r==null?void 0:r.address,abi:o,functionName:`getMaxPositionSizeAtCurrentTick`,args:[a,n],query:{enabled:!!a&&!!r},gas:100000000n}),{data:l,refetch:u}=D({address:r==null?void 0:r.address,abi:o,functionName:`getMaxPositionSize`,args:[a,t,n],query:{enabled:!!a&&!!r&&t!==void 0},gas:100000000n}),d=t===void 0?s:l,{maxCallSize:f,maxPutSize:p}=C(()=>d&&i?{maxCallSize:h(d[0],i),maxPutSize:h(d[1],i)}:{},[d,i]);return{maxCallSize:f,maxPutSize:p,refetch:()=>{c(),u()}}},K=async e=>{let[t,{1:n}]=await Promise.all([e.read.tickSpacing(),e.read.slot0()]);return{exact:n,rounded:Math.floor(n/t)*t}},q=e=>{let t=E(),{data:n}=N({queryKey:[`currentTick`,typeof e==`string`?e:(e==null?void 0:e.address)||`-`],queryFn:()=>K(typeof e==`string`?a(e,t):e),enabled:!!e&&!!t,refetchInterval:5e3});return n||{}},J=e=>{let t=typeof e==`string`?e:e==null?void 0:e.address,{timelockLens:n}=H(),r=E(),{data:i}=D({address:n==null?void 0:n.address,abi:o,functionName:`getPoolData`,args:t?[t]:void 0,query:{enabled:!!t&&!!r}});return i||{}},ee=t=>{let{timelockLens:n}=H(),{payoutAsset:i,vault:a,pool:o,optionAssetIsToken0:u}=U(t),{tickSpacing:d}=J(o),{exact:f}=q(o),p=E(),{address:m}=w(),{writeContractAsync:h,data:g,isPending:_,error:b}=k(),{isLoading:x,isSuccess:S}=O({hash:g}),C=typeof t==`string`?t:t==null?void 0:t.address,T=async t=>{if(!p||!m)throw Error(`Wallet not connected`);if(!i||!C)throw Error(`Tokens not available`);await e(i,p).read.allowance([m,C])<t&&await M(p,{hash:await h({address:i,abi:v,functionName:`approve`,args:[C,y]})})};return{mintOption:async(e,t,i,o)=>{if(!p)throw Error(`Wallet not connected`);if(!n||!a||!C||!f||!d)throw Error(`Lowest tick lower not available`);o=o??f,o=e===`CALL`&&u||e===`PUT`&&!u?l(o,d):c(o,d),await T(await r(C,p).read.calculatePremium([e===`CALL`?0:1,t,o,BigInt(i)]));let m=await h({address:C,abi:s,functionName:`mintOption`,args:[e===`CALL`?0:1,t,o,BigInt(i),BigInt(1e69),await n.read.getRefTick([a,o])]});return await M(p,{hash:m}),m},hash:g,isPending:_,isConfirming:x,isSuccess:S,error:b,isLoading:_||x}},te=e=>{let{marketAddr:t,optionType:n,entryTick:r,positionSizeCurrent:i}=e,{pool:a,optionAssetIsToken0:o,payoutAssetDecimals:s}=U(t),{exact:c}=q(a),{displayPnl:l,unrealizedPayout:u}=C(()=>{if(o===void 0||c===void 0||!i||!s)return{};let e=o?f(i,c)-f(i,r):p(i,c)-p(i,r),t=h(n===`CALL`?e:-e,s);return{unrealizedPayout:h(t.scaled<0?0n:t.scaled,s),displayPnl:t}},[e,o,c,i]);return{displayPnl:l,unrealizedPayout:u}},ne=(e,t,n,r)=>{let{pool:i}=U(e),a=q(i),{tickSpacing:o}=J(i),{payoutAssetDecimals:c}=U(e),l=typeof e==`string`?e:e==null?void 0:e.address,u=C(()=>{if(!(a.rounded===void 0||o===void 0))return t===`CALL`?a.rounded+o:a.rounded},[a.rounded,o,t]),{data:d}=D({address:l,abi:s,functionName:`calculatePremium`,args:u===void 0?void 0:[t===`CALL`?0:1,n,u,BigInt(r)],query:{enabled:a.rounded!==void 0&&c!==void 0&&o!==void 0&&u!==void 0}});return C(()=>{if(!(d===void 0||c===void 0))return h(d,c)},[d,c])},Y=(e,t=!1)=>{let{graphqlClient:n}=V(),{data:r,...i}=N({queryKey:[`userTrades`,e||`--`,t],queryFn:()=>t?n==null?void 0:n.GetActiveUserOptions({user:e.toLowerCase()}):n==null?void 0:n.GetClosedUserOptions({user:e.toLowerCase()}),select:e=>{var t;return e==null||(t=e.UserOption)==null?void 0:t.map(e=>({...e,id:BigInt(e.id),marketAddr:e.marketAddr,optionType:e.optionType,createdAt:new Date(Number(e.createdAt)*1e3),expiresAt:new Date(Number(e.expiresAt)*1e3),premiumPaid:BigInt(e.premiumPaid),realizedPayout:BigInt(e.realizedPayout),liquiditiesAtOpen:e.liquiditiesAtOpen.map(e=>BigInt(e)),liquiditiesCurrent:e.liquiditiesCurrent.map(e=>BigInt(e)),positionSizeAtOpen:BigInt(e.positionSizeAtOpen),positionSizeCurrent:BigInt(e.positionSizeCurrent),strikePrice:BigInt(e.strikePrice),entryPrice:BigInt(e.entryPrice)}))},enabled:!!e&&!!n});return{data:C(()=>(r==null?void 0:r.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()))||[],[r]),...i}},re=e=>Y(e,!0),ie=e=>Y(e,!1),X=(e,n)=>{let{token0Decimals:r,token1Decimals:i}=J(n);return C(()=>e&&r&&i?g(t(e),r,i):void 0,[e,r,i])},Z=e=>{let t=q(e);return{currentPrice:X(t.exact,e),currentTick:t}},Q=e=>{let{data:t}=D({address:typeof e==`string`?e:e==null?void 0:e.address,abi:u,functionName:`pool`});return{pool:t}},ae=e=>{let t=E(),{pool:n}=Q(e),r=q(n),{timelockLens:i}=H(),a=typeof e==`string`?e:e==null?void 0:e.address,{writeContractAsync:o,data:s,isPending:c,error:l}=k(),{isLoading:d,isSuccess:f}=O({hash:s}),p=async(e,n,r)=>{if(!t)throw Error(`Wallet not connected`);if(!a||!i)throw Error(`Vault/lens not available`);let s=await o({address:a,abi:u,functionName:`burn`,args:[e,n,r,await i.read.getRefTick([a,e])]});return await M(t,{hash:s}),s};return{burnMultiple:async e=>{if(!t)throw Error(`Wallet not connected`);if(!r.exact)throw Error(`Current tick not available`);if(e.length===0)throw Error(`No positions to burn`);if(!i||!a)throw Error(`Vault/lens not available`);if(e.length===1)await p(e[0].tickLower,e[0].tickUpper,e[0].liquidity);else{let n=await i.read.batchGetRefTick([a,e.map(e=>e.tickLower)]);await M(t,{hash:await o({address:a,abi:u,functionName:`multicall`,args:[e.map((e,t)=>_({abi:u,functionName:`burn`,args:[e.tickLower,e.tickUpper,e.liquidity,n[t]]}))]})})}},burn:p,hash:s,isPending:c,isConfirming:d,isSuccess:f,error:l,isLoading:c||d}},oe=e=>{let{timelockLens:t}=H(),{pool:n}=Q(e),{token0Decimals:r,token1Decimals:i}=J(n),{currentPrice:a}=Z(n),o=typeof e==`string`?e:e==null?void 0:e.address,{data:s=[],refetch:c}=N({queryKey:[`liquidityBlocks`,o],queryFn:()=>t.read.getAllBlocks([o]),enabled:!!o&&!!t}),{totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f}=C(()=>({totalAmount0:r?h(s.reduce((e,t)=>e+t.totalAmount0,0n),r):void 0,totalAmount1:i?h(s.reduce((e,t)=>e+t.totalAmount1,0n),i):void 0,borrowedAmount0:r?h(s.reduce((e,t)=>e+t.borrowedAmount0,0n),r):void 0,borrowedAmount1:i?h(s.reduce((e,t)=>e+t.borrowedAmount1,0n),i):void 0}),[s,r,i]);return{tvl1:C(()=>{if(!l||!u||!a||!i)return;let e=l.scaled*a.scaled/10n**18n,t=u.scaled;return h(e+t,i)},[l,u,a,i]),blocks:s,totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f,refetch:c}},$=async(e,t,n,r,i)=>{let a=Array(t.length).fill(i),o=await e.read.batchGetAmountsForLiquidityTicks([a,t,n,r]),s=0n,c=0n,l=[],u=[];for(let e of o[0])s+=e,l.push(e);for(let e of o[1])c+=e,u.push(e);return{totalAmount0:s,totalAmount1:c,amounts0:l,amounts1:u}},se=t=>{let n=E(),{address:r}=w(),{pool:i}=Q(t),{timelockLens:a,uniswapLens:o}=H(),s=q(i),{token0:c,token1:l}=J(i),d=typeof t==`string`?t:t==null?void 0:t.address,{writeContractAsync:f,data:p,isPending:m,error:h}=k(),{isLoading:g,isSuccess:b}=O({hash:p}),x=async t=>{if(!r||!n)throw Error(`Wallet not connected`);if(s.exact===void 0||!c||!l||!d||!o)throw Error(`Current tick not available`);let{totalAmount0:i,totalAmount1:a}=await $(o,t.map(e=>e.tickLower),t.map(e=>e.tickUpper),t.map(e=>e.liquidity),s.exact),[u,p]=await Promise.all([e(c,n).read.allowance([r,d]),e(l,n).read.allowance([r,d])]),m=[];if(u<=i){let e=await f({address:c,abi:v,functionName:`approve`,args:[d,y]});m.push(M(n,{hash:e}))}if(p<=a){let e=await f({address:l,abi:v,functionName:`approve`,args:[d,y]});m.push(M(n,{hash:e}))}m.length>0&&await Promise.all(m)},S=async(e,t,r)=>{if(!n)throw Error(`Wallet not connected`);if(!d||!a)throw Error(`Vault/lens not available`);await x([{tickLower:e,tickUpper:t,liquidity:r}]);let i=await f({address:d,abi:u,functionName:`mint`,args:[e,t,r,await a.read.getRefTick([d,e])]});return await M(n,{hash:i}),i};return{mintMultiple:async e=>{if(!n)throw Error(`Wallet not connected`);if(!s.exact)throw Error(`Current tick not available`);if(e.length===0)throw Error(`No positions to mint`);if(!a||!d)throw Error(`Vault/lens not available`);if(e.length===1)await S(e[0].tickLower,e[0].tickUpper,e[0].liquidity);else{await x(e);let t=await a.read.batchGetRefTick([d,e.map(e=>e.tickLower)]);await M(n,{hash:await f({address:d,abi:u,functionName:`multicall`,args:[e.map((e,n)=>_({abi:u,functionName:`mint`,args:[e.tickLower,e.tickUpper,e.liquidity,t[n]]}))]})})}},mint:S,hash:p,isPending:m,isConfirming:g,isSuccess:b,error:h,isLoading:m||g}},ce=e=>{let{timelockLens:t}=H(),{pool:n}=Q(e),{token0Decimals:r,token1Decimals:i}=J(n),a=typeof e==`string`?e:e==null?void 0:e.address,{data:s,refetch:c}=D({address:t==null?void 0:t.address,abi:o,functionName:`getVaultTVL`,args:[a],query:{enabled:!!a&&!!t}}),l=s&&r?h(s[0],r):void 0,u=s&&i?h(s[1],i):void 0,d=s&&r?h(s[2],r):void 0,f=s&&i?h(s[3],i):void 0;return{tvl0:s&&r?h(s[4],r):void 0,tvl1:s&&i?h(s[5],i):void 0,totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f,refetch:c}};export{z as TimelockMarketProvider,$ as batchGetAmountsFromLiquidity,K as getCurrentTick,re as useActiveUserOptions,ae as useBurnLiquidity,ie as useClosedUserOptions,B as useCurrentMarket,Z as useCurrentPrice,q as useCurrentTick,W as useExerciseOption,H as useLens,oe as useLiquidityBlocks,U as useMarketData,G as useMaxPositionSize,se as useMintLiquidity,ee as useMintOption,te as useOptionPnl,ne as useOptionPremium,J as usePoolData,X as usePriceAtTick,V as useTimelockConfig,Q as useVaultData,ce as useVaultTVL};
|
|
63
|
+
`,F=A`
|
|
64
|
+
query GetMarketData($marketAddr: String!) {
|
|
65
|
+
TimelockMarket(where: {id: {_eq: $marketAddr}}, limit: 1) {
|
|
66
|
+
id
|
|
67
|
+
optionsCount
|
|
68
|
+
tradersCount
|
|
69
|
+
vault
|
|
70
|
+
pool
|
|
71
|
+
tickSpacing
|
|
72
|
+
optionAssetIsToken0
|
|
73
|
+
optionAsset
|
|
74
|
+
payoutAsset
|
|
75
|
+
optionAssetDecimals
|
|
76
|
+
payoutAssetDecimals
|
|
77
|
+
optionAssetSymbol
|
|
78
|
+
payoutAssetSymbol
|
|
79
|
+
optionAssetName
|
|
80
|
+
payoutAssetName
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`,I=(e,t,n,r)=>e();function L(e,t=I){return{GetActiveUserOptions(n,r,i){return t(t=>e.request({document:N,variables:n,requestHeaders:{...r,...t},signal:i}),`GetActiveUserOptions`,`query`,n)},GetClosedUserOptions(n,r,i){return t(t=>e.request({document:P,variables:n,requestHeaders:{...r,...t},signal:i}),`GetClosedUserOptions`,`query`,n)},GetMarketData(n,r,i){return t(t=>e.request({document:F,variables:n,requestHeaders:{...r,...t},signal:i}),`GetMarketData`,`query`,n)}}}const R=x(void 0),z=({children:e,marketData:t,envioGraphqlUrl:n})=>{let r=T(),i=d[r],a=m[r];return b.createElement(R.Provider,{value:{marketData:t||{},lensAddr:i,uniswapMathLensAddr:a,envioGraphqlUrl:n}},e)},B=()=>{let e=S(R);if(e===void 0)throw Error(`useCurrentMarket must be used within a TimelockMarketProvider`);return e.marketData},V=()=>{let e=S(R);if(e===void 0)throw Error(`useConfig must be used within a TimelockMarketProvider`);return{lensAddr:e.lensAddr,uniswapMathLensAddr:e.uniswapMathLensAddr,envioGraphqlUrl:e.envioGraphqlUrl,graphqlClient:e.envioGraphqlUrl?L(new ee(e.envioGraphqlUrl)):void 0}},H=e=>{let{graphqlClient:t}=V(),n=typeof e==`string`?e:e==null?void 0:e.address,{data:r}=M({queryKey:[`marketData`,n||`--`],queryFn:()=>t.GetMarketData({marketAddr:n}),select:e=>({...e.TimelockMarket[0],pool:e.TimelockMarket[0].pool,vault:e.TimelockMarket[0].vault,optionAsset:e.TimelockMarket[0].optionAsset,payoutAsset:e.TimelockMarket[0].payoutAsset,optionsCount:BigInt(e.TimelockMarket[0].optionsCount),tradersCount:BigInt(e.TimelockMarket[0].tradersCount)}),enabled:!!n&&!!t});return r||{}},U=e=>{let{vault:t}=H(e),n=E(),{data:r}=D({address:t,abi:u,functionName:`lowestTick`}),{writeContractAsync:i,data:a,isPending:o,error:c}=k(),{isLoading:l,isSuccess:d}=O({hash:a}),f=typeof e==`string`?e:e==null?void 0:e.address;return{exerciseOption:async(e,t)=>{if(!n)throw Error(`Wallet not connected`);if(r===void 0||!f)throw Error(`Lowest tick lower not available`);let a=await i({address:f,abi:s,functionName:`exerciseOption`,args:[e,t,0n,r]});return await j(n,{hash:a}),a},hash:a,isPending:o,isConfirming:l,isSuccess:d,error:c,isLoading:o||l}},W=()=>{let e=E(),t=e?n(e):void 0;return{uniswapLens:e?i(e):void 0,timelockLens:t}},G=(e,t,n=100)=>{let{timelockLens:r}=W(),{optionAssetDecimals:i}=H(e),a=typeof e==`string`?e:e==null?void 0:e.address,{data:s,refetch:c}=D({address:r==null?void 0:r.address,abi:o,functionName:`getMaxPositionSizeAtCurrentTick`,args:[a,n],query:{enabled:!!a&&!!r},gas:100000000n}),{data:l,refetch:u}=D({address:r==null?void 0:r.address,abi:o,functionName:`getMaxPositionSize`,args:[a,t,n],query:{enabled:!!a&&!!r&&t!==void 0},gas:100000000n}),d=t===void 0?s:l,{maxCallSize:f,maxPutSize:p}=C(()=>d&&i?{maxCallSize:h(d[0],i),maxPutSize:h(d[1],i)}:{},[d,i]);return{maxCallSize:f,maxPutSize:p,refetch:()=>{c(),u()}}},K=async e=>{let[t,{1:n}]=await Promise.all([e.read.tickSpacing(),e.read.slot0()]);return{exact:n,rounded:Math.floor(n/t)*t}},q=e=>{let t=E(),{data:n}=M({queryKey:[`currentTick`,typeof e==`string`?e:(e==null?void 0:e.address)||`-`],queryFn:()=>K(typeof e==`string`?a(e,t):e),enabled:!!e&&!!t,refetchInterval:5e3});return n||{}},J=e=>{let t=typeof e==`string`?e:e==null?void 0:e.address,{timelockLens:n}=W(),r=E(),{data:i}=D({address:n==null?void 0:n.address,abi:o,functionName:`getPoolData`,args:t?[t]:void 0,query:{enabled:!!t&&!!r}});return i||{}},te=t=>{let{timelockLens:n}=W(),{payoutAsset:i,vault:a,pool:o,optionAssetIsToken0:u}=H(t),{tickSpacing:d}=J(o),{exact:f}=q(o),p=E(),{address:m}=w(),{writeContractAsync:h,data:g,isPending:_,error:b}=k(),{isLoading:x,isSuccess:S}=O({hash:g}),C=typeof t==`string`?t:t==null?void 0:t.address,T=async t=>{if(!p||!m)throw Error(`Wallet not connected`);if(!i||!C)throw Error(`Tokens not available`);await e(i,p).read.allowance([m,C])<t&&await j(p,{hash:await h({address:i,abi:v,functionName:`approve`,args:[C,y]})})};return{mintOption:async(e,t,i,o)=>{if(!p)throw Error(`Wallet not connected`);if(!n||!a||!C||!f||!d)throw Error(`Lowest tick lower not available`);o=o??f,o=e===`CALL`&&u||e===`PUT`&&!u?l(o,d):c(o,d),await T(await r(C,p).read.calculatePremium([e===`CALL`?0:1,t,o,BigInt(i)]));let m=await h({address:C,abi:s,functionName:`mintOption`,args:[e===`CALL`?0:1,t,o,BigInt(i),BigInt(1e69),await n.read.getRefTick([a,o])]});return await j(p,{hash:m}),m},hash:g,isPending:_,isConfirming:x,isSuccess:S,error:b,isLoading:_||x}},ne=e=>{let{marketAddr:t,optionType:n,entryTick:r,positionSizeCurrent:i}=e,{pool:a,optionAssetIsToken0:o,payoutAssetDecimals:s}=H(t),{exact:c}=q(a),{displayPnl:l,unrealizedPayout:u}=C(()=>{if(o===void 0||c===void 0||!i||!s)return{};let e=o?f(i,c)-f(i,r):p(i,c)-p(i,r),t=h(n===`CALL`?e:-e,s);return{unrealizedPayout:h(t.scaled<0?0n:t.scaled,s),displayPnl:t}},[e,o,c,i]);return{displayPnl:l,unrealizedPayout:u}},re=(e,t,n,r)=>{let{pool:i,payoutAssetDecimals:a}=H(e),{tickSpacing:o}=J(i),c=q(i),l=typeof e==`string`?e:e==null?void 0:e.address,u=C(()=>{if(!(c.rounded===void 0||o===void 0))return t===`CALL`?c.rounded+o:c.rounded},[c.rounded,o,t]),{data:d}=D({address:l,abi:s,functionName:`calculatePremium`,args:u===void 0?void 0:[t===`CALL`?0:1,n,u,BigInt(r)],query:{enabled:c.rounded!==void 0&&a!==void 0&&o!==void 0&&u!==void 0}});return C(()=>{if(!(d===void 0||a===void 0))return h(d,a)},[d,a])},Y=(e,t=!1)=>{let{graphqlClient:n}=V(),{data:r,...i}=M({queryKey:[`userTrades`,e||`--`,t],queryFn:()=>t?n==null?void 0:n.GetActiveUserOptions({user:e.toLowerCase()}):n==null?void 0:n.GetClosedUserOptions({user:e.toLowerCase()}),select:e=>{var t;return e==null||(t=e.UserOption)==null?void 0:t.map(e=>({...e,id:BigInt(e.id),marketAddr:e.marketAddr,optionType:e.optionType,createdAt:new Date(Number(e.createdAt)*1e3),expiresAt:new Date(Number(e.expiresAt)*1e3),premiumPaid:BigInt(e.premiumPaid),realizedPayout:BigInt(e.realizedPayout),liquiditiesAtOpen:e.liquiditiesAtOpen.map(e=>BigInt(e)),liquiditiesCurrent:e.liquiditiesCurrent.map(e=>BigInt(e)),positionSizeAtOpen:BigInt(e.positionSizeAtOpen),positionSizeCurrent:BigInt(e.positionSizeCurrent),strikePrice:BigInt(e.strikePrice),entryPrice:BigInt(e.entryPrice)}))},enabled:!!e&&!!n});return{data:C(()=>(r==null?void 0:r.sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()))||[],[r]),...i}},ie=e=>Y(e,!0),ae=e=>Y(e,!1),X=(e,n)=>{let{token0Decimals:r,token1Decimals:i}=J(n);return C(()=>e&&r&&i?g(t(e),r,i):void 0,[e,r,i])},Z=e=>{let t=q(e);return{currentPrice:X(t.exact,e),currentTick:t}},Q=e=>{let{data:t}=D({address:typeof e==`string`?e:e==null?void 0:e.address,abi:u,functionName:`pool`});return{pool:t}},oe=e=>{let t=E(),{pool:n}=Q(e),r=q(n),{timelockLens:i}=W(),a=typeof e==`string`?e:e==null?void 0:e.address,{writeContractAsync:o,data:s,isPending:c,error:l}=k(),{isLoading:d,isSuccess:f}=O({hash:s}),p=async(e,n,r)=>{if(!t)throw Error(`Wallet not connected`);if(!a||!i)throw Error(`Vault/lens not available`);let s=await o({address:a,abi:u,functionName:`burn`,args:[e,n,r,await i.read.getRefTick([a,e])]});return await j(t,{hash:s}),s};return{burnMultiple:async e=>{if(!t)throw Error(`Wallet not connected`);if(!r.exact)throw Error(`Current tick not available`);if(e.length===0)throw Error(`No positions to burn`);if(!i||!a)throw Error(`Vault/lens not available`);if(e.length===1)await p(e[0].tickLower,e[0].tickUpper,e[0].liquidity);else{let n=await i.read.batchGetRefTick([a,e.map(e=>e.tickLower)]);await j(t,{hash:await o({address:a,abi:u,functionName:`multicall`,args:[e.map((e,t)=>_({abi:u,functionName:`burn`,args:[e.tickLower,e.tickUpper,e.liquidity,n[t]]}))]})})}},burn:p,hash:s,isPending:c,isConfirming:d,isSuccess:f,error:l,isLoading:c||d}},se=e=>{let{timelockLens:t}=W(),{pool:n}=Q(e),{token0Decimals:r,token1Decimals:i}=J(n),{currentPrice:a}=Z(n),o=typeof e==`string`?e:e==null?void 0:e.address,{data:s=[],refetch:c}=M({queryKey:[`liquidityBlocks`,o],queryFn:()=>t.read.getAllBlocks([o]),enabled:!!o&&!!t}),{totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f}=C(()=>({totalAmount0:r?h(s.reduce((e,t)=>e+t.totalAmount0,0n),r):void 0,totalAmount1:i?h(s.reduce((e,t)=>e+t.totalAmount1,0n),i):void 0,borrowedAmount0:r?h(s.reduce((e,t)=>e+t.borrowedAmount0,0n),r):void 0,borrowedAmount1:i?h(s.reduce((e,t)=>e+t.borrowedAmount1,0n),i):void 0}),[s,r,i]);return{tvl1:C(()=>{if(!l||!u||!a||!i)return;let e=l.scaled*a.scaled/10n**18n,t=u.scaled;return h(e+t,i)},[l,u,a,i]),blocks:s,totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f,refetch:c}},$=async(e,t,n,r,i)=>{let a=Array(t.length).fill(i),o=await e.read.batchGetAmountsForLiquidityTicks([a,t,n,r]),s=0n,c=0n,l=[],u=[];for(let e of o[0])s+=e,l.push(e);for(let e of o[1])c+=e,u.push(e);return{totalAmount0:s,totalAmount1:c,amounts0:l,amounts1:u}},ce=t=>{let n=E(),{address:r}=w(),{pool:i}=Q(t),{timelockLens:a,uniswapLens:o}=W(),s=q(i),{token0:c,token1:l}=J(i),d=typeof t==`string`?t:t==null?void 0:t.address,{writeContractAsync:f,data:p,isPending:m,error:h}=k(),{isLoading:g,isSuccess:b}=O({hash:p}),x=async t=>{if(!r||!n)throw Error(`Wallet not connected`);if(s.exact===void 0||!c||!l||!d||!o)throw Error(`Current tick not available`);let{totalAmount0:i,totalAmount1:a}=await $(o,t.map(e=>e.tickLower),t.map(e=>e.tickUpper),t.map(e=>e.liquidity),s.exact),[u,p]=await Promise.all([e(c,n).read.allowance([r,d]),e(l,n).read.allowance([r,d])]),m=[];if(u<=i){let e=await f({address:c,abi:v,functionName:`approve`,args:[d,y]});m.push(j(n,{hash:e}))}if(p<=a){let e=await f({address:l,abi:v,functionName:`approve`,args:[d,y]});m.push(j(n,{hash:e}))}m.length>0&&await Promise.all(m)},S=async(e,t,r)=>{if(!n)throw Error(`Wallet not connected`);if(!d||!a)throw Error(`Vault/lens not available`);await x([{tickLower:e,tickUpper:t,liquidity:r}]);let i=await f({address:d,abi:u,functionName:`mint`,args:[e,t,r,await a.read.getRefTick([d,e])]});return await j(n,{hash:i}),i};return{mintMultiple:async e=>{if(!n)throw Error(`Wallet not connected`);if(!s.exact)throw Error(`Current tick not available`);if(e.length===0)throw Error(`No positions to mint`);if(!a||!d)throw Error(`Vault/lens not available`);if(e.length===1)await S(e[0].tickLower,e[0].tickUpper,e[0].liquidity);else{await x(e);let t=await a.read.batchGetRefTick([d,e.map(e=>e.tickLower)]);await j(n,{hash:await f({address:d,abi:u,functionName:`multicall`,args:[e.map((e,n)=>_({abi:u,functionName:`mint`,args:[e.tickLower,e.tickUpper,e.liquidity,t[n]]}))]})})}},mint:S,hash:p,isPending:m,isConfirming:g,isSuccess:b,error:h,isLoading:m||g}},le=e=>{let{timelockLens:t}=W(),{pool:n}=Q(e),{token0Decimals:r,token1Decimals:i}=J(n),a=typeof e==`string`?e:e==null?void 0:e.address,{data:s,refetch:c}=D({address:t==null?void 0:t.address,abi:o,functionName:`getVaultTVL`,args:[a],query:{enabled:!!a&&!!t}}),l=s&&r?h(s[0],r):void 0,u=s&&i?h(s[1],i):void 0,d=s&&r?h(s[2],r):void 0,f=s&&i?h(s[3],i):void 0;return{tvl0:s&&r?h(s[4],r):void 0,tvl1:s&&i?h(s[5],i):void 0,totalAmount0:l,totalAmount1:u,borrowedAmount0:d,borrowedAmount1:f,refetch:c}};export{z as TimelockMarketProvider,$ as batchGetAmountsFromLiquidity,K as getCurrentTick,ie as useActiveUserOptions,oe as useBurnLiquidity,ae as useClosedUserOptions,B as useCurrentMarket,Z as useCurrentPrice,q as useCurrentTick,U as useExerciseOption,W as useLens,se as useLiquidityBlocks,H as useMarketData,G as useMaxPositionSize,ce as useMintLiquidity,te as useMintOption,ne as useOptionPnl,re as useOptionPremium,J as usePoolData,X as usePriceAtTick,V as useTimelockConfig,Q as useVaultData,le as useVaultTVL};
|
|
64
84
|
//# sourceMappingURL=client.js.map
|