timelock-sdk 0.0.119 → 0.0.121
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-Cgi8okgz.d.cts → client-D7objc4l.d.ts} +2566 -2953
- package/dist/{client-CxAAahmW.d.ts → client-bCuyjf6z.d.cts} +2566 -2953
- package/dist/client.cjs +60 -60
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +60 -60
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-ZSFOJxaV.cjs → optionUtils-DENHUR2w.cjs} +59 -15
- package/dist/optionUtils-DENHUR2w.cjs.map +1 -0
- package/dist/{optionUtils-D8zF6lcX.js → optionUtils-MZU-Gklx.js} +28 -14
- package/dist/optionUtils-MZU-Gklx.js.map +1 -0
- package/dist/{optionsMarket-D6zrIXc3.cjs → optionsMarket-C8-v8IvX.cjs} +65 -155
- package/dist/optionsMarket-C8-v8IvX.cjs.map +1 -0
- package/dist/{optionsMarket-DBuVI-kl.js → optionsMarket-Dkwpa2uO.js} +65 -155
- package/dist/optionsMarket-Dkwpa2uO.js.map +1 -0
- package/dist/package.cjs +8 -3
- package/dist/package.d.cts +3 -3
- package/dist/package.d.ts +3 -3
- package/dist/package.js +3 -3
- package/dist/{uniswapMathLens-ChJFZ6hc.d.ts → uniswapMathLens-DtacRMPz.d.cts} +55 -124
- package/dist/{uniswapMathLens-B_cHjOOB.d.cts → uniswapMathLens-JKcBN1v_.d.ts} +55 -124
- package/package.json +1 -1
- package/dist/optionUtils-D8zF6lcX.js.map +0 -1
- package/dist/optionUtils-ZSFOJxaV.cjs.map +0 -1
- package/dist/optionsMarket-D6zrIXc3.cjs.map +0 -1
- package/dist/optionsMarket-DBuVI-kl.js.map +0 -1
|
@@ -112,30 +112,10 @@ declare const lensAbi: readonly [{
|
|
|
112
112
|
readonly name: "strikePrice";
|
|
113
113
|
readonly type: "uint256";
|
|
114
114
|
readonly internalType: "uint256";
|
|
115
|
-
}, {
|
|
116
|
-
readonly name: "optionAssetBorrowed";
|
|
117
|
-
readonly type: "uint256";
|
|
118
|
-
readonly internalType: "uint256";
|
|
119
|
-
}, {
|
|
120
|
-
readonly name: "payoutAssetBorrowed";
|
|
121
|
-
readonly type: "uint256";
|
|
122
|
-
readonly internalType: "uint256";
|
|
123
|
-
}, {
|
|
124
|
-
readonly name: "optionAssetToRepay";
|
|
125
|
-
readonly type: "uint256";
|
|
126
|
-
readonly internalType: "uint256";
|
|
127
|
-
}, {
|
|
128
|
-
readonly name: "payoutAssetToRepay";
|
|
129
|
-
readonly type: "uint256";
|
|
130
|
-
readonly internalType: "uint256";
|
|
131
115
|
}, {
|
|
132
116
|
readonly name: "positionSize";
|
|
133
117
|
readonly type: "uint256";
|
|
134
118
|
readonly internalType: "uint256";
|
|
135
|
-
}, {
|
|
136
|
-
readonly name: "netOptionAssetToRepay";
|
|
137
|
-
readonly type: "uint256";
|
|
138
|
-
readonly internalType: "uint256";
|
|
139
119
|
}, {
|
|
140
120
|
readonly name: "expiresAt";
|
|
141
121
|
readonly type: "uint32";
|
|
@@ -328,30 +308,10 @@ declare const lensAbi: readonly [{
|
|
|
328
308
|
readonly name: "strikePrice";
|
|
329
309
|
readonly type: "uint256";
|
|
330
310
|
readonly internalType: "uint256";
|
|
331
|
-
}, {
|
|
332
|
-
readonly name: "optionAssetBorrowed";
|
|
333
|
-
readonly type: "uint256";
|
|
334
|
-
readonly internalType: "uint256";
|
|
335
|
-
}, {
|
|
336
|
-
readonly name: "payoutAssetBorrowed";
|
|
337
|
-
readonly type: "uint256";
|
|
338
|
-
readonly internalType: "uint256";
|
|
339
|
-
}, {
|
|
340
|
-
readonly name: "optionAssetToRepay";
|
|
341
|
-
readonly type: "uint256";
|
|
342
|
-
readonly internalType: "uint256";
|
|
343
|
-
}, {
|
|
344
|
-
readonly name: "payoutAssetToRepay";
|
|
345
|
-
readonly type: "uint256";
|
|
346
|
-
readonly internalType: "uint256";
|
|
347
311
|
}, {
|
|
348
312
|
readonly name: "positionSize";
|
|
349
313
|
readonly type: "uint256";
|
|
350
314
|
readonly internalType: "uint256";
|
|
351
|
-
}, {
|
|
352
|
-
readonly name: "netOptionAssetToRepay";
|
|
353
|
-
readonly type: "uint256";
|
|
354
|
-
readonly internalType: "uint256";
|
|
355
315
|
}, {
|
|
356
316
|
readonly name: "expiresAt";
|
|
357
317
|
readonly type: "uint32";
|
|
@@ -403,30 +363,10 @@ declare const lensAbi: readonly [{
|
|
|
403
363
|
readonly name: "strikePrice";
|
|
404
364
|
readonly type: "uint256";
|
|
405
365
|
readonly internalType: "uint256";
|
|
406
|
-
}, {
|
|
407
|
-
readonly name: "optionAssetBorrowed";
|
|
408
|
-
readonly type: "uint256";
|
|
409
|
-
readonly internalType: "uint256";
|
|
410
|
-
}, {
|
|
411
|
-
readonly name: "payoutAssetBorrowed";
|
|
412
|
-
readonly type: "uint256";
|
|
413
|
-
readonly internalType: "uint256";
|
|
414
|
-
}, {
|
|
415
|
-
readonly name: "optionAssetToRepay";
|
|
416
|
-
readonly type: "uint256";
|
|
417
|
-
readonly internalType: "uint256";
|
|
418
|
-
}, {
|
|
419
|
-
readonly name: "payoutAssetToRepay";
|
|
420
|
-
readonly type: "uint256";
|
|
421
|
-
readonly internalType: "uint256";
|
|
422
366
|
}, {
|
|
423
367
|
readonly name: "positionSize";
|
|
424
368
|
readonly type: "uint256";
|
|
425
369
|
readonly internalType: "uint256";
|
|
426
|
-
}, {
|
|
427
|
-
readonly name: "netOptionAssetToRepay";
|
|
428
|
-
readonly type: "uint256";
|
|
429
|
-
readonly internalType: "uint256";
|
|
430
370
|
}, {
|
|
431
371
|
readonly name: "expiresAt";
|
|
432
372
|
readonly type: "uint32";
|
|
@@ -511,6 +451,33 @@ declare const lensAbi: readonly [{
|
|
|
511
451
|
readonly internalType: "int24";
|
|
512
452
|
}];
|
|
513
453
|
readonly stateMutability: "view";
|
|
454
|
+
}, {
|
|
455
|
+
readonly type: "function";
|
|
456
|
+
readonly name: "getTokenData";
|
|
457
|
+
readonly inputs: readonly [{
|
|
458
|
+
readonly name: "token";
|
|
459
|
+
readonly type: "address";
|
|
460
|
+
readonly internalType: "address";
|
|
461
|
+
}];
|
|
462
|
+
readonly outputs: readonly [{
|
|
463
|
+
readonly name: "tokenData";
|
|
464
|
+
readonly type: "tuple";
|
|
465
|
+
readonly internalType: "struct TimelockLens.TokenData";
|
|
466
|
+
readonly components: readonly [{
|
|
467
|
+
readonly name: "decimals";
|
|
468
|
+
readonly type: "uint8";
|
|
469
|
+
readonly internalType: "uint8";
|
|
470
|
+
}, {
|
|
471
|
+
readonly name: "symbol";
|
|
472
|
+
readonly type: "string";
|
|
473
|
+
readonly internalType: "string";
|
|
474
|
+
}, {
|
|
475
|
+
readonly name: "name";
|
|
476
|
+
readonly type: "string";
|
|
477
|
+
readonly internalType: "string";
|
|
478
|
+
}];
|
|
479
|
+
}];
|
|
480
|
+
readonly stateMutability: "view";
|
|
514
481
|
}, {
|
|
515
482
|
readonly type: "function";
|
|
516
483
|
readonly name: "getUserOptions";
|
|
@@ -559,30 +526,10 @@ declare const lensAbi: readonly [{
|
|
|
559
526
|
readonly name: "strikePrice";
|
|
560
527
|
readonly type: "uint256";
|
|
561
528
|
readonly internalType: "uint256";
|
|
562
|
-
}, {
|
|
563
|
-
readonly name: "optionAssetBorrowed";
|
|
564
|
-
readonly type: "uint256";
|
|
565
|
-
readonly internalType: "uint256";
|
|
566
|
-
}, {
|
|
567
|
-
readonly name: "payoutAssetBorrowed";
|
|
568
|
-
readonly type: "uint256";
|
|
569
|
-
readonly internalType: "uint256";
|
|
570
|
-
}, {
|
|
571
|
-
readonly name: "optionAssetToRepay";
|
|
572
|
-
readonly type: "uint256";
|
|
573
|
-
readonly internalType: "uint256";
|
|
574
|
-
}, {
|
|
575
|
-
readonly name: "payoutAssetToRepay";
|
|
576
|
-
readonly type: "uint256";
|
|
577
|
-
readonly internalType: "uint256";
|
|
578
529
|
}, {
|
|
579
530
|
readonly name: "positionSize";
|
|
580
531
|
readonly type: "uint256";
|
|
581
532
|
readonly internalType: "uint256";
|
|
582
|
-
}, {
|
|
583
|
-
readonly name: "netOptionAssetToRepay";
|
|
584
|
-
readonly type: "uint256";
|
|
585
|
-
readonly internalType: "uint256";
|
|
586
533
|
}, {
|
|
587
534
|
readonly name: "expiresAt";
|
|
588
535
|
readonly type: "uint32";
|
|
@@ -852,50 +799,34 @@ declare const optionsMarketAbi: readonly [{
|
|
|
852
799
|
readonly stateMutability: "view";
|
|
853
800
|
}, {
|
|
854
801
|
readonly type: "function";
|
|
855
|
-
readonly name: "
|
|
856
|
-
readonly inputs: readonly [];
|
|
857
|
-
readonly outputs: readonly [{
|
|
858
|
-
readonly name: "";
|
|
859
|
-
readonly type: "address";
|
|
860
|
-
readonly internalType: "contract TimelockGuardian";
|
|
861
|
-
}];
|
|
862
|
-
readonly stateMutability: "view";
|
|
863
|
-
}, {
|
|
864
|
-
readonly type: "function";
|
|
865
|
-
readonly name: "liquiditiesToAmounts";
|
|
802
|
+
readonly name: "getPositionSize";
|
|
866
803
|
readonly inputs: readonly [{
|
|
867
|
-
readonly name: "
|
|
804
|
+
readonly name: "optionType";
|
|
805
|
+
readonly type: "uint8";
|
|
806
|
+
readonly internalType: "uint8";
|
|
807
|
+
}, {
|
|
808
|
+
readonly name: "strikeTick";
|
|
868
809
|
readonly type: "int24";
|
|
869
810
|
readonly internalType: "int24";
|
|
870
811
|
}, {
|
|
871
|
-
readonly name: "
|
|
812
|
+
readonly name: "liquidities";
|
|
872
813
|
readonly type: "uint128[]";
|
|
873
814
|
readonly internalType: "uint128[]";
|
|
874
|
-
}, {
|
|
875
|
-
readonly name: "optionType";
|
|
876
|
-
readonly type: "uint8";
|
|
877
|
-
readonly internalType: "uint8";
|
|
878
815
|
}];
|
|
879
816
|
readonly outputs: readonly [{
|
|
880
|
-
readonly name: "
|
|
881
|
-
readonly type: "uint256";
|
|
882
|
-
readonly internalType: "uint256";
|
|
883
|
-
}, {
|
|
884
|
-
readonly name: "payoutAssetToRepay";
|
|
885
|
-
readonly type: "uint256";
|
|
886
|
-
readonly internalType: "uint256";
|
|
887
|
-
}, {
|
|
888
|
-
readonly name: "optionAssetBorrowed";
|
|
889
|
-
readonly type: "uint256";
|
|
890
|
-
readonly internalType: "uint256";
|
|
891
|
-
}, {
|
|
892
|
-
readonly name: "payoutAssetBorrowed";
|
|
817
|
+
readonly name: "";
|
|
893
818
|
readonly type: "uint256";
|
|
894
819
|
readonly internalType: "uint256";
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
820
|
+
}];
|
|
821
|
+
readonly stateMutability: "view";
|
|
822
|
+
}, {
|
|
823
|
+
readonly type: "function";
|
|
824
|
+
readonly name: "guardian";
|
|
825
|
+
readonly inputs: readonly [];
|
|
826
|
+
readonly outputs: readonly [{
|
|
827
|
+
readonly name: "";
|
|
828
|
+
readonly type: "address";
|
|
829
|
+
readonly internalType: "contract TimelockGuardian";
|
|
899
830
|
}];
|
|
900
831
|
readonly stateMutability: "view";
|
|
901
832
|
}, {
|
|
@@ -1233,10 +1164,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1233
1164
|
readonly indexed: false;
|
|
1234
1165
|
readonly internalType: "uint128[]";
|
|
1235
1166
|
}, {
|
|
1236
|
-
readonly name: "
|
|
1237
|
-
readonly type: "
|
|
1167
|
+
readonly name: "currentPrice";
|
|
1168
|
+
readonly type: "uint256";
|
|
1238
1169
|
readonly indexed: false;
|
|
1239
|
-
readonly internalType: "
|
|
1170
|
+
readonly internalType: "uint256";
|
|
1240
1171
|
}, {
|
|
1241
1172
|
readonly name: "payout";
|
|
1242
1173
|
readonly type: "uint256";
|
|
@@ -1263,10 +1194,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1263
1194
|
readonly indexed: false;
|
|
1264
1195
|
readonly internalType: "uint256";
|
|
1265
1196
|
}, {
|
|
1266
|
-
readonly name: "
|
|
1267
|
-
readonly type: "
|
|
1197
|
+
readonly name: "currentPrice";
|
|
1198
|
+
readonly type: "uint256";
|
|
1268
1199
|
readonly indexed: false;
|
|
1269
|
-
readonly internalType: "
|
|
1200
|
+
readonly internalType: "uint256";
|
|
1270
1201
|
}, {
|
|
1271
1202
|
readonly name: "addedDuration";
|
|
1272
1203
|
readonly type: "uint32";
|
|
@@ -1298,10 +1229,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1298
1229
|
readonly indexed: false;
|
|
1299
1230
|
readonly internalType: "int24";
|
|
1300
1231
|
}, {
|
|
1301
|
-
readonly name: "
|
|
1302
|
-
readonly type: "
|
|
1232
|
+
readonly name: "currentPrice";
|
|
1233
|
+
readonly type: "uint256";
|
|
1303
1234
|
readonly indexed: false;
|
|
1304
|
-
readonly internalType: "
|
|
1235
|
+
readonly internalType: "uint256";
|
|
1305
1236
|
}, {
|
|
1306
1237
|
readonly name: "expiresAt";
|
|
1307
1238
|
readonly type: "uint32";
|
|
@@ -2128,4 +2059,4 @@ declare const uniswapMathLensAbi: readonly [{
|
|
|
2128
2059
|
}];
|
|
2129
2060
|
//#endregion
|
|
2130
2061
|
export { optionsMarketAbi as n, lensAbi as r, uniswapMathLensAbi as t };
|
|
2131
|
-
//# sourceMappingURL=uniswapMathLens-
|
|
2062
|
+
//# sourceMappingURL=uniswapMathLens-DtacRMPz.d.cts.map
|
|
@@ -112,30 +112,10 @@ declare const lensAbi: readonly [{
|
|
|
112
112
|
readonly name: "strikePrice";
|
|
113
113
|
readonly type: "uint256";
|
|
114
114
|
readonly internalType: "uint256";
|
|
115
|
-
}, {
|
|
116
|
-
readonly name: "optionAssetBorrowed";
|
|
117
|
-
readonly type: "uint256";
|
|
118
|
-
readonly internalType: "uint256";
|
|
119
|
-
}, {
|
|
120
|
-
readonly name: "payoutAssetBorrowed";
|
|
121
|
-
readonly type: "uint256";
|
|
122
|
-
readonly internalType: "uint256";
|
|
123
|
-
}, {
|
|
124
|
-
readonly name: "optionAssetToRepay";
|
|
125
|
-
readonly type: "uint256";
|
|
126
|
-
readonly internalType: "uint256";
|
|
127
|
-
}, {
|
|
128
|
-
readonly name: "payoutAssetToRepay";
|
|
129
|
-
readonly type: "uint256";
|
|
130
|
-
readonly internalType: "uint256";
|
|
131
115
|
}, {
|
|
132
116
|
readonly name: "positionSize";
|
|
133
117
|
readonly type: "uint256";
|
|
134
118
|
readonly internalType: "uint256";
|
|
135
|
-
}, {
|
|
136
|
-
readonly name: "netOptionAssetToRepay";
|
|
137
|
-
readonly type: "uint256";
|
|
138
|
-
readonly internalType: "uint256";
|
|
139
119
|
}, {
|
|
140
120
|
readonly name: "expiresAt";
|
|
141
121
|
readonly type: "uint32";
|
|
@@ -328,30 +308,10 @@ declare const lensAbi: readonly [{
|
|
|
328
308
|
readonly name: "strikePrice";
|
|
329
309
|
readonly type: "uint256";
|
|
330
310
|
readonly internalType: "uint256";
|
|
331
|
-
}, {
|
|
332
|
-
readonly name: "optionAssetBorrowed";
|
|
333
|
-
readonly type: "uint256";
|
|
334
|
-
readonly internalType: "uint256";
|
|
335
|
-
}, {
|
|
336
|
-
readonly name: "payoutAssetBorrowed";
|
|
337
|
-
readonly type: "uint256";
|
|
338
|
-
readonly internalType: "uint256";
|
|
339
|
-
}, {
|
|
340
|
-
readonly name: "optionAssetToRepay";
|
|
341
|
-
readonly type: "uint256";
|
|
342
|
-
readonly internalType: "uint256";
|
|
343
|
-
}, {
|
|
344
|
-
readonly name: "payoutAssetToRepay";
|
|
345
|
-
readonly type: "uint256";
|
|
346
|
-
readonly internalType: "uint256";
|
|
347
311
|
}, {
|
|
348
312
|
readonly name: "positionSize";
|
|
349
313
|
readonly type: "uint256";
|
|
350
314
|
readonly internalType: "uint256";
|
|
351
|
-
}, {
|
|
352
|
-
readonly name: "netOptionAssetToRepay";
|
|
353
|
-
readonly type: "uint256";
|
|
354
|
-
readonly internalType: "uint256";
|
|
355
315
|
}, {
|
|
356
316
|
readonly name: "expiresAt";
|
|
357
317
|
readonly type: "uint32";
|
|
@@ -403,30 +363,10 @@ declare const lensAbi: readonly [{
|
|
|
403
363
|
readonly name: "strikePrice";
|
|
404
364
|
readonly type: "uint256";
|
|
405
365
|
readonly internalType: "uint256";
|
|
406
|
-
}, {
|
|
407
|
-
readonly name: "optionAssetBorrowed";
|
|
408
|
-
readonly type: "uint256";
|
|
409
|
-
readonly internalType: "uint256";
|
|
410
|
-
}, {
|
|
411
|
-
readonly name: "payoutAssetBorrowed";
|
|
412
|
-
readonly type: "uint256";
|
|
413
|
-
readonly internalType: "uint256";
|
|
414
|
-
}, {
|
|
415
|
-
readonly name: "optionAssetToRepay";
|
|
416
|
-
readonly type: "uint256";
|
|
417
|
-
readonly internalType: "uint256";
|
|
418
|
-
}, {
|
|
419
|
-
readonly name: "payoutAssetToRepay";
|
|
420
|
-
readonly type: "uint256";
|
|
421
|
-
readonly internalType: "uint256";
|
|
422
366
|
}, {
|
|
423
367
|
readonly name: "positionSize";
|
|
424
368
|
readonly type: "uint256";
|
|
425
369
|
readonly internalType: "uint256";
|
|
426
|
-
}, {
|
|
427
|
-
readonly name: "netOptionAssetToRepay";
|
|
428
|
-
readonly type: "uint256";
|
|
429
|
-
readonly internalType: "uint256";
|
|
430
370
|
}, {
|
|
431
371
|
readonly name: "expiresAt";
|
|
432
372
|
readonly type: "uint32";
|
|
@@ -511,6 +451,33 @@ declare const lensAbi: readonly [{
|
|
|
511
451
|
readonly internalType: "int24";
|
|
512
452
|
}];
|
|
513
453
|
readonly stateMutability: "view";
|
|
454
|
+
}, {
|
|
455
|
+
readonly type: "function";
|
|
456
|
+
readonly name: "getTokenData";
|
|
457
|
+
readonly inputs: readonly [{
|
|
458
|
+
readonly name: "token";
|
|
459
|
+
readonly type: "address";
|
|
460
|
+
readonly internalType: "address";
|
|
461
|
+
}];
|
|
462
|
+
readonly outputs: readonly [{
|
|
463
|
+
readonly name: "tokenData";
|
|
464
|
+
readonly type: "tuple";
|
|
465
|
+
readonly internalType: "struct TimelockLens.TokenData";
|
|
466
|
+
readonly components: readonly [{
|
|
467
|
+
readonly name: "decimals";
|
|
468
|
+
readonly type: "uint8";
|
|
469
|
+
readonly internalType: "uint8";
|
|
470
|
+
}, {
|
|
471
|
+
readonly name: "symbol";
|
|
472
|
+
readonly type: "string";
|
|
473
|
+
readonly internalType: "string";
|
|
474
|
+
}, {
|
|
475
|
+
readonly name: "name";
|
|
476
|
+
readonly type: "string";
|
|
477
|
+
readonly internalType: "string";
|
|
478
|
+
}];
|
|
479
|
+
}];
|
|
480
|
+
readonly stateMutability: "view";
|
|
514
481
|
}, {
|
|
515
482
|
readonly type: "function";
|
|
516
483
|
readonly name: "getUserOptions";
|
|
@@ -559,30 +526,10 @@ declare const lensAbi: readonly [{
|
|
|
559
526
|
readonly name: "strikePrice";
|
|
560
527
|
readonly type: "uint256";
|
|
561
528
|
readonly internalType: "uint256";
|
|
562
|
-
}, {
|
|
563
|
-
readonly name: "optionAssetBorrowed";
|
|
564
|
-
readonly type: "uint256";
|
|
565
|
-
readonly internalType: "uint256";
|
|
566
|
-
}, {
|
|
567
|
-
readonly name: "payoutAssetBorrowed";
|
|
568
|
-
readonly type: "uint256";
|
|
569
|
-
readonly internalType: "uint256";
|
|
570
|
-
}, {
|
|
571
|
-
readonly name: "optionAssetToRepay";
|
|
572
|
-
readonly type: "uint256";
|
|
573
|
-
readonly internalType: "uint256";
|
|
574
|
-
}, {
|
|
575
|
-
readonly name: "payoutAssetToRepay";
|
|
576
|
-
readonly type: "uint256";
|
|
577
|
-
readonly internalType: "uint256";
|
|
578
529
|
}, {
|
|
579
530
|
readonly name: "positionSize";
|
|
580
531
|
readonly type: "uint256";
|
|
581
532
|
readonly internalType: "uint256";
|
|
582
|
-
}, {
|
|
583
|
-
readonly name: "netOptionAssetToRepay";
|
|
584
|
-
readonly type: "uint256";
|
|
585
|
-
readonly internalType: "uint256";
|
|
586
533
|
}, {
|
|
587
534
|
readonly name: "expiresAt";
|
|
588
535
|
readonly type: "uint32";
|
|
@@ -852,50 +799,34 @@ declare const optionsMarketAbi: readonly [{
|
|
|
852
799
|
readonly stateMutability: "view";
|
|
853
800
|
}, {
|
|
854
801
|
readonly type: "function";
|
|
855
|
-
readonly name: "
|
|
856
|
-
readonly inputs: readonly [];
|
|
857
|
-
readonly outputs: readonly [{
|
|
858
|
-
readonly name: "";
|
|
859
|
-
readonly type: "address";
|
|
860
|
-
readonly internalType: "contract TimelockGuardian";
|
|
861
|
-
}];
|
|
862
|
-
readonly stateMutability: "view";
|
|
863
|
-
}, {
|
|
864
|
-
readonly type: "function";
|
|
865
|
-
readonly name: "liquiditiesToAmounts";
|
|
802
|
+
readonly name: "getPositionSize";
|
|
866
803
|
readonly inputs: readonly [{
|
|
867
|
-
readonly name: "
|
|
804
|
+
readonly name: "optionType";
|
|
805
|
+
readonly type: "uint8";
|
|
806
|
+
readonly internalType: "uint8";
|
|
807
|
+
}, {
|
|
808
|
+
readonly name: "strikeTick";
|
|
868
809
|
readonly type: "int24";
|
|
869
810
|
readonly internalType: "int24";
|
|
870
811
|
}, {
|
|
871
|
-
readonly name: "
|
|
812
|
+
readonly name: "liquidities";
|
|
872
813
|
readonly type: "uint128[]";
|
|
873
814
|
readonly internalType: "uint128[]";
|
|
874
|
-
}, {
|
|
875
|
-
readonly name: "optionType";
|
|
876
|
-
readonly type: "uint8";
|
|
877
|
-
readonly internalType: "uint8";
|
|
878
815
|
}];
|
|
879
816
|
readonly outputs: readonly [{
|
|
880
|
-
readonly name: "
|
|
881
|
-
readonly type: "uint256";
|
|
882
|
-
readonly internalType: "uint256";
|
|
883
|
-
}, {
|
|
884
|
-
readonly name: "payoutAssetToRepay";
|
|
885
|
-
readonly type: "uint256";
|
|
886
|
-
readonly internalType: "uint256";
|
|
887
|
-
}, {
|
|
888
|
-
readonly name: "optionAssetBorrowed";
|
|
889
|
-
readonly type: "uint256";
|
|
890
|
-
readonly internalType: "uint256";
|
|
891
|
-
}, {
|
|
892
|
-
readonly name: "payoutAssetBorrowed";
|
|
817
|
+
readonly name: "";
|
|
893
818
|
readonly type: "uint256";
|
|
894
819
|
readonly internalType: "uint256";
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
820
|
+
}];
|
|
821
|
+
readonly stateMutability: "view";
|
|
822
|
+
}, {
|
|
823
|
+
readonly type: "function";
|
|
824
|
+
readonly name: "guardian";
|
|
825
|
+
readonly inputs: readonly [];
|
|
826
|
+
readonly outputs: readonly [{
|
|
827
|
+
readonly name: "";
|
|
828
|
+
readonly type: "address";
|
|
829
|
+
readonly internalType: "contract TimelockGuardian";
|
|
899
830
|
}];
|
|
900
831
|
readonly stateMutability: "view";
|
|
901
832
|
}, {
|
|
@@ -1233,10 +1164,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1233
1164
|
readonly indexed: false;
|
|
1234
1165
|
readonly internalType: "uint128[]";
|
|
1235
1166
|
}, {
|
|
1236
|
-
readonly name: "
|
|
1237
|
-
readonly type: "
|
|
1167
|
+
readonly name: "currentPrice";
|
|
1168
|
+
readonly type: "uint256";
|
|
1238
1169
|
readonly indexed: false;
|
|
1239
|
-
readonly internalType: "
|
|
1170
|
+
readonly internalType: "uint256";
|
|
1240
1171
|
}, {
|
|
1241
1172
|
readonly name: "payout";
|
|
1242
1173
|
readonly type: "uint256";
|
|
@@ -1263,10 +1194,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1263
1194
|
readonly indexed: false;
|
|
1264
1195
|
readonly internalType: "uint256";
|
|
1265
1196
|
}, {
|
|
1266
|
-
readonly name: "
|
|
1267
|
-
readonly type: "
|
|
1197
|
+
readonly name: "currentPrice";
|
|
1198
|
+
readonly type: "uint256";
|
|
1268
1199
|
readonly indexed: false;
|
|
1269
|
-
readonly internalType: "
|
|
1200
|
+
readonly internalType: "uint256";
|
|
1270
1201
|
}, {
|
|
1271
1202
|
readonly name: "addedDuration";
|
|
1272
1203
|
readonly type: "uint32";
|
|
@@ -1298,10 +1229,10 @@ declare const optionsMarketAbi: readonly [{
|
|
|
1298
1229
|
readonly indexed: false;
|
|
1299
1230
|
readonly internalType: "int24";
|
|
1300
1231
|
}, {
|
|
1301
|
-
readonly name: "
|
|
1302
|
-
readonly type: "
|
|
1232
|
+
readonly name: "currentPrice";
|
|
1233
|
+
readonly type: "uint256";
|
|
1303
1234
|
readonly indexed: false;
|
|
1304
|
-
readonly internalType: "
|
|
1235
|
+
readonly internalType: "uint256";
|
|
1305
1236
|
}, {
|
|
1306
1237
|
readonly name: "expiresAt";
|
|
1307
1238
|
readonly type: "uint32";
|
|
@@ -2128,4 +2059,4 @@ declare const uniswapMathLensAbi: readonly [{
|
|
|
2128
2059
|
}];
|
|
2129
2060
|
//#endregion
|
|
2130
2061
|
export { optionsMarketAbi as n, lensAbi as r, uniswapMathLensAbi as t };
|
|
2131
|
-
//# sourceMappingURL=uniswapMathLens-
|
|
2062
|
+
//# sourceMappingURL=uniswapMathLens-JKcBN1v_.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optionUtils-D8zF6lcX.js","names":["erc20Abi","timelockLenses: Record<number, Address>","uniswapMathLenses: Record<number, Address>","filled: PriceDataPoint[]","lastKnownPrice: PriceDataPoint | null","EMPTY_ARRAY: never[]","zero: Amount"],"sources":["../src/lib/contracts.ts","../src/lib/price.ts","../src/lib/liquidityUtils.ts","../src/lib/numberUtils.ts","../src/lib/optionUtils.ts"],"sourcesContent":["import type {Address, Client, PublicClient, GetContractReturnType} from 'viem';\nimport {getContract} from 'viem';\nimport {monadTestnet} from 'viem/chains';\n\nimport {erc20Abi} from '~/abis/erc20';\nimport {lensAbi} from '~/abis/lens';\nimport {uniswapMathLensAbi} from '~/abis/uniswapMathLens';\nimport {optionsMarketAbi} from '~/abis/optionsMarket';\n\nexport type TimelockMarket = GetContractReturnType<\n typeof optionsMarketAbi,\n Client,\n Address\n>;\nexport type TimelockLens = GetContractReturnType<\n typeof lensAbi,\n Client,\n Address\n>;\nexport type UniswapMathLens = GetContractReturnType<\n typeof uniswapMathLensAbi,\n Client,\n Address\n>;\n\nexport type TimelockMarketData = Awaited<\n ReturnType<TimelockLens['read']['getMarketData']>\n> & {address: Address};\n\nexport const getErc20 = (address: Address, client: Client) =>\n getContract({abi: erc20Abi, address, client});\n\nexport const getTimelockMarket = (\n address: Address,\n client: Client,\n): TimelockMarket => {\n return getContract({abi: optionsMarketAbi, address, client});\n};\n\nexport const getUniswapMathLens = (client: Client | PublicClient) =>\n getContract({\n abi: uniswapMathLensAbi,\n address: uniswapMathLenses[client.chain!.id],\n client,\n });\n\nexport const getTimelockLens = (client: Client | PublicClient) =>\n getContract({\n abi: lensAbi,\n address: timelockLenses[client.chain!.id],\n client,\n });\n\nexport const timelockLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x1409b2318d9e691f1eB037F00cB4E9528BAdC463',\n};\nexport const uniswapMathLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x4C8375D1F6D5F452e92e211C1D3E7a44F78dFc95',\n};\n","export interface PriceData {\n currentPrice: number;\n percentChange: number;\n poolAddress: string;\n timestamp: number;\n}\n\nexport interface PriceDataPoint {\n timestamp: Date;\n price: number;\n}\n\nexport type PriceResolution = '1m' | '5m' | '15m' | '1h' | '4h' | '1d';\n\nconst getResolutionConfig = (resolution: PriceResolution) => {\n const resolutionMap = {\n '1m': {timeframe: 'minute', aggregate: '1', seconds: 60},\n '5m': {timeframe: 'minute', aggregate: '5', seconds: 300},\n '15m': {timeframe: 'minute', aggregate: '15', seconds: 900},\n '1h': {timeframe: 'hour', aggregate: '1', seconds: 3600},\n '4h': {timeframe: 'hour', aggregate: '4', seconds: 14400},\n '1d': {timeframe: 'day', aggregate: '1', seconds: 86400},\n };\n return resolutionMap[resolution];\n};\n\nconst fillGaps = (\n prices: PriceDataPoint[],\n start: Date,\n end: Date,\n intervalMs: number,\n): PriceDataPoint[] => {\n if (prices.length === 0) return [];\n\n const priceMap = new Map<number, PriceDataPoint>();\n\n for (const point of prices) {\n const alignedTime =\n Math.floor(point.timestamp.getTime() / intervalMs) * intervalMs;\n priceMap.set(alignedTime, point);\n }\n const filled: PriceDataPoint[] = [];\n\n const actualStart =\n Math.floor(prices[0].timestamp.getTime() / intervalMs) * intervalMs;\n\n let currentTime = actualStart;\n let lastKnownPrice: PriceDataPoint | null = null;\n\n while (currentTime <= end.getTime()) {\n const existing = priceMap.get(currentTime);\n\n if (existing) {\n filled.push(existing);\n lastKnownPrice = existing;\n } else if (lastKnownPrice) {\n filled.push({\n timestamp: new Date(currentTime),\n price: lastKnownPrice.price,\n });\n }\n currentTime += intervalMs;\n }\n return filled;\n};\n\nexport const getPriceHistory = async (\n poolAddress: string,\n resolution: PriceResolution,\n start: Date,\n end: Date,\n): Promise<PriceDataPoint[]> => {\n const network = 'monad-testnet';\n const {timeframe, aggregate, seconds} = getResolutionConfig(resolution);\n\n if (end.getTime() > Date.now()) {\n end = new Date(Date.now());\n }\n const startSecs = Math.floor(start.getTime() / 1000);\n const endSecs = Math.floor(end.getTime() / 1000);\n const diffSeconds = endSecs - startSecs;\n\n const limit = Math.min(Math.ceil(diffSeconds / seconds), 1000);\n\n const url =\n `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}` +\n `?aggregate=${aggregate}` +\n `&limit=${limit}` +\n '&token=quote' +\n '¤cy=usd' +\n `&before_timestamp=${endSecs}`;\n\n const res = await fetch(url, {headers: {Accept: 'application/json'}});\n\n if (!res.ok) {\n throw new Error(`Failed to fetch price history: ${res.statusText}`);\n }\n const data = (await res.json()) as {\n data: {\n attributes: {\n ohlcv_list: [number, number, number, number, number, number][];\n };\n };\n };\n const prices: PriceDataPoint[] = data.data.attributes.ohlcv_list\n .map(([timestamp, , , , close]) => ({\n timestamp: new Date(timestamp * 1000),\n price: close,\n }))\n .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\n\n return fillGaps(prices, start, end, seconds * 1000).filter(\n point =>\n point.timestamp.getTime() / 1000 >= startSecs &&\n point.timestamp.getTime() / 1000 <= endSecs,\n );\n};\n\nexport const getCurrentPrice = async (\n poolAddress: string,\n): Promise<PriceData> => {\n const network = 'monad-testnet';\n const geckoUrl = `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress.toLowerCase()}`;\n\n const response = await fetch(geckoUrl, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n 'User-Agent': 'TimelockTrade/1.0',\n },\n cache: 'no-store', // Keep no-store for real-time data\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch price data for pool ${poolAddress}`);\n }\n const data = (await response.json()) as {\n data: {\n attributes: {\n quote_token_price_usd: string;\n price_change_percentage: {h24: string};\n };\n };\n };\n const pool = data.data.attributes;\n\n return {\n currentPrice: parseFloat(pool.quote_token_price_usd || '0'),\n percentChange: parseFloat(pool.price_change_percentage?.h24 || '0'),\n poolAddress: poolAddress,\n timestamp: Date.now(),\n };\n};\n","import {SqrtPriceMath, TickMath} from '@uniswap/v3-sdk';\nimport Big from 'big.js';\nimport JSBI from 'jsbi';\n\nexport const PRICE_PRECISION = BigInt(1e18);\n\nexport const getPriceSqrtPriceX96 = (sqrtPriceX96: bigint) => {\n const priceX192 = sqrtPriceX96 * sqrtPriceX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getPriceAtTick = (tick: number) => {\n const sqrtRatioX96 = BigInt(TickMath.getSqrtRatioAtTick(tick).toString());\n\n const priceX192 = sqrtRatioX96 * sqrtRatioX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getTickAtPrice = (price: bigint) => {\n const priceX192 = (price * BigInt(2 ** 192)) / PRICE_PRECISION;\n const sqrtPriceX96 = JSBI.BigInt(\n new Big(priceX192.toString()).sqrt().toFixed(0),\n );\n return TickMath.getTickAtSqrtRatio(sqrtPriceX96);\n};\n\nexport const getNearestValidStrikeTick = (\n optionType: 'CALL' | 'PUT',\n optionAssetIsToken0: boolean,\n tickSpacing: number,\n currentTick: number,\n strikeTick?: number,\n) => {\n strikeTick = roundTickDown(strikeTick ?? currentTick, tickSpacing);\n\n if (\n (optionType === 'CALL' && optionAssetIsToken0) ||\n (optionType === 'PUT' && !optionAssetIsToken0)\n ) {\n strikeTick += tickSpacing;\n }\n return strikeTick;\n};\n\nexport const roundTickDown = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem >= 0) return tick - rem;\n return tick - rem - spacing;\n};\n\nexport const roundTickUp = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem === 0) return tick;\n if (rem > 0) return tick - rem + spacing;\n return tick - rem;\n};\n\nexport const token0ToToken1 = (amount0: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount0 * price) / PRICE_PRECISION;\n};\n\nexport const token1ToToken0 = (amount1: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount1 * PRICE_PRECISION) / price;\n};\n\nexport const getAmountsFromLiquidity = (\n tickLower: number,\n tickUpper: number,\n liquidity: bigint,\n currentTick: number,\n): [bigint, bigint] => {\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n let delta0 = JSBI.BigInt(0);\n let delta1 = JSBI.BigInt(0);\n\n if (currentTick < tickLower) {\n delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n } else if (currentTick >= tickUpper) {\n delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n } else {\n delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n }\n return [BigInt(delta0.toString()), BigInt(delta1.toString())];\n};\n\nexport const liquiditiesToAmount0 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount0 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount0Delta = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(amount0Delta.toString());\n }\n return amount0;\n};\n\nexport const liquiditiesToAmount1 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount1 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount1Delta = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(amount1Delta.toString());\n }\n return amount1;\n};\n\nexport const liquiditiesToAmounts = (\n liquidities: bigint[],\n startTick: number,\n currentTick: number,\n tickSpacing: number,\n) => {\n let amount0 = 0n;\n let amount1 = 0n;\n\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n if (currentTick < tickLower) {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n } else if (currentTick >= tickUpper) {\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(delta1.toString());\n } else {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n amount1 += BigInt(delta1.toString());\n }\n }\n return [amount0, amount1];\n};\n","import Big from 'big.js';\n\nexport const EMPTY_ARRAY: never[] = [];\n\nexport type Amount = {\n scaled: bigint;\n unscaled: Big;\n decimals: number;\n formatted: string;\n};\n\nexport const zero: Amount = {\n scaled: 0n,\n unscaled: Big(0),\n decimals: 18,\n formatted: '0',\n};\n\nexport const wrapAmount = (scaled: bigint, decimals: number): Amount => {\n const unscaled = unscaleAmount(scaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapAmountUnscaled = (\n unscaled: Big | number | string,\n decimals: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scaleAmount(unscaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapPrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n): Amount => {\n const unscaled = unscalePrice(scaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const wrapPriceUnscaled = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scalePrice(unscaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const unscaleAmount = (scaled: bigint, decimals: number) => {\n return new Big(scaled.toString()).div(new Big(10).pow(decimals));\n};\n\nexport const scaleAmount = (\n unscaled: Big | number | string,\n decimals: number,\n) => {\n return BigInt(\n Big(unscaled).mul(new Big(10).pow(decimals)).round().toFixed(0),\n );\n};\n\nexport const unscalePrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return new Big(scaled.toString())\n .mul(new Big(10).pow(decimals0))\n .div(new Big(10).pow(decimals1))\n .div(new Big(10).pow(precision));\n};\n\nexport const scalePrice = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return BigInt(\n Big(unscaled)\n .mul(new Big(10).pow(precision))\n .mul(new Big(10).pow(decimals1))\n .div(new Big(10).pow(decimals0))\n .round()\n .toFixed(0),\n );\n};\n\nexport const formatAmount = (value?: Big | number | string) => {\n if (value === undefined) return '-';\n // return value < 1 ? value.toPrecision(2) : value.toFixed(2);\n return formatCondensed(Big(value).toFixed(100));\n};\n\nexport const formatVagueAmount = (value: number | bigint) => {\n value = Number(value);\n if (value === 0) return '0';\n\n const formatted = value.toExponential(2);\n return formatted.replace(/\\.?0+e/, 'e').replace(/e\\+/, 'e');\n};\n\nexport const formatCondensed = (\n input: string | number,\n decimals = 2,\n): string => {\n const str = (typeof input === 'number' ? input.toFixed(20) : input)\n .replace(/(\\.\\d*?)0+$/, '$1')\n .replace(/\\.$/, '');\n\n const [whole, decimal] = str.split('.');\n\n const formattedWhole = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (!decimal) return formattedWhole;\n\n const leadingZeroMatch = decimal.match(/^(0{3,})/);\n\n if (leadingZeroMatch) {\n const zeroCount = leadingZeroMatch[1].length;\n const subscript = toSubscript(zeroCount.toString());\n const remaining = decimal.slice(zeroCount);\n\n const twoDigits = remaining.slice(0, decimals);\n return `${formattedWhole}.0${subscript}${twoDigits}`;\n } else {\n // No subscript needed, find first 2 significant digits\n const nonZeroStart = decimal.search(/[1-9]/); // Find first non-zero digit\n\n if (nonZeroStart === -1) {\n return formattedWhole; // All zeros\n }\n const significantPart = decimal.slice(nonZeroStart);\n const twoDigits = significantPart.slice(0, decimals);\n const leadingZeros = decimal.slice(0, nonZeroStart);\n\n return `${formattedWhole}.${leadingZeros}${twoDigits}`;\n }\n};\n\nconst toSubscript = (input: string) => {\n return input.replace(/[0-9]/g, m => '₀₁₂₃₄₅₆₇₈₉'[+m]);\n};\n\nexport const formatUSD = (value: Big | string | number): string => {\n return '$' + formatAmount(value);\n};\n","import type {OptionData} from '~/package/client';\nimport {\n liquiditiesToAmounts,\n token0ToToken1,\n token1ToToken0,\n} from './liquidityUtils';\n\nexport const getPayoutAtTick = (\n option: OptionData,\n liquidities: bigint[],\n tick: number,\n tickSpacing: number,\n optionAssetIsToken0: boolean,\n) => {\n const [borrowedAmount0, borrowedAmount1] = liquiditiesToAmounts(\n liquidities,\n option.startTick,\n option.entryTick,\n tickSpacing,\n );\n const [repayAmount0, repayAmount1] = liquiditiesToAmounts(\n liquidities,\n option.startTick,\n tick,\n tickSpacing,\n );\n const totalAmount = optionAssetIsToken0\n ? borrowedAmount1 + token0ToToken1(borrowedAmount0, tick)\n : borrowedAmount0 + token1ToToken0(borrowedAmount1, tick);\n\n const repayAmount = optionAssetIsToken0\n ? repayAmount1 + token0ToToken1(repayAmount0, tick)\n : repayAmount0 + token1ToToken0(repayAmount1, tick);\n\n const delta = totalAmount - repayAmount;\n const payout = delta < 0n ? 0n : delta;\n\n return payout;\n};\n"],"mappings":";;;;;;;;AA6BA,MAAa,YAAY,SAAkB,WACzC,YAAY;CAAC,KAAKA;CAAU;CAAS;CAAO,CAAC;AAE/C,MAAa,qBACX,SACA,WACmB;AACnB,QAAO,YAAY;EAAC,KAAK;EAAkB;EAAS;EAAO,CAAC;;AAG9D,MAAa,sBAAsB,WACjC,YAAY;CACV,KAAK;CACL,SAAS,kBAAkB,OAAO,MAAO;CACzC;CACD,CAAC;AAEJ,MAAa,mBAAmB,WAC9B,YAAY;CACV,KAAK;CACL,SAAS,eAAe,OAAO,MAAO;CACtC;CACD,CAAC;AAEJ,MAAaC,iBAA0C,GACpD,aAAa,KAAK,8CACpB;AACD,MAAaC,oBAA6C,GACvD,aAAa,KAAK,8CACpB;;;;AC5CD,MAAM,uBAAuB,eAAgC;AAS3D,QARsB;EACpB,MAAM;GAAC,WAAW;GAAU,WAAW;GAAK,SAAS;GAAG;EACxD,MAAM;GAAC,WAAW;GAAU,WAAW;GAAK,SAAS;GAAI;EACzD,OAAO;GAAC,WAAW;GAAU,WAAW;GAAM,SAAS;GAAI;EAC3D,MAAM;GAAC,WAAW;GAAQ,WAAW;GAAK,SAAS;GAAK;EACxD,MAAM;GAAC,WAAW;GAAQ,WAAW;GAAK,SAAS;GAAM;EACzD,MAAM;GAAC,WAAW;GAAO,WAAW;GAAK,SAAS;GAAM;EACzD,CACoB;;AAGvB,MAAM,YACJ,QACA,OACA,KACA,eACqB;AACrB,KAAI,OAAO,WAAW,EAAG,QAAO,EAAE;CAElC,MAAM,2BAAW,IAAI,KAA6B;AAElD,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,cACJ,KAAK,MAAM,MAAM,UAAU,SAAS,GAAG,WAAW,GAAG;AACvD,WAAS,IAAI,aAAa,MAAM;;CAElC,MAAMC,SAA2B,EAAE;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