@merkl/api 0.10.177 → 0.10.181
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 +348 -63
- package/dist/src/index.d.ts +140 -21
- package/dist/src/index.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +2 -2
- package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicDataRefacto.js +3 -3
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +4 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.d.ts +1 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/AuraProcessor.js +12 -3
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleProcessor.d.ts +1 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleProcessor.js +1 -3
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/StakingProcessor.d.ts +39 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/StakingProcessor.js +45 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.d.ts +2 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.js +25 -1
- 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 +140 -21
- package/dist/src/modules/v4/router.js +2 -2
- package/dist/src/modules/v4/token/token.controller.d.ts +38 -4
- 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 +18 -5
- package/dist/src/modules/v4/token/token.service.js +9 -2
- package/dist/src/routes/v3/blacklist.d.ts +140 -21
- package/dist/src/routes/v3/campaigns.d.ts +140 -21
- package/dist/src/routes/v3/campaignsInfo.d.ts +140 -21
- package/dist/src/routes/v3/multiChainPositions.d.ts +140 -21
- package/dist/src/routes/v3/opportunity.d.ts +140 -21
- package/dist/src/routes/v3/positions.d.ts +140 -21
- package/dist/src/routes/v3/rewards.d.ts +140 -21
- package/dist/src/routes/v3/updates.d.ts +140 -21
- package/dist/src/routes/v3/userRewards.d.ts +140 -21
- package/dist/src/utils/decodeCalls.js +5 -1
- package/dist/src/utils/encodeCalls.js +13 -1
- package/dist/src/utils/generateCardName.js +3 -1
- 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
@@ -98,6 +98,30 @@ export declare const ChainController: Elysia<"/chains", false, {
|
|
98
98
|
};
|
99
99
|
};
|
100
100
|
};
|
101
|
+
} & {
|
102
|
+
chains: {
|
103
|
+
":chainId": {
|
104
|
+
patch: {
|
105
|
+
body: {
|
106
|
+
icon?: string | undefined;
|
107
|
+
};
|
108
|
+
params: {
|
109
|
+
chainId: number;
|
110
|
+
};
|
111
|
+
query: unknown;
|
112
|
+
headers: {
|
113
|
+
authorization: string;
|
114
|
+
};
|
115
|
+
response: {
|
116
|
+
200: {
|
117
|
+
name: string;
|
118
|
+
id: number;
|
119
|
+
icon: string;
|
120
|
+
};
|
121
|
+
};
|
122
|
+
};
|
123
|
+
};
|
124
|
+
};
|
101
125
|
}, {
|
102
126
|
derive: {};
|
103
127
|
resolve: {};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { AuthorizationHeadersDto } from "../../../guards/BackOffice.guard";
|
1
|
+
import { AuthorizationHeadersDto, BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
2
|
import { TokenAuthGuard } from "../../../guards/TokenAuth.guard";
|
3
3
|
import Elysia from "elysia";
|
4
4
|
import { ExplorerService } from "../explorer";
|
5
|
-
import { ChainUniqueDto, CreateChainExplorerDto, GetChainQueryDto } from "./chain.model";
|
5
|
+
import { ChainUniqueDto, CreateChainExplorerDto, GetChainQueryDto, UpdateChainDto } from "./chain.model";
|
6
6
|
import { ChainService } from "./chain.service";
|
7
7
|
// ─── Chains Controller ───────────────────────────────────────────────────────
|
8
8
|
export const ChainController = new Elysia({ prefix: "/chains", detail: { tags: ["Chains"] } })
|
@@ -35,4 +35,10 @@ export const ChainController = new Elysia({ prefix: "/chains", detail: { tags: [
|
|
35
35
|
body: CreateChainExplorerDto,
|
36
36
|
detail: { hide: true },
|
37
37
|
});
|
38
|
+
})
|
39
|
+
.patch("/:chainId", async ({ params, body }) => await ChainService.update(params.chainId, body), {
|
40
|
+
params: ChainUniqueDto,
|
41
|
+
body: UpdateChainDto,
|
42
|
+
headers: AuthorizationHeadersDto,
|
43
|
+
beforeHandle: BackOfficeGuard,
|
38
44
|
});
|
@@ -22,6 +22,10 @@ export declare const CreateChainExplorerDto: import("@sinclair/typebox").TObject
|
|
22
22
|
chainId: import("@sinclair/typebox").TNumber;
|
23
23
|
url: import("@sinclair/typebox").TString;
|
24
24
|
}>;
|
25
|
+
export declare const UpdateChainDto: import("@sinclair/typebox").TObject<{
|
26
|
+
icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
27
|
+
}>;
|
25
28
|
export type ChainUniqueModel = typeof ChainUniqueDto.static;
|
26
29
|
export type ChainSearchDto = typeof GetChainQueryDto.static;
|
27
30
|
export type ChainsArrayModel = typeof ChainArrayDto.static;
|
31
|
+
export type UpdateChainModel = typeof UpdateChainDto.static;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Campaign, CampaignParameters } from "@sdk";
|
2
|
-
import type { Chain, ChainSearchDto } from "./chain.model";
|
2
|
+
import type { Chain, ChainSearchDto, UpdateChainModel } from "./chain.model";
|
3
3
|
export declare abstract class ChainRepository {
|
4
4
|
#private;
|
5
5
|
/**
|
@@ -63,4 +63,9 @@ export declare abstract class ChainRepository {
|
|
63
63
|
* @returns
|
64
64
|
*/
|
65
65
|
static fetchDynamicDataV3<CampaignType extends Campaign>(chainId: number, campaignType: CampaignType, campaigns: CampaignParameters<CampaignType>[]): Promise<any>;
|
66
|
+
static update(id: number, data: UpdateChainModel): Promise<{
|
67
|
+
name: string;
|
68
|
+
id: number;
|
69
|
+
icon: string;
|
70
|
+
}>;
|
66
71
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ChainSearchDto } from "./chain.model";
|
1
|
+
import type { ChainSearchDto, UpdateChainModel } from "./chain.model";
|
2
2
|
export declare abstract class ChainService {
|
3
3
|
static get(chainId: number): Promise<({
|
4
4
|
Explorer: {
|
@@ -39,4 +39,9 @@ export declare abstract class ChainService {
|
|
39
39
|
* @returns an array of chainId
|
40
40
|
*/
|
41
41
|
static getSupportedIds(): Promise<number[]>;
|
42
|
+
static update(id: number, data: UpdateChainModel): Promise<{
|
43
|
+
name: string;
|
44
|
+
id: number;
|
45
|
+
icon: string;
|
46
|
+
}>;
|
42
47
|
}
|
@@ -39,4 +39,11 @@ export class ChainService {
|
|
39
39
|
}
|
40
40
|
return supportedIds;
|
41
41
|
}
|
42
|
+
static async update(id, data) {
|
43
|
+
// let iconUri = data.icon;
|
44
|
+
// if (data.iconFile) {
|
45
|
+
// iconUri = await BucketService.upload("merkl-assets", `/chains/${id}`, data.iconFile.stream(), true);
|
46
|
+
// }
|
47
|
+
return await ChainRepository.update(id, data);
|
48
|
+
}
|
42
49
|
}
|
@@ -12,7 +12,7 @@ export declare abstract class EnsoService {
|
|
12
12
|
id: string;
|
13
13
|
tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
|
14
14
|
icon: string;
|
15
|
-
} & {})[]
|
15
|
+
} & {})[]>;
|
16
16
|
static getTokens(chainId: number, slug: EnsoSlug, identifier?: string): Promise<{
|
17
17
|
type: "base" | "defi";
|
18
18
|
chainId: number;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher } from "../
|
3
|
+
import type { PositionFetcher } from "../liquidity.model";
|
4
4
|
export declare class AjnaPositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<import("..").PositionT[]>;
|
6
6
|
}
|
package/dist/src/modules/v4/{position → liquidity}/implementations/BadgerPositionFetcher.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher, PositionT } from "../
|
3
|
+
import type { PositionFetcher, PositionT } from "../liquidity.model";
|
4
4
|
export declare class BadgerPositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<PositionT[]>;
|
6
6
|
}
|
package/dist/src/modules/v4/{position → liquidity}/implementations/ClammPositionFetcher.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher, PositionT } from "../
|
3
|
+
import type { PositionFetcher, PositionT } from "../liquidity.model";
|
4
4
|
export declare class ClammPositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<PositionT[]>;
|
6
6
|
}
|
package/dist/src/modules/v4/{position → liquidity}/implementations/DolomitePositionFetcher.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher } from "../
|
3
|
+
import type { PositionFetcher } from "../liquidity.model";
|
4
4
|
export declare class DolomitePositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<import("..").PositionT[]>;
|
6
6
|
}
|
package/dist/src/modules/v4/{position → liquidity}/implementations/DolomitePositionFetcher.js
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { Campaign } from "@sdk";
|
2
2
|
import { utils } from "ethers";
|
3
3
|
import { CampaignService } from "../../campaign";
|
4
|
-
import {
|
4
|
+
import { LiquidityRepository } from "../liquidity.repository";
|
5
5
|
const campaignType = Campaign.DOLOMITE;
|
6
6
|
export class DolomitePositionFetcher {
|
7
7
|
fetchPositions = async (chainId, user, opportunities) => {
|
8
8
|
opportunities = opportunities.filter(o => o.type === Campaign[campaignType] && o.tokens?.length > 0 && o.chainId === chainId);
|
9
|
-
const dolomitePositions = await
|
9
|
+
const dolomitePositions = await LiquidityRepository.findManyDolomitePositions(chainId, user);
|
10
10
|
// Generic calls
|
11
11
|
for (const opportunity of opportunities) {
|
12
12
|
// Call per opportunity
|
package/dist/src/modules/v4/{position → liquidity}/implementations/ERC20PositionFetcher.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher, PositionT } from "../
|
3
|
+
import type { PositionFetcher, PositionT } from "../liquidity.model";
|
4
4
|
export declare class ERC20PositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<PositionT[]>;
|
6
6
|
}
|
package/dist/src/modules/v4/{position → liquidity}/implementations/EulerPositionFetcher.d.ts
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { Opportunity } from "../../opportunity";
|
3
|
-
import type { PositionFetcher, PositionT } from "../
|
3
|
+
import type { PositionFetcher, PositionT } from "../liquidity.model";
|
4
4
|
export declare class EulerPositionFetcher implements PositionFetcher {
|
5
5
|
fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<PositionT[]>;
|
6
6
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Elysia } from "elysia";
|
2
|
-
export declare const
|
2
|
+
export declare const LiquidityController: Elysia<"/liquidity", false, {
|
3
3
|
decorator: {};
|
4
4
|
store: {};
|
5
5
|
derive: {};
|
@@ -12,7 +12,7 @@ export declare const PositionController: Elysia<"/positions", false, {
|
|
12
12
|
macro: {};
|
13
13
|
macroFn: {};
|
14
14
|
}, {
|
15
|
-
|
15
|
+
liquidity: {
|
16
16
|
index: {
|
17
17
|
get: {
|
18
18
|
body: unknown;
|
@@ -23,7 +23,7 @@ export declare const PositionController: Elysia<"/positions", false, {
|
|
23
23
|
};
|
24
24
|
headers: unknown;
|
25
25
|
response: {
|
26
|
-
200:
|
26
|
+
200: import("./liquidity.model").PositionT[];
|
27
27
|
};
|
28
28
|
};
|
29
29
|
};
|
package/dist/src/modules/v4/{position/position.controller.js → liquidity/liquidity.controller.js}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
|
2
2
|
import { Elysia } from "elysia";
|
3
|
-
import { PositionsInputDto } from "./
|
4
|
-
import {
|
3
|
+
import { PositionsInputDto } from "./liquidity.model";
|
4
|
+
import { LiquidityService } from "./liquidity.service";
|
5
5
|
// ─── Positions Controller ──────────────────────────────────────────────
|
6
|
-
export const
|
6
|
+
export const LiquidityController = new Elysia({ prefix: "/liquidity", detail: { tags: ["Positions"] } })
|
7
7
|
// ─── Get User Positions on a Chain ───────────────────────────────────
|
8
8
|
.get("/", async ({ query }) => {
|
9
|
-
return await
|
9
|
+
return await LiquidityService.fetchPositions(query);
|
10
10
|
}, {
|
11
11
|
query: PositionsInputDto,
|
12
12
|
beforeHandle: ({ query }) => {
|
@@ -7,7 +7,7 @@ import { ClammPositionFetcher } from "./implementations/ClammPositionFetcher";
|
|
7
7
|
import { DolomitePositionFetcher } from "./implementations/DolomitePositionFetcher";
|
8
8
|
import { ERC20PositionFetcher } from "./implementations/ERC20PositionFetcher";
|
9
9
|
import { EulerPositionFetcher } from "./implementations/EulerPositionFetcher";
|
10
|
-
export class
|
10
|
+
export class LiquidityService {
|
11
11
|
static #fetchers = {
|
12
12
|
[Campaign.ERC20]: new ERC20PositionFetcher(),
|
13
13
|
[Campaign.EULER]: new EulerPositionFetcher(),
|
@@ -20,7 +20,7 @@ export class PositionService {
|
|
20
20
|
const opportunities = await OpportunityService.findLiveWithFirstCampaign(query.chainId);
|
21
21
|
const promises = [];
|
22
22
|
for (const campaignType of Object.keys(Campaign)) {
|
23
|
-
const fetcher =
|
23
|
+
const fetcher = LiquidityService.#fetchers[Number.parseInt(campaignType)];
|
24
24
|
if (fetcher) {
|
25
25
|
promises.push(withTimeout(fetcher.fetchPositions(query.chainId, query.address, opportunities.filter(o => !!o)), MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT));
|
26
26
|
}
|
@@ -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 {};
|