@merkl/api 0.20.56 → 0.20.58
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/src/eden/index.d.ts +25 -0
- package/dist/src/engine/dynamicData/implementations/Clamm.js +34 -30
- package/dist/src/index.d.ts +5 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +5 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +1 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.js +1 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +51 -23
- package/dist/src/modules/v4/router.d.ts +5 -0
- package/dist/src/modules/v4/uniswap/uniswap.service.js +11 -10
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -531,6 +531,7 @@ declare const eden: {
|
|
531
531
|
get: (options: {
|
532
532
|
headers?: Record<string, unknown> | undefined;
|
533
533
|
query: {
|
534
|
+
search?: string | undefined;
|
534
535
|
name?: string | undefined;
|
535
536
|
type?: string | undefined;
|
536
537
|
status?: string | undefined;
|
@@ -726,6 +727,7 @@ declare const eden: {
|
|
726
727
|
get: (options: {
|
727
728
|
headers?: Record<string, unknown> | undefined;
|
728
729
|
query: {
|
730
|
+
search?: string | undefined;
|
729
731
|
name?: string | undefined;
|
730
732
|
type?: string | undefined;
|
731
733
|
status?: string | undefined;
|
@@ -936,6 +938,7 @@ declare const eden: {
|
|
936
938
|
get: (options: {
|
937
939
|
headers?: Record<string, unknown> | undefined;
|
938
940
|
query: {
|
941
|
+
search?: string | undefined;
|
939
942
|
name?: string | undefined;
|
940
943
|
type?: string | undefined;
|
941
944
|
status?: string | undefined;
|
@@ -970,6 +973,7 @@ declare const eden: {
|
|
970
973
|
get: (options: {
|
971
974
|
headers?: Record<string, unknown> | undefined;
|
972
975
|
query: {
|
976
|
+
search?: string | undefined;
|
973
977
|
name?: string | undefined;
|
974
978
|
type?: string | undefined;
|
975
979
|
status?: string | undefined;
|
@@ -1004,6 +1008,7 @@ declare const eden: {
|
|
1004
1008
|
get: (options: {
|
1005
1009
|
headers?: Record<string, unknown> | undefined;
|
1006
1010
|
query: {
|
1011
|
+
search?: string | undefined;
|
1007
1012
|
name?: string | undefined;
|
1008
1013
|
type?: string | undefined;
|
1009
1014
|
status?: string | undefined;
|
@@ -4554,6 +4559,7 @@ declare const eden: {
|
|
4554
4559
|
get: (options: {
|
4555
4560
|
headers?: Record<string, unknown> | undefined;
|
4556
4561
|
query: {
|
4562
|
+
search?: string | undefined;
|
4557
4563
|
name?: string | undefined;
|
4558
4564
|
type?: string | undefined;
|
4559
4565
|
status?: string | undefined;
|
@@ -4749,6 +4755,7 @@ declare const eden: {
|
|
4749
4755
|
get: (options: {
|
4750
4756
|
headers?: Record<string, unknown> | undefined;
|
4751
4757
|
query: {
|
4758
|
+
search?: string | undefined;
|
4752
4759
|
name?: string | undefined;
|
4753
4760
|
type?: string | undefined;
|
4754
4761
|
status?: string | undefined;
|
@@ -4959,6 +4966,7 @@ declare const eden: {
|
|
4959
4966
|
get: (options: {
|
4960
4967
|
headers?: Record<string, unknown> | undefined;
|
4961
4968
|
query: {
|
4969
|
+
search?: string | undefined;
|
4962
4970
|
name?: string | undefined;
|
4963
4971
|
type?: string | undefined;
|
4964
4972
|
status?: string | undefined;
|
@@ -4993,6 +5001,7 @@ declare const eden: {
|
|
4993
5001
|
get: (options: {
|
4994
5002
|
headers?: Record<string, unknown> | undefined;
|
4995
5003
|
query: {
|
5004
|
+
search?: string | undefined;
|
4996
5005
|
name?: string | undefined;
|
4997
5006
|
type?: string | undefined;
|
4998
5007
|
status?: string | undefined;
|
@@ -5027,6 +5036,7 @@ declare const eden: {
|
|
5027
5036
|
get: (options: {
|
5028
5037
|
headers?: Record<string, unknown> | undefined;
|
5029
5038
|
query: {
|
5039
|
+
search?: string | undefined;
|
5030
5040
|
name?: string | undefined;
|
5031
5041
|
type?: string | undefined;
|
5032
5042
|
status?: string | undefined;
|
@@ -9091,6 +9101,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9091
9101
|
body: unknown;
|
9092
9102
|
params: {};
|
9093
9103
|
query: {
|
9104
|
+
search?: string | undefined;
|
9094
9105
|
name?: string | undefined;
|
9095
9106
|
type?: string | undefined;
|
9096
9107
|
status?: string | undefined;
|
@@ -9291,6 +9302,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9291
9302
|
body: unknown;
|
9292
9303
|
params: {};
|
9293
9304
|
query: {
|
9305
|
+
search?: string | undefined;
|
9294
9306
|
name?: string | undefined;
|
9295
9307
|
type?: string | undefined;
|
9296
9308
|
status?: string | undefined;
|
@@ -9793,6 +9805,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9793
9805
|
field: never;
|
9794
9806
|
};
|
9795
9807
|
query: {
|
9808
|
+
search?: string | undefined;
|
9796
9809
|
name?: string | undefined;
|
9797
9810
|
type?: string | undefined;
|
9798
9811
|
status?: string | undefined;
|
@@ -9835,6 +9848,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9835
9848
|
field: never;
|
9836
9849
|
};
|
9837
9850
|
query: {
|
9851
|
+
search?: string | undefined;
|
9838
9852
|
name?: string | undefined;
|
9839
9853
|
type?: string | undefined;
|
9840
9854
|
status?: string | undefined;
|
@@ -9878,6 +9892,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9878
9892
|
field: never;
|
9879
9893
|
};
|
9880
9894
|
query: {
|
9895
|
+
search?: string | undefined;
|
9881
9896
|
name?: string | undefined;
|
9882
9897
|
type?: string | undefined;
|
9883
9898
|
status?: string | undefined;
|
@@ -15253,6 +15268,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15253
15268
|
get: (options: {
|
15254
15269
|
headers?: Record<string, unknown> | undefined;
|
15255
15270
|
query: {
|
15271
|
+
search?: string | undefined;
|
15256
15272
|
name?: string | undefined;
|
15257
15273
|
type?: string | undefined;
|
15258
15274
|
status?: string | undefined;
|
@@ -15448,6 +15464,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15448
15464
|
get: (options: {
|
15449
15465
|
headers?: Record<string, unknown> | undefined;
|
15450
15466
|
query: {
|
15467
|
+
search?: string | undefined;
|
15451
15468
|
name?: string | undefined;
|
15452
15469
|
type?: string | undefined;
|
15453
15470
|
status?: string | undefined;
|
@@ -15658,6 +15675,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15658
15675
|
get: (options: {
|
15659
15676
|
headers?: Record<string, unknown> | undefined;
|
15660
15677
|
query: {
|
15678
|
+
search?: string | undefined;
|
15661
15679
|
name?: string | undefined;
|
15662
15680
|
type?: string | undefined;
|
15663
15681
|
status?: string | undefined;
|
@@ -15692,6 +15710,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15692
15710
|
get: (options: {
|
15693
15711
|
headers?: Record<string, unknown> | undefined;
|
15694
15712
|
query: {
|
15713
|
+
search?: string | undefined;
|
15695
15714
|
name?: string | undefined;
|
15696
15715
|
type?: string | undefined;
|
15697
15716
|
status?: string | undefined;
|
@@ -15726,6 +15745,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15726
15745
|
get: (options: {
|
15727
15746
|
headers?: Record<string, unknown> | undefined;
|
15728
15747
|
query: {
|
15748
|
+
search?: string | undefined;
|
15729
15749
|
name?: string | undefined;
|
15730
15750
|
type?: string | undefined;
|
15731
15751
|
status?: string | undefined;
|
@@ -19276,6 +19296,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19276
19296
|
get: (options: {
|
19277
19297
|
headers?: Record<string, unknown> | undefined;
|
19278
19298
|
query: {
|
19299
|
+
search?: string | undefined;
|
19279
19300
|
name?: string | undefined;
|
19280
19301
|
type?: string | undefined;
|
19281
19302
|
status?: string | undefined;
|
@@ -19471,6 +19492,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19471
19492
|
get: (options: {
|
19472
19493
|
headers?: Record<string, unknown> | undefined;
|
19473
19494
|
query: {
|
19495
|
+
search?: string | undefined;
|
19474
19496
|
name?: string | undefined;
|
19475
19497
|
type?: string | undefined;
|
19476
19498
|
status?: string | undefined;
|
@@ -19681,6 +19703,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19681
19703
|
get: (options: {
|
19682
19704
|
headers?: Record<string, unknown> | undefined;
|
19683
19705
|
query: {
|
19706
|
+
search?: string | undefined;
|
19684
19707
|
name?: string | undefined;
|
19685
19708
|
type?: string | undefined;
|
19686
19709
|
status?: string | undefined;
|
@@ -19715,6 +19738,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19715
19738
|
get: (options: {
|
19716
19739
|
headers?: Record<string, unknown> | undefined;
|
19717
19740
|
query: {
|
19741
|
+
search?: string | undefined;
|
19718
19742
|
name?: string | undefined;
|
19719
19743
|
type?: string | undefined;
|
19720
19744
|
status?: string | undefined;
|
@@ -19749,6 +19773,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19749
19773
|
get: (options: {
|
19750
19774
|
headers?: Record<string, unknown> | undefined;
|
19751
19775
|
query: {
|
19776
|
+
search?: string | undefined;
|
19752
19777
|
name?: string | undefined;
|
19753
19778
|
type?: string | undefined;
|
19754
19779
|
status?: string | undefined;
|
@@ -321,13 +321,13 @@ export class ClammDynamicData {
|
|
321
321
|
for (const w of pool.alms.filter(a => a.target.toLowerCase() === pool.address.toLowerCase() && a.type !== ALM.A51)) {
|
322
322
|
const prevI = i;
|
323
323
|
try {
|
324
|
-
const totalSupply =
|
325
|
-
const almIdleBalance0 =
|
324
|
+
const totalSupply = BigNumber.from(ERC20Interface.decodeFunctionResult("totalSupply", result[i++].returnData)[0]);
|
325
|
+
const almIdleBalance0 = BigNumber.from(ERC20Interface.decodeFunctionResult("balanceOf", result[i++].returnData)[0]);
|
326
326
|
let almBalance0 = almIdleBalance0;
|
327
|
-
const almIdleBalance1 =
|
327
|
+
const almIdleBalance1 = BigNumber.from(ERC20Interface.decodeFunctionResult("balanceOf", result[i++].returnData)[0]);
|
328
328
|
let almBalance1 = almIdleBalance1;
|
329
|
-
let almTotalLiquidity = 0;
|
330
|
-
let almInRangeLiquidity = 0;
|
329
|
+
let almTotalLiquidity = BigNumber.from(0);
|
330
|
+
let almInRangeLiquidity = BigNumber.from(0);
|
331
331
|
const almPositions = positions?.[pool.amm]?.filter(pos => pos.pool.id === pool.address.toLowerCase() &&
|
332
332
|
[w.address.toLowerCase(), ...[!!w?.owner && w.owner.toLowerCase()]].includes(pos.owner.toLowerCase()));
|
333
333
|
const almPositionsWithAPIType = [];
|
@@ -336,22 +336,23 @@ export class ClammDynamicData {
|
|
336
336
|
const upperTick = Number.parseInt(position.tickUpper);
|
337
337
|
const lowerTick = Number.parseInt(position.tickLower);
|
338
338
|
const [amount0, amount1] = getAmountsForLiquidity(sqrtPrice, lowerTick, upperTick, BigNumber.from(position.liquidity));
|
339
|
-
const balance0 =
|
340
|
-
const balance1 =
|
341
|
-
const totalLiquidity =
|
342
|
-
const inRangeLiquidity = balance0 > 0 &&
|
343
|
-
almTotalLiquidity
|
344
|
-
almInRangeLiquidity
|
345
|
-
almBalance0
|
346
|
-
almBalance1
|
339
|
+
const balance0 = BigNumber.from(amount0);
|
340
|
+
const balance1 = BigNumber.from(amount1);
|
341
|
+
const totalLiquidity = BigNumber.from(position.liquidity);
|
342
|
+
const inRangeLiquidity = balance0 > BigNumber.from(0) && BigNumber.from(0) ? (BigNumber.from(position.liquidity) ?? 0) : 0;
|
343
|
+
almTotalLiquidity = almTotalLiquidity.add(totalLiquidity);
|
344
|
+
almInRangeLiquidity = almInRangeLiquidity.add(inRangeLiquidity);
|
345
|
+
almBalance0 = almBalance0.add(balance0);
|
346
|
+
almBalance1 = almBalance1.add(balance1);
|
347
347
|
almPositionsWithAPIType.push({
|
348
|
-
balance0,
|
349
|
-
balance1,
|
348
|
+
balance0: BN2Number(balance0, d.campaignParameters.decimalsToken0),
|
349
|
+
balance1: BN2Number(balance1, d.campaignParameters.decimalsToken0),
|
350
350
|
id: position.id,
|
351
|
-
inRangeLiquidity,
|
351
|
+
inRangeLiquidity: BN2Number(inRangeLiquidity),
|
352
352
|
lowerTick,
|
353
|
-
totalLiquidity,
|
354
|
-
tvl: priceToken0 * balance0 +
|
353
|
+
totalLiquidity: BN2Number(totalLiquidity),
|
354
|
+
tvl: priceToken0 * BN2Number(balance0, d.campaignParameters.decimalsToken0) +
|
355
|
+
priceToken1 * BN2Number(balance1, d.campaignParameters.decimalsToken0),
|
355
356
|
upperTick,
|
356
357
|
});
|
357
358
|
}
|
@@ -360,13 +361,14 @@ export class ClammDynamicData {
|
|
360
361
|
almDetails.push({
|
361
362
|
almAPR: 0, // filled later on
|
362
363
|
almAddress: utils.getAddress(w.address),
|
363
|
-
almBalance0,
|
364
|
-
almIdleBalance0,
|
365
|
-
almIdleBalance1,
|
366
|
-
almBalance1,
|
367
|
-
almInRangeLiquidity,
|
368
|
-
almTVL: almBalance0 * priceToken0 +
|
369
|
-
|
364
|
+
almBalance0: BN2Number(almBalance0, d.campaignParameters.decimalsToken0),
|
365
|
+
almIdleBalance0: BN2Number(almIdleBalance0, d.campaignParameters.decimalsToken0),
|
366
|
+
almIdleBalance1: BN2Number(almIdleBalance1, d.campaignParameters.decimalsToken1),
|
367
|
+
almBalance1: BN2Number(almBalance1, d.campaignParameters.decimalsToken1),
|
368
|
+
almInRangeLiquidity: BN2Number(almInRangeLiquidity),
|
369
|
+
almTVL: BN2Number(almBalance0, d.campaignParameters.decimalsToken0) * priceToken0 +
|
370
|
+
BN2Number(almBalance1, d.campaignParameters.decimalsToken1) * priceToken1,
|
371
|
+
almTotalLiquidity: BN2Number(almTotalLiquidity),
|
370
372
|
forwarderType: Forwarder.CLAMM,
|
371
373
|
label: `${ALMMapping[pool.amm]?.[w.type]} ${w.address}`,
|
372
374
|
origin: w.type,
|
@@ -375,7 +377,7 @@ export class ClammDynamicData {
|
|
375
377
|
sender: utils.getAddress(w.address),
|
376
378
|
target: w.target,
|
377
379
|
owner: utils.getAddress(w.owner ?? w.address),
|
378
|
-
totalSupply,
|
380
|
+
totalSupply: BN2Number(totalSupply),
|
379
381
|
type: w.type,
|
380
382
|
});
|
381
383
|
}
|
@@ -647,12 +649,14 @@ export class ClammDynamicData {
|
|
647
649
|
catch {
|
648
650
|
log.warn(`merklDynamic data - failed to handle whitelisted positions of pool ${pool.address} on ${NETWORK_LABELS[chainId]} - ${pos.owner} ${pos.tickLower} ${pos.tickUpper} ${pos.liquidity}`);
|
649
651
|
}
|
650
|
-
blacklistedBalance0 = blacklistedBalance0.sub((BN2Number(amount0,
|
651
|
-
blacklistedBalance1 = blacklistedBalance1.sub(BigNumber.from((BN2Number(amount1,
|
652
|
+
blacklistedBalance0 = blacklistedBalance0.sub(BigNumber.from(Math.floor((BN2Number(amount0, 0) * childALM.almBalance0) / almHolding.almBalance0)));
|
653
|
+
blacklistedBalance1 = blacklistedBalance1.sub(BigNumber.from(Math.floor((BN2Number(amount1, 0) * childALM.almBalance1) / almHolding.almBalance1)));
|
652
654
|
if (c.campaignParameters.isOutOfRangeIncentivized
|
653
655
|
? BN2Number(amount0, decimalsToken0) > 0 || BN2Number(amount1, decimalsToken1) > 0
|
654
|
-
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0)
|
655
|
-
blacklistedLiquidity = blacklistedLiquidity.sub(
|
656
|
+
: BN2Number(amount0, decimalsToken0) > 0 && BN2Number(amount1, decimalsToken1) > 0) {
|
657
|
+
blacklistedLiquidity = blacklistedLiquidity.sub(BigInt(Math.floor((BN2Number(pos.liquidity, 0) * childALM.almTotalLiquidity) /
|
658
|
+
almHolding.almTotalLiquidity)));
|
659
|
+
}
|
656
660
|
}
|
657
661
|
}
|
658
662
|
}
|
package/dist/src/index.d.ts
CHANGED
@@ -334,6 +334,7 @@ declare const app: Elysia<"", false, {
|
|
334
334
|
body: unknown;
|
335
335
|
params: {};
|
336
336
|
query: {
|
337
|
+
search?: string | undefined;
|
337
338
|
name?: string | undefined;
|
338
339
|
type?: string | undefined;
|
339
340
|
status?: string | undefined;
|
@@ -534,6 +535,7 @@ declare const app: Elysia<"", false, {
|
|
534
535
|
body: unknown;
|
535
536
|
params: {};
|
536
537
|
query: {
|
538
|
+
search?: string | undefined;
|
537
539
|
name?: string | undefined;
|
538
540
|
type?: string | undefined;
|
539
541
|
status?: string | undefined;
|
@@ -1036,6 +1038,7 @@ declare const app: Elysia<"", false, {
|
|
1036
1038
|
field: never;
|
1037
1039
|
};
|
1038
1040
|
query: {
|
1041
|
+
search?: string | undefined;
|
1039
1042
|
name?: string | undefined;
|
1040
1043
|
type?: string | undefined;
|
1041
1044
|
status?: string | undefined;
|
@@ -1078,6 +1081,7 @@ declare const app: Elysia<"", false, {
|
|
1078
1081
|
field: never;
|
1079
1082
|
};
|
1080
1083
|
query: {
|
1084
|
+
search?: string | undefined;
|
1081
1085
|
name?: string | undefined;
|
1082
1086
|
type?: string | undefined;
|
1083
1087
|
status?: string | undefined;
|
@@ -1121,6 +1125,7 @@ declare const app: Elysia<"", false, {
|
|
1121
1125
|
field: never;
|
1122
1126
|
};
|
1123
1127
|
query: {
|
1128
|
+
search?: string | undefined;
|
1124
1129
|
name?: string | undefined;
|
1125
1130
|
type?: string | undefined;
|
1126
1131
|
status?: string | undefined;
|
@@ -189,6 +189,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
189
189
|
body: unknown;
|
190
190
|
params: {};
|
191
191
|
query: {
|
192
|
+
search?: string | undefined;
|
192
193
|
name?: string | undefined;
|
193
194
|
type?: string | undefined;
|
194
195
|
status?: string | undefined;
|
@@ -389,6 +390,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
389
390
|
body: unknown;
|
390
391
|
params: {};
|
391
392
|
query: {
|
393
|
+
search?: string | undefined;
|
392
394
|
name?: string | undefined;
|
393
395
|
type?: string | undefined;
|
394
396
|
status?: string | undefined;
|
@@ -891,6 +893,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
891
893
|
field: never;
|
892
894
|
};
|
893
895
|
query: {
|
896
|
+
search?: string | undefined;
|
894
897
|
name?: string | undefined;
|
895
898
|
type?: string | undefined;
|
896
899
|
status?: string | undefined;
|
@@ -933,6 +936,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
933
936
|
field: never;
|
934
937
|
};
|
935
938
|
query: {
|
939
|
+
search?: string | undefined;
|
936
940
|
name?: string | undefined;
|
937
941
|
type?: string | undefined;
|
938
942
|
status?: string | undefined;
|
@@ -976,6 +980,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
976
980
|
field: never;
|
977
981
|
};
|
978
982
|
query: {
|
983
|
+
search?: string | undefined;
|
979
984
|
name?: string | undefined;
|
980
985
|
type?: string | undefined;
|
981
986
|
status?: string | undefined;
|
@@ -293,6 +293,7 @@ export declare const AggregationResourceDto: import("@sinclair/typebox").TObject
|
|
293
293
|
}>;
|
294
294
|
export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObject<{
|
295
295
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
296
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
296
297
|
campaignId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
297
298
|
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
298
299
|
action: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRegExp>;
|
@@ -52,6 +52,7 @@ export const AggregationResourceDto = t.Object({
|
|
52
52
|
});
|
53
53
|
export const GetOpportunitiesQueryDto = t.Object({
|
54
54
|
name: t.Optional(t.String({ description: "Filter by name" })),
|
55
|
+
search: t.Optional(t.String({ description: "Search amongst multiple values (token, protocols, tags, campaigns)" })),
|
55
56
|
campaignId: t.Optional(t.String({ description: "Search the opportunity linked to a given campaignId" })),
|
56
57
|
//TODO: find a systemic way of handling query param arrays
|
57
58
|
chainId: t.Optional(t.RegExp(/^\d+(,\d+)*$/, {
|
@@ -15,6 +15,7 @@ export class OpportunityRepository {
|
|
15
15
|
const actions = query.action?.split(",");
|
16
16
|
const status = query.status?.split(",");
|
17
17
|
const tokens = query.tokens?.split(",");
|
18
|
+
const search = query.search?.split(" ");
|
18
19
|
const rewardTokenSymbol = query.rewardTokenSymbol;
|
19
20
|
const types = query.type?.split(",");
|
20
21
|
const protocols = query.mainProtocolId?.split(",");
|
@@ -29,31 +30,57 @@ export class OpportunityRepository {
|
|
29
30
|
return {
|
30
31
|
orderBy,
|
31
32
|
where: {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
33
|
+
AND: [
|
34
|
+
{
|
35
|
+
tags: !filters.tags ? undefined : { has: filters.tags },
|
36
|
+
type: !filters.type ? undefined : { in: types },
|
37
|
+
tvl: filters.minimumTvl ? { gte: filters.minimumTvl } : undefined,
|
38
|
+
chainId: !chainIds ? undefined : { in: chainIds },
|
39
|
+
name: !filters.name ? undefined : { contains: filters.name, mode: "insensitive" },
|
40
|
+
action: !actions ? undefined : { in: actions },
|
41
|
+
status: !status ? undefined : { in: status },
|
42
|
+
mainProtocolId: !protocols ? undefined : { in: protocols, mode: "insensitive" },
|
43
|
+
identifier: !identifier ? undefined : { in: identifiers, mode: "insensitive" },
|
44
|
+
Campaigns: test && !creatorAddress && !rewardTokenSymbol && !filters.campaignId
|
45
|
+
? undefined
|
46
|
+
: {
|
47
|
+
some: {
|
48
|
+
campaignId: filters.campaignId ? filters.campaignId : undefined,
|
49
|
+
RewardToken: test && !rewardTokenSymbol
|
50
|
+
? undefined
|
51
|
+
: {
|
52
|
+
isTest: !test ? false : undefined,
|
53
|
+
isPoint: point,
|
54
|
+
symbol: rewardTokenSymbol
|
55
|
+
? { equals: rewardTokenSymbol, mode: "insensitive" }
|
56
|
+
: undefined,
|
57
|
+
},
|
58
|
+
creatorAddress: creatorAddress ? creatorAddress : undefined,
|
52
59
|
},
|
53
|
-
|
54
|
-
},
|
60
|
+
},
|
61
|
+
Tokens: { some: { symbol: { in: tokens } } },
|
55
62
|
},
|
56
|
-
|
63
|
+
!search
|
64
|
+
? {}
|
65
|
+
: {
|
66
|
+
AND: search?.map(keyword => ({
|
67
|
+
OR: [
|
68
|
+
{ id: { contains: keyword, mode: "insensitive" } },
|
69
|
+
{ name: { contains: keyword, mode: "insensitive" } },
|
70
|
+
{ identifier: { contains: keyword, mode: "insensitive" } },
|
71
|
+
{ explorerAddress: { contains: keyword, mode: "insensitive" } },
|
72
|
+
{ type: { contains: keyword, mode: "insensitive" } },
|
73
|
+
{ MainProtocol: { name: { contains: keyword, mode: "insensitive" } } },
|
74
|
+
{ mainProtocolId: { contains: keyword, mode: "insensitive" } },
|
75
|
+
{ Tokens: { some: { name: { contains: keyword, mode: "insensitive" } } } },
|
76
|
+
{ Tokens: { some: { symbol: { contains: keyword, mode: "insensitive" } } } },
|
77
|
+
{ Campaigns: { some: { campaignId: { contains: keyword, mode: "insensitive" } } } },
|
78
|
+
{ Campaigns: { some: { id: { contains: keyword, mode: "insensitive" } } } },
|
79
|
+
{ Chain: { name: { contains: keyword, mode: "insensitive" } } },
|
80
|
+
],
|
81
|
+
})),
|
82
|
+
},
|
83
|
+
],
|
57
84
|
},
|
58
85
|
};
|
59
86
|
}
|
@@ -269,6 +296,7 @@ export class OpportunityRepository {
|
|
269
296
|
const withPoints = query.point ?? false;
|
270
297
|
const withCampaigns = query.campaigns ?? false;
|
271
298
|
const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
|
299
|
+
const search = query.search ?? undefined;
|
272
300
|
return await apiDbClient.opportunity.findMany({
|
273
301
|
take: items === 0 ? undefined : items,
|
274
302
|
skip: page * items,
|
@@ -204,6 +204,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
204
204
|
body: unknown;
|
205
205
|
params: {};
|
206
206
|
query: {
|
207
|
+
search?: string | undefined;
|
207
208
|
name?: string | undefined;
|
208
209
|
type?: string | undefined;
|
209
210
|
status?: string | undefined;
|
@@ -404,6 +405,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
404
405
|
body: unknown;
|
405
406
|
params: {};
|
406
407
|
query: {
|
408
|
+
search?: string | undefined;
|
407
409
|
name?: string | undefined;
|
408
410
|
type?: string | undefined;
|
409
411
|
status?: string | undefined;
|
@@ -906,6 +908,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
906
908
|
field: never;
|
907
909
|
};
|
908
910
|
query: {
|
911
|
+
search?: string | undefined;
|
909
912
|
name?: string | undefined;
|
910
913
|
type?: string | undefined;
|
911
914
|
status?: string | undefined;
|
@@ -948,6 +951,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
948
951
|
field: never;
|
949
952
|
};
|
950
953
|
query: {
|
954
|
+
search?: string | undefined;
|
951
955
|
name?: string | undefined;
|
952
956
|
type?: string | undefined;
|
953
957
|
status?: string | undefined;
|
@@ -991,6 +995,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
991
995
|
field: never;
|
992
996
|
};
|
993
997
|
query: {
|
998
|
+
search?: string | undefined;
|
994
999
|
name?: string | undefined;
|
995
1000
|
type?: string | undefined;
|
996
1001
|
status?: string | undefined;
|
@@ -36,13 +36,14 @@ export class UniswapService {
|
|
36
36
|
const { opportunity: rawOpportunity, ...props } = breakdown;
|
37
37
|
const opportunity = OpportunityService.formatResponseBase(rawOpportunity);
|
38
38
|
const chainId = opportunity.chainId;
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
const positionId = breakdown.reason.split("_")[version === "v3" ? 1 : 2];
|
40
|
+
// There can be chain, pool and position Id filter in the request
|
41
|
+
if (!!chainId && (!query.chainId || chainId === query.chainId)) {
|
42
|
+
if (!!pool && (!query.pool || pool === query.pool)) {
|
43
|
+
if (!!positionId && (!query.positionId || positionId === query.positionId)) {
|
44
|
+
try {
|
45
|
+
res[chainId] = res[chainId] ?? {};
|
46
|
+
res[chainId][pool] = res[chainId][pool] ?? {};
|
46
47
|
res[chainId][pool][positionId] = res[chainId][pool][positionId] ?? [];
|
47
48
|
res[chainId][pool][positionId].push({
|
48
49
|
...props,
|
@@ -50,12 +51,12 @@ export class UniswapService {
|
|
50
51
|
rewardToken,
|
51
52
|
});
|
52
53
|
}
|
54
|
+
catch {
|
55
|
+
log.warn(`failed to parse positionId for reason for pool ${pool} and version ${version}`);
|
56
|
+
}
|
53
57
|
}
|
54
58
|
}
|
55
59
|
}
|
56
|
-
catch {
|
57
|
-
log.warn(`failed to parse positionId for reason for pool ${pool} and version ${version}`);
|
58
|
-
}
|
59
60
|
}
|
60
61
|
}
|
61
62
|
return res;
|