@merkl/api 0.20.62 → 0.20.64
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/database/index.js +1 -1
- package/dist/src/eden/index.d.ts +0 -154
- package/dist/src/engine/dynamicData/factory.js +3 -2
- package/dist/src/engine/dynamicData/implementations/CompoundV3.d.ts +7 -0
- package/dist/src/engine/dynamicData/implementations/CompoundV3.js +69 -0
- package/dist/src/engine/opportunityMetadata/factory.js +3 -2
- package/dist/src/engine/opportunityMetadata/implementations/CompoundV3.d.ts +17 -0
- package/dist/src/engine/opportunityMetadata/implementations/CompoundV3.js +19 -0
- package/dist/src/index.d.ts +0 -38
- package/dist/src/jobs/update-analytics.d.ts +1 -0
- package/dist/src/jobs/update-analytics.js +21 -0
- package/dist/src/jobs/update-dynamic-data.js +10 -12
- package/dist/src/jobs/update-rpc-calls-cache.js +2 -1
- package/dist/src/modules/v4/campaign/campaign.controller.js +5 -3
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +0 -38
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +2 -9
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -11
- package/dist/src/modules/v4/opportunity/opportunity.model.js +0 -5
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +2 -2
- package/dist/src/modules/v4/programPayload/programPayload.model.d.ts +12 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +12 -1
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +24 -13
- package/dist/src/modules/v4/reward/reward.controller.js +5 -3
- package/dist/src/modules/v4/router.d.ts +0 -38
- package/dist/src/modules/v4/token/token.service.js +1 -2
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +2 -1
package/dist/database/index.js
CHANGED
@@ -2,7 +2,7 @@ import { PrismaClient as ApiPrismaClient } from "@db/api";
|
|
2
2
|
import { PrismaClient as EnginePrismaClient } from "@db/engine";
|
3
3
|
import { drizzle } from "drizzle-orm/prisma/pg";
|
4
4
|
export const apiDbClient = new ApiPrismaClient({
|
5
|
-
datasources: { db: { url: `${process.env.DATABASE_API_URL}&connection_limit=
|
5
|
+
datasources: { db: { url: `${process.env.DATABASE_API_URL}&connection_limit=100&pool_timeout=60` } },
|
6
6
|
}).$extends(drizzle());
|
7
7
|
export const engineDbClient = new EnginePrismaClient({
|
8
8
|
datasources: {
|
package/dist/src/eden/index.d.ts
CHANGED
@@ -456,35 +456,6 @@ declare const eden: {
|
|
456
456
|
};
|
457
457
|
}>>;
|
458
458
|
};
|
459
|
-
patch: (body: {
|
460
|
-
name?: string | undefined;
|
461
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
462
|
-
tags?: string[] | undefined;
|
463
|
-
}, options: {
|
464
|
-
headers: {
|
465
|
-
authorization: string;
|
466
|
-
};
|
467
|
-
query?: Record<string, unknown> | undefined;
|
468
|
-
fetch?: RequestInit | undefined;
|
469
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
470
|
-
200: {
|
471
|
-
id: string;
|
472
|
-
name: string;
|
473
|
-
type: string;
|
474
|
-
status: import("@db/api").$Enums.Status;
|
475
|
-
tags: string[];
|
476
|
-
identifier: string;
|
477
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
478
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
479
|
-
chainId: number;
|
480
|
-
depositUrl: string | null;
|
481
|
-
explorerAddress: string | null;
|
482
|
-
mainProtocolId: string | null;
|
483
|
-
tvl: number;
|
484
|
-
apr: number;
|
485
|
-
dailyRewards: number;
|
486
|
-
};
|
487
|
-
}>>;
|
488
459
|
}) & {
|
489
460
|
index: {
|
490
461
|
post: (body: {
|
@@ -4489,35 +4460,6 @@ declare const eden: {
|
|
4489
4460
|
};
|
4490
4461
|
}>>;
|
4491
4462
|
};
|
4492
|
-
patch: (body: {
|
4493
|
-
name?: string | undefined;
|
4494
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
4495
|
-
tags?: string[] | undefined;
|
4496
|
-
}, options: {
|
4497
|
-
headers: {
|
4498
|
-
authorization: string;
|
4499
|
-
};
|
4500
|
-
query?: Record<string, unknown> | undefined;
|
4501
|
-
fetch?: RequestInit | undefined;
|
4502
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
4503
|
-
200: {
|
4504
|
-
id: string;
|
4505
|
-
name: string;
|
4506
|
-
type: string;
|
4507
|
-
status: import("@db/api").$Enums.Status;
|
4508
|
-
tags: string[];
|
4509
|
-
identifier: string;
|
4510
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
4511
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
4512
|
-
chainId: number;
|
4513
|
-
depositUrl: string | null;
|
4514
|
-
explorerAddress: string | null;
|
4515
|
-
mainProtocolId: string | null;
|
4516
|
-
tvl: number;
|
4517
|
-
apr: number;
|
4518
|
-
dailyRewards: number;
|
4519
|
-
};
|
4520
|
-
}>>;
|
4521
4463
|
}) & {
|
4522
4464
|
index: {
|
4523
4465
|
post: (body: {
|
@@ -9939,44 +9881,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
9939
9881
|
};
|
9940
9882
|
};
|
9941
9883
|
};
|
9942
|
-
} & {
|
9943
|
-
opportunities: {
|
9944
|
-
":id": {
|
9945
|
-
patch: {
|
9946
|
-
body: {
|
9947
|
-
name?: string | undefined;
|
9948
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
9949
|
-
tags?: string[] | undefined;
|
9950
|
-
};
|
9951
|
-
params: {
|
9952
|
-
id: string;
|
9953
|
-
};
|
9954
|
-
query: unknown;
|
9955
|
-
headers: {
|
9956
|
-
authorization: string;
|
9957
|
-
};
|
9958
|
-
response: {
|
9959
|
-
200: {
|
9960
|
-
id: string;
|
9961
|
-
name: string;
|
9962
|
-
type: string;
|
9963
|
-
status: import("@db/api").$Enums.Status;
|
9964
|
-
tags: string[];
|
9965
|
-
identifier: string;
|
9966
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
9967
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
9968
|
-
chainId: number;
|
9969
|
-
depositUrl: string | null;
|
9970
|
-
explorerAddress: string | null;
|
9971
|
-
mainProtocolId: string | null;
|
9972
|
-
tvl: number;
|
9973
|
-
apr: number;
|
9974
|
-
dailyRewards: number;
|
9975
|
-
};
|
9976
|
-
};
|
9977
|
-
};
|
9978
|
-
};
|
9979
|
-
};
|
9980
9884
|
};
|
9981
9885
|
} & {
|
9982
9886
|
v4: {
|
@@ -15216,35 +15120,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
15216
15120
|
};
|
15217
15121
|
}>>;
|
15218
15122
|
};
|
15219
|
-
patch: (body: {
|
15220
|
-
name?: string | undefined;
|
15221
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
15222
|
-
tags?: string[] | undefined;
|
15223
|
-
}, options: {
|
15224
|
-
headers: {
|
15225
|
-
authorization: string;
|
15226
|
-
};
|
15227
|
-
query?: Record<string, unknown> | undefined;
|
15228
|
-
fetch?: RequestInit | undefined;
|
15229
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
15230
|
-
200: {
|
15231
|
-
id: string;
|
15232
|
-
name: string;
|
15233
|
-
type: string;
|
15234
|
-
status: import("@db/api").$Enums.Status;
|
15235
|
-
tags: string[];
|
15236
|
-
identifier: string;
|
15237
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
15238
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
15239
|
-
chainId: number;
|
15240
|
-
depositUrl: string | null;
|
15241
|
-
explorerAddress: string | null;
|
15242
|
-
mainProtocolId: string | null;
|
15243
|
-
tvl: number;
|
15244
|
-
apr: number;
|
15245
|
-
dailyRewards: number;
|
15246
|
-
};
|
15247
|
-
}>>;
|
15248
15123
|
}) & {
|
15249
15124
|
index: {
|
15250
15125
|
post: (body: {
|
@@ -19249,35 +19124,6 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
19249
19124
|
};
|
19250
19125
|
}>>;
|
19251
19126
|
};
|
19252
|
-
patch: (body: {
|
19253
|
-
name?: string | undefined;
|
19254
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
19255
|
-
tags?: string[] | undefined;
|
19256
|
-
}, options: {
|
19257
|
-
headers: {
|
19258
|
-
authorization: string;
|
19259
|
-
};
|
19260
|
-
query?: Record<string, unknown> | undefined;
|
19261
|
-
fetch?: RequestInit | undefined;
|
19262
|
-
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
19263
|
-
200: {
|
19264
|
-
id: string;
|
19265
|
-
name: string;
|
19266
|
-
type: string;
|
19267
|
-
status: import("@db/api").$Enums.Status;
|
19268
|
-
tags: string[];
|
19269
|
-
identifier: string;
|
19270
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
19271
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
19272
|
-
chainId: number;
|
19273
|
-
depositUrl: string | null;
|
19274
|
-
explorerAddress: string | null;
|
19275
|
-
mainProtocolId: string | null;
|
19276
|
-
tvl: number;
|
19277
|
-
apr: number;
|
19278
|
-
dailyRewards: number;
|
19279
|
-
};
|
19280
|
-
}>>;
|
19281
19127
|
}) & {
|
19282
19128
|
index: {
|
19283
19129
|
post: (body: {
|
@@ -4,6 +4,7 @@ import { AmbiantDynamicData } from "./implementations/Ambiant";
|
|
4
4
|
import { BadgerDynamicData } from "./implementations/Badger";
|
5
5
|
import { ClammDynamicData } from "./implementations/Clamm";
|
6
6
|
import { CompoundDynamicData } from "./implementations/Compound";
|
7
|
+
import { CompoundV3DynamicData } from "./implementations/CompoundV3";
|
7
8
|
import { DolomiteDynamicData } from "./implementations/Dolomite";
|
8
9
|
import { EigenLayerDynamicData } from "./implementations/EigenLayer";
|
9
10
|
import { EncompassingDynamicData } from "./implementations/Encompassing";
|
@@ -27,6 +28,8 @@ const map = {
|
|
27
28
|
[Campaign.BADGER]: new BadgerDynamicData(),
|
28
29
|
[Campaign.CLAMM]: new ClammDynamicData(),
|
29
30
|
[Campaign.COMPOUND]: new CompoundDynamicData(),
|
31
|
+
[Campaign.COMPOUND_V3]: new CompoundV3DynamicData(),
|
32
|
+
[Campaign.COMPOUND_V3_FIXAPR]: new CompoundV3DynamicData(),
|
30
33
|
[Campaign.DOLOMITE]: new DolomiteDynamicData(),
|
31
34
|
[Campaign.EIGENLAYER]: new EigenLayerDynamicData(),
|
32
35
|
[Campaign.ENCOMPASSING]: new EncompassingDynamicData(),
|
@@ -53,8 +56,6 @@ const map = {
|
|
53
56
|
[Campaign.MAVERICK_BP]: new DefaultDynamicData(), // TODO
|
54
57
|
[Campaign.ERC6909]: new DefaultDynamicData(), // TODO
|
55
58
|
[Campaign.ERC6909FIXAPR]: new DefaultDynamicData(), // TODO
|
56
|
-
[Campaign.COMPOUND_V3]: new DefaultDynamicData(), // TODO,
|
57
|
-
[Campaign.COMPOUND_V3_FIXAPR]: new DefaultDynamicData(), // TODO
|
58
59
|
[Campaign.ERC1155]: new DefaultDynamicData(), // TODO
|
59
60
|
[Campaign.ERC1155FIXAPR]: new DefaultDynamicData(), // TODO
|
60
61
|
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
|
2
|
+
import type { DynamicDataBuilder } from "../interface";
|
3
|
+
type campaignType = Campaign.COMPOUND_V3;
|
4
|
+
export declare class CompoundV3DynamicData implements DynamicDataBuilder<campaignType> {
|
5
|
+
build(chainId: MerklChainId, campaigns: CampaignParameters<campaignType>[]): Promise<CompoundV3CampaignDynamicData[]>;
|
6
|
+
}
|
7
|
+
export {};
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { TokenService } from "@/modules/v4/token/token.service";
|
2
|
+
import { BN2Number, ChainInteractionService, CompoundV3Interface, CompoundV3SubCampaignType, NULL_ADDRESS, YEAR, } from "@sdk";
|
3
|
+
import { log } from "../../../utils/logger";
|
4
|
+
import { Pricer } from "../../../utils/pricer";
|
5
|
+
export class CompoundV3DynamicData {
|
6
|
+
async build(chainId, campaigns) {
|
7
|
+
const pricer = await Pricer.load();
|
8
|
+
const calls = [];
|
9
|
+
for (const campaign of campaigns) {
|
10
|
+
if (campaign.campaignSubType === CompoundV3SubCampaignType.SUPPLY) {
|
11
|
+
calls.push({
|
12
|
+
allowFailure: true,
|
13
|
+
callData: CompoundV3Interface.encodeFunctionData("totalSupply"),
|
14
|
+
target: campaign.campaignParameters.targetToken,
|
15
|
+
});
|
16
|
+
calls.push({
|
17
|
+
allowFailure: true,
|
18
|
+
callData: CompoundV3Interface.encodeFunctionData("baseToken"),
|
19
|
+
target: campaign.campaignParameters.targetToken,
|
20
|
+
});
|
21
|
+
}
|
22
|
+
}
|
23
|
+
const result = await ChainInteractionService(chainId).fetchState(calls);
|
24
|
+
let i = 0;
|
25
|
+
const dynamicData = [];
|
26
|
+
for (const campaign of campaigns) {
|
27
|
+
let totalSupply;
|
28
|
+
let underlyingToken;
|
29
|
+
if (campaign.campaignSubType === CompoundV3SubCampaignType.SUPPLY) {
|
30
|
+
try {
|
31
|
+
totalSupply = BN2Number(CompoundV3Interface.decodeFunctionResult("totalSupply", result[i++].returnData)[0], campaign.campaignParameters.decimalsTargetToken);
|
32
|
+
underlyingToken = CompoundV3Interface.decodeFunctionResult("baseToken", result[i++].returnData)[0];
|
33
|
+
}
|
34
|
+
catch {
|
35
|
+
log.warn(`Error getting totalSupply for campaign ${campaign.campaignId} and token ${campaign.campaignParameters.targetToken}`);
|
36
|
+
totalSupply = 0.0000001;
|
37
|
+
underlyingToken = NULL_ADDRESS;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
totalSupply = 0.0000001;
|
42
|
+
underlyingToken = NULL_ADDRESS;
|
43
|
+
}
|
44
|
+
const priceRewardToken = await TokenService.getRewardTokenPrice(campaign);
|
45
|
+
const priceTargetToken = (await pricer.get({
|
46
|
+
address: underlyingToken,
|
47
|
+
chainId: campaign.computeChainId,
|
48
|
+
// Remove the `c` at the beginning of the symbol and the `v3` at the end
|
49
|
+
symbol: campaign.campaignParameters.symbolTargetToken.slice(1, -2),
|
50
|
+
})) ?? 0;
|
51
|
+
let apr = (priceRewardToken * BN2Number(campaign.amount, campaign.campaignParameters.decimalsRewardToken) * YEAR * 100) /
|
52
|
+
campaign.campaignParameters.duration /
|
53
|
+
(totalSupply * priceTargetToken);
|
54
|
+
const rewardTokens = await TokenService.findManyOrCreate([
|
55
|
+
{ chainId: campaign.chainId, address: campaign.rewardToken },
|
56
|
+
]);
|
57
|
+
const rewardToken = rewardTokens[0];
|
58
|
+
apr = rewardToken.isPoint ? apr / 365 / 100 : apr;
|
59
|
+
dynamicData.push({
|
60
|
+
...campaign,
|
61
|
+
apr,
|
62
|
+
totalSupplyTargetToken: totalSupply,
|
63
|
+
tvl: totalSupply * priceTargetToken,
|
64
|
+
priceRewardToken: priceRewardToken,
|
65
|
+
});
|
66
|
+
}
|
67
|
+
return dynamicData;
|
68
|
+
}
|
69
|
+
}
|
@@ -4,6 +4,7 @@ import { AmbientMetadata } from "./implementations/Ambient";
|
|
4
4
|
import { BadgerMetadata } from "./implementations/Badger";
|
5
5
|
import { ClammMetadata } from "./implementations/Clamm";
|
6
6
|
import { CompoundMetadata } from "./implementations/Compound";
|
7
|
+
import { CompoundV3Metadata } from "./implementations/CompoundV3";
|
7
8
|
import { DefaultMetadata } from "./implementations/Default";
|
8
9
|
import { DolomiteMetadata } from "./implementations/Dolomite";
|
9
10
|
import { EigenLayerMetadata } from "./implementations/EigenLayer";
|
@@ -35,6 +36,8 @@ const map = {
|
|
35
36
|
[Campaign.AJNA]: new AjnaMetadata(),
|
36
37
|
[Campaign.EULER]: new EulerMetadata(),
|
37
38
|
[Campaign.COMPOUND]: new CompoundMetadata(),
|
39
|
+
[Campaign.COMPOUND_V3]: new CompoundV3Metadata(),
|
40
|
+
[Campaign.COMPOUND_V3_FIXAPR]: new CompoundV3Metadata(),
|
38
41
|
[Campaign.ION]: new IonMetadata(),
|
39
42
|
[Campaign.MORPHO]: new MorphoMetadata(),
|
40
43
|
[Campaign.HYPERDRIVELOGFIXPROCESSOR]: new HyperdriveMetadata(),
|
@@ -56,8 +59,6 @@ const map = {
|
|
56
59
|
[Campaign.MAVERICK_BP]: new DefaultMetadata(), // TODO
|
57
60
|
[Campaign.ERC6909]: new DefaultMetadata(), // TODO
|
58
61
|
[Campaign.ERC6909FIXAPR]: new DefaultMetadata(), // TODO
|
59
|
-
[Campaign.COMPOUND_V3]: new DefaultMetadata(), // TODO,
|
60
|
-
[Campaign.COMPOUND_V3_FIXAPR]: new DefaultMetadata(), // TODO
|
61
62
|
[Campaign.ERC1155]: new DefaultMetadata(), // TODO
|
62
63
|
[Campaign.ERC1155FIXAPR]: new DefaultMetadata(), // TODO
|
63
64
|
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
|
2
|
+
import type { ProtocolId } from "../../../modules/v4/protocol/protocol.model";
|
3
|
+
import type { MetadataBuilder } from "../interface";
|
4
|
+
type campaignType = CampaignEnum.COMPOUND_V3;
|
5
|
+
export declare class CompoundV3Metadata implements MetadataBuilder<campaignType> {
|
6
|
+
build(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], subType: CampaignParameters<campaignType>["campaignSubType"]): Promise<{
|
7
|
+
action: "LEND" | "BORROW";
|
8
|
+
name: string;
|
9
|
+
tokens: {
|
10
|
+
chainId: ChainId;
|
11
|
+
address: any;
|
12
|
+
}[];
|
13
|
+
mainProtocol: ProtocolId;
|
14
|
+
depositUrl: undefined;
|
15
|
+
}>;
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { OpportunityAction } from "@db/api";
|
2
|
+
import { CompoundV3SubCampaignType } from "@sdk";
|
3
|
+
export class CompoundV3Metadata {
|
4
|
+
async build(computeChainId, params, subType) {
|
5
|
+
const symbolUnderlyingToken = params.symbolTargetToken.slice(1, -2);
|
6
|
+
return {
|
7
|
+
action: subType === CompoundV3SubCampaignType.SUPPLY ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
8
|
+
name: [
|
9
|
+
subType === CompoundV3SubCampaignType.SUPPLY
|
10
|
+
? `Supply ${symbolUnderlyingToken} on`
|
11
|
+
: `Borrow ${symbolUnderlyingToken} on`,
|
12
|
+
"Compound V3",
|
13
|
+
].join(" "),
|
14
|
+
tokens: [{ chainId: computeChainId, address: params.targetToken }],
|
15
|
+
mainProtocol: "compound",
|
16
|
+
depositUrl: undefined, // TODO, shall depend on compFork
|
17
|
+
};
|
18
|
+
}
|
19
|
+
}
|
package/dist/src/index.d.ts
CHANGED
@@ -1158,44 +1158,6 @@ declare const app: Elysia<"", false, {
|
|
1158
1158
|
};
|
1159
1159
|
};
|
1160
1160
|
};
|
1161
|
-
} & {
|
1162
|
-
opportunities: {
|
1163
|
-
":id": {
|
1164
|
-
patch: {
|
1165
|
-
body: {
|
1166
|
-
name?: string | undefined;
|
1167
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
1168
|
-
tags?: string[] | undefined;
|
1169
|
-
};
|
1170
|
-
params: {
|
1171
|
-
id: string;
|
1172
|
-
};
|
1173
|
-
query: unknown;
|
1174
|
-
headers: {
|
1175
|
-
authorization: string;
|
1176
|
-
};
|
1177
|
-
response: {
|
1178
|
-
200: {
|
1179
|
-
id: string;
|
1180
|
-
name: string;
|
1181
|
-
type: string;
|
1182
|
-
status: import("@db/api").$Enums.Status;
|
1183
|
-
tags: string[];
|
1184
|
-
identifier: string;
|
1185
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
1186
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
1187
|
-
chainId: number;
|
1188
|
-
depositUrl: string | null;
|
1189
|
-
explorerAddress: string | null;
|
1190
|
-
mainProtocolId: string | null;
|
1191
|
-
tvl: number;
|
1192
|
-
apr: number;
|
1193
|
-
dailyRewards: number;
|
1194
|
-
};
|
1195
|
-
};
|
1196
|
-
};
|
1197
|
-
};
|
1198
|
-
};
|
1199
1161
|
};
|
1200
1162
|
} & {
|
1201
1163
|
v4: {
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { CacheService } from "@/modules/v4/cache";
|
2
|
+
import { TTLPresets } from "@/modules/v4/cache/cache.model";
|
3
|
+
import { RewardService } from "@/modules/v4/reward";
|
4
|
+
import { log } from "@/utils/logger";
|
5
|
+
const main = async () => {
|
6
|
+
const today = new Date();
|
7
|
+
const firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1).getTime() / 1000;
|
8
|
+
const promises = [
|
9
|
+
CacheService.set(TTLPresets.DAY_1, RewardService.getTotalDistributed, firstDayOfMonth).then(() => log.info("Total Distributed cache updated successfully")),
|
10
|
+
CacheService.set(TTLPresets.DAY_1, RewardService.getTotalDistributedByChains, firstDayOfMonth).then(() => log.info("Total Distributed by Chains cache updated successfully")),
|
11
|
+
CacheService.set(TTLPresets.DAY_1, RewardService.getTotalDistributedByType, firstDayOfMonth).then(() => log.info("Total Distributed by Type cache updated successfully")),
|
12
|
+
CacheService.set(TTLPresets.DAY_1, RewardService.getTotalDistributedByOpportunities, firstDayOfMonth).then(() => log.info("Total Distributed by Opportunities cache updated successfully")),
|
13
|
+
];
|
14
|
+
await Promise.all(promises);
|
15
|
+
};
|
16
|
+
main()
|
17
|
+
.then(() => process.exit(0))
|
18
|
+
.catch(err => {
|
19
|
+
console.error(err);
|
20
|
+
process.exit(1);
|
21
|
+
});
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { CampaignService } from "@/modules/v4/campaign";
|
2
|
-
import { ChainService } from "@/modules/v4/chain/chain.service";
|
3
2
|
import { DynamicDataService } from "@/modules/v4/dynamicData/dynamicData.service";
|
4
3
|
import { OpportunityService } from "@/modules/v4/opportunity";
|
5
4
|
import { Campaign as CampaignEnum } from "@sdk";
|
6
5
|
import moment from "moment";
|
7
6
|
// ─── Required Env Variables ──────────────────────────────────────────────────
|
8
|
-
|
9
|
-
|
7
|
+
const chainId = Number(process.env.CHAIN_ID);
|
8
|
+
if (!chainId)
|
9
|
+
throw new Error("Environment variable CHAIN_ID is required.");
|
10
10
|
// ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
|
11
|
-
const main = async (
|
11
|
+
const main = async () => {
|
12
12
|
const liveCampaigns = (await CampaignService.getLiveCampaigns({ computeChainId: chainId })).map(c => {
|
13
13
|
return {
|
14
14
|
amount: c.amount,
|
@@ -58,13 +58,11 @@ const main = async (chainId) => {
|
|
58
58
|
// 4. Update the status of the opportunities associated to live campaigns
|
59
59
|
await OpportunityService.updateMany(liveOpportunityIds, { status: "LIVE" });
|
60
60
|
};
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
.then(success => (success ? process.exit(0) : process.exit(1)))
|
67
|
-
.catch((err) => {
|
61
|
+
try {
|
62
|
+
await main();
|
63
|
+
process.exit(0);
|
64
|
+
}
|
65
|
+
catch (err) {
|
68
66
|
console.error(err);
|
69
67
|
process.exit(1);
|
70
|
-
}
|
68
|
+
}
|
@@ -3,7 +3,8 @@ import { TTLPresets } from "@/modules/v4/cache/cache.model";
|
|
3
3
|
import { ChainService } from "@/modules/v4/chain/chain.service";
|
4
4
|
import { MerklRootRepository } from "@/modules/v4/merklRoot/merklRoot.repository";
|
5
5
|
import { OpportunityService } from "@/modules/v4/opportunity";
|
6
|
-
import {
|
6
|
+
import { log } from "@/utils/logger";
|
7
|
+
import { NETWORK_LABELS } from "@sdk";
|
7
8
|
const main = async () => {
|
8
9
|
try {
|
9
10
|
const chains = await ChainService.getSupportedIds();
|
@@ -5,6 +5,8 @@ import { ChainUniqueDto } from "@/modules/v4/chain/chain.model";
|
|
5
5
|
import { Campaign } from "@sdk";
|
6
6
|
import Elysia, { t } from "elysia";
|
7
7
|
import { throwOnUnsupportedChainId } from "src/utils/throw";
|
8
|
+
import { CacheService } from "../cache";
|
9
|
+
import { TTLPresets } from "../cache/cache.model";
|
8
10
|
import { DynamicDataService } from "../dynamicData/dynamicData.service";
|
9
11
|
import { OpportunityConvertorService } from "../opportunity/opportunity.converter";
|
10
12
|
import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, RemoveManualOverrideDto, UpdateCampaignCreatorDto, UpdateCampaignDto, UpdateMetaDataCampaignDto, } from "./campaign.model";
|
@@ -149,6 +151,6 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
|
|
149
151
|
beforeHandle: BackOfficeGuard,
|
150
152
|
detail: { hide: true },
|
151
153
|
})
|
152
|
-
.get("count/by-chains", async ({ query }) => await CampaignService.countByChains
|
153
|
-
.get("/count/by-types", async ({ query }) => await CampaignService.countByType
|
154
|
-
.get("/count/by-protocols", async ({ query }) => await CampaignService.countByProtocol
|
154
|
+
.get("count/by-chains", async ({ query }) => await CacheService.wrap(TTLPresets.DAY_1, CampaignService.countByChains, query))
|
155
|
+
.get("/count/by-types", async ({ query }) => await CacheService.wrap(TTLPresets.DAY_1, CampaignService.countByType, query))
|
156
|
+
.get("/count/by-protocols", async ({ query }) => await CacheService.wrap(TTLPresets.DAY_1, CampaignService.countByProtocol, query));
|
@@ -1013,44 +1013,6 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
1013
1013
|
};
|
1014
1014
|
};
|
1015
1015
|
};
|
1016
|
-
} & {
|
1017
|
-
opportunities: {
|
1018
|
-
":id": {
|
1019
|
-
patch: {
|
1020
|
-
body: {
|
1021
|
-
name?: string | undefined;
|
1022
|
-
status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
|
1023
|
-
tags?: string[] | undefined;
|
1024
|
-
};
|
1025
|
-
params: {
|
1026
|
-
id: string;
|
1027
|
-
};
|
1028
|
-
query: unknown;
|
1029
|
-
headers: {
|
1030
|
-
authorization: string;
|
1031
|
-
};
|
1032
|
-
response: {
|
1033
|
-
200: {
|
1034
|
-
id: string;
|
1035
|
-
name: string;
|
1036
|
-
type: string;
|
1037
|
-
status: import("@db/api").$Enums.Status;
|
1038
|
-
tags: string[];
|
1039
|
-
identifier: string;
|
1040
|
-
action: import("@db/api").$Enums.OpportunityAction;
|
1041
|
-
manualOverrides: import("@db/api").$Enums.OpportunityManualOverride[];
|
1042
|
-
chainId: number;
|
1043
|
-
depositUrl: string | null;
|
1044
|
-
explorerAddress: string | null;
|
1045
|
-
mainProtocolId: string | null;
|
1046
|
-
tvl: number;
|
1047
|
-
apr: number;
|
1048
|
-
dailyRewards: number;
|
1049
|
-
};
|
1050
|
-
};
|
1051
|
-
};
|
1052
|
-
};
|
1053
|
-
};
|
1054
1016
|
}, {
|
1055
1017
|
derive: {};
|
1056
1018
|
resolve: {};
|
@@ -3,7 +3,7 @@ import { BackOfficeGuard } from "@/guards/BackOffice.guard";
|
|
3
3
|
import { AuthorizationHeadersDto, TokenAuthGuard } from "@/guards/TokenAuth.guard";
|
4
4
|
import Elysia, { t } from "elysia";
|
5
5
|
import { GetCampaignQueryDto } from "../campaign";
|
6
|
-
import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto,
|
6
|
+
import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityDeleteOverrideDto, OpportunityOverrideDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, } from "./opportunity.model";
|
7
7
|
import { OpportunityService } from "./opportunity.service";
|
8
8
|
import { transformId } from "./transform-id.pipe";
|
9
9
|
import { validateId } from "./validate-id.pipe";
|
@@ -33,6 +33,7 @@ export const OpportunityController = new Elysia({
|
|
33
33
|
params: OpportunityUniqueDto,
|
34
34
|
body: OpportunityDeleteOverrideDto,
|
35
35
|
beforeHandle: BackOfficeGuard,
|
36
|
+
detail: { hide: true },
|
36
37
|
})
|
37
38
|
// ─── Tries to reparse An Opportunity ─────────────────────────────────
|
38
39
|
.post("/:id", async ({ params }) => {
|
@@ -157,12 +158,4 @@ export const OpportunityController = new Elysia({
|
|
157
158
|
.get("/aggregate/min/:field", async ({ query, params }) => await OpportunityService.aggregateMin(query, params.field), {
|
158
159
|
params: OpportunityAggregateFieldDto,
|
159
160
|
query: GetOpportunitiesQueryDto,
|
160
|
-
})
|
161
|
-
// ─── Update An Opportunity ───────────────────────────────────────────
|
162
|
-
.patch("/:id", async ({ params, body }) => await OpportunityService.update(params.id, body), {
|
163
|
-
params: OpportunityIdDto,
|
164
|
-
body: UpdateOpportunityDto,
|
165
|
-
headers: AuthorizationHeadersDto,
|
166
|
-
beforeHandle: BackOfficeGuard,
|
167
|
-
detail: { hide: true },
|
168
161
|
});
|
@@ -356,16 +356,6 @@ export declare const OpportunityAggregateFieldDto: import("@sinclair/typebox").T
|
|
356
356
|
export declare const OpportunityIdDto: import("@sinclair/typebox").TObject<{
|
357
357
|
id: import("@sinclair/typebox").TString;
|
358
358
|
}>;
|
359
|
-
export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
|
360
|
-
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
361
|
-
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
362
|
-
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
363
|
-
NONE: "NONE";
|
364
|
-
PAST: "PAST";
|
365
|
-
LIVE: "LIVE";
|
366
|
-
SOON: "SOON";
|
367
|
-
}>>;
|
368
|
-
}>;
|
369
359
|
export declare const OpportunityOverrideDto: import("@sinclair/typebox").TObject<{
|
370
360
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
371
361
|
depositUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
@@ -392,7 +382,6 @@ export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
|
|
392
382
|
export type GetOpportunityQueryModel = typeof GetOpportunityQueryDto.static;
|
393
383
|
export type CreateOpportunityModel = typeof CreateOpportunityDto.static;
|
394
384
|
export type OpportunityAggregateField = typeof OpportunityAggregateFieldDto.static;
|
395
|
-
export type UpdateOpportunityModel = typeof UpdateOpportunityDto.static;
|
396
385
|
export type OpportunityResourceModel = typeof OpportunityResourceDto.static;
|
397
386
|
export type OpportunityWithCampaignsResourceModel = typeof OpportunityWithCampaignsResourceDto.static;
|
398
387
|
export type OpportunityOverrideModel = typeof OpportunityOverrideDto.static;
|
@@ -110,11 +110,6 @@ export const OpportunityAggregateFieldDto = t.Object({
|
|
110
110
|
field: t.Union(["dailyRewards", "tvl", "apr"].map(v => t.Literal(v))),
|
111
111
|
});
|
112
112
|
export const OpportunityIdDto = t.Object({ id: t.String() });
|
113
|
-
export const UpdateOpportunityDto = t.Object({
|
114
|
-
name: t.Optional(t.String()),
|
115
|
-
tags: t.Optional(t.Array(t.String())),
|
116
|
-
status: t.Optional(t.Enum(Status)),
|
117
|
-
});
|
118
113
|
export const OpportunityOverrideDto = t.Object({
|
119
114
|
name: t.Optional(t.String()),
|
120
115
|
depositUrl: t.Optional(t.String({ format: "uri" })),
|
@@ -4,7 +4,7 @@ import { type AprRecord } from "../apr";
|
|
4
4
|
import type { Campaign } from "../campaign";
|
5
5
|
import { type DailyRewardsRecord } from "../reward";
|
6
6
|
import { type TvlRecord } from "../tvl";
|
7
|
-
import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity
|
7
|
+
import type { CreateOpportunityModel, GetOpportunitiesQueryModel, Opportunity } from "./opportunity.model";
|
8
8
|
export declare abstract class OpportunityRepository {
|
9
9
|
#private;
|
10
10
|
static create(newOpp: CreateOpportunityModel & {
|
@@ -975,7 +975,7 @@ export declare abstract class OpportunityRepository {
|
|
975
975
|
apr: number;
|
976
976
|
dailyRewards: number;
|
977
977
|
}>;
|
978
|
-
static updateMany(ids: string[], data:
|
978
|
+
static updateMany(ids: string[], data: Partial<Opportunity["raw"]>): Promise<import("database/api/.generated/runtime/library").GetBatchResult>;
|
979
979
|
static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
|
980
980
|
sum: string;
|
981
981
|
}>;
|