timelock-sdk 0.0.49 → 0.0.51
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/abis.cjs +1 -1
- package/dist/abis.d.cts +1 -1
- package/dist/abis.d.ts +1 -1
- package/dist/abis.js +1 -1
- package/dist/client.cjs +33 -24
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +57 -513
- package/dist/client.d.ts +57 -513
- package/dist/client.js +34 -25
- package/dist/client.js.map +1 -1
- package/dist/{index-Bg4UAy7Y.d.cts → index-BPKijlT_.d.cts} +2 -458
- package/dist/{index-DiDvh-kv.d.ts → index-Dt4gerGl.d.ts} +93 -549
- package/dist/{numberUtils-BKQtAolx.cjs → numberUtils-CkwkoxOr.cjs} +3 -3
- package/dist/{numberUtils-BKQtAolx.cjs.map → numberUtils-CkwkoxOr.cjs.map} +1 -1
- package/dist/{numberUtils-Dk0TuHnT.js → numberUtils-Cznv1Tfa.js} +3 -3
- package/dist/{numberUtils-Dk0TuHnT.js.map → numberUtils-Cznv1Tfa.js.map} +1 -1
- package/dist/{optionsMarket-CvArD6d_.js → optionsMarket-BDBU1gUS.js} +1 -41
- package/dist/optionsMarket-BDBU1gUS.js.map +1 -0
- package/dist/{optionsMarket-PBduSBXF.cjs → optionsMarket-DEFMUI2G.cjs} +1 -41
- package/dist/optionsMarket-DEFMUI2G.cjs.map +1 -0
- package/dist/package.cjs +2 -2
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/dist/{uniswapMathLens-uDGUc-kg.d.ts → uniswapMathLens-BQ_ArpKd.d.cts} +1 -33
- package/dist/{uniswapMathLens-BiaRFVeY.d.cts → uniswapMathLens-DCuaXAGZ.d.ts} +1 -33
- package/package.json +1 -1
- package/dist/optionsMarket-CvArD6d_.js.map +0 -1
- package/dist/optionsMarket-PBduSBXF.cjs.map +0 -1
package/dist/abis.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
1
|
+
const require_optionsMarket = require('./optionsMarket-DEFMUI2G.cjs');
|
|
2
2
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
3
3
|
|
|
4
4
|
exports.erc20Abi = require_optionsMarket.erc20Abi;
|
package/dist/abis.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-
|
|
1
|
+
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-BQ_ArpKd.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/abis/erc20.d.ts
|
|
4
4
|
declare const erc20Abi: readonly [{
|
package/dist/abis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-
|
|
1
|
+
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-DCuaXAGZ.js";
|
|
2
2
|
|
|
3
3
|
//#region src/abis/erc20.d.ts
|
|
4
4
|
declare const erc20Abi: readonly [{
|
package/dist/abis.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-
|
|
1
|
+
import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-BDBU1gUS.js";
|
|
2
2
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
|
|
3
3
|
|
|
4
4
|
export { erc20Abi, lensAbi, optionsMarketAbi, singleOwnerVaultAbi, uniswapMathLensAbi, uniswapV3PoolAbi };
|
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_numberUtils = require('./numberUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
4
|
+
const require_numberUtils = require('./numberUtils-CkwkoxOr.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-DEFMUI2G.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
viem = require_numberUtils.__toESM(viem);
|
|
@@ -217,16 +217,33 @@ const useLens = () => {
|
|
|
217
217
|
}), [client]);
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/hooks/pool/usePoolData.ts
|
|
222
|
+
const usePoolData = (poolAddr) => {
|
|
223
|
+
const { timelockLens } = useLens();
|
|
224
|
+
const client = (0, wagmi.useClient)();
|
|
225
|
+
const { data } = (0, wagmi.useReadContract)({
|
|
226
|
+
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
227
|
+
abi: require_optionsMarket.lensAbi,
|
|
228
|
+
functionName: "getPoolData",
|
|
229
|
+
args: poolAddr ? [poolAddr] : void 0,
|
|
230
|
+
query: { enabled: !!poolAddr && !!client }
|
|
231
|
+
});
|
|
232
|
+
return data || {};
|
|
233
|
+
};
|
|
234
|
+
|
|
220
235
|
//#endregion
|
|
221
236
|
//#region src/hooks/market/useExerciseOption.ts
|
|
237
|
+
const swapper = "0xc396aa907F8De0c32460050B8Adbf047186C504d";
|
|
222
238
|
const useExerciseOption = (marketAddr) => {
|
|
223
|
-
const { vault } = useMarketData(marketAddr);
|
|
239
|
+
const { vault, pool } = useMarketData(marketAddr);
|
|
240
|
+
const { fee } = usePoolData(pool);
|
|
224
241
|
const { timelockLens } = useLens();
|
|
225
242
|
const client = (0, wagmi.useClient)();
|
|
226
243
|
const { writeContractAsync, data: hash, isPending, error } = (0, wagmi.useWriteContract)();
|
|
227
244
|
const { isLoading: isConfirming, isSuccess } = (0, wagmi.useWaitForTransactionReceipt)({ hash });
|
|
228
245
|
const exerciseOption = async (option, liquidities) => {
|
|
229
|
-
if (!client || !timelockLens || !vault || !marketAddr) throw new Error("Wallet not connected");
|
|
246
|
+
if (!client || !timelockLens || !vault || !marketAddr || !fee) throw new Error("Wallet not connected");
|
|
230
247
|
const refTick = await timelockLens.read.getRefTick([vault, option.startTick]);
|
|
231
248
|
const hash$1 = await writeContractAsync({
|
|
232
249
|
address: marketAddr,
|
|
@@ -236,6 +253,8 @@ const useExerciseOption = (marketAddr) => {
|
|
|
236
253
|
option.optionId,
|
|
237
254
|
liquidities,
|
|
238
255
|
0n,
|
|
256
|
+
swapper,
|
|
257
|
+
(0, viem.encodeAbiParameters)([{ type: "uint24" }], [fee]),
|
|
239
258
|
refTick
|
|
240
259
|
]
|
|
241
260
|
});
|
|
@@ -294,21 +313,6 @@ const useMaxPositionSize = (marketAddr, strikeTick, maxBorrowableRange = 100) =>
|
|
|
294
313
|
};
|
|
295
314
|
};
|
|
296
315
|
|
|
297
|
-
//#endregion
|
|
298
|
-
//#region src/hooks/pool/usePoolData.ts
|
|
299
|
-
const usePoolData = (poolAddr) => {
|
|
300
|
-
const { timelockLens } = useLens();
|
|
301
|
-
const client = (0, wagmi.useClient)();
|
|
302
|
-
const { data } = (0, wagmi.useReadContract)({
|
|
303
|
-
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
304
|
-
abi: require_optionsMarket.lensAbi,
|
|
305
|
-
functionName: "getPoolData",
|
|
306
|
-
args: poolAddr ? [poolAddr] : void 0,
|
|
307
|
-
query: { enabled: !!poolAddr && !!client }
|
|
308
|
-
});
|
|
309
|
-
return data || {};
|
|
310
|
-
};
|
|
311
|
-
|
|
312
316
|
//#endregion
|
|
313
317
|
//#region src/hooks/pool/useCurrentTick.ts
|
|
314
318
|
const useCurrentTick = (poolAddr) => {
|
|
@@ -351,15 +355,19 @@ const useMintOption = (marketAddr) => {
|
|
|
351
355
|
};
|
|
352
356
|
const mintOption = async (optionType, amount, duration, strikeTick) => {
|
|
353
357
|
if (!client) throw new Error("Wallet not connected");
|
|
354
|
-
if (!
|
|
358
|
+
if (!marketAddr) throw new Error("Market address not available");
|
|
359
|
+
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
360
|
+
if (!vault) throw new Error("Vault not available");
|
|
361
|
+
if (currentTick === void 0 || !tickSpacing) throw new Error("Pool data not available");
|
|
355
362
|
strikeTick = require_numberUtils.roundTickDown(strikeTick ?? currentTick, tickSpacing);
|
|
356
363
|
if (optionType === "CALL" && optionAssetIsToken0 || optionType === "PUT" && !optionAssetIsToken0) strikeTick += tickSpacing;
|
|
357
|
-
|
|
364
|
+
const [premium, protocolFee] = await require_numberUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
|
|
358
365
|
optionType === "CALL" ? 0 : 1,
|
|
359
366
|
amount,
|
|
360
367
|
strikeTick,
|
|
361
|
-
|
|
362
|
-
])
|
|
368
|
+
duration
|
|
369
|
+
]);
|
|
370
|
+
await askForApproval(premium + protocolFee);
|
|
363
371
|
const hash$1 = await writeContractAsync({
|
|
364
372
|
address: marketAddr,
|
|
365
373
|
abi: require_optionsMarket.optionsMarketAbi,
|
|
@@ -368,8 +376,9 @@ const useMintOption = (marketAddr) => {
|
|
|
368
376
|
optionType === "CALL" ? 0 : 1,
|
|
369
377
|
amount,
|
|
370
378
|
strikeTick,
|
|
371
|
-
|
|
379
|
+
duration,
|
|
372
380
|
BigInt(1e69),
|
|
381
|
+
false,
|
|
373
382
|
await timelockLens.read.getRefTick([vault, strikeTick])
|
|
374
383
|
]
|
|
375
384
|
});
|