@merkl/api 0.10.176 → 0.10.180
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database/api/.generated/edge.js +6 -6
- package/dist/database/api/.generated/index-browser.js +4 -4
- package/dist/database/api/.generated/index.d.ts +2 -2
- package/dist/database/api/.generated/index.js +6 -6
- package/dist/database/api/.generated/libquery_engine-debian-openssl-1.1.x.so.node +0 -0
- package/dist/database/api/.generated/libquery_engine-linux-arm64-openssl-1.1.x.so.node +0 -0
- package/dist/database/api/.generated/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node +0 -0
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/runtime/edge-esm.js +15 -15
- package/dist/database/api/.generated/runtime/edge.js +16 -16
- package/dist/database/api/.generated/runtime/library.d.ts +23 -34
- package/dist/database/api/.generated/runtime/library.js +56 -56
- package/dist/database/api/.generated/runtime/react-native.js +23 -23
- package/dist/database/api/.generated/runtime/wasm.js +15 -15
- package/dist/database/api/.generated/wasm.js +4 -4
- package/dist/database/engine/.generated/edge.js +6 -6
- package/dist/database/engine/.generated/index-browser.js +4 -4
- package/dist/database/engine/.generated/index.d.ts +2 -2
- package/dist/database/engine/.generated/index.js +6 -6
- package/dist/database/engine/.generated/libquery_engine-debian-openssl-1.1.x.so.node +0 -0
- package/dist/database/engine/.generated/libquery_engine-linux-arm64-openssl-1.1.x.so.node +0 -0
- package/dist/database/engine/.generated/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node +0 -0
- package/dist/database/engine/.generated/package.json +1 -1
- package/dist/database/engine/.generated/runtime/edge-esm.js +15 -15
- package/dist/database/engine/.generated/runtime/edge.js +16 -16
- package/dist/database/engine/.generated/runtime/library.d.ts +23 -34
- package/dist/database/engine/.generated/runtime/library.js +56 -56
- package/dist/database/engine/.generated/runtime/react-native.js +23 -23
- package/dist/database/engine/.generated/runtime/wasm.js +15 -15
- package/dist/database/engine/.generated/wasm.js +4 -4
- package/dist/src/eden/index.d.ts +336 -51
- package/dist/src/index.d.ts +136 -17
- package/dist/src/index.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +2 -2
- package/dist/src/modules/v4/bucket/bucket.service.d.ts +5 -0
- package/dist/src/modules/v4/bucket/bucket.service.js +11 -0
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +11 -13
- package/dist/src/modules/v4/campaign/campaign.controller.js +3 -3
- package/dist/src/modules/v4/campaign/campaign.repository.js +1 -1
- package/dist/src/modules/v4/chain/chain.controller.d.ts +24 -0
- package/dist/src/modules/v4/chain/chain.controller.js +8 -2
- package/dist/src/modules/v4/chain/chain.model.d.ts +4 -0
- package/dist/src/modules/v4/chain/chain.model.js +4 -0
- package/dist/src/modules/v4/chain/chain.repository.d.ts +6 -1
- package/dist/src/modules/v4/chain/chain.repository.js +3 -0
- package/dist/src/modules/v4/chain/chain.service.d.ts +6 -1
- package/dist/src/modules/v4/chain/chain.service.js +7 -0
- package/dist/src/modules/v4/enso/enso.service.d.ts +1 -1
- package/dist/src/modules/v4/interaction/interaction.controller.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/AjnaPositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/BadgerPositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/ClammPositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/DolomitePositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/DolomitePositionFetcher.js +2 -2
- package/dist/src/modules/v4/{position → liquidity}/implementations/ERC20PositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/{position → liquidity}/implementations/EulerPositionFetcher.d.ts +1 -1
- package/dist/src/modules/v4/liquidity/index.d.ts +2 -0
- package/dist/src/modules/v4/liquidity/index.js +2 -0
- package/dist/src/modules/v4/{position/position.controller.d.ts → liquidity/liquidity.controller.d.ts} +3 -3
- package/dist/src/modules/v4/{position/position.controller.js → liquidity/liquidity.controller.js} +4 -4
- package/dist/src/modules/v4/{position/position.repository.d.ts → liquidity/liquidity.repository.d.ts} +1 -1
- package/dist/src/modules/v4/{position/position.repository.js → liquidity/liquidity.repository.js} +1 -1
- package/dist/src/modules/v4/liquidity/liquidity.service.d.ts +5 -0
- package/dist/src/modules/v4/{position/position.service.js → liquidity/liquidity.service.js} +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +34 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +11 -2
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +8 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.js +5 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +29 -1
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +6 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +15 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.js +7 -6
- package/dist/src/modules/v4/protocol/protocol.controller.d.ts +30 -1
- package/dist/src/modules/v4/protocol/protocol.controller.js +9 -2
- package/dist/src/modules/v4/protocol/protocol.model.d.ts +10 -1
- package/dist/src/modules/v4/protocol/protocol.model.js +9 -0
- package/dist/src/modules/v4/protocol/protocol.repository.d.ts +9 -1
- package/dist/src/modules/v4/protocol/protocol.repository.js +4 -1
- package/dist/src/modules/v4/protocol/protocol.service.d.ts +11 -3
- package/dist/src/modules/v4/protocol/protocol.service.js +38 -32
- package/dist/src/modules/v4/reward/subservices/converter.js +2 -2
- package/dist/src/modules/v4/router.d.ts +136 -17
- package/dist/src/modules/v4/router.js +2 -2
- package/dist/src/modules/v4/token/token.controller.d.ts +34 -0
- package/dist/src/modules/v4/token/token.controller.js +11 -3
- package/dist/src/modules/v4/token/token.model.d.ts +9 -0
- package/dist/src/modules/v4/token/token.model.js +7 -0
- package/dist/src/modules/v4/token/token.repository.d.ts +14 -1
- package/dist/src/modules/v4/token/token.repository.js +3 -0
- package/dist/src/modules/v4/token/token.service.d.ts +14 -1
- package/dist/src/modules/v4/token/token.service.js +7 -0
- package/dist/src/routes/v3/blacklist.d.ts +136 -17
- package/dist/src/routes/v3/campaigns.d.ts +136 -17
- package/dist/src/routes/v3/campaignsInfo.d.ts +136 -17
- package/dist/src/routes/v3/multiChainPositions.d.ts +136 -17
- package/dist/src/routes/v3/opportunity.d.ts +137 -18
- package/dist/src/routes/v3/opportunity.js +1 -1
- package/dist/src/routes/v3/positions.d.ts +136 -17
- package/dist/src/routes/v3/rewards.d.ts +136 -17
- package/dist/src/routes/v3/updates.d.ts +136 -17
- package/dist/src/routes/v3/userRewards.d.ts +136 -17
- package/dist/src/utils/logger.d.ts +12 -6
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +24 -24
- package/dist/src/modules/v4/position/index.d.ts +0 -2
- package/dist/src/modules/v4/position/index.js +0 -2
- package/dist/src/modules/v4/position/position.service.d.ts +0 -5
- /package/dist/src/modules/v4/{position → liquidity}/implementations/AjnaPositionFetcher.js +0 -0
- /package/dist/src/modules/v4/{position → liquidity}/implementations/BadgerPositionFetcher.js +0 -0
- /package/dist/src/modules/v4/{position → liquidity}/implementations/ClammPositionFetcher.js +0 -0
- /package/dist/src/modules/v4/{position → liquidity}/implementations/ERC20PositionFetcher.js +0 -0
- /package/dist/src/modules/v4/{position → liquidity}/implementations/EulerPositionFetcher.js +0 -0
- /package/dist/src/modules/v4/{position/position.model.d.ts → liquidity/liquidity.model.d.ts} +0 -0
- /package/dist/src/modules/v4/{position/position.model.js → liquidity/liquidity.model.js} +0 -0
@@ -468,6 +468,40 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
468
468
|
};
|
469
469
|
};
|
470
470
|
};
|
471
|
+
} & {
|
472
|
+
opportunities: {
|
473
|
+
":id": {
|
474
|
+
patch: {
|
475
|
+
body: {
|
476
|
+
name?: string | undefined;
|
477
|
+
tags?: string[] | undefined;
|
478
|
+
};
|
479
|
+
params: {
|
480
|
+
id: string;
|
481
|
+
};
|
482
|
+
query: unknown;
|
483
|
+
headers: {
|
484
|
+
authorization: string;
|
485
|
+
};
|
486
|
+
response: {
|
487
|
+
200: {
|
488
|
+
name: string;
|
489
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
490
|
+
id: string;
|
491
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
492
|
+
tags: string[];
|
493
|
+
identifier: string;
|
494
|
+
chainId: number;
|
495
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
496
|
+
mainProtocolId: string | null;
|
497
|
+
tvl: number;
|
498
|
+
apr: number;
|
499
|
+
dailyRewards: number;
|
500
|
+
};
|
501
|
+
};
|
502
|
+
};
|
503
|
+
};
|
504
|
+
};
|
471
505
|
}, {
|
472
506
|
derive: {};
|
473
507
|
resolve: {};
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { NotFoundError } from "../../../errors";
|
2
|
+
import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
3
|
import { AuthorizationHeadersDto, TokenAuthGuard } from "../../../guards/TokenAuth.guard";
|
3
4
|
import Elysia from "elysia";
|
4
|
-
import { CreateOpportunityDto, GetOpportunitiesQueryDto, OpportunityAggregateFieldDto, OpportunityUniqueDto, } from "./opportunity.model";
|
5
|
+
import { CreateOpportunityDto, GetOpportunitiesQueryDto, OpportunityAggregateFieldDto, OpportunityIdDto, OpportunityUniqueDto, UpdateOpportunityDto, } from "./opportunity.model";
|
5
6
|
import { OpportunityService } from "./opportunity.service";
|
6
7
|
import { transformId } from "./transform-id.pipe";
|
7
8
|
import { validateId } from "./validate-id.pipe";
|
@@ -65,8 +66,16 @@ export const OpportunityController = new Elysia({
|
|
65
66
|
})
|
66
67
|
// ─── Get Opportunities Count ─────────────────────────────────────────
|
67
68
|
.get("/count", async ({ query }) => await OpportunityService.countMany(query), { query: GetOpportunitiesQueryDto })
|
68
|
-
// ─── Get Aggregate
|
69
|
+
// ─── Get Aggregate Fields ────────────────────────────────────────────
|
69
70
|
.get("/aggregate/:field", async ({ query, params }) => await OpportunityService.aggregate(query, params.field), {
|
70
71
|
params: OpportunityAggregateFieldDto,
|
71
72
|
query: GetOpportunitiesQueryDto,
|
73
|
+
})
|
74
|
+
// ─── Update An Opportunity ───────────────────────────────────────────
|
75
|
+
.patch("/:id", async ({ params, body }) => await OpportunityService.update(params.id, body), {
|
76
|
+
params: OpportunityIdDto,
|
77
|
+
body: UpdateOpportunityDto,
|
78
|
+
headers: AuthorizationHeadersDto,
|
79
|
+
beforeHandle: BackOfficeGuard,
|
80
|
+
detail: { hide: true },
|
72
81
|
});
|
@@ -112,8 +112,16 @@ export declare const CreateOpportunityDto: import("@sinclair/typebox").TObject<{
|
|
112
112
|
export declare const OpportunityAggregateFieldDto: import("@sinclair/typebox").TObject<{
|
113
113
|
field: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"dailyRewards">[]>;
|
114
114
|
}>;
|
115
|
+
export declare const OpportunityIdDto: import("@sinclair/typebox").TObject<{
|
116
|
+
id: import("@sinclair/typebox").TString;
|
117
|
+
}>;
|
118
|
+
export declare const UpdateOpportunityDto: import("@sinclair/typebox").TObject<{
|
119
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
120
|
+
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
121
|
+
}>;
|
115
122
|
export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
|
116
123
|
export type CreateOpportunityModel = typeof CreateOpportunityDto.static & {
|
117
124
|
id: string;
|
118
125
|
};
|
119
126
|
export type OpportunityAggregateField = typeof OpportunityAggregateFieldDto.static;
|
127
|
+
export type UpdateOpportunityModel = typeof UpdateOpportunityDto.static;
|
@@ -39,3 +39,8 @@ export const CreateOpportunityDto = t.Object({
|
|
39
39
|
export const OpportunityAggregateFieldDto = t.Object({
|
40
40
|
field: t.Union(["dailyRewards"].map(v => t.Literal(v))),
|
41
41
|
});
|
42
|
+
export const OpportunityIdDto = t.Object({ id: t.String() });
|
43
|
+
export const UpdateOpportunityDto = t.Object({
|
44
|
+
name: t.Optional(t.String()),
|
45
|
+
tags: t.Optional(t.Array(t.String())),
|
46
|
+
});
|
@@ -3,7 +3,7 @@ import type { MerklChainId } from "@sdk";
|
|
3
3
|
import { type AprRecord } from "../apr";
|
4
4
|
import { type DailyRewardsRecord } from "../reward";
|
5
5
|
import { type TvlRecord } from "../tvl";
|
6
|
-
import type { CreateOpportunityModel, GetOpportunitiesQueryModel } from "./opportunity.model";
|
6
|
+
import type { CreateOpportunityModel, GetOpportunitiesQueryModel, UpdateOpportunityModel } from "./opportunity.model";
|
7
7
|
export declare abstract class OpportunityRepository {
|
8
8
|
#private;
|
9
9
|
static create(newOpp: CreateOpportunityModel): Promise<void>;
|
@@ -701,7 +701,35 @@ export declare abstract class OpportunityRepository {
|
|
701
701
|
apr: number;
|
702
702
|
dailyRewards: number;
|
703
703
|
}>;
|
704
|
+
static updateChainId(id: string, chainId: MerklChainId): Promise<{
|
705
|
+
name: string;
|
706
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
707
|
+
id: string;
|
708
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
709
|
+
tags: string[];
|
710
|
+
identifier: string;
|
711
|
+
chainId: number;
|
712
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
713
|
+
mainProtocolId: string | null;
|
714
|
+
tvl: number;
|
715
|
+
apr: number;
|
716
|
+
dailyRewards: number;
|
717
|
+
}>;
|
704
718
|
static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
|
705
719
|
sum: never;
|
706
720
|
}>;
|
721
|
+
static update(id: string, data: UpdateOpportunityModel): Promise<{
|
722
|
+
name: string;
|
723
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
724
|
+
id: string;
|
725
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
726
|
+
tags: string[];
|
727
|
+
identifier: string;
|
728
|
+
chainId: number;
|
729
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
730
|
+
mainProtocolId: string | null;
|
731
|
+
tvl: number;
|
732
|
+
apr: number;
|
733
|
+
dailyRewards: number;
|
734
|
+
}>;
|
707
735
|
}
|
@@ -281,6 +281,9 @@ export class OpportunityRepository {
|
|
281
281
|
static async updateName(id, name) {
|
282
282
|
return await apiDbClient.opportunity.update({ where: { id }, data: { name } });
|
283
283
|
}
|
284
|
+
static async updateChainId(id, chainId) {
|
285
|
+
return await apiDbClient.opportunity.update({ where: { id }, data: { chainId } });
|
286
|
+
}
|
284
287
|
static async aggregateSum(field, query) {
|
285
288
|
const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
|
286
289
|
const result = await apiDbClient.opportunity.aggregate({
|
@@ -291,4 +294,7 @@ export class OpportunityRepository {
|
|
291
294
|
});
|
292
295
|
return { sum: result._sum[field] ?? null };
|
293
296
|
}
|
297
|
+
static async update(id, data) {
|
298
|
+
return await apiDbClient.opportunity.update({ where: { id }, data });
|
299
|
+
}
|
294
300
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { type CreateCampaignModel } from "../campaign";
|
2
2
|
import { Prisma } from "../../../../database/api/.generated";
|
3
3
|
import { type ChainId, type MerklChainId } from "@sdk";
|
4
|
-
import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityMetadata, OpportunityUnique } from "./opportunity.model";
|
4
|
+
import type { CreateOpportunityModel, GetOpportunitiesQueryModel, LightOpportunityFromDB, OpportunityMetadata, OpportunityUnique, UpdateOpportunityModel } from "./opportunity.model";
|
5
5
|
import { OpportunityRepository } from "./opportunity.repository";
|
6
6
|
export declare abstract class OpportunityService {
|
7
7
|
static hashId(opportunity: OpportunityUnique): string;
|
@@ -605,4 +605,18 @@ export declare abstract class OpportunityService {
|
|
605
605
|
static aggregate(query: GetOpportunitiesQueryModel, field: keyof Prisma.OpportunitySumAggregateInputType): Promise<{
|
606
606
|
sum: never;
|
607
607
|
}>;
|
608
|
+
static update(id: string, data: UpdateOpportunityModel): Promise<{
|
609
|
+
name: string;
|
610
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
611
|
+
id: string;
|
612
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
613
|
+
tags: string[];
|
614
|
+
identifier: string;
|
615
|
+
chainId: number;
|
616
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
617
|
+
mainProtocolId: string | null;
|
618
|
+
tvl: number;
|
619
|
+
apr: number;
|
620
|
+
dailyRewards: number;
|
621
|
+
}>;
|
608
622
|
}
|
@@ -146,12 +146,10 @@ export class OpportunityService {
|
|
146
146
|
* @returns A list of opportunities
|
147
147
|
*/
|
148
148
|
static async getMany(query) {
|
149
|
-
return
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}, query);
|
154
|
-
});
|
149
|
+
return await CacheService.wrap(TTLPresets.MIN_5, async (query) => {
|
150
|
+
const opportunities = await OpportunityRepository.findMany(query);
|
151
|
+
return opportunities.map(OpportunityService.formatResponse);
|
152
|
+
}, query);
|
155
153
|
}
|
156
154
|
static async findLiveWithFirstCampaign(chainId) {
|
157
155
|
return record("data-layer.access", async () => {
|
@@ -221,4 +219,7 @@ export class OpportunityService {
|
|
221
219
|
static aggregate(query, field) {
|
222
220
|
return OpportunityRepository.aggregateSum(field, query);
|
223
221
|
}
|
222
|
+
static async update(id, data) {
|
223
|
+
return await OpportunityRepository.update(id, data);
|
224
|
+
}
|
224
225
|
}
|
@@ -56,7 +56,7 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
|
|
56
56
|
id: string;
|
57
57
|
tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
|
58
58
|
icon: string;
|
59
|
-
} & {})[]
|
59
|
+
} & {})[];
|
60
60
|
};
|
61
61
|
};
|
62
62
|
};
|
@@ -75,6 +75,35 @@ export declare const ProtocolController: Elysia<"/protocols", false, {
|
|
75
75
|
};
|
76
76
|
};
|
77
77
|
};
|
78
|
+
} & {
|
79
|
+
protocols: {
|
80
|
+
":id": {
|
81
|
+
patch: {
|
82
|
+
body: {
|
83
|
+
url?: string | undefined;
|
84
|
+
description?: string | undefined;
|
85
|
+
icon?: string | undefined;
|
86
|
+
};
|
87
|
+
params: {
|
88
|
+
id: string;
|
89
|
+
};
|
90
|
+
query: unknown;
|
91
|
+
headers: {
|
92
|
+
authorization: string;
|
93
|
+
};
|
94
|
+
response: {
|
95
|
+
200: {
|
96
|
+
name: string;
|
97
|
+
url: string;
|
98
|
+
description: string;
|
99
|
+
id: string;
|
100
|
+
tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
|
101
|
+
icon: string;
|
102
|
+
};
|
103
|
+
};
|
104
|
+
};
|
105
|
+
};
|
106
|
+
};
|
78
107
|
}, {
|
79
108
|
derive: {};
|
80
109
|
resolve: {};
|
@@ -1,5 +1,6 @@
|
|
1
|
+
import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
1
2
|
import Elysia from "elysia";
|
2
|
-
import { GetProtocolsQueryDto } from "./protocol.model";
|
3
|
+
import { GetProtocolsQueryDto, ProtocolIdDto, UpdateProtocolDto } from "./protocol.model";
|
3
4
|
import { ProtocolService } from "./protocol.service";
|
4
5
|
// ─── Protocols Controller ────────────────────────────────────────────────────
|
5
6
|
export const ProtocolController = new Elysia({ prefix: "/protocols", detail: { tags: ["Protocols"] } })
|
@@ -15,4 +16,10 @@ export const ProtocolController = new Elysia({ prefix: "/protocols", detail: { t
|
|
15
16
|
query: GetProtocolsQueryDto,
|
16
17
|
})
|
17
18
|
// ─── Count Protocols ──────────────────────────────────────────────
|
18
|
-
.get("/count", async ({ query }) => await ProtocolService.countMany(query))
|
19
|
+
.get("/count", async ({ query }) => await ProtocolService.countMany(query))
|
20
|
+
.patch("/:id", async ({ params, body }) => await ProtocolService.update(params.id, body), {
|
21
|
+
params: ProtocolIdDto,
|
22
|
+
body: UpdateProtocolDto,
|
23
|
+
headers: AuthorizationHeadersDto,
|
24
|
+
beforeHandle: BackOfficeGuard,
|
25
|
+
});
|
@@ -5,7 +5,7 @@ import type { Resource } from "../prisma";
|
|
5
5
|
* @see {@link Resource}
|
6
6
|
*/
|
7
7
|
export type Protocol = Resource<"Protocol">;
|
8
|
-
declare const protocolTypes: readonly ["arthswap", "baseswap", "camelot", "crust", "fenix", "horiza", "izumi", "kim", "pancakeswap-v3", "quickswap-algebra", "quickswap-uni", "ramses", "retro", "stryke", "stryke-pcs", "stryke-sushi", "sushiswap-v3", "swapr", "thruster", "uniswap-v3", "voltage", "zero", "koi", "supswap-v3", "uniswap-v2", "velodrome", "aerodrome", "balancer", "curve", "aura", "akron", "beefy", "dragonswap", "poolside", "koi", "radiant", "aave", "euler", "gearbox", "compound", "sturdy", "frax", "ionic", "moonwell", "fluid", "silo", "morpho", "coumpound", "dolomite", "badger", "ajna", "layerbank"];
|
8
|
+
declare const protocolTypes: readonly ["arthswap", "baseswap", "camelot", "crust", "fenix", "horiza", "izumi", "kim", "pancakeswap-v3", "quickswap-algebra", "quickswap-uni", "ramses", "retro", "stryke", "stryke-pcs", "stryke-sushi", "sushiswap-v3", "swapr", "thruster", "uniswap-v3", "voltage", "zero", "koi", "supswap-v3", "zkswap", "thirdtrade", "uniswap-v2", "velodrome", "aerodrome", "balancer", "curve", "aura", "akron", "beefy", "dragonswap", "poolside", "koi", "radiant", "aave", "euler", "gearbox", "compound", "sturdy", "frax", "ionic", "moonwell", "fluid", "silo", "morpho", "coumpound", "dolomite", "badger", "ajna", "layerbank"];
|
9
9
|
export type ProtocolId = (typeof protocolTypes)[number];
|
10
10
|
export declare const GetProtocolsQueryDto: import("@sinclair/typebox").TObject<{
|
11
11
|
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTransform<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>, string[]>>;
|
@@ -22,6 +22,15 @@ export declare const GetProtocolsQueryDto: import("@sinclair/typebox").TObject<{
|
|
22
22
|
export declare const GetProtocolParamsDto: import("@sinclair/typebox").TObject<{
|
23
23
|
id: import("@sinclair/typebox").TString;
|
24
24
|
}>;
|
25
|
+
export declare const UpdateProtocolDto: import("@sinclair/typebox").TObject<{
|
26
|
+
icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
27
|
+
url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
28
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
29
|
+
}>;
|
30
|
+
export declare const ProtocolIdDto: import("@sinclair/typebox").TObject<{
|
31
|
+
id: import("@sinclair/typebox").TString;
|
32
|
+
}>;
|
25
33
|
export type GetProtocolsQueryModel = typeof GetProtocolsQueryDto.static;
|
26
34
|
export type GetProtocolModel = typeof GetProtocolParamsDto.static;
|
35
|
+
export type UpdateProtocolModel = typeof UpdateProtocolDto.static;
|
27
36
|
export {};
|
@@ -26,6 +26,8 @@ const protocolTypes = [
|
|
26
26
|
"zero",
|
27
27
|
"koi",
|
28
28
|
"supswap-v3",
|
29
|
+
"zkswap",
|
30
|
+
"thirdtrade",
|
29
31
|
// ─── LP DEX ──────────────────────────────────────────────────────────
|
30
32
|
"uniswap-v2",
|
31
33
|
"velodrome",
|
@@ -69,3 +71,10 @@ export const GetProtocolsQueryDto = t.Object({
|
|
69
71
|
items: t.Optional(t.Numeric()),
|
70
72
|
});
|
71
73
|
export const GetProtocolParamsDto = t.Object({ id: t.String() });
|
74
|
+
export const UpdateProtocolDto = t.Object({
|
75
|
+
icon: t.Optional(t.String({ format: "uri" })),
|
76
|
+
url: t.Optional(t.String({ format: "uri" })),
|
77
|
+
description: t.Optional(t.String()),
|
78
|
+
// iconFile: t.Optional(t.File()),
|
79
|
+
});
|
80
|
+
export const ProtocolIdDto = t.Object({ id: t.String() });
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { GetProtocolsQueryModel, Protocol } from "./protocol.model";
|
1
|
+
import type { GetProtocolsQueryModel, Protocol, UpdateProtocolModel } from "./protocol.model";
|
2
2
|
export declare abstract class ProtocolRepository {
|
3
3
|
#private;
|
4
4
|
static create(template: Protocol["action"]["create"]["args"]): Promise<{
|
@@ -34,4 +34,12 @@ export declare abstract class ProtocolRepository {
|
|
34
34
|
icon: string;
|
35
35
|
}[]>;
|
36
36
|
static countMany(query: GetProtocolsQueryModel): Promise<number>;
|
37
|
+
static update(id: string, data: UpdateProtocolModel): Promise<{
|
38
|
+
name: string;
|
39
|
+
url: string;
|
40
|
+
description: string;
|
41
|
+
id: string;
|
42
|
+
tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
|
43
|
+
icon: string;
|
44
|
+
}>;
|
37
45
|
}
|
@@ -15,7 +15,7 @@ export class ProtocolRepository {
|
|
15
15
|
where: {
|
16
16
|
name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
|
17
17
|
tags: query.tags ? { hasEvery: query.tags } : undefined,
|
18
|
-
id: query.id ? { in: query.id } : undefined,
|
18
|
+
id: typeof query.id === "string" ? query.id : !!query.id ? { in: query.id } : undefined,
|
19
19
|
},
|
20
20
|
};
|
21
21
|
}
|
@@ -34,4 +34,7 @@ export class ProtocolRepository {
|
|
34
34
|
const args = ProtocolRepository.#transformQueryToPrismaFilters(query);
|
35
35
|
return await apiDbClient.protocol.count(args);
|
36
36
|
}
|
37
|
+
static async update(id, data) {
|
38
|
+
return await apiDbClient.protocol.update({ where: { id }, data });
|
39
|
+
}
|
37
40
|
}
|
@@ -1,10 +1,18 @@
|
|
1
1
|
import { AMM as AMMV3 } from "@sdk";
|
2
|
-
import type { GetProtocolsQueryModel, Protocol, ProtocolId } from "./protocol.model";
|
2
|
+
import type { GetProtocolsQueryModel, Protocol, ProtocolId, UpdateProtocolModel } from "./protocol.model";
|
3
3
|
export declare abstract class ProtocolService {
|
4
4
|
static getIdFromAmmV3(amm: AMMV3): ProtocolId;
|
5
|
-
static
|
6
|
-
static findMany(query: GetProtocolsQueryModel): Promise<Protocol["model"][] | null>;
|
5
|
+
static findMany(query: GetProtocolsQueryModel): Promise<Protocol["model"][]>;
|
7
6
|
static countMany(query: GetProtocolsQueryModel): Promise<number>;
|
8
7
|
static getFromId(id: ProtocolId | string): Promise<Protocol["model"] | null>;
|
9
8
|
static getFromName(name: string): Promise<Protocol["model"] | null>;
|
9
|
+
static update(id: string, data: UpdateProtocolModel): Promise<{
|
10
|
+
name: string;
|
11
|
+
url: string;
|
12
|
+
description: string;
|
13
|
+
id: string;
|
14
|
+
tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
|
15
|
+
icon: string;
|
16
|
+
}>;
|
17
|
+
static changeLogoUrls(): Promise<void>;
|
10
18
|
}
|
@@ -1,4 +1,7 @@
|
|
1
|
+
import { log } from "../../../utils/logger";
|
1
2
|
import { AMM as AMMV3 } from "@sdk";
|
3
|
+
import { ChainService } from "../chain";
|
4
|
+
import { TokenService } from "../token";
|
2
5
|
import { ProtocolRepository } from "./protocol.repository";
|
3
6
|
// ─── Protocols Services ──────────────────────────────────────────────────────
|
4
7
|
export class ProtocolService {
|
@@ -28,40 +31,11 @@ export class ProtocolService {
|
|
28
31
|
[AMMV3.ZERO]: "zero",
|
29
32
|
[AMMV3.KOI]: "koi",
|
30
33
|
[AMMV3.SupswapV3]: "supswap-v3",
|
34
|
+
[AMMV3.AERODROME]: "aerodrome",
|
35
|
+
[AMMV3.zkSwap]: "zkswap",
|
36
|
+
[AMMV3.ThirdTrade]: "thirdtrade",
|
31
37
|
}[amm];
|
32
38
|
}
|
33
|
-
static getIdFromErc20Type(_type) {
|
34
|
-
return {
|
35
|
-
uniswapv2: "uniswap-v2",
|
36
|
-
velodrome: "velodrome",
|
37
|
-
aerodrome: "aerodrome",
|
38
|
-
balancerGauge: "balancer",
|
39
|
-
balancerPool: "balancer",
|
40
|
-
curve: "curve",
|
41
|
-
aura: "aura",
|
42
|
-
akron: "akron",
|
43
|
-
dragonswap: "dragonswap",
|
44
|
-
poolside: "poolside",
|
45
|
-
koi: "koi",
|
46
|
-
radiant_borrow: "radiant",
|
47
|
-
radiant_lend: "radiant",
|
48
|
-
aave_borrowing: "radiant",
|
49
|
-
euler_borrow: "euler",
|
50
|
-
euler_lend: "euler",
|
51
|
-
gearbox: "gearbox",
|
52
|
-
compound: "compound",
|
53
|
-
aave_lending: "aave",
|
54
|
-
sturdy_aggregator: "sturdy",
|
55
|
-
sturdy_silo: "sturdy",
|
56
|
-
fraxlend: "frax",
|
57
|
-
moonwell: "moonwell",
|
58
|
-
ionic: "ionic",
|
59
|
-
fluid: "fluid",
|
60
|
-
silostaking: "silo",
|
61
|
-
layerbank: "layerbank",
|
62
|
-
beefy: "beefy",
|
63
|
-
}[_type];
|
64
|
-
}
|
65
39
|
static async findMany(query) {
|
66
40
|
return ProtocolRepository.findMany(query);
|
67
41
|
}
|
@@ -75,4 +49,36 @@ export class ProtocolService {
|
|
75
49
|
static async getFromName(name) {
|
76
50
|
return (await ProtocolRepository.findManyByName(name))[0];
|
77
51
|
}
|
52
|
+
static async update(id, data) {
|
53
|
+
// let iconUri = data.icon;
|
54
|
+
// if (data.iconFile) {
|
55
|
+
// iconUri = await BucketService.upload("merkl-assets", `/protocols/${id}`, data.iconFile.stream(), true);
|
56
|
+
// }
|
57
|
+
return await ProtocolRepository.update(id, data);
|
58
|
+
}
|
59
|
+
static async changeLogoUrls() {
|
60
|
+
const oldUrl = "https://storage.googleapis.com/merkl-assets/";
|
61
|
+
const newUrl = "https://raw.githubusercontent.com/AngleProtocol/angle-token-list/main/src/assets/";
|
62
|
+
const protocols = await ProtocolService.findMany({ items: 10_000 });
|
63
|
+
for (const protocol of protocols) {
|
64
|
+
if (protocol.icon.includes(oldUrl)) {
|
65
|
+
await ProtocolService.update(protocol.id, { icon: protocol.icon.replace(oldUrl, newUrl) });
|
66
|
+
log.info(`Updated protocol ${protocol.id} icon`);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
const chains = await ChainService.findMany();
|
70
|
+
for (const chain of chains) {
|
71
|
+
if (chain.icon.includes(oldUrl)) {
|
72
|
+
await ChainService.update(chain.id, { icon: chain.icon.replace(oldUrl, newUrl) });
|
73
|
+
log.info(`Updated chain ${chain.id} icon`);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
const tokens = await TokenService.findMany({});
|
77
|
+
for (const token of tokens) {
|
78
|
+
if (token.icon.includes(oldUrl)) {
|
79
|
+
await TokenService.update(token.id, { icon: token.icon.replace(oldUrl, newUrl) });
|
80
|
+
log.info(`Updated token ${token.id} icon`);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
78
84
|
}
|
@@ -77,8 +77,8 @@ export class RewardConvertorService {
|
|
77
77
|
accumulated: "0",
|
78
78
|
unclaimed: "0",
|
79
79
|
pending: "0",
|
80
|
-
auxiliaryData1: breakdown.auxiliaryData1 === "" ? "0" : breakdown.auxiliaryData1 ?? "0",
|
81
|
-
auxiliaryData2: breakdown.auxiliaryData2 === "" ? "0" : breakdown.auxiliaryData2 ?? "0",
|
80
|
+
auxiliaryData1: breakdown.auxiliaryData1 === "" ? "0" : (breakdown.auxiliaryData1 ?? "0"),
|
81
|
+
auxiliaryData2: breakdown.auxiliaryData2 === "" ? "0" : (breakdown.auxiliaryData2 ?? "0"),
|
82
82
|
decimals: token.decimals,
|
83
83
|
mainParameter: breakdown.opportunity.identifier,
|
84
84
|
symbol: token.symbol,
|