@merkl/api 0.10.138 → 0.10.140
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 +291 -520
- package/dist/src/index.d.ts +99 -186
- package/dist/src/index.js +1 -1
- package/dist/src/libs/deprecated-merklv3/index.js +1 -1
- package/dist/src/modules/v4/blacklist/blacklist.controller.d.ts +0 -21
- package/dist/src/modules/v4/blacklist/blacklist.controller.js +2 -2
- package/dist/src/modules/v4/blacklist/blacklist.repository.d.ts +0 -8
- package/dist/src/modules/v4/blacklist/blacklist.repository.js +1 -4
- package/dist/src/modules/v4/blacklist/blacklist.service.d.ts +1 -9
- package/dist/src/modules/v4/blacklist/blacklist.service.js +1 -4
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +3 -3
- package/dist/src/modules/v4/campaign/campaign.controller.js +8 -6
- package/dist/src/modules/v4/campaign/campaign.service.js +1 -2
- package/dist/src/modules/v4/chain/chain.controller.js +2 -1
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +20 -26
- package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +5 -5
- package/dist/src/modules/v4/enso/enso.service.d.ts +1 -1
- package/dist/src/modules/v4/{participate/participate.controller.d.ts → interaction/interaction.controller.d.ts} +6 -6
- package/dist/src/modules/v4/{participate/participate.controller.js → interaction/interaction.controller.js} +12 -13
- package/dist/src/modules/v4/{participate/participate.model.d.ts → interaction/interaction.model.d.ts} +12 -12
- package/dist/src/modules/v4/{participate/participate.model.js → interaction/interaction.model.js} +3 -3
- package/dist/src/modules/v4/{participate/participate.service.d.ts → interaction/interaction.service.d.ts} +5 -5
- package/dist/src/modules/v4/{participate/participate.service.js → interaction/interaction.service.js} +3 -3
- package/dist/src/modules/v4/merklRoot/merklRoot.controller.d.ts +2 -2
- package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +5 -1
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +28 -2
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +16 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +2 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.js +30 -0
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +3 -3
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +2 -2
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +1 -1
- package/dist/src/modules/v4/price/price.controller.js +3 -0
- package/dist/src/modules/v4/reward/reward.controller.d.ts +31 -29
- package/dist/src/modules/v4/reward/reward.controller.js +3 -3
- package/dist/src/modules/v4/reward/{rewardConvertor.service.d.ts → subservices/converter.d.ts} +2 -2
- package/dist/src/modules/v4/reward/{rewardConvertor.service.js → subservices/converter.js} +1 -1
- package/dist/src/modules/v4/router.d.ts +99 -186
- package/dist/src/modules/v4/router.js +2 -2
- package/dist/src/modules/v4/status/status.controller.d.ts +40 -102
- package/dist/src/modules/v4/status/status.controller.js +16 -22
- package/dist/src/modules/v4/status/status.model.d.ts +33 -26
- package/dist/src/modules/v4/status/status.model.js +9 -20
- package/dist/src/modules/v4/status/status.repository.d.ts +12 -42
- package/dist/src/modules/v4/status/status.repository.js +10 -22
- package/dist/src/modules/v4/status/status.service.d.ts +4 -36
- package/dist/src/modules/v4/status/status.service.js +9 -18
- package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.d.ts +1 -1
- package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.js +1 -1
- package/dist/src/modules/v4/user/user.controller.js +3 -2
- package/dist/src/routes/v3/ERC20Campaigns.d.ts +99 -186
- package/dist/src/routes/v3/blacklist.d.ts +99 -186
- package/dist/src/routes/v3/campaigns.d.ts +99 -186
- package/dist/src/routes/v3/campaignsInfo.d.ts +99 -186
- package/dist/src/routes/v3/multiChainPositions.d.ts +99 -186
- package/dist/src/routes/v3/opportunity.d.ts +99 -186
- package/dist/src/routes/v3/positions.d.ts +99 -186
- package/dist/src/routes/v3/rewards.d.ts +99 -186
- package/dist/src/routes/v3/rewards.js +1 -1
- package/dist/src/routes/v3/updates.d.ts +99 -186
- package/dist/src/routes/v3/userRewards.d.ts +99 -186
- package/dist/src/routes/v3/userRewards.js +1 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/dist/src/modules/v4/apr/apr.repository.d.ts +0 -0
- package/dist/src/modules/v4/apr/apr.repository.js +0 -1
- package/dist/src/modules/v4/tvl/tvl.repository.d.ts +0 -0
- package/dist/src/modules/v4/tvl/tvl.repository.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Elysia from "elysia";
|
|
2
|
-
export declare const DynamicDataController: Elysia<"/
|
|
2
|
+
export declare const DynamicDataController: Elysia<"/dynamic-data", false, {
|
|
3
3
|
decorator: {};
|
|
4
4
|
store: {};
|
|
5
5
|
derive: {};
|
|
@@ -12,31 +12,25 @@ export declare const DynamicDataController: Elysia<"/dynamicData", false, {
|
|
|
12
12
|
macro: {};
|
|
13
13
|
macroFn: {};
|
|
14
14
|
}, {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cardName: string;
|
|
35
|
-
blacklistedSupply: number;
|
|
36
|
-
priceTargetToken: number;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
15
|
+
"dynamic-data": {
|
|
16
|
+
index: {
|
|
17
|
+
get: {
|
|
18
|
+
body: unknown;
|
|
19
|
+
params: {};
|
|
20
|
+
query: {
|
|
21
|
+
chainId: number;
|
|
22
|
+
tokenAddress: string;
|
|
23
|
+
};
|
|
24
|
+
headers: {
|
|
25
|
+
authorization: string;
|
|
26
|
+
};
|
|
27
|
+
response: {
|
|
28
|
+
200: {
|
|
29
|
+
tvl: number;
|
|
30
|
+
totalSupply: number;
|
|
31
|
+
cardName: string;
|
|
32
|
+
blacklistedSupply: number;
|
|
33
|
+
priceTargetToken: number;
|
|
40
34
|
};
|
|
41
35
|
};
|
|
42
36
|
};
|
|
@@ -4,13 +4,13 @@ import { throwOnUnsupportedChainId } from "src/utils/throw";
|
|
|
4
4
|
import { DynamicDataSourceIdentifier } from "./dynamicData.model";
|
|
5
5
|
import { DynamicDataService } from "./dynamicData.service";
|
|
6
6
|
// ─── DynamicDatas Controller ───────────────────────────────────────────────────────
|
|
7
|
-
export const DynamicDataController = new Elysia({ prefix: "/
|
|
7
|
+
export const DynamicDataController = new Elysia({ prefix: "/dynamic-data", detail: { tags: ["DynamicData"] } })
|
|
8
8
|
// ─── Get type Info By Token Address ───────────────────────────────────────
|
|
9
|
-
.get("/
|
|
10
|
-
|
|
9
|
+
.get("/", async ({ query }) => await DynamicDataService.queryERC20DynamicData(query.chainId, query.tokenAddress), {
|
|
10
|
+
query: DynamicDataSourceIdentifier,
|
|
11
11
|
headers: AuthorizationHeadersDto,
|
|
12
|
-
beforeHandle: ({
|
|
12
|
+
beforeHandle: ({ query, headers }) => {
|
|
13
13
|
BackOfficeGuard({ headers });
|
|
14
|
-
throwOnUnsupportedChainId(
|
|
14
|
+
throwOnUnsupportedChainId(query.chainId);
|
|
15
15
|
},
|
|
16
16
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetParticipateProtocolsQuery } from "../
|
|
1
|
+
import type { GetParticipateProtocolsQuery } from "../interaction/interaction.model";
|
|
2
2
|
import { type ProtocolId } from "../protocol";
|
|
3
3
|
import { type EnsoApi, type EnsoSlug } from "./enso.model";
|
|
4
4
|
export declare abstract class EnsoService {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Elysia from "elysia";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const InteractionController: Elysia<"/interaction", false, {
|
|
3
3
|
decorator: {};
|
|
4
4
|
store: {};
|
|
5
5
|
derive: {};
|
|
@@ -12,7 +12,7 @@ export declare const ParticipateController: Elysia<"/participate", false, {
|
|
|
12
12
|
macro: {};
|
|
13
13
|
macroFn: {};
|
|
14
14
|
}, {
|
|
15
|
-
|
|
15
|
+
interaction: {
|
|
16
16
|
targets: {
|
|
17
17
|
get: {
|
|
18
18
|
body: unknown;
|
|
@@ -24,13 +24,13 @@ export declare const ParticipateController: Elysia<"/participate", false, {
|
|
|
24
24
|
};
|
|
25
25
|
headers: unknown;
|
|
26
26
|
response: {
|
|
27
|
-
200: import("./
|
|
27
|
+
200: import("./interaction.model").InteractionTarget[] | undefined;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
} & {
|
|
33
|
-
|
|
33
|
+
interaction: {
|
|
34
34
|
protocols: {
|
|
35
35
|
get: {
|
|
36
36
|
body: unknown;
|
|
@@ -53,7 +53,7 @@ export declare const ParticipateController: Elysia<"/participate", false, {
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
} & {
|
|
56
|
-
|
|
56
|
+
interaction: {
|
|
57
57
|
quote: {
|
|
58
58
|
get: {
|
|
59
59
|
body: unknown;
|
|
@@ -79,7 +79,7 @@ export declare const ParticipateController: Elysia<"/participate", false, {
|
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
81
|
} & {
|
|
82
|
-
|
|
82
|
+
interaction: {
|
|
83
83
|
transaction: {
|
|
84
84
|
get: {
|
|
85
85
|
body: unknown;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import Elysia from "elysia";
|
|
2
2
|
import { EnsoService } from "../enso/enso.service";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
// ───
|
|
6
|
-
export const
|
|
7
|
-
// ─── Get All Targets ───────────────────────────────────────────────
|
|
3
|
+
import { GetInteractionProtocolsQueryDto, GetInteractionQuoteQueryDto, GetInteractionTargetsQueryDto, } from "./interaction.model";
|
|
4
|
+
import { InteractionService } from "./interaction.service";
|
|
5
|
+
// ─── Interaction Controller ──────────────────────────────────────────────────
|
|
6
|
+
export const InteractionController = new Elysia({ prefix: "/interaction", detail: { tags: ["Interaction"] } })
|
|
8
7
|
.get("/targets", async ({ query: { protocolId, chainId, identifier } }) => {
|
|
9
8
|
if (identifier)
|
|
10
|
-
return await
|
|
11
|
-
return await
|
|
9
|
+
return await InteractionService.getTarget(chainId, protocolId, identifier);
|
|
10
|
+
return await InteractionService.getTargets(chainId, protocolId);
|
|
12
11
|
}, {
|
|
13
|
-
query:
|
|
12
|
+
query: GetInteractionTargetsQueryDto,
|
|
14
13
|
detail: {
|
|
15
14
|
summary: "Available interaction targets for a protocol",
|
|
16
15
|
description: "Retrieves all the pool/token/contract",
|
|
@@ -18,7 +17,7 @@ export const ParticipateController = new Elysia({ prefix: "/participate", detail
|
|
|
18
17
|
})
|
|
19
18
|
// ─── Get All Compatible Protocols ───────────────────────────────────────
|
|
20
19
|
.get("/protocols", async ({ query }) => await EnsoService.getCompatibleProtocols(query), {
|
|
21
|
-
query:
|
|
20
|
+
query: GetInteractionProtocolsQueryDto,
|
|
22
21
|
detail: {
|
|
23
22
|
summary: "Interactable protocols",
|
|
24
23
|
description: "Retrieves protocols integrated by merkl which supports being interacted with",
|
|
@@ -26,7 +25,7 @@ export const ParticipateController = new Elysia({ prefix: "/participate", detail
|
|
|
26
25
|
})
|
|
27
26
|
// ─── Get Quote ───────────────────────────────────────────────────────
|
|
28
27
|
.get("/quote", async ({ query: { protocolId, chainId, identifier, userAddress, fromAmount, fromTokenAddress } }) => {
|
|
29
|
-
const [target] = (await
|
|
28
|
+
const [target] = (await InteractionService.getTarget(chainId, protocolId, identifier)) ?? [];
|
|
30
29
|
//TODO: throw error
|
|
31
30
|
if (!target)
|
|
32
31
|
return;
|
|
@@ -39,7 +38,7 @@ export const ParticipateController = new Elysia({ prefix: "/participate", detail
|
|
|
39
38
|
chainId,
|
|
40
39
|
});
|
|
41
40
|
}, {
|
|
42
|
-
query:
|
|
41
|
+
query: GetInteractionQuoteQueryDto,
|
|
43
42
|
detail: {
|
|
44
43
|
summary: "Preview participate transaction",
|
|
45
44
|
description: "",
|
|
@@ -47,7 +46,7 @@ export const ParticipateController = new Elysia({ prefix: "/participate", detail
|
|
|
47
46
|
})
|
|
48
47
|
// ─── Get Transaction ─────────────────────────────────────────────────
|
|
49
48
|
.get("/transaction", async ({ query: { protocolId, chainId, identifier, userAddress, fromAmount, fromTokenAddress } }) => {
|
|
50
|
-
const [target] = (await
|
|
49
|
+
const [target] = (await InteractionService.getTarget(chainId, protocolId, identifier)) ?? [];
|
|
51
50
|
//TODO: throw error
|
|
52
51
|
if (!target)
|
|
53
52
|
return;
|
|
@@ -60,7 +59,7 @@ export const ParticipateController = new Elysia({ prefix: "/participate", detail
|
|
|
60
59
|
chainId,
|
|
61
60
|
});
|
|
62
61
|
}, {
|
|
63
|
-
query:
|
|
62
|
+
query: GetInteractionQuoteQueryDto,
|
|
64
63
|
detail: {
|
|
65
64
|
summary: "Get participate transaction",
|
|
66
65
|
description: "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Token } from "../token";
|
|
2
2
|
export declare const participateInputTypes: readonly ["tokenAmount", "token"];
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
3
|
+
export type InteractionInputType = (typeof participateInputTypes)[number];
|
|
4
|
+
export type InteractionInput<T extends InteractionInputType = InteractionInputType> = {
|
|
5
5
|
tokenAmount: {
|
|
6
6
|
chain: number[];
|
|
7
7
|
address: string[];
|
|
@@ -12,32 +12,32 @@ export type ParticipateInput<T extends ParticipateInputType = ParticipateInputTy
|
|
|
12
12
|
};
|
|
13
13
|
}[T];
|
|
14
14
|
export declare const participateTypes: readonly ["link", "deposit", "withdraw"];
|
|
15
|
-
export type
|
|
16
|
-
export type
|
|
15
|
+
export type InteractionType = (typeof participateTypes)[number];
|
|
16
|
+
export type InteractionSchema<T extends InteractionType> = {
|
|
17
17
|
link: {
|
|
18
18
|
link: string;
|
|
19
19
|
};
|
|
20
20
|
deposit: {
|
|
21
|
-
inputs:
|
|
21
|
+
inputs: InteractionInput[];
|
|
22
22
|
};
|
|
23
23
|
withdraw: {
|
|
24
24
|
d: string;
|
|
25
25
|
};
|
|
26
26
|
}[T];
|
|
27
|
-
export type
|
|
27
|
+
export type InteractionTarget = {
|
|
28
28
|
identifier: string;
|
|
29
29
|
name: string;
|
|
30
30
|
tokens: Token["model"][];
|
|
31
31
|
};
|
|
32
|
-
export type
|
|
33
|
-
[T in
|
|
32
|
+
export type InteractionSchemas = {
|
|
33
|
+
[T in InteractionType]?: InteractionSchema<T>;
|
|
34
34
|
};
|
|
35
|
-
export declare const
|
|
35
|
+
export declare const GetInteractionTargetsQueryDto: import("@sinclair/typebox").TObject<{
|
|
36
36
|
chainId: import("@sinclair/typebox").TNumber;
|
|
37
37
|
protocolId: import("@sinclair/typebox").TString;
|
|
38
38
|
identifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
39
39
|
}>;
|
|
40
|
-
export declare const
|
|
40
|
+
export declare const GetInteractionQuoteQueryDto: import("@sinclair/typebox").TObject<{
|
|
41
41
|
chainId: import("@sinclair/typebox").TNumber;
|
|
42
42
|
protocolId: import("@sinclair/typebox").TString;
|
|
43
43
|
identifier: import("@sinclair/typebox").TString;
|
|
@@ -45,7 +45,7 @@ export declare const GetParticipateQuoteQueryDto: import("@sinclair/typebox").TO
|
|
|
45
45
|
fromTokenAddress: import("@sinclair/typebox").TString;
|
|
46
46
|
fromAmount: import("@sinclair/typebox").TString;
|
|
47
47
|
}>;
|
|
48
|
-
export declare const
|
|
48
|
+
export declare const GetInteractionProtocolsQueryDto: import("@sinclair/typebox").TObject<{
|
|
49
49
|
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
50
50
|
}>;
|
|
51
|
-
export type
|
|
51
|
+
export type GetInteractionProtocolsQuery = typeof GetInteractionProtocolsQueryDto.static;
|
package/dist/src/modules/v4/{participate/participate.model.js → interaction/interaction.model.js}
RENAMED
|
@@ -2,14 +2,14 @@ import protocol from "database/api/seeder/resources/protocol";
|
|
|
2
2
|
import { t } from "elysia";
|
|
3
3
|
export const participateInputTypes = ["tokenAmount", "token"];
|
|
4
4
|
export const participateTypes = ["link", "deposit", "withdraw"];
|
|
5
|
-
export const
|
|
5
|
+
export const GetInteractionTargetsQueryDto = t.Object({
|
|
6
6
|
chainId: t.Numeric(),
|
|
7
7
|
protocolId: t.String({
|
|
8
8
|
examples: Object.values(protocol).reduce((obj, i) => Object.assign(obj, { [i.name]: { value: i.id } }), {}),
|
|
9
9
|
}),
|
|
10
10
|
identifier: t.Optional(t.String()),
|
|
11
11
|
});
|
|
12
|
-
export const
|
|
12
|
+
export const GetInteractionQuoteQueryDto = t.Object({
|
|
13
13
|
chainId: t.Numeric(),
|
|
14
14
|
protocolId: t.String({
|
|
15
15
|
examples: Object.values(protocol).reduce((obj, i) => Object.assign(obj, { [i.name]: { value: i.id } }), {}),
|
|
@@ -19,6 +19,6 @@ export const GetParticipateQuoteQueryDto = t.Object({
|
|
|
19
19
|
fromTokenAddress: t.String(),
|
|
20
20
|
fromAmount: t.String(),
|
|
21
21
|
});
|
|
22
|
-
export const
|
|
22
|
+
export const GetInteractionProtocolsQueryDto = t.Object({
|
|
23
23
|
chainId: t.Optional(t.Numeric()),
|
|
24
24
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EnsoService } from "../enso/enso.service";
|
|
2
2
|
import type { ProtocolId } from "../protocol";
|
|
3
|
-
import type {
|
|
4
|
-
export declare abstract class
|
|
5
|
-
static getTarget(chainId: number, protocolId: ProtocolId, identifier: string): Promise<
|
|
6
|
-
static getTargetsFromEnsoTokens(tokens: Awaited<ReturnType<typeof EnsoService.getTokens>>): Promise<
|
|
7
|
-
static getTargets(chainId: number, protocolId: ProtocolId): Promise<
|
|
3
|
+
import type { InteractionTarget } from "./interaction.model";
|
|
4
|
+
export declare abstract class InteractionService {
|
|
5
|
+
static getTarget(chainId: number, protocolId: ProtocolId, identifier: string): Promise<InteractionTarget[] | undefined>;
|
|
6
|
+
static getTargetsFromEnsoTokens(tokens: Awaited<ReturnType<typeof EnsoService.getTokens>>): Promise<InteractionTarget[]>;
|
|
7
|
+
static getTargets(chainId: number, protocolId: ProtocolId): Promise<InteractionTarget[] | undefined>;
|
|
8
8
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EnsoService } from "../enso/enso.service";
|
|
2
2
|
import { TokenService } from "../token";
|
|
3
|
-
export class
|
|
3
|
+
export class InteractionService {
|
|
4
4
|
static async getTarget(chainId, protocolId, identifier) {
|
|
5
5
|
const slug = EnsoService.getSlug(protocolId);
|
|
6
6
|
if (!slug)
|
|
7
7
|
return;
|
|
8
8
|
const tokens = await EnsoService.getTokens(chainId, slug, identifier);
|
|
9
|
-
return await
|
|
9
|
+
return await InteractionService.getTargetsFromEnsoTokens(tokens);
|
|
10
10
|
}
|
|
11
11
|
static async getTargetsFromEnsoTokens(tokens) {
|
|
12
12
|
const targets = [];
|
|
@@ -28,6 +28,6 @@ export class ParticipateService {
|
|
|
28
28
|
if (!slug)
|
|
29
29
|
return;
|
|
30
30
|
const tokens = await EnsoService.getTokens(chainId, slug);
|
|
31
|
-
return await
|
|
31
|
+
return await InteractionService.getTargetsFromEnsoTokens(tokens);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -13,7 +13,7 @@ export declare const MerklRootController: Elysia<"/roots", false, {
|
|
|
13
13
|
macroFn: {};
|
|
14
14
|
}, {
|
|
15
15
|
roots: {
|
|
16
|
-
|
|
16
|
+
index: {
|
|
17
17
|
get: {
|
|
18
18
|
body: unknown;
|
|
19
19
|
params: {};
|
|
@@ -36,7 +36,7 @@ export declare const MerklRootController: Elysia<"/roots", false, {
|
|
|
36
36
|
};
|
|
37
37
|
} & {
|
|
38
38
|
roots: {
|
|
39
|
-
|
|
39
|
+
live: {
|
|
40
40
|
get: {
|
|
41
41
|
body: unknown;
|
|
42
42
|
params: {};
|
|
@@ -5,11 +5,11 @@ import { MerklRootService } from "./merklRoot.service";
|
|
|
5
5
|
// ─── Merkl Roots Controller ──────────────────────────────────────────────────
|
|
6
6
|
export const MerklRootController = new Elysia({ prefix: "/roots", detail: { tags: ["Roots"] } })
|
|
7
7
|
// ─── Get Merkl Root By Timestamp ─────────────────────────────────────
|
|
8
|
-
.get("/
|
|
8
|
+
.get("/", async ({ query }) => await MerklRootService.rootForTimestamp(query), {
|
|
9
9
|
query: RootByTimestampsDto,
|
|
10
10
|
beforeHandle: async ({ query }) => {
|
|
11
11
|
throwOnUnsupportedChainId(query.chainId);
|
|
12
12
|
},
|
|
13
13
|
})
|
|
14
14
|
// ─── Get all live Merkl Roots ─────────────────────────────────────────
|
|
15
|
-
.get("/", async () => await MerklRootService.fetchAll());
|
|
15
|
+
.get("/live", async () => await MerklRootService.fetchAll());
|
|
@@ -6,12 +6,16 @@ import { OpportunityService } from "./opportunity.service";
|
|
|
6
6
|
import { transformId } from "./transform-id.pipe";
|
|
7
7
|
import { validateId } from "./validate-id.pipe";
|
|
8
8
|
// ─── Opportunities Controller ────────────────────────────────────────────────
|
|
9
|
-
export const OpportunityController = new Elysia({
|
|
9
|
+
export const OpportunityController = new Elysia({
|
|
10
|
+
prefix: "/opportunities",
|
|
11
|
+
detail: { tags: ["Opportunities"] },
|
|
12
|
+
})
|
|
10
13
|
// ─── Create An Opportunity ───────────────────────────────────────────
|
|
11
14
|
.post("/", async ({ body }) => await OpportunityService.create(body), {
|
|
12
15
|
beforeHandle: TokenAuthGuard,
|
|
13
16
|
headers: AuthorizationHeadersDto,
|
|
14
17
|
body: CreateOpportunityDto,
|
|
18
|
+
detail: { hide: true },
|
|
15
19
|
})
|
|
16
20
|
// ─── Get An Opportunity By Id ────────────────────────────────────────
|
|
17
21
|
.get("/:id", async ({ params }) => {
|
|
@@ -254,7 +254,19 @@ export declare abstract class OpportunityRepository {
|
|
|
254
254
|
dailyRewards: number;
|
|
255
255
|
}>;
|
|
256
256
|
static findManyWithCampaigns(filters: Prisma.OpportunityFindManyArgs): Promise<({
|
|
257
|
-
Campaigns: {
|
|
257
|
+
Campaigns: ({
|
|
258
|
+
RewardToken: {
|
|
259
|
+
symbol: string;
|
|
260
|
+
name: string | null;
|
|
261
|
+
id: string;
|
|
262
|
+
chainId: number;
|
|
263
|
+
address: string;
|
|
264
|
+
icon: string;
|
|
265
|
+
decimals: number;
|
|
266
|
+
verified: boolean;
|
|
267
|
+
price: number | null;
|
|
268
|
+
};
|
|
269
|
+
} & {
|
|
258
270
|
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
|
259
271
|
id: string;
|
|
260
272
|
params: Prisma.JsonValue;
|
|
@@ -268,7 +280,7 @@ export declare abstract class OpportunityRepository {
|
|
|
268
280
|
amount: string;
|
|
269
281
|
opportunityId: string;
|
|
270
282
|
creatorAddress: string;
|
|
271
|
-
}[];
|
|
283
|
+
})[];
|
|
272
284
|
} & {
|
|
273
285
|
name: string;
|
|
274
286
|
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
|
@@ -462,6 +474,20 @@ export declare abstract class OpportunityRepository {
|
|
|
462
474
|
apr: number;
|
|
463
475
|
dailyRewards: number;
|
|
464
476
|
}>;
|
|
477
|
+
static updateName(id: string, name: string): Promise<{
|
|
478
|
+
name: string;
|
|
479
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
|
480
|
+
id: string;
|
|
481
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
|
482
|
+
tags: string[];
|
|
483
|
+
identifier: string;
|
|
484
|
+
chainId: number;
|
|
485
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
|
486
|
+
mainProtocolId: string | null;
|
|
487
|
+
tvl: number;
|
|
488
|
+
apr: number;
|
|
489
|
+
dailyRewards: number;
|
|
490
|
+
}>;
|
|
465
491
|
static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryEntity): Promise<{
|
|
466
492
|
sum: never;
|
|
467
493
|
}>;
|
|
@@ -93,7 +93,19 @@ export class OpportunityRepository {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
static async findManyWithCampaigns(filters) {
|
|
96
|
-
return await apiDbClient.opportunity.findMany({
|
|
96
|
+
return await apiDbClient.opportunity.findMany({
|
|
97
|
+
...filters,
|
|
98
|
+
include: {
|
|
99
|
+
Campaigns: {
|
|
100
|
+
include: {
|
|
101
|
+
RewardToken: true,
|
|
102
|
+
},
|
|
103
|
+
orderBy: {
|
|
104
|
+
endTimestamp: "desc",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
97
109
|
}
|
|
98
110
|
static #transformQueryToPrismaFilters(query) {
|
|
99
111
|
const { page: _page, items: _items, ...filters } = query;
|
|
@@ -215,6 +227,9 @@ export class OpportunityRepository {
|
|
|
215
227
|
return await apiDbClient.opportunity.update({ where: { id }, data: { status, apr: 0, dailyRewards: 0 } });
|
|
216
228
|
return await apiDbClient.opportunity.update({ where: { id }, data: { status } });
|
|
217
229
|
}
|
|
230
|
+
static async updateName(id, name) {
|
|
231
|
+
return await apiDbClient.opportunity.update({ where: { id }, data: { name } });
|
|
232
|
+
}
|
|
218
233
|
static async aggregateSum(field, query) {
|
|
219
234
|
const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
|
|
220
235
|
const result = await apiDbClient.opportunity.aggregate({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CreateCampaignModel } from "../campaign";
|
|
2
2
|
import { Prisma } from "../../../../database/api/.generated";
|
|
3
|
-
import type
|
|
3
|
+
import { type ChainId } from "@sdk";
|
|
4
4
|
import type { CreateOpportunityModel, GetOpportunitiesQueryEntity, LightOpportunityFromDB, OpportunityMetadata, OpportunityUnique } from "./opportunity.model";
|
|
5
5
|
import { OpportunityRepository } from "./opportunity.repository";
|
|
6
6
|
export declare abstract class OpportunityService {
|
|
@@ -17,6 +17,7 @@ export declare abstract class OpportunityService {
|
|
|
17
17
|
* @returns {OpportunityMetadata}
|
|
18
18
|
*/
|
|
19
19
|
static getMetadata(campaign: CreateCampaignModel): Promise<OpportunityMetadata>;
|
|
20
|
+
static updateNames(): Promise<void>;
|
|
20
21
|
static updateMetadata(chain: ChainId): Promise<void>;
|
|
21
22
|
static getUniqueWithCampaignsOrThrow(opportunityId: string | OpportunityUnique): Promise<({
|
|
22
23
|
aprRecord: {
|
|
@@ -3,6 +3,7 @@ import { CampaignService } from "../campaign";
|
|
|
3
3
|
import { log } from "../../../utils/logger";
|
|
4
4
|
import { OpportunityAction, Prisma } from "../../../../database/api/.generated";
|
|
5
5
|
import { record } from "@elysiajs/opentelemetry";
|
|
6
|
+
import { Campaign } from "@sdk";
|
|
6
7
|
import { CacheService } from "../cache";
|
|
7
8
|
import { TTLPresets } from "../cache/cache.model";
|
|
8
9
|
import { OpportunityRepository } from "./opportunity.repository";
|
|
@@ -75,6 +76,35 @@ export class OpportunityService {
|
|
|
75
76
|
throw "UNKNOWN CAMPAIGN TYPE";
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
static async updateNames() {
|
|
80
|
+
const opportunities = await OpportunityRepository.findManyWithCampaigns({});
|
|
81
|
+
log.info(`updating ${opportunities.length} opportunities names`);
|
|
82
|
+
for (const [i, opp] of opportunities.entries()) {
|
|
83
|
+
try {
|
|
84
|
+
const campaignData = opp.Campaigns[0];
|
|
85
|
+
const campaign = {
|
|
86
|
+
...campaignData,
|
|
87
|
+
creator: campaignData.creatorAddress,
|
|
88
|
+
chainId: campaignData.distributionChainId,
|
|
89
|
+
rewardTokenAddress: campaignData.RewardToken.address,
|
|
90
|
+
opportunityIdentifier: opp.identifier,
|
|
91
|
+
subType: campaignData.subType ?? undefined,
|
|
92
|
+
type: Campaign[campaignData.type],
|
|
93
|
+
params: JSON.stringify(campaignData.params),
|
|
94
|
+
startTimestamp: campaignData.startTimestamp.toString(),
|
|
95
|
+
endTimestamp: campaignData.endTimestamp.toString(),
|
|
96
|
+
};
|
|
97
|
+
const metadata = await OpportunityService.getMetadata(campaign);
|
|
98
|
+
if (opp.name !== metadata.name) {
|
|
99
|
+
log.info(`updating opportunity ${opp.id} name from ${opp.name} to ${metadata.name}`);
|
|
100
|
+
await OpportunityRepository.updateName(opp.id, metadata.name);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
log.error(`failed to update opportunity ${opp.id} name`, err);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
78
108
|
static async updateMetadata(chain) {
|
|
79
109
|
try {
|
|
80
110
|
const opportunities = await OpportunityRepository.findManyWithCampaigns({
|
|
@@ -22,7 +22,7 @@ export const getClammMetadata = (chainId, params) => {
|
|
|
22
22
|
platform = "iZUMi";
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
|
-
name:
|
|
25
|
+
name: `Provide liquidity to ${params.symbolToken0}-${params.symbolToken1}${params.poolFee ? ` ${params.poolFee}%` : ""}`,
|
|
26
26
|
action: OpportunityAction.POOL,
|
|
27
27
|
tokens: [
|
|
28
28
|
{ chainId, address: params.token0 },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpportunityAction } from "../../../../../database/api/.generated";
|
|
2
2
|
export const getDolomiteMetadata = (chainId, campaignSubType, params) => {
|
|
3
3
|
const subtypes = [
|
|
4
|
-
{ name: "
|
|
4
|
+
{ name: "Supply (delta)", action: OpportunityAction.LEND },
|
|
5
5
|
{ name: "Supply", action: OpportunityAction.LEND },
|
|
6
6
|
{ name: "Borrow", action: OpportunityAction.BORROW },
|
|
7
7
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpportunityAction } from "../../../../../database/api/.generated";
|
|
2
2
|
export const getErc20SnapshotMetadata = (chainId, params) => {
|
|
3
3
|
return {
|
|
4
|
-
name: ["
|
|
4
|
+
name: ["Get", params.symbolTargetToken, "airdrop"].join(" "),
|
|
5
5
|
action: OpportunityAction.DROP,
|
|
6
6
|
tokens: [{ chainId, address: params.targetToken }],
|
|
7
7
|
};
|
|
@@ -3,9 +3,9 @@ import { OpportunityAction } from "../../../../../database/api/.generated";
|
|
|
3
3
|
export const getJsonAirdropMetadata = async (chainId, creator, params) => {
|
|
4
4
|
const ACI = "0xdeadD8aB03075b7FBA81864202a2f59EE25B312b".toLowerCase();
|
|
5
5
|
const aaveDAO = "0x5300A1a15135EA4dc7aD5a167152C01EFc9b192A".toLowerCase();
|
|
6
|
-
const aciPrefix = creator.toLowerCase() === ACI && "
|
|
7
|
-
const aavePrefix = creator.toLowerCase() === aaveDAO && "
|
|
8
|
-
const prefix = aavePrefix ? aavePrefix : aciPrefix ? aciPrefix : "
|
|
6
|
+
const aciPrefix = creator.toLowerCase() === ACI && "Get Merit rewards -";
|
|
7
|
+
const aavePrefix = creator.toLowerCase() === aaveDAO && "Get aAMPL distribution -";
|
|
8
|
+
const prefix = aavePrefix ? aavePrefix : aciPrefix ? aciPrefix : "Get airdrop in";
|
|
9
9
|
let tokenAddress;
|
|
10
10
|
try {
|
|
11
11
|
const res = await fetch(params.jsonUrl);
|
|
@@ -4,10 +4,10 @@ export const getMorphoMetadata = (chainId, campaignSubType, params) => {
|
|
|
4
4
|
const morphoParams = params;
|
|
5
5
|
const market = `${morphoParams.symbolLoanToken}/${morphoParams.symbolBorrowToken} ${morphoParams?.LLTV && BN2Number(morphoParams?.LLTV, 16)}%`;
|
|
6
6
|
const subtypes = [
|
|
7
|
-
{ name: `
|
|
7
|
+
{ name: `Deposit in ${morphoParams.nameTargetToken} - Metamorpho`, action: OpportunityAction.LEND },
|
|
8
8
|
{ name: `Supply ${morphoParams.symbolLoanToken} on ${market}`, action: OpportunityAction.LEND },
|
|
9
9
|
{ name: `Borrow ${morphoParams.symbolLoanToken} on ${market}`, action: OpportunityAction.BORROW },
|
|
10
|
-
{ name: `
|
|
10
|
+
{ name: `Lend ${morphoParams.symbolBorrowToken} on ${market}`, action: OpportunityAction.LEND },
|
|
11
11
|
];
|
|
12
12
|
const subtype = subtypes[campaignSubType];
|
|
13
13
|
return {
|
|
@@ -2,7 +2,7 @@ import { OpportunityAction } from "../../../../../database/api/.generated";
|
|
|
2
2
|
export const getRadiantMetadata = (chainId, campaignSubType, params) => {
|
|
3
3
|
return {
|
|
4
4
|
action: campaignSubType <= 1 ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
|
5
|
-
name: ["
|
|
5
|
+
name: [campaignSubType <= 1 ? "Lend" : "Borrow", params.symbolTargetToken].join(" "),
|
|
6
6
|
tokens: [{ chainId, address: params.targetToken }],
|
|
7
7
|
mainProtocol: "radiant",
|
|
8
8
|
};
|
|
@@ -6,7 +6,7 @@ export const getSiloMetadata = (chainId, campaignSubType, params) => {
|
|
|
6
6
|
suffix += ` (${assetSymbol} Market)`;
|
|
7
7
|
return {
|
|
8
8
|
action: campaignSubType <= 1 ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
|
9
|
-
name: ["
|
|
9
|
+
name: [campaignSubType <= 1 ? "Lend" : "Borrow", params.symbolTargetToken, suffix].join(" "),
|
|
10
10
|
tokens: [{ chainId, address: params.targetToken }],
|
|
11
11
|
mainProtocol: "silo",
|
|
12
12
|
};
|
|
@@ -35,6 +35,7 @@ export const PriceController = new Elysia({ prefix: "/prices", detail: { tags: [
|
|
|
35
35
|
headers: AuthorizationHeadersDto,
|
|
36
36
|
body: CreatePriceSourceDto,
|
|
37
37
|
beforeHandle: BackOfficeGuard,
|
|
38
|
+
detail: { hide: true },
|
|
38
39
|
})
|
|
39
40
|
// ─── Update A Price Source ───────────────────
|
|
40
41
|
.patch("/symbol/:symbol", async ({ params, body }) => await PriceService.updatePriceSource(params.symbol, body), {
|
|
@@ -42,11 +43,13 @@ export const PriceController = new Elysia({ prefix: "/prices", detail: { tags: [
|
|
|
42
43
|
params: PriceSourceIdentifier,
|
|
43
44
|
body: UpdatePriceSourceDto,
|
|
44
45
|
beforeHandle: BackOfficeGuard,
|
|
46
|
+
detail: { hide: true },
|
|
45
47
|
})
|
|
46
48
|
// ─── Delete A Price Source ───────────────────
|
|
47
49
|
.delete("/symbol/:symbol", async ({ params }) => await PriceService.deletePriceSource(params.symbol), {
|
|
48
50
|
headers: AuthorizationHeadersDto,
|
|
49
51
|
params: PriceSourceIdentifier,
|
|
50
52
|
beforeHandle: BackOfficeGuard,
|
|
53
|
+
detail: { hide: true },
|
|
51
54
|
}));
|
|
52
55
|
});
|