@merkl/api 0.20.78 → 0.20.80

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.
Files changed (30) hide show
  1. package/dist/src/eden/index.d.ts +5998 -14089
  2. package/dist/src/engine/dynamicData/implementations/Clamm.js +8 -0
  3. package/dist/src/index.d.ts +2 -23
  4. package/dist/src/jobs/update-analytics.js +247 -4
  5. package/dist/src/modules/v4/cache/cache.repository.js +3 -52
  6. package/dist/src/modules/v4/campaign/campaign.controller.js +2 -2
  7. package/dist/src/modules/v4/campaign/campaign.service.d.ts +4 -4
  8. package/dist/src/modules/v4/campaign/campaign.service.js +7 -7
  9. package/dist/src/modules/v4/chain/chain.controller.d.ts +1 -0
  10. package/dist/src/modules/v4/chain/chain.repository.d.ts +2 -0
  11. package/dist/src/modules/v4/chain/chain.repository.js +1 -0
  12. package/dist/src/modules/v4/chain/chain.service.d.ts +2 -0
  13. package/dist/src/modules/v4/chain/chain.service.js +3 -0
  14. package/dist/src/modules/v4/chainInteraction/chainInteraction.service.js +1 -1
  15. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +3 -3
  16. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +4 -4
  17. package/dist/src/modules/v4/opportunity/opportunity.repository.js +3 -3
  18. package/dist/src/modules/v4/reward/reward.controller.d.ts +0 -22
  19. package/dist/src/modules/v4/reward/reward.controller.js +0 -2
  20. package/dist/src/modules/v4/router.d.ts +2 -23
  21. package/dist/src/modules/v4/router.js +21 -17
  22. package/dist/src/modules/v4/tvl/tvl.service.js +12 -1
  23. package/dist/src/utils/TailSampler.d.ts +8 -0
  24. package/dist/src/utils/TailSampler.js +23 -0
  25. package/dist/tsconfig.package.tsbuildinfo +1 -1
  26. package/package.json +4 -2
  27. package/dist/src/modules/v4/tracer/index.d.ts +0 -1
  28. package/dist/src/modules/v4/tracer/index.js +0 -1
  29. package/dist/src/modules/v4/tvl/index.d.ts +0 -2
  30. package/dist/src/modules/v4/tvl/index.js +0 -2
