timelock-sdk 0.0.9 → 0.0.10
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 +95 -70
- package/dist/client.d.ts +91 -66
- package/dist/client.js +23 -3
- package/dist/client.js.map +1 -1
- package/dist/{index-sG69Fv-T.d.ts → index-BCGDfKXC.d.cts} +123 -122
- package/dist/{index-DDAsERk2.d.cts → index-D6LBNb6K.d.ts} +16 -15
- 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-D6LBNb6K.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,7 +156,7 @@ declare const TimelockMarketProvider: ({
|
|
|
150
156
|
marketData?: Partial<TimelockMarketData>;
|
|
151
157
|
envioGraphqlUrl?: string;
|
|
152
158
|
}) => React.JSX.Element;
|
|
153
|
-
declare const useCurrentMarket: () => Partial<
|
|
159
|
+
declare const useCurrentMarket: () => Partial<{
|
|
154
160
|
optionAssetIsToken0: boolean;
|
|
155
161
|
vault: `0x${string}`;
|
|
156
162
|
pool: `0x${string}`;
|
|
@@ -163,9 +169,7 @@ declare const useCurrentMarket: () => Partial<Required<Partial<{
|
|
|
163
169
|
optionAssetName: string;
|
|
164
170
|
payoutAssetName: string;
|
|
165
171
|
optionsCount: bigint;
|
|
166
|
-
}
|
|
167
|
-
address: Address;
|
|
168
|
-
}>>>;
|
|
172
|
+
}>;
|
|
169
173
|
declare const useTimelockConfig: () => {
|
|
170
174
|
lensAddr: `0x${string}` | undefined;
|
|
171
175
|
uniswapMathLensAddr: `0x${string}` | undefined;
|
|
@@ -173,6 +177,7 @@ declare const useTimelockConfig: () => {
|
|
|
173
177
|
graphqlClient: {
|
|
174
178
|
GetActiveUserOptions(variables: GetActiveUserOptionsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetActiveUserOptionsQuery>;
|
|
175
179
|
GetClosedUserOptions(variables: GetClosedUserOptionsQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetClosedUserOptionsQuery>;
|
|
180
|
+
GetMarketData(variables: GetMarketDataQueryVariables, requestHeaders?: any, signal?: RequestInit["signal"]): Promise<GetMarketDataQuery>;
|
|
176
181
|
} | undefined;
|
|
177
182
|
};
|
|
178
183
|
//#endregion
|
|
@@ -187,6 +192,26 @@ declare const useExerciseOption: (market?: Address | TimelockMarket) => {
|
|
|
187
192
|
isLoading: boolean;
|
|
188
193
|
};
|
|
189
194
|
//#endregion
|
|
195
|
+
//#region src/hooks/market/useMarketData.d.ts
|
|
196
|
+
declare const useMarketData: (market?: Address | TimelockMarket) => Partial<NonUndefinedGuard<{
|
|
197
|
+
pool: Address;
|
|
198
|
+
vault: Address;
|
|
199
|
+
optionAsset: Address;
|
|
200
|
+
payoutAsset: Address;
|
|
201
|
+
optionsCount: bigint;
|
|
202
|
+
tradersCount: bigint;
|
|
203
|
+
__typename: "TimelockMarket";
|
|
204
|
+
id: string;
|
|
205
|
+
tickSpacing: number;
|
|
206
|
+
optionAssetIsToken0: boolean;
|
|
207
|
+
optionAssetDecimals: number;
|
|
208
|
+
payoutAssetDecimals: number;
|
|
209
|
+
optionAssetSymbol: string;
|
|
210
|
+
payoutAssetSymbol: string;
|
|
211
|
+
optionAssetName: string;
|
|
212
|
+
payoutAssetName: string;
|
|
213
|
+
} | undefined>>;
|
|
214
|
+
//#endregion
|
|
190
215
|
//#region src/hooks/market/useMaxPositionSize.d.ts
|
|
191
216
|
declare const useMaxPositionSize: (market: Address | TimelockMarket | undefined, strikeTick?: number, maxBorrowableRange?: number) => {
|
|
192
217
|
maxCallSize: Amount | undefined;
|
|
@@ -205,7 +230,7 @@ declare const useMintOption: (market?: Address | TimelockMarket) => {
|
|
|
205
230
|
isLoading: boolean;
|
|
206
231
|
};
|
|
207
232
|
//#endregion
|
|
208
|
-
//#region src/hooks/market/
|
|
233
|
+
//#region src/hooks/market/useOptionPnl.d.ts
|
|
209
234
|
declare const useOptionPnl: (optionData: {
|
|
210
235
|
marketAddr: Address;
|
|
211
236
|
optionType: "CALL" | "PUT";
|
|
@@ -2292,14 +2317,14 @@ declare const useVaultTVL: (vault?: Address | TimelockVault) => {
|
|
|
2292
2317
|
totalAmount1: Amount | undefined;
|
|
2293
2318
|
borrowedAmount0: Amount | undefined;
|
|
2294
2319
|
borrowedAmount1: Amount | undefined;
|
|
2295
|
-
refetch: (options?: _tanstack_query_core0.RefetchOptions) => Promise<_tanstack_query_core0.QueryObserverResult<readonly [bigint, bigint, bigint, bigint, bigint, bigint],
|
|
2320
|
+
refetch: (options?: _tanstack_query_core0.RefetchOptions) => Promise<_tanstack_query_core0.QueryObserverResult<readonly [bigint, bigint, bigint, bigint, bigint, bigint], viem382.ReadContractErrorType>>;
|
|
2296
2321
|
};
|
|
2297
2322
|
//#endregion
|
|
2298
2323
|
//#region src/hooks/useLens.d.ts
|
|
2299
2324
|
declare const useLens: () => {
|
|
2300
2325
|
uniswapLens: {
|
|
2301
2326
|
read: {
|
|
2302
|
-
batchGetAmount0ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?:
|
|
2327
|
+
batchGetAmount0ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
2303
2328
|
readonly type: "function";
|
|
2304
2329
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
2305
2330
|
readonly inputs: readonly [{
|
|
@@ -2920,7 +2945,7 @@ declare const useLens: () => {
|
|
|
2920
2945
|
}];
|
|
2921
2946
|
readonly stateMutability: "pure";
|
|
2922
2947
|
}], "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?:
|
|
2948
|
+
batchGetAmount0ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
2924
2949
|
readonly type: "function";
|
|
2925
2950
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
2926
2951
|
readonly inputs: readonly [{
|
|
@@ -3541,7 +3566,7 @@ declare const useLens: () => {
|
|
|
3541
3566
|
}];
|
|
3542
3567
|
readonly stateMutability: "pure";
|
|
3543
3568
|
}], "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?:
|
|
3569
|
+
batchGetAmount1ForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
3545
3570
|
readonly type: "function";
|
|
3546
3571
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
3547
3572
|
readonly inputs: readonly [{
|
|
@@ -4162,7 +4187,7 @@ declare const useLens: () => {
|
|
|
4162
4187
|
}];
|
|
4163
4188
|
readonly stateMutability: "pure";
|
|
4164
4189
|
}], "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?:
|
|
4190
|
+
batchGetAmount1ForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
4166
4191
|
readonly type: "function";
|
|
4167
4192
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
4168
4193
|
readonly inputs: readonly [{
|
|
@@ -4783,7 +4808,7 @@ declare const useLens: () => {
|
|
|
4783
4808
|
}];
|
|
4784
4809
|
readonly stateMutability: "pure";
|
|
4785
4810
|
}], "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?:
|
|
4811
|
+
batchGetAmountsForLiquidity: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
4787
4812
|
readonly type: "function";
|
|
4788
4813
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
4789
4814
|
readonly inputs: readonly [{
|
|
@@ -5404,7 +5429,7 @@ declare const useLens: () => {
|
|
|
5404
5429
|
}];
|
|
5405
5430
|
readonly stateMutability: "pure";
|
|
5406
5431
|
}], "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?:
|
|
5432
|
+
batchGetAmountsForLiquidityTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
5408
5433
|
readonly type: "function";
|
|
5409
5434
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
5410
5435
|
readonly inputs: readonly [{
|
|
@@ -6025,7 +6050,7 @@ declare const useLens: () => {
|
|
|
6025
6050
|
}];
|
|
6026
6051
|
readonly stateMutability: "pure";
|
|
6027
6052
|
}], "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?:
|
|
6053
|
+
batchGetLiquidityForAmount0: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
6029
6054
|
readonly type: "function";
|
|
6030
6055
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
6031
6056
|
readonly inputs: readonly [{
|
|
@@ -6646,7 +6671,7 @@ declare const useLens: () => {
|
|
|
6646
6671
|
}];
|
|
6647
6672
|
readonly stateMutability: "pure";
|
|
6648
6673
|
}], "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?:
|
|
6674
|
+
batchGetLiquidityForAmount0Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
6650
6675
|
readonly type: "function";
|
|
6651
6676
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
6652
6677
|
readonly inputs: readonly [{
|
|
@@ -7267,7 +7292,7 @@ declare const useLens: () => {
|
|
|
7267
7292
|
}];
|
|
7268
7293
|
readonly stateMutability: "pure";
|
|
7269
7294
|
}], "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?:
|
|
7295
|
+
batchGetLiquidityForAmount1: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
7271
7296
|
readonly type: "function";
|
|
7272
7297
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
7273
7298
|
readonly inputs: readonly [{
|
|
@@ -7888,7 +7913,7 @@ declare const useLens: () => {
|
|
|
7888
7913
|
}];
|
|
7889
7914
|
readonly stateMutability: "pure";
|
|
7890
7915
|
}], "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?:
|
|
7916
|
+
batchGetLiquidityForAmount1Ticks: (args: readonly [readonly number[], readonly number[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
7892
7917
|
readonly type: "function";
|
|
7893
7918
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
7894
7919
|
readonly inputs: readonly [{
|
|
@@ -8509,7 +8534,7 @@ declare const useLens: () => {
|
|
|
8509
8534
|
}];
|
|
8510
8535
|
readonly stateMutability: "pure";
|
|
8511
8536
|
}], "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?:
|
|
8537
|
+
batchGetLiquidityForAmounts: (args: readonly [readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
8513
8538
|
readonly type: "function";
|
|
8514
8539
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
8515
8540
|
readonly inputs: readonly [{
|
|
@@ -9130,7 +9155,7 @@ declare const useLens: () => {
|
|
|
9130
9155
|
}];
|
|
9131
9156
|
readonly stateMutability: "pure";
|
|
9132
9157
|
}], "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?:
|
|
9158
|
+
batchGetLiquidityForAmountsTicks: (args: readonly [readonly number[], readonly number[], readonly number[], readonly bigint[], readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
9134
9159
|
readonly type: "function";
|
|
9135
9160
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
9136
9161
|
readonly inputs: readonly [{
|
|
@@ -9751,7 +9776,7 @@ declare const useLens: () => {
|
|
|
9751
9776
|
}];
|
|
9752
9777
|
readonly stateMutability: "pure";
|
|
9753
9778
|
}], "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?:
|
|
9779
|
+
batchGetPriceAtTick: (args: readonly [readonly number[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
9755
9780
|
readonly type: "function";
|
|
9756
9781
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
9757
9782
|
readonly inputs: readonly [{
|
|
@@ -10372,7 +10397,7 @@ declare const useLens: () => {
|
|
|
10372
10397
|
}];
|
|
10373
10398
|
readonly stateMutability: "pure";
|
|
10374
10399
|
}], "batchGetPriceAtTick", readonly [readonly number[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly bigint[]>;
|
|
10375
|
-
getAmount0ForLiquidity: (args: readonly [bigint, bigint, bigint], options?:
|
|
10400
|
+
getAmount0ForLiquidity: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
10376
10401
|
readonly type: "function";
|
|
10377
10402
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
10378
10403
|
readonly inputs: readonly [{
|
|
@@ -10993,7 +11018,7 @@ declare const useLens: () => {
|
|
|
10993
11018
|
}];
|
|
10994
11019
|
readonly stateMutability: "pure";
|
|
10995
11020
|
}], "getAmount0ForLiquidity", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
10996
|
-
getAmount0ForLiquidityTicks: (args: readonly [number, number, bigint], options?:
|
|
11021
|
+
getAmount0ForLiquidityTicks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
10997
11022
|
readonly type: "function";
|
|
10998
11023
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
10999
11024
|
readonly inputs: readonly [{
|
|
@@ -11614,7 +11639,7 @@ declare const useLens: () => {
|
|
|
11614
11639
|
}];
|
|
11615
11640
|
readonly stateMutability: "pure";
|
|
11616
11641
|
}], "getAmount0ForLiquidityTicks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
11617
|
-
getAmount1ForLiquidity: (args: readonly [bigint, bigint, bigint], options?:
|
|
11642
|
+
getAmount1ForLiquidity: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
11618
11643
|
readonly type: "function";
|
|
11619
11644
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
11620
11645
|
readonly inputs: readonly [{
|
|
@@ -12235,7 +12260,7 @@ declare const useLens: () => {
|
|
|
12235
12260
|
}];
|
|
12236
12261
|
readonly stateMutability: "pure";
|
|
12237
12262
|
}], "getAmount1ForLiquidity", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
12238
|
-
getAmount1ForLiquidityTicks: (args: readonly [number, number, bigint], options?:
|
|
12263
|
+
getAmount1ForLiquidityTicks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
12239
12264
|
readonly type: "function";
|
|
12240
12265
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
12241
12266
|
readonly inputs: readonly [{
|
|
@@ -12856,7 +12881,7 @@ declare const useLens: () => {
|
|
|
12856
12881
|
}];
|
|
12857
12882
|
readonly stateMutability: "pure";
|
|
12858
12883
|
}], "getAmount1ForLiquidityTicks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
12859
|
-
getAmountsForLiquidity: (args: readonly [bigint, bigint, bigint, bigint], options?:
|
|
12884
|
+
getAmountsForLiquidity: (args: readonly [bigint, bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
12860
12885
|
readonly type: "function";
|
|
12861
12886
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
12862
12887
|
readonly inputs: readonly [{
|
|
@@ -13477,7 +13502,7 @@ declare const useLens: () => {
|
|
|
13477
13502
|
}];
|
|
13478
13503
|
readonly stateMutability: "pure";
|
|
13479
13504
|
}], "getAmountsForLiquidity", readonly [bigint, bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
13480
|
-
getAmountsForLiquidityTicks: (args: readonly [number, number, number, bigint], options?:
|
|
13505
|
+
getAmountsForLiquidityTicks: (args: readonly [number, number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
13481
13506
|
readonly type: "function";
|
|
13482
13507
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
13483
13508
|
readonly inputs: readonly [{
|
|
@@ -14098,7 +14123,7 @@ declare const useLens: () => {
|
|
|
14098
14123
|
}];
|
|
14099
14124
|
readonly stateMutability: "pure";
|
|
14100
14125
|
}], "getAmountsForLiquidityTicks", readonly [number, number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
14101
|
-
getLiquidityForAmount0: (args: readonly [bigint, bigint, bigint], options?:
|
|
14126
|
+
getLiquidityForAmount0: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
14102
14127
|
readonly type: "function";
|
|
14103
14128
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
14104
14129
|
readonly inputs: readonly [{
|
|
@@ -14719,7 +14744,7 @@ declare const useLens: () => {
|
|
|
14719
14744
|
}];
|
|
14720
14745
|
readonly stateMutability: "pure";
|
|
14721
14746
|
}], "getLiquidityForAmount0", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
14722
|
-
getLiquidityForAmount0Ticks: (args: readonly [number, number, bigint], options?:
|
|
14747
|
+
getLiquidityForAmount0Ticks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
14723
14748
|
readonly type: "function";
|
|
14724
14749
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
14725
14750
|
readonly inputs: readonly [{
|
|
@@ -15340,7 +15365,7 @@ declare const useLens: () => {
|
|
|
15340
15365
|
}];
|
|
15341
15366
|
readonly stateMutability: "pure";
|
|
15342
15367
|
}], "getLiquidityForAmount0Ticks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
15343
|
-
getLiquidityForAmount1: (args: readonly [bigint, bigint, bigint], options?:
|
|
15368
|
+
getLiquidityForAmount1: (args: readonly [bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
15344
15369
|
readonly type: "function";
|
|
15345
15370
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
15346
15371
|
readonly inputs: readonly [{
|
|
@@ -15961,7 +15986,7 @@ declare const useLens: () => {
|
|
|
15961
15986
|
}];
|
|
15962
15987
|
readonly stateMutability: "pure";
|
|
15963
15988
|
}], "getLiquidityForAmount1", readonly [bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
15964
|
-
getLiquidityForAmount1Ticks: (args: readonly [number, number, bigint], options?:
|
|
15989
|
+
getLiquidityForAmount1Ticks: (args: readonly [number, number, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
15965
15990
|
readonly type: "function";
|
|
15966
15991
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
15967
15992
|
readonly inputs: readonly [{
|
|
@@ -16582,7 +16607,7 @@ declare const useLens: () => {
|
|
|
16582
16607
|
}];
|
|
16583
16608
|
readonly stateMutability: "pure";
|
|
16584
16609
|
}], "getLiquidityForAmount1Ticks", readonly [number, number, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
16585
|
-
getLiquidityForAmounts: (args: readonly [bigint, bigint, bigint, bigint, bigint], options?:
|
|
16610
|
+
getLiquidityForAmounts: (args: readonly [bigint, bigint, bigint, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
16586
16611
|
readonly type: "function";
|
|
16587
16612
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
16588
16613
|
readonly inputs: readonly [{
|
|
@@ -17203,7 +17228,7 @@ declare const useLens: () => {
|
|
|
17203
17228
|
}];
|
|
17204
17229
|
readonly stateMutability: "pure";
|
|
17205
17230
|
}], "getLiquidityForAmounts", readonly [bigint, bigint, bigint, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
17206
|
-
getLiquidityForAmountsTicks: (args: readonly [number, number, number, bigint, bigint], options?:
|
|
17231
|
+
getLiquidityForAmountsTicks: (args: readonly [number, number, number, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
17207
17232
|
readonly type: "function";
|
|
17208
17233
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
17209
17234
|
readonly inputs: readonly [{
|
|
@@ -17824,7 +17849,7 @@ declare const useLens: () => {
|
|
|
17824
17849
|
}];
|
|
17825
17850
|
readonly stateMutability: "pure";
|
|
17826
17851
|
}], "getLiquidityForAmountsTicks", readonly [number, number, number, bigint, bigint]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<bigint>;
|
|
17827
|
-
getPriceAtTick: (args: readonly [number], options?:
|
|
17852
|
+
getPriceAtTick: (args: readonly [number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
17828
17853
|
readonly type: "function";
|
|
17829
17854
|
readonly name: "batchGetAmount0ForLiquidity";
|
|
17830
17855
|
readonly inputs: readonly [{
|
|
@@ -19071,7 +19096,7 @@ declare const useLens: () => {
|
|
|
19071
19096
|
} | undefined;
|
|
19072
19097
|
timelockLens: {
|
|
19073
19098
|
read: {
|
|
19074
|
-
batchGetRefTick: (args: readonly [`0x${string}`, readonly number[]], options?:
|
|
19099
|
+
batchGetRefTick: (args: readonly [`0x${string}`, readonly number[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
19075
19100
|
readonly type: "function";
|
|
19076
19101
|
readonly name: "batchGetRefTick";
|
|
19077
19102
|
readonly inputs: readonly [{
|
|
@@ -19773,7 +19798,7 @@ declare const useLens: () => {
|
|
|
19773
19798
|
}];
|
|
19774
19799
|
readonly stateMutability: "view";
|
|
19775
19800
|
}], "batchGetRefTick", readonly [`0x${string}`, readonly number[]]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly number[]>;
|
|
19776
|
-
getAllBlocks: (args: readonly [`0x${string}`], options?:
|
|
19801
|
+
getAllBlocks: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
19777
19802
|
readonly type: "function";
|
|
19778
19803
|
readonly name: "batchGetRefTick";
|
|
19779
19804
|
readonly inputs: readonly [{
|
|
@@ -20485,7 +20510,7 @@ declare const useLens: () => {
|
|
|
20485
20510
|
borrowedAmount0: bigint;
|
|
20486
20511
|
borrowedAmount1: bigint;
|
|
20487
20512
|
}[]>;
|
|
20488
|
-
getExpiredOptions: (args: readonly [`0x${string}`, bigint, bigint], options?:
|
|
20513
|
+
getExpiredOptions: (args: readonly [`0x${string}`, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
20489
20514
|
readonly type: "function";
|
|
20490
20515
|
readonly name: "batchGetRefTick";
|
|
20491
20516
|
readonly inputs: readonly [{
|
|
@@ -21206,7 +21231,7 @@ declare const useLens: () => {
|
|
|
21206
21231
|
createdAt: bigint;
|
|
21207
21232
|
liquidities: readonly bigint[];
|
|
21208
21233
|
}[], bigint, boolean]>;
|
|
21209
|
-
getLiquidityAtTick: (args: readonly [`0x${string}`, number], options?:
|
|
21234
|
+
getLiquidityAtTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
21210
21235
|
readonly type: "function";
|
|
21211
21236
|
readonly name: "batchGetRefTick";
|
|
21212
21237
|
readonly inputs: readonly [{
|
|
@@ -21908,7 +21933,7 @@ declare const useLens: () => {
|
|
|
21908
21933
|
}];
|
|
21909
21934
|
readonly stateMutability: "view";
|
|
21910
21935
|
}], "getLiquidityAtTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
21911
|
-
getMarketData: (args: readonly [`0x${string}`], options?:
|
|
21936
|
+
getMarketData: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
21912
21937
|
readonly type: "function";
|
|
21913
21938
|
readonly name: "batchGetRefTick";
|
|
21914
21939
|
readonly inputs: readonly [{
|
|
@@ -22623,7 +22648,7 @@ declare const useLens: () => {
|
|
|
22623
22648
|
payoutAssetName: string;
|
|
22624
22649
|
optionsCount: bigint;
|
|
22625
22650
|
}>;
|
|
22626
|
-
getMaxPositionSize: (args: readonly [`0x${string}`, number, number], options?:
|
|
22651
|
+
getMaxPositionSize: (args: readonly [`0x${string}`, number, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
22627
22652
|
readonly type: "function";
|
|
22628
22653
|
readonly name: "batchGetRefTick";
|
|
22629
22654
|
readonly inputs: readonly [{
|
|
@@ -23325,7 +23350,7 @@ declare const useLens: () => {
|
|
|
23325
23350
|
}];
|
|
23326
23351
|
readonly stateMutability: "view";
|
|
23327
23352
|
}], "getMaxPositionSize", readonly [`0x${string}`, number, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
23328
|
-
getMaxPositionSizeAtCurrentTick: (args: readonly [`0x${string}`, number], options?:
|
|
23353
|
+
getMaxPositionSizeAtCurrentTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
23329
23354
|
readonly type: "function";
|
|
23330
23355
|
readonly name: "batchGetRefTick";
|
|
23331
23356
|
readonly inputs: readonly [{
|
|
@@ -24027,7 +24052,7 @@ declare const useLens: () => {
|
|
|
24027
24052
|
}];
|
|
24028
24053
|
readonly stateMutability: "view";
|
|
24029
24054
|
}], "getMaxPositionSizeAtCurrentTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<readonly [bigint, bigint]>;
|
|
24030
|
-
getOptionData: (args: readonly [`0x${string}`, bigint], options?:
|
|
24055
|
+
getOptionData: (args: readonly [`0x${string}`, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
24031
24056
|
readonly type: "function";
|
|
24032
24057
|
readonly name: "batchGetRefTick";
|
|
24033
24058
|
readonly inputs: readonly [{
|
|
@@ -24748,7 +24773,7 @@ declare const useLens: () => {
|
|
|
24748
24773
|
createdAt: bigint;
|
|
24749
24774
|
liquidities: readonly bigint[];
|
|
24750
24775
|
}>;
|
|
24751
|
-
getOptionsData: (args: readonly [`0x${string}`, readonly bigint[]], options?:
|
|
24776
|
+
getOptionsData: (args: readonly [`0x${string}`, readonly bigint[]], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
24752
24777
|
readonly type: "function";
|
|
24753
24778
|
readonly name: "batchGetRefTick";
|
|
24754
24779
|
readonly inputs: readonly [{
|
|
@@ -25469,7 +25494,7 @@ declare const useLens: () => {
|
|
|
25469
25494
|
createdAt: bigint;
|
|
25470
25495
|
liquidities: readonly bigint[];
|
|
25471
25496
|
}[]>;
|
|
25472
|
-
getPoolData: (args: readonly [`0x${string}`], options?:
|
|
25497
|
+
getPoolData: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
25473
25498
|
readonly type: "function";
|
|
25474
25499
|
readonly name: "batchGetRefTick";
|
|
25475
25500
|
readonly inputs: readonly [{
|
|
@@ -26182,7 +26207,7 @@ declare const useLens: () => {
|
|
|
26182
26207
|
tickSpacing: number;
|
|
26183
26208
|
fee: number;
|
|
26184
26209
|
}>;
|
|
26185
|
-
getRefTick: (args: readonly [`0x${string}`, number], options?:
|
|
26210
|
+
getRefTick: (args: readonly [`0x${string}`, number], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
26186
26211
|
readonly type: "function";
|
|
26187
26212
|
readonly name: "batchGetRefTick";
|
|
26188
26213
|
readonly inputs: readonly [{
|
|
@@ -26884,7 +26909,7 @@ declare const useLens: () => {
|
|
|
26884
26909
|
}];
|
|
26885
26910
|
readonly stateMutability: "view";
|
|
26886
26911
|
}], "getRefTick", readonly [`0x${string}`, number]>, "address" | "abi" | "args" | "functionName">> | undefined) => Promise<number>;
|
|
26887
|
-
getUserOptions: (args: readonly [`0x${string}`, `0x${string}`, bigint, bigint], options?:
|
|
26912
|
+
getUserOptions: (args: readonly [`0x${string}`, `0x${string}`, bigint, bigint], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
26888
26913
|
readonly type: "function";
|
|
26889
26914
|
readonly name: "batchGetRefTick";
|
|
26890
26915
|
readonly inputs: readonly [{
|
|
@@ -27605,7 +27630,7 @@ declare const useLens: () => {
|
|
|
27605
27630
|
createdAt: bigint;
|
|
27606
27631
|
liquidities: readonly bigint[];
|
|
27607
27632
|
}[], bigint, boolean]>;
|
|
27608
|
-
getVaultTVL: (args: readonly [`0x${string}`], options?:
|
|
27633
|
+
getVaultTVL: (args: readonly [`0x${string}`], options?: viem382.Prettify<viem382.UnionOmit<viem382.ReadContractParameters<readonly [{
|
|
27609
27634
|
readonly type: "function";
|
|
27610
27635
|
readonly name: "batchGetRefTick";
|
|
27611
27636
|
readonly inputs: readonly [{
|
|
@@ -29014,5 +29039,5 @@ declare const useLens: () => {
|
|
|
29014
29039
|
} | undefined;
|
|
29015
29040
|
};
|
|
29016
29041
|
//#endregion
|
|
29017
|
-
export { LiquidityBlockData, OptionData,
|
|
29042
|
+
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
29043
|
//# 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
|