@merkl/api 0.16.21 → 0.16.22
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 +82 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/libs/campaigns/campaignTypes/UniswapV4DynamicData.js +23 -15
- package/dist/src/modules/v4/router.d.ts +22 -0
- package/dist/src/modules/v4/status/status.controller.d.ts +22 -0
- package/dist/src/modules/v4/status/status.controller.js +10 -1
- package/dist/src/modules/v4/status/status.model.d.ts +3 -0
- package/dist/src/modules/v4/status/status.model.js +1 -0
- package/dist/src/modules/v4/status/status.repository.d.ts +8 -0
- package/dist/src/modules/v4/status/status.repository.js +10 -0
- package/dist/src/modules/v4/status/status.service.d.ts +1 -0
- package/dist/src/modules/v4/status/status.service.js +13 -0
- package/dist/src/utils/generateIcons.js +7 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -2670,6 +2670,21 @@ declare const eden: {
|
|
2670
2670
|
200: void;
|
2671
2671
|
}>>;
|
2672
2672
|
}) & {
|
2673
|
+
computedUntil: ((params: {
|
2674
|
+
campaignId: string | number;
|
2675
|
+
}) => {
|
2676
|
+
put: (body: {
|
2677
|
+
computedUntil: number;
|
2678
|
+
}, options: {
|
2679
|
+
headers: {
|
2680
|
+
authorization: string;
|
2681
|
+
};
|
2682
|
+
query?: Record<string, unknown> | undefined;
|
2683
|
+
fetch?: RequestInit | undefined;
|
2684
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
2685
|
+
200: void;
|
2686
|
+
}>>;
|
2687
|
+
}) & {};
|
2673
2688
|
overlaps: {
|
2674
2689
|
get: (options: {
|
2675
2690
|
headers: {
|
@@ -5847,6 +5862,21 @@ declare const eden: {
|
|
5847
5862
|
200: void;
|
5848
5863
|
}>>;
|
5849
5864
|
}) & {
|
5865
|
+
computedUntil: ((params: {
|
5866
|
+
campaignId: string | number;
|
5867
|
+
}) => {
|
5868
|
+
put: (body: {
|
5869
|
+
computedUntil: number;
|
5870
|
+
}, options: {
|
5871
|
+
headers: {
|
5872
|
+
authorization: string;
|
5873
|
+
};
|
5874
|
+
query?: Record<string, unknown> | undefined;
|
5875
|
+
fetch?: RequestInit | undefined;
|
5876
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
5877
|
+
200: void;
|
5878
|
+
}>>;
|
5879
|
+
}) & {};
|
5850
5880
|
overlaps: {
|
5851
5881
|
get: (options: {
|
5852
5882
|
headers: {
|
@@ -10318,6 +10348,28 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
10318
10348
|
};
|
10319
10349
|
};
|
10320
10350
|
};
|
10351
|
+
} & {
|
10352
|
+
engine: {
|
10353
|
+
computedUntil: {
|
10354
|
+
":campaignId": {
|
10355
|
+
put: {
|
10356
|
+
body: {
|
10357
|
+
computedUntil: number;
|
10358
|
+
};
|
10359
|
+
params: {
|
10360
|
+
campaignId: string;
|
10361
|
+
};
|
10362
|
+
query: unknown;
|
10363
|
+
headers: {
|
10364
|
+
authorization: string;
|
10365
|
+
};
|
10366
|
+
response: {
|
10367
|
+
200: void;
|
10368
|
+
};
|
10369
|
+
};
|
10370
|
+
};
|
10371
|
+
};
|
10372
|
+
};
|
10321
10373
|
} & {
|
10322
10374
|
engine: {
|
10323
10375
|
overlaps: {
|
@@ -14567,6 +14619,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
14567
14619
|
200: void;
|
14568
14620
|
}>>;
|
14569
14621
|
}) & {
|
14622
|
+
computedUntil: ((params: {
|
14623
|
+
campaignId: string | number;
|
14624
|
+
}) => {
|
14625
|
+
put: (body: {
|
14626
|
+
computedUntil: number;
|
14627
|
+
}, options: {
|
14628
|
+
headers: {
|
14629
|
+
authorization: string;
|
14630
|
+
};
|
14631
|
+
query?: Record<string, unknown> | undefined;
|
14632
|
+
fetch?: RequestInit | undefined;
|
14633
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
14634
|
+
200: void;
|
14635
|
+
}>>;
|
14636
|
+
}) & {};
|
14570
14637
|
overlaps: {
|
14571
14638
|
get: (options: {
|
14572
14639
|
headers: {
|
@@ -17744,6 +17811,21 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
17744
17811
|
200: void;
|
17745
17812
|
}>>;
|
17746
17813
|
}) & {
|
17814
|
+
computedUntil: ((params: {
|
17815
|
+
campaignId: string | number;
|
17816
|
+
}) => {
|
17817
|
+
put: (body: {
|
17818
|
+
computedUntil: number;
|
17819
|
+
}, options: {
|
17820
|
+
headers: {
|
17821
|
+
authorization: string;
|
17822
|
+
};
|
17823
|
+
query?: Record<string, unknown> | undefined;
|
17824
|
+
fetch?: RequestInit | undefined;
|
17825
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
17826
|
+
200: void;
|
17827
|
+
}>>;
|
17828
|
+
}) & {};
|
17747
17829
|
overlaps: {
|
17748
17830
|
get: (options: {
|
17749
17831
|
headers: {
|
package/dist/src/index.d.ts
CHANGED
@@ -3266,6 +3266,28 @@ declare const app: Elysia<"", false, {
|
|
3266
3266
|
};
|
3267
3267
|
};
|
3268
3268
|
};
|
3269
|
+
} & {
|
3270
|
+
engine: {
|
3271
|
+
computedUntil: {
|
3272
|
+
":campaignId": {
|
3273
|
+
put: {
|
3274
|
+
body: {
|
3275
|
+
computedUntil: number;
|
3276
|
+
};
|
3277
|
+
params: {
|
3278
|
+
campaignId: string;
|
3279
|
+
};
|
3280
|
+
query: unknown;
|
3281
|
+
headers: {
|
3282
|
+
authorization: string;
|
3283
|
+
};
|
3284
|
+
response: {
|
3285
|
+
200: void;
|
3286
|
+
};
|
3287
|
+
};
|
3288
|
+
};
|
3289
|
+
};
|
3290
|
+
};
|
3269
3291
|
} & {
|
3270
3292
|
engine: {
|
3271
3293
|
overlaps: {
|
@@ -12,22 +12,30 @@ const CALLS_LENGTH = 2;
|
|
12
12
|
* it's only an estimate
|
13
13
|
*/
|
14
14
|
async function computeUniV4PoolTVLFromMostRecentStateSave(chainId, poolID, priceCurrency0, priceCurrency1, decimalsCurrency0, decimalsCurrency1) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
let stateSave;
|
16
|
+
let blockNumber;
|
17
|
+
let states = {};
|
18
|
+
try {
|
19
|
+
const currentBlock = await ChainInteractionService(chainId).getBlockNumber();
|
20
|
+
const mostRecentStateSave = await engineDbClient.stateSave.findFirst({
|
21
|
+
where: {
|
22
|
+
id: `UniswapV4_${chainId}_${poolID}`,
|
23
|
+
blockNumber: {
|
24
|
+
lte: currentBlock,
|
25
|
+
},
|
21
26
|
},
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
orderBy: {
|
28
|
+
blockNumber: "desc",
|
29
|
+
},
|
30
|
+
});
|
31
|
+
stateSave = mostRecentStateSave.state;
|
32
|
+
blockNumber = mostRecentStateSave?.blockNumber;
|
33
|
+
states = stateSave.states;
|
34
|
+
// const globalState = stateSave.globalState as { tick: number; liquidity: string };
|
35
|
+
}
|
36
|
+
catch (e) {
|
37
|
+
log.warn(`merklDynamic data - failed to read a recent state of pool ${poolID} on ${NETWORK_LABELS[chainId]}`);
|
38
|
+
}
|
31
39
|
const { fileName, bucketName } = states;
|
32
40
|
// Bucket service
|
33
41
|
let tvl = 0;
|
@@ -3136,6 +3136,28 @@ export declare const v4: Elysia<"/v4", false, {
|
|
3136
3136
|
};
|
3137
3137
|
};
|
3138
3138
|
};
|
3139
|
+
} & {
|
3140
|
+
engine: {
|
3141
|
+
computedUntil: {
|
3142
|
+
":campaignId": {
|
3143
|
+
put: {
|
3144
|
+
body: {
|
3145
|
+
computedUntil: number;
|
3146
|
+
};
|
3147
|
+
params: {
|
3148
|
+
campaignId: string;
|
3149
|
+
};
|
3150
|
+
query: unknown;
|
3151
|
+
headers: {
|
3152
|
+
authorization: string;
|
3153
|
+
};
|
3154
|
+
response: {
|
3155
|
+
200: void;
|
3156
|
+
};
|
3157
|
+
};
|
3158
|
+
};
|
3159
|
+
};
|
3160
|
+
};
|
3139
3161
|
} & {
|
3140
3162
|
engine: {
|
3141
3163
|
overlaps: {
|
@@ -44,6 +44,28 @@ export declare const StatusController: Elysia<"/campaign-status", false, {
|
|
44
44
|
};
|
45
45
|
};
|
46
46
|
};
|
47
|
+
} & {
|
48
|
+
engine: {
|
49
|
+
computedUntil: {
|
50
|
+
":campaignId": {
|
51
|
+
put: {
|
52
|
+
body: {
|
53
|
+
computedUntil: number;
|
54
|
+
};
|
55
|
+
params: {
|
56
|
+
campaignId: string;
|
57
|
+
};
|
58
|
+
query: unknown;
|
59
|
+
headers: {
|
60
|
+
authorization: string;
|
61
|
+
};
|
62
|
+
response: {
|
63
|
+
200: void;
|
64
|
+
};
|
65
|
+
};
|
66
|
+
};
|
67
|
+
};
|
68
|
+
};
|
47
69
|
} & {
|
48
70
|
engine: {
|
49
71
|
overlaps: {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
|
2
2
|
import { throwOnUnsupportedChainId } from "../../../utils/throw";
|
3
3
|
import Elysia from "elysia";
|
4
|
-
import { CampaignUniqueDto, DelayDto, QueryCampaignStatusDto, UpdateCampaignStatusDto } from "./status.model";
|
4
|
+
import { CampaignUniqueDto, ComputedUntilDto, DelayDto, QueryCampaignStatusDto, UpdateCampaignStatusDto, } from "./status.model";
|
5
5
|
import { StatusService } from "./status.service";
|
6
6
|
export const StatusController = new Elysia({ prefix: "/campaign-status", detail: { tags: ["Status"], hide: true } })
|
7
7
|
// ─── Update a Campaign Status ──────────────────────────────────────
|
@@ -12,6 +12,15 @@ export const StatusController = new Elysia({ prefix: "/campaign-status", detail:
|
|
12
12
|
beforeHandle: EngineGuard,
|
13
13
|
headers: AuthorizationHeadersDto,
|
14
14
|
body: UpdateCampaignStatusDto,
|
15
|
+
})
|
16
|
+
// ─── Updates only the computed until field ───────────────────────────
|
17
|
+
.put("/engine/computedUntil/:campaignId", async ({ params, body }) => {
|
18
|
+
const [distributionChain, campaignId] = params.campaignId.split("-");
|
19
|
+
return await StatusService.updateComputedUntil({ distributionChain: +distributionChain, campaignId }, body.computedUntil);
|
20
|
+
}, {
|
21
|
+
beforeHandle: EngineGuard,
|
22
|
+
headers: AuthorizationHeadersDto,
|
23
|
+
body: ComputedUntilDto,
|
15
24
|
})
|
16
25
|
// ─── Is Safe For Overlaps ───────────────────────────────────────────
|
17
26
|
.get("/engine/overlaps", async ({ query }) => await StatusService.isSafeForOverlaps(query), {
|
@@ -35,6 +35,9 @@ export declare const UpdateCampaignStatusDto: import("@sinclair/typebox").TUnion
|
|
35
35
|
error: import("@sinclair/typebox").TString;
|
36
36
|
details: import("@sinclair/typebox").TString;
|
37
37
|
}>]>;
|
38
|
+
export declare const ComputedUntilDto: import("@sinclair/typebox").TObject<{
|
39
|
+
computedUntil: import("@sinclair/typebox").TNumber;
|
40
|
+
}>;
|
38
41
|
export declare const QueryCampaignStatusDto: import("@sinclair/typebox").TObject<{
|
39
42
|
computeChainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
40
43
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TEnum<{
|
@@ -26,6 +26,7 @@ export const UpdateCampaignStatusDto = t.Union([
|
|
26
26
|
t.Object({ value: t.Literal(RunStatus.SKIPPED), error: t.String(), details: t.String() }),
|
27
27
|
t.Object({ value: t.Literal(RunStatus.FAILED), error: t.String(), details: t.String() }),
|
28
28
|
]);
|
29
|
+
export const ComputedUntilDto = t.Object({ computedUntil: t.Numeric() });
|
29
30
|
export const QueryCampaignStatusDto = t.Object({
|
30
31
|
computeChainId: t.Optional(t.Numeric()),
|
31
32
|
status: t.Optional(t.Union([t.Array(t.Enum(RunStatus)), t.Enum(RunStatus)])),
|
@@ -74,6 +74,14 @@ export declare class StatusRepository {
|
|
74
74
|
computedUntil: bigint;
|
75
75
|
processingStarted: bigint;
|
76
76
|
}]>;
|
77
|
+
static updateComputedUntil(campaignUnique: CampaignUnique, computedUntil: number): Promise<{
|
78
|
+
error: string;
|
79
|
+
details: Prisma.JsonValue;
|
80
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
81
|
+
campaignId: string;
|
82
|
+
computedUntil: bigint;
|
83
|
+
processingStarted: bigint;
|
84
|
+
}>;
|
77
85
|
static findManyDelay(query: DelayModel): Promise<{
|
78
86
|
startTimestamp: bigint;
|
79
87
|
endTimestamp: bigint;
|
@@ -104,6 +104,16 @@ export class StatusRepository {
|
|
104
104
|
}),
|
105
105
|
]);
|
106
106
|
}
|
107
|
+
static async updateComputedUntil(campaignUnique, computedUntil) {
|
108
|
+
return await apiDbClient.campaignStatus.update({
|
109
|
+
where: {
|
110
|
+
campaignId: CampaignService.hashId(campaignUnique),
|
111
|
+
},
|
112
|
+
data: {
|
113
|
+
computedUntil,
|
114
|
+
},
|
115
|
+
});
|
116
|
+
}
|
107
117
|
static async findManyDelay(query) {
|
108
118
|
return await apiDbClient.campaign.findMany({
|
109
119
|
where: {
|
@@ -34,6 +34,7 @@ export declare class StatusService {
|
|
34
34
|
processingStarted: bigint;
|
35
35
|
} | null>;
|
36
36
|
static update(campaignUnique: CampaignUnique, status: UpdateStatusModel): Promise<void>;
|
37
|
+
static updateComputedUntil(campaignUnique: CampaignUnique, computedUntil: number): Promise<void>;
|
37
38
|
static isSafeForOverlaps(campaignUnique: CampaignUnique): Promise<boolean>;
|
38
39
|
static findUpdatesAndDelays(): Promise<Record<number, {
|
39
40
|
live: string;
|
@@ -45,6 +45,19 @@ export class StatusService {
|
|
45
45
|
return;
|
46
46
|
}
|
47
47
|
}
|
48
|
+
static async updateComputedUntil(campaignUnique, computedUntil) {
|
49
|
+
// Check if the status exists already, otherwise create it
|
50
|
+
const campaignStatus = await StatusRepository.findUnique(campaignUnique);
|
51
|
+
if (!campaignStatus) {
|
52
|
+
let campaign = await CampaignService.findUnique(campaignUnique);
|
53
|
+
if (!campaign) {
|
54
|
+
await CampaignService.fill([campaignUnique]);
|
55
|
+
campaign = await CampaignService.findUniqueOrThrow(campaignUnique);
|
56
|
+
}
|
57
|
+
await StatusRepository.create(campaignUnique, campaign.startTimestamp);
|
58
|
+
}
|
59
|
+
await StatusRepository.updateComputedUntil(campaignUnique, computedUntil);
|
60
|
+
}
|
48
61
|
static async isSafeForOverlaps(campaignUnique) {
|
49
62
|
const status = await StatusRepository.findUnique(campaignUnique);
|
50
63
|
if (!status) {
|
@@ -44,6 +44,13 @@ export function generateIcons(type, typeInfo, campaign, symbols = [""]) {
|
|
44
44
|
case tokenType.toros:
|
45
45
|
case tokenType.enzyme:
|
46
46
|
return [typeInfo.symbolUnderlyingToken];
|
47
|
+
case tokenType.pendleYT: {
|
48
|
+
let symbol = campaign.campaignParameters.symbolTargetToken;
|
49
|
+
symbol = symbol.split("-").slice(0, 2).join("-");
|
50
|
+
return [symbol];
|
51
|
+
}
|
52
|
+
case tokenType.pendle:
|
53
|
+
return [typeInfo.symbolUnderlyingToken];
|
47
54
|
default:
|
48
55
|
return [campaign.campaignParameters.symbolTargetToken];
|
49
56
|
}
|