@@ -18,7 +18,7 @@ export declare const v4: Elysia<"/v4", false, {
18
18
  macro: {};
19
19
  macroFn: {};
20
20
  }, {
21
- v4: {} | {
21
+ v4: {
22
22
  derive: {};
23
23
  resolve: {};
24
24
  schema: {};
@@ -2757,28 +2757,6 @@ export declare const v4: Elysia<"/v4", false, {
2757
2757
  };
2758
2758
  };
2759
2759
  };
2760
- } & {
2761
- rewards: {
2762
- total: {
2763
- distributed: {
2764
- "by-opportunities": {
2765
- get: {
2766
- body: unknown;
2767
- params: {};
2768
- query: {
2769
- since: Date;
2770
- };
2771
- headers: {
2772
- authorization: string;
2773
- };
2774
- response: {
2775
- 200: string;
2776
- };
2777
- };
2778
- };
2779
- };
2780
- };
2781
- };
2782
2760
  } & {
2783
2761
  rewards: {
2784
2762
  total: {
@@ -2964,6 +2942,7 @@ export declare const v4: Elysia<"/v4", false, {
2964
2942
  };
2965
2943
  response: {
2966
2944
  200: {
2945
+ name: string;
2967
2946
  Explorer: {
2968
2947
  id: string;
2969
2948
  type: import("@db/api").$Enums.ExplorerType;
@@ -22,35 +22,39 @@ import { TokenController } from "@/modules/v4/token/token.controller";
22
22
  import { UniswapController } from "@/modules/v4/uniswap/uniswap.controller";
23
23
  import { UserController } from "@/modules/v4/user/user.controller";
24
24
  import { ErrorHandler } from "@/plugins/error-handling.plugin";
25
+ import { TailSampler } from "@/utils/TailSampler";
25
26
  import bigintToString from "@/utils/bigintToString";
26
27
  import { opentelemetry } from "@elysiajs/opentelemetry";
27
28
  import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
28
29
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
29
- import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
30
+ import { PgInstrumentation } from "@opentelemetry/instrumentation-pg";
31
+ import { RedisInstrumentation } from "@opentelemetry/instrumentation-redis";
32
+ import { AlwaysOffSampler, BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
30
33
  import { PrismaInstrumentation } from "@prisma/instrumentation";
31
34
  import Elysia from "elysia";
32
35
  import { ReferralController } from "./referral/referral.controller";
33
36
  // ─── V4 Router ───────────────────────────────────────────────────────────────
34
37
  export const v4 = new Elysia({ tags: ["v4"], prefix: "/v4" })
35
38
  // ─── OpenTelemetry ───────────────────────────────────────────────────
36
- .use(process.env.TRACE === "true"
37
- ? opentelemetry({
38
- spanProcessors: [
39
- new BatchSpanProcessor(new OTLPTraceExporter({
40
- url: process.env.OTEL_COLLECTOR,
41
- headers: {
42
- "signoz-ingestion-key": String(process.env.SIGNOZ_INGESTION_KEY),
43
- },
44
- })),
45
- ],
46
- instrumentations: [new PrismaInstrumentation(), getNodeAutoInstrumentations()],
47
- })
48
- : new Elysia() // not optimal
49
- )
39
+ .use(opentelemetry({
40
+ sampler: process.env.TRACE === "true" ? new TailSampler(0.1) : new AlwaysOffSampler(),
41
+ spanProcessors: [
42
+ new BatchSpanProcessor(new OTLPTraceExporter({
43
+ url: process.env.OTEL_COLLECTOR,
44
+ headers: {
45
+ "signoz-ingestion-key": String(process.env.SIGNOZ_INGESTION_KEY),
46
+ },
47
+ })),
48
+ ],
49
+ instrumentations: [
50
+ new PgInstrumentation(),
51
+ new RedisInstrumentation(),
52
+ new PrismaInstrumentation(),
53
+ getNodeAutoInstrumentations(),
54
+ ],
55
+ }))
50
56
  // ─── Error Handling ──────────────────────────────────────────────────
51
57
  .use(ErrorHandler)
52
- // ─── Logger ──────────────────────────────────────────────────────────
53
- // .use(Logger)
54
58
  // ─── Response Transformation ─────────────────────────────────────────
55
59
  .onAfterHandle(({ response }) => bigintToString(response))
56
60
  // ─── Route Controllers ───────────────────────────────────────────────
@@ -9,7 +9,18 @@ export class TvlService {
9
9
  const typesWithoutApr = [Campaign.INVALID, Campaign.JSON_AIRDROP, Campaign.ERC20_SNAPSHOT];
10
10
  if (typesWithoutApr.includes(type))
11
11
  return { timestamp, total: 0, breakdowns: [] };
12
- const opportunitySummary = dynamicData.reduce((merged, c) => Object.assign(merged, c), {});
12
+ /**
13
+ * Merge dynamic data and take the max tvl encountered
14
+ * @dev Useful if campaigns have different hooks or blacklists and so different target tvl
15
+ */
16
+ const opportunitySummary = dynamicData.reduce((merged, c) => {
17
+ const res = Object.assign(merged, c);
18
+ const campaignTvl = c?.tvl ?? 0;
19
+ if (campaignTvl > (merged?.tvl ?? 0)) {
20
+ res.tvl = campaignTvl;
21
+ }
22
+ return res;
23
+ }, {});
13
24
  let breakdowns = [];
14
25
  if (type === Campaign.CLAMM) {
15
26
  breakdowns = [
@@ -0,0 +1,8 @@
1
+ import type { Attributes, Context, Link, SpanKind } from "@opentelemetry/api";
2
+ import { type Sampler, type SamplingResult } from "@opentelemetry/sdk-trace-node";
3
+ export declare class TailSampler implements Sampler {
4
+ private baseSampler;
5
+ constructor(ratio: number);
6
+ shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, attributes: Attributes, links: Link[]): SamplingResult;
7
+ toString(): string;
8
+ }
@@ -0,0 +1,23 @@
1
+ import { ParentBasedSampler, SamplingDecision, TraceIdRatioBasedSampler, } from "@opentelemetry/sdk-trace-node";
2
+ export class TailSampler {
3
+ baseSampler;
4
+ constructor(ratio) {
5
+ this.baseSampler = new ParentBasedSampler({
6
+ root: new TraceIdRatioBasedSampler(ratio),
7
+ });
8
+ }
9
+ shouldSample(context, traceId, spanName, spanKind, attributes, links) {
10
+ const result = this.baseSampler.shouldSample(context, traceId, spanName, spanKind, attributes, links);
11
+ // Override sampling decision if error detected
12
+ if (attributes["error"] || Number(attributes["http.status_code"]) >= 500) {
13
+ return {
14
+ decision: SamplingDecision.RECORD_AND_SAMPLED,
15
+ attributes: { error_sampled: "true" },
16
+ };
17
+ }
18
+ return result;
19
+ }
20
+ toString() {
21
+ return "CustomTailSampler";
22
+ }
23
+ }