@merkl/api 0.10.168 → 0.10.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/api/.generated/edge.js +6 -3
- package/dist/database/api/.generated/index-browser.js +3 -0
- package/dist/database/api/.generated/index.d.ts +113 -0
- package/dist/database/api/.generated/index.js +6 -3
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/schema.prisma +17 -15
- package/dist/database/api/.generated/wasm.js +3 -0
- package/dist/src/cache/declaration.d.ts +0 -30
- package/dist/src/cache/declaration.js +0 -30
- package/dist/src/eden/index.d.ts +167 -15
- package/dist/src/index.d.ts +59 -5
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +2 -2
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/factoryFinder.js +2 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +3 -1
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +8 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleYTProcessor.d.ts +29 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/PendleYTProcessor.js +31 -0
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +3 -0
- package/dist/src/libs/positions/clamm/index.d.ts +1 -2
- package/dist/src/libs/positions/clamm/index.js +322 -330
- package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.d.ts +1 -1
- package/dist/src/libs/positions/clamm/thegraph/fetchAlmPositions.js +1 -1
- package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.d.ts +1 -1
- package/dist/src/libs/positions/clamm/thegraph/fetchAmmPositions.js +2 -2
- package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.d.ts +1 -2
- package/dist/src/libs/positions/clamm/thegraph/fetchFarmedPositions.js +1 -4
- package/dist/src/libs/positions/euler/index.js +2 -3
- package/dist/src/libs/positions/index.js +1 -1
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +6 -2
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +1 -0
- package/dist/src/modules/v4/campaign/campaign.model.js +1 -0
- package/dist/src/modules/v4/campaign/campaign.repository.d.ts +2 -0
- package/dist/src/modules/v4/campaign/campaign.repository.js +2 -1
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +10 -5
- package/dist/src/modules/v4/campaign/campaign.service.js +10 -2
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +20 -3
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +2 -1
- package/dist/src/modules/v4/opportunity/opportunity.model.js +1 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +83 -5
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +31 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +162 -8
- package/dist/src/modules/v4/opportunity/opportunity.service.js +11 -0
- package/dist/src/modules/v4/position/implementations/AjnaPositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/AjnaPositionFetcher.js +90 -0
- package/dist/src/modules/v4/position/implementations/BadgerPositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/BadgerPositionFetcher.js +69 -0
- package/dist/src/modules/v4/position/implementations/ClammPositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/ClammPositionFetcher.js +71 -0
- package/dist/src/modules/v4/position/implementations/DolomitePositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/DolomitePositionFetcher.js +45 -0
- package/dist/src/modules/v4/position/implementations/ERC20PositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/ERC20PositionFetcher.js +47 -0
- package/dist/src/modules/v4/position/implementations/EulerPositionFetcher.d.ts +6 -0
- package/dist/src/modules/v4/position/implementations/EulerPositionFetcher.js +40 -0
- package/dist/src/modules/v4/position/index.d.ts +2 -0
- package/dist/src/modules/v4/position/index.js +2 -0
- package/dist/src/modules/v4/position/position.controller.d.ts +39 -0
- package/dist/src/modules/v4/position/position.controller.js +16 -0
- package/dist/src/modules/v4/position/position.model.d.ts +25 -0
- package/dist/src/modules/v4/position/position.model.js +5 -0
- package/dist/src/modules/v4/position/position.repository.d.ts +14 -0
- package/dist/src/modules/v4/position/position.repository.js +6 -0
- package/dist/src/modules/v4/position/position.service.d.ts +5 -0
- package/dist/src/modules/v4/position/position.service.js +34 -0
- package/dist/src/modules/v4/price/price.controller.js +1 -1
- package/dist/src/modules/v4/price/price.service.d.ts +1 -1
- package/dist/src/modules/v4/price/price.service.js +3 -3
- package/dist/src/modules/v4/reward/reward.repository.d.ts +4 -0
- package/dist/src/modules/v4/reward/reward.service.d.ts +27 -0
- package/dist/src/modules/v4/reward/reward.service.js +5 -2
- package/dist/src/modules/v4/router.d.ts +59 -5
- package/dist/src/modules/v4/router.js +3 -1
- package/dist/src/modules/v4/token/token.controller.d.ts +6 -0
- package/dist/src/modules/v4/token/token.service.d.ts +12 -0
- package/dist/src/modules/v4/user/user.controller.d.ts +8 -0
- package/dist/src/routes/v1/prices.js +2 -4
- package/dist/src/routes/v3/blacklist.d.ts +59 -5
- package/dist/src/routes/v3/campaigns.d.ts +60 -6
- package/dist/src/routes/v3/campaignsInfo.d.ts +59 -5
- package/dist/src/routes/v3/multiChainPositions.d.ts +59 -5
- package/dist/src/routes/v3/opportunity.d.ts +59 -5
- package/dist/src/routes/v3/positions.d.ts +59 -5
- package/dist/src/routes/v3/recipients.d.ts +6 -2
- package/dist/src/routes/v3/recipients.js +14 -8
- package/dist/src/routes/v3/rewards.d.ts +59 -5
- package/dist/src/routes/v3/updates.d.ts +59 -5
- package/dist/src/routes/v3/userRewards.d.ts +59 -5
- package/dist/src/utils/decodeCalls.js +4 -1
- package/dist/src/utils/encodeCalls.js +4 -1
- package/dist/src/utils/generateCardName.js +2 -0
- package/dist/src/utils/prices/services/erc4626Service.js +10 -4
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/libs/reports/campaignReport.d.ts +0 -9
- package/dist/src/libs/reports/campaignReport.js +0 -37
- package/dist/src/libs/reports/mainParameterRewards.d.ts +0 -3
- package/dist/src/libs/reports/mainParameterRewards.js +0 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
|
2
2
|
import { BigNumber } from "ethers";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function fetchAlmPositions(chainId: MerklChainId, user: string): Promise<{
|
|
4
4
|
[token: string]: BigNumber;
|
|
5
5
|
}>;
|
|
@@ -4,7 +4,7 @@ import { request } from "graphql-request";
|
|
|
4
4
|
import { almBalancesQuery, almNFTBalancesQuery } from ".";
|
|
5
5
|
import { MERKL_USER_POSITION_FETCHING_TIMEOUT } from "../../../../constants";
|
|
6
6
|
import { log } from "../../../../utils/logger";
|
|
7
|
-
export async function
|
|
7
|
+
export async function fetchAlmPositions(chainId, user) {
|
|
8
8
|
const res = {};
|
|
9
9
|
const availableALMEndpoints = merklSubgraphALMEndpoints[chainId];
|
|
10
10
|
if (Object.keys(availableALMEndpoints).length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AMM, type ANGLE_NETWORKS } from "@sdk";
|
|
2
2
|
import { type PositionType } from ".";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function fetchAmmPositions(chainId: (typeof ANGLE_NETWORKS.merkl)[number], user: string, amms: AMM[]): Promise<{
|
|
4
4
|
[amm in AMM]?: {
|
|
5
5
|
nft: PositionType[];
|
|
6
6
|
direct: PositionType[];
|
|
@@ -3,7 +3,7 @@ import { request } from "graphql-request";
|
|
|
3
3
|
import { positionsQuery } from ".";
|
|
4
4
|
import { MERKL_USER_POSITION_FETCHING_TIMEOUT } from "../../../../constants";
|
|
5
5
|
import { log } from "../../../../utils/logger";
|
|
6
|
-
export async function
|
|
6
|
+
export async function fetchAmmPositions(chainId, user, amms) {
|
|
7
7
|
const res = {};
|
|
8
8
|
const promises = amms.map(async (amm) => {
|
|
9
9
|
const tgURL = merklSubgraphAMMEndpoints[chainId][amm];
|
|
@@ -12,7 +12,7 @@ export async function fetchAmmPositionsV2(chainId, user, amms) {
|
|
|
12
12
|
owner: user?.toLowerCase(),
|
|
13
13
|
}), MERKL_USER_POSITION_FETCHING_TIMEOUT)
|
|
14
14
|
.then(fetchedData => {
|
|
15
|
-
res[amm] = {};
|
|
15
|
+
res[amm] = { nft: [], direct: [] };
|
|
16
16
|
res[amm].nft = fetchedData?.nft?.reduce((prev, curr) => {
|
|
17
17
|
if (!prev.map(i => i.id).includes(curr.id))
|
|
18
18
|
prev.push(curr);
|
|
@@ -7,5 +7,4 @@ export type FarmPositionsType = {
|
|
|
7
7
|
holder: string;
|
|
8
8
|
}[];
|
|
9
9
|
};
|
|
10
|
-
export declare function
|
|
11
|
-
export declare const fetchFarmedPositionsV2WithCache: (chainId: MerklChainId, user: string[], amm: AMM) => Promise<any>;
|
|
10
|
+
export declare function fetchFarmedPositions(chainId: MerklChainId, owners: string[], amm: AMM): Promise<FarmPositionsType>;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Redis } from "../../../../cache";
|
|
2
1
|
import { MERKL_USER_POSITION_FETCHING_TIMEOUT } from "../../../../constants";
|
|
3
|
-
import { hashArray } from "../../../../utils/hashArray";
|
|
4
2
|
import { AMM, NETWORK_LABELS, getSupportedNFPWrapperMapping, merklSubgraphNFPWrapperEndpoints, withTimeout, } from "@sdk";
|
|
5
3
|
import { request } from "graphql-request";
|
|
6
4
|
import { nftWrapperPositionsQuery } from ".";
|
|
7
5
|
import { log } from "../../../../utils/logger";
|
|
8
|
-
export async function
|
|
6
|
+
export async function fetchFarmedPositions(chainId, owners, amm) {
|
|
9
7
|
const res = {};
|
|
10
8
|
const promises = getSupportedNFPWrapperMapping(chainId, amm).map(async (wrapper) => {
|
|
11
9
|
const tgURL = merklSubgraphNFPWrapperEndpoints[chainId][wrapper];
|
|
@@ -41,4 +39,3 @@ export async function fetchFarmedPositionsV2(chainId, owners, amm) {
|
|
|
41
39
|
await Promise.all(promises);
|
|
42
40
|
return res;
|
|
43
41
|
}
|
|
44
|
-
export const fetchFarmedPositionsV2WithCache = async (chainId, user, amm) => await Redis.getOrSet(`FarmedPositions_${hashArray(chainId, user, amm)}$`, fetchFarmedPositionsV2, chainId, user, amm);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BN2Number, Campaign, ERC20Interface
|
|
1
|
+
import { BN2Number, Campaign, ERC20Interface } from "@sdk";
|
|
2
2
|
import { getAddress } from "ethers/lib/utils";
|
|
3
|
-
const EulerVaultInterface = EulerVault__factory.createInterface();
|
|
4
3
|
export async function getEulerUserPositions(user, _chainId, tokens) {
|
|
5
4
|
/**
|
|
6
5
|
* Fetch user positions
|
|
@@ -9,7 +8,7 @@ export async function getEulerUserPositions(user, _chainId, tokens) {
|
|
|
9
8
|
for (const token of Object.keys(tokens)) {
|
|
10
9
|
calls.push({
|
|
11
10
|
allowFailure: true,
|
|
12
|
-
callData:
|
|
11
|
+
callData: ERC20Interface.encodeFunctionData("balanceOf", [user]),
|
|
13
12
|
target: token,
|
|
14
13
|
});
|
|
15
14
|
}
|
|
@@ -17,7 +17,7 @@ chainId, user) {
|
|
|
17
17
|
const numkey = Number(key);
|
|
18
18
|
switch (numkey) {
|
|
19
19
|
case Campaign.CLAMM:
|
|
20
|
-
promises.push(withTimeout(
|
|
20
|
+
promises.push(withTimeout(getClammUserPositions(user, chainId, positionsToCheck[numkey]), MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT));
|
|
21
21
|
break;
|
|
22
22
|
case Campaign.ERC20:
|
|
23
23
|
promises.push(withTimeout(executeSimple(chainId, getERC20UserPositions(user, chainId, positionsToCheck[numkey])), MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT));
|
|
@@ -72,10 +72,11 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
|
72
72
|
campaignId?: string | undefined;
|
|
73
73
|
opportunityId?: string | undefined;
|
|
74
74
|
tokenSymbol?: string | undefined;
|
|
75
|
+
test?: boolean | undefined;
|
|
75
76
|
};
|
|
76
77
|
headers: unknown;
|
|
77
78
|
response: {
|
|
78
|
-
200:
|
|
79
|
+
200: {
|
|
79
80
|
params: any;
|
|
80
81
|
chain: {
|
|
81
82
|
name: string;
|
|
@@ -90,7 +91,9 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
|
90
91
|
address: string;
|
|
91
92
|
icon: string;
|
|
92
93
|
decimals: number;
|
|
94
|
+
displaySymbol: string;
|
|
93
95
|
verified: boolean;
|
|
96
|
+
isTest: boolean;
|
|
94
97
|
price: number | null;
|
|
95
98
|
};
|
|
96
99
|
distributionChain: {
|
|
@@ -118,7 +121,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
|
118
121
|
amount: string;
|
|
119
122
|
opportunityId: string;
|
|
120
123
|
creatorAddress: string;
|
|
121
|
-
}
|
|
124
|
+
}[];
|
|
122
125
|
};
|
|
123
126
|
};
|
|
124
127
|
};
|
|
@@ -140,6 +143,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
|
140
143
|
campaignId?: string | undefined;
|
|
141
144
|
opportunityId?: string | undefined;
|
|
142
145
|
tokenSymbol?: string | undefined;
|
|
146
|
+
test?: boolean | undefined;
|
|
143
147
|
};
|
|
144
148
|
headers: unknown;
|
|
145
149
|
response: {
|
|
@@ -77,6 +77,7 @@ export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
|
|
|
77
77
|
mainParameter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
78
78
|
tokenSymbol: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
79
79
|
tokenAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
80
|
+
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
80
81
|
opportunityId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
81
82
|
startTimestamp: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
82
83
|
endTimestamp: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -48,6 +48,7 @@ export const GetCampaignQueryDto = t.Object({
|
|
|
48
48
|
mainParameter: t.Optional(t.String()),
|
|
49
49
|
tokenSymbol: t.Optional(t.String()),
|
|
50
50
|
tokenAddress: t.Optional(t.String()),
|
|
51
|
+
test: t.Optional(t.Boolean()),
|
|
51
52
|
opportunityId: t.Optional(t.String()),
|
|
52
53
|
startTimestamp: t.Optional(t.String({ pattern: "[0-9].*" })),
|
|
53
54
|
endTimestamp: t.Optional(t.String({ pattern: "[0-9].*" })),
|
|
@@ -10,7 +10,7 @@ import { TokenService } from "../token";
|
|
|
10
10
|
export class CampaignRepository {
|
|
11
11
|
// ─── Private Methods ─────────────────────────────────────────────────
|
|
12
12
|
static #transformQueryToPrismaFilters(query) {
|
|
13
|
-
const { chainId, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, subType, type, tokenAddress, tokenSymbol, } = query;
|
|
13
|
+
const { chainId, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, subType, type, tokenAddress, tokenSymbol, test, } = query;
|
|
14
14
|
return {
|
|
15
15
|
where: {
|
|
16
16
|
computeChainId: chainId,
|
|
@@ -26,6 +26,7 @@ export class CampaignRepository {
|
|
|
26
26
|
RewardToken: {
|
|
27
27
|
address: tokenAddress ? tokenAddress : undefined,
|
|
28
28
|
symbol: tokenSymbol ? tokenSymbol : undefined,
|
|
29
|
+
isTest: !test ? false : undefined,
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CampaignUnique, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel } from "./";
|
|
1
|
+
import { type Campaign, type CampaignUnique, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel } from "./";
|
|
2
2
|
import { CampaignRepository } from "./campaign.repository";
|
|
3
3
|
import type { CampaignType } from "../../../../database/api/.generated";
|
|
4
4
|
import { type CampaignParameters, type Campaign as CampaignTypeV3, type ChainId } from "@sdk";
|
|
@@ -28,7 +28,7 @@ export declare abstract class CampaignService {
|
|
|
28
28
|
* @param query
|
|
29
29
|
* @returns A list of campaigns
|
|
30
30
|
*/
|
|
31
|
-
static findMany(query: GetCampaignQueryModel): Promise<
|
|
31
|
+
static findMany(query: GetCampaignQueryModel): Promise<{
|
|
32
32
|
params: any;
|
|
33
33
|
chain: {
|
|
34
34
|
name: string;
|
|
@@ -43,7 +43,9 @@ export declare abstract class CampaignService {
|
|
|
43
43
|
address: string;
|
|
44
44
|
icon: string;
|
|
45
45
|
decimals: number;
|
|
46
|
+
displaySymbol: string;
|
|
46
47
|
verified: boolean;
|
|
48
|
+
isTest: boolean;
|
|
47
49
|
price: number | null;
|
|
48
50
|
};
|
|
49
51
|
distributionChain: {
|
|
@@ -71,7 +73,7 @@ export declare abstract class CampaignService {
|
|
|
71
73
|
amount: string;
|
|
72
74
|
opportunityId: string;
|
|
73
75
|
creatorAddress: string;
|
|
74
|
-
}
|
|
76
|
+
}[]>;
|
|
75
77
|
/**
|
|
76
78
|
* Counts the number of campaigns that complies to query
|
|
77
79
|
* @description used for pagination purposes
|
|
@@ -160,7 +162,7 @@ export declare abstract class CampaignService {
|
|
|
160
162
|
* @returns A list of opportunities
|
|
161
163
|
* TODO: remove this function in favor of prisma client extensions
|
|
162
164
|
*/
|
|
163
|
-
static format(campaign: NonNullable<Awaited<ReturnType<typeof CampaignRepository.findMany>>>[number]
|
|
165
|
+
static format(campaign: NonNullable<Awaited<ReturnType<typeof CampaignRepository.findMany>>>[number]): {
|
|
164
166
|
params: any;
|
|
165
167
|
chain: {
|
|
166
168
|
name: string;
|
|
@@ -175,7 +177,9 @@ export declare abstract class CampaignService {
|
|
|
175
177
|
address: string;
|
|
176
178
|
icon: string;
|
|
177
179
|
decimals: number;
|
|
180
|
+
displaySymbol: string;
|
|
178
181
|
verified: boolean;
|
|
182
|
+
isTest: boolean;
|
|
179
183
|
price: number | null;
|
|
180
184
|
};
|
|
181
185
|
distributionChain: {
|
|
@@ -203,7 +207,8 @@ export declare abstract class CampaignService {
|
|
|
203
207
|
amount: string;
|
|
204
208
|
opportunityId: string;
|
|
205
209
|
creatorAddress: string;
|
|
206
|
-
}
|
|
210
|
+
};
|
|
211
|
+
static formatAsCampaignParameters<C extends CampaignTypeV3>(campaign: Campaign["model"]): CampaignParameters<C>;
|
|
207
212
|
/**
|
|
208
213
|
* Fetches the campaign dynamic data for a v3 campaign onchain
|
|
209
214
|
* @param chainId
|
|
@@ -164,8 +164,6 @@ export class CampaignService {
|
|
|
164
164
|
* TODO: remove this function in favor of prisma client extensions
|
|
165
165
|
*/
|
|
166
166
|
static format(campaign) {
|
|
167
|
-
if (campaign === null)
|
|
168
|
-
return null;
|
|
169
167
|
const { DistributionChain, ComputeChain, RewardToken, params, CampaignStatus, ...c } = campaign;
|
|
170
168
|
return {
|
|
171
169
|
...c,
|
|
@@ -177,6 +175,16 @@ export class CampaignService {
|
|
|
177
175
|
campaignStatus: CampaignStatus?.[0],
|
|
178
176
|
};
|
|
179
177
|
}
|
|
178
|
+
static formatAsCampaignParameters(campaign) {
|
|
179
|
+
return {
|
|
180
|
+
campaignSubType: campaign.subType ?? 0,
|
|
181
|
+
campaignParameters: campaign.params,
|
|
182
|
+
computeChainId: campaign.computeChainId,
|
|
183
|
+
campaignId: campaign.campaignId,
|
|
184
|
+
rewardToken: campaign.rewardToken.address,
|
|
185
|
+
amount: campaign.amount,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
180
188
|
/**
|
|
181
189
|
* Fetches the campaign dynamic data for a v3 campaign onchain
|
|
182
190
|
* @param chainId
|
|
@@ -92,7 +92,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
92
92
|
address: string;
|
|
93
93
|
icon: string;
|
|
94
94
|
decimals: number;
|
|
95
|
+
displaySymbol: string;
|
|
95
96
|
verified: boolean;
|
|
97
|
+
isTest: boolean;
|
|
96
98
|
price: number | null;
|
|
97
99
|
};
|
|
98
100
|
amount: bigint;
|
|
@@ -107,7 +109,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
107
109
|
address: string;
|
|
108
110
|
icon: string;
|
|
109
111
|
decimals: number;
|
|
112
|
+
displaySymbol: string;
|
|
110
113
|
verified: boolean;
|
|
114
|
+
isTest: boolean;
|
|
111
115
|
price: number | null;
|
|
112
116
|
}[];
|
|
113
117
|
chain: {
|
|
@@ -191,7 +195,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
191
195
|
address: string;
|
|
192
196
|
icon: string;
|
|
193
197
|
decimals: number;
|
|
198
|
+
displaySymbol: string;
|
|
194
199
|
verified: boolean;
|
|
200
|
+
isTest: boolean;
|
|
195
201
|
price: number | null;
|
|
196
202
|
};
|
|
197
203
|
amount: bigint;
|
|
@@ -206,7 +212,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
206
212
|
address: string;
|
|
207
213
|
icon: string;
|
|
208
214
|
decimals: number;
|
|
215
|
+
displaySymbol: string;
|
|
209
216
|
verified: boolean;
|
|
217
|
+
isTest: boolean;
|
|
210
218
|
price: number | null;
|
|
211
219
|
}[];
|
|
212
220
|
chain: {
|
|
@@ -232,7 +240,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
232
240
|
tvl: number;
|
|
233
241
|
apr: number;
|
|
234
242
|
dailyRewards: number;
|
|
235
|
-
campaigns:
|
|
243
|
+
campaigns: {
|
|
236
244
|
params: any;
|
|
237
245
|
chain: {
|
|
238
246
|
name: string;
|
|
@@ -247,7 +255,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
247
255
|
address: string;
|
|
248
256
|
icon: string;
|
|
249
257
|
decimals: number;
|
|
258
|
+
displaySymbol: string;
|
|
250
259
|
verified: boolean;
|
|
260
|
+
isTest: boolean;
|
|
251
261
|
price: number | null;
|
|
252
262
|
};
|
|
253
263
|
distributionChain: {
|
|
@@ -275,7 +285,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
275
285
|
amount: string;
|
|
276
286
|
opportunityId: string;
|
|
277
287
|
creatorAddress: string;
|
|
278
|
-
}
|
|
288
|
+
}[];
|
|
279
289
|
} | null | undefined;
|
|
280
290
|
};
|
|
281
291
|
};
|
|
@@ -300,6 +310,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
300
310
|
action?: string | undefined;
|
|
301
311
|
mainProtocolId?: string | undefined;
|
|
302
312
|
order?: undefined;
|
|
313
|
+
test?: boolean | undefined;
|
|
303
314
|
minimumTvl?: number | undefined;
|
|
304
315
|
};
|
|
305
316
|
headers: unknown;
|
|
@@ -345,7 +356,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
345
356
|
address: string;
|
|
346
357
|
icon: string;
|
|
347
358
|
decimals: number;
|
|
359
|
+
displaySymbol: string;
|
|
348
360
|
verified: boolean;
|
|
361
|
+
isTest: boolean;
|
|
349
362
|
price: number | null;
|
|
350
363
|
};
|
|
351
364
|
amount: bigint;
|
|
@@ -360,7 +373,9 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
360
373
|
address: string;
|
|
361
374
|
icon: string;
|
|
362
375
|
decimals: number;
|
|
376
|
+
displaySymbol: string;
|
|
363
377
|
verified: boolean;
|
|
378
|
+
isTest: boolean;
|
|
364
379
|
price: number | null;
|
|
365
380
|
}[];
|
|
366
381
|
chain: {
|
|
@@ -409,6 +424,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
409
424
|
action?: string | undefined;
|
|
410
425
|
mainProtocolId?: string | undefined;
|
|
411
426
|
order?: undefined;
|
|
427
|
+
test?: boolean | undefined;
|
|
412
428
|
minimumTvl?: number | undefined;
|
|
413
429
|
};
|
|
414
430
|
headers: unknown;
|
|
@@ -439,12 +455,13 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
|
439
455
|
action?: string | undefined;
|
|
440
456
|
mainProtocolId?: string | undefined;
|
|
441
457
|
order?: undefined;
|
|
458
|
+
test?: boolean | undefined;
|
|
442
459
|
minimumTvl?: number | undefined;
|
|
443
460
|
};
|
|
444
461
|
headers: unknown;
|
|
445
462
|
response: {
|
|
446
463
|
200: {
|
|
447
|
-
sum:
|
|
464
|
+
sum: number | null;
|
|
448
465
|
};
|
|
449
466
|
};
|
|
450
467
|
};
|
|
@@ -53,6 +53,7 @@ export declare const GetOpportunitiesQueryDto: import("@sinclair/typebox").TObje
|
|
|
53
53
|
INVALID: "INVALID";
|
|
54
54
|
}>, import("@sinclair/typebox").TRegExp]>>;
|
|
55
55
|
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
56
|
+
test: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
56
57
|
minimumTvl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
57
58
|
tokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
58
59
|
status: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TEnum<{
|
|
@@ -111,7 +112,7 @@ export declare const CreateOpportunityDto: import("@sinclair/typebox").TObject<{
|
|
|
111
112
|
export declare const OpportunityAggregateFieldDto: import("@sinclair/typebox").TObject<{
|
|
112
113
|
field: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"dailyRewards">[]>;
|
|
113
114
|
}>;
|
|
114
|
-
export type
|
|
115
|
+
export type GetOpportunitiesQueryModel = typeof GetOpportunitiesQueryDto.static;
|
|
115
116
|
export type CreateOpportunityModel = typeof CreateOpportunityDto.static & {
|
|
116
117
|
id: string;
|
|
117
118
|
};
|
|
@@ -15,6 +15,7 @@ export const GetOpportunitiesQueryDto = t.Object({
|
|
|
15
15
|
//TODO: find a systemic way of handling query param arrays
|
|
16
16
|
action: t.Optional(t.Union([t.Enum(OpportunityAction), t.RegExp(/^(POOL|HOLD|DROP|LEND|BORROW)+(,(POOL|HOLD|DROP|LEND|BORROW)+)*$/)])),
|
|
17
17
|
tags: t.Optional(t.String()),
|
|
18
|
+
test: t.Optional(t.Boolean()),
|
|
18
19
|
minimumTvl: t.Optional(t.Number()),
|
|
19
20
|
tokens: t.Optional(t.String({ title: "Symbol" })),
|
|
20
21
|
status: t.Optional(t.Union([t.Enum(Status), t.RegExp(/^(LIVE|PAST|SOON)+(,(LIVE|PAST|SOON)+)*$/)])),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type Prisma, Status } from "../../../../database/api/.generated";
|
|
2
|
+
import type { MerklChainId } from "@sdk";
|
|
2
3
|
import { type AprRecord } from "../apr";
|
|
3
4
|
import { type DailyRewardsRecord } from "../reward";
|
|
4
5
|
import { type TvlRecord } from "../tvl";
|
|
5
|
-
import type { CreateOpportunityModel,
|
|
6
|
+
import type { CreateOpportunityModel, GetOpportunitiesQueryModel } from "./opportunity.model";
|
|
6
7
|
export declare abstract class OpportunityRepository {
|
|
7
8
|
#private;
|
|
8
9
|
static create(newOpp: CreateOpportunityModel): Promise<void>;
|
|
@@ -20,7 +21,9 @@ export declare abstract class OpportunityRepository {
|
|
|
20
21
|
address: string;
|
|
21
22
|
icon: string;
|
|
22
23
|
decimals: number;
|
|
24
|
+
displaySymbol: string;
|
|
23
25
|
verified: boolean;
|
|
26
|
+
isTest: boolean;
|
|
24
27
|
price: number | null;
|
|
25
28
|
}[];
|
|
26
29
|
Protocols: {
|
|
@@ -81,7 +84,9 @@ export declare abstract class OpportunityRepository {
|
|
|
81
84
|
address: string;
|
|
82
85
|
icon: string;
|
|
83
86
|
decimals: number;
|
|
87
|
+
displaySymbol: string;
|
|
84
88
|
verified: boolean;
|
|
89
|
+
isTest: boolean;
|
|
85
90
|
price: number | null;
|
|
86
91
|
};
|
|
87
92
|
CampaignStatus: {
|
|
@@ -144,7 +149,9 @@ export declare abstract class OpportunityRepository {
|
|
|
144
149
|
address: string;
|
|
145
150
|
icon: string;
|
|
146
151
|
decimals: number;
|
|
152
|
+
displaySymbol: string;
|
|
147
153
|
verified: boolean;
|
|
154
|
+
isTest: boolean;
|
|
148
155
|
price: number | null;
|
|
149
156
|
};
|
|
150
157
|
CampaignStatus: {
|
|
@@ -178,7 +185,9 @@ export declare abstract class OpportunityRepository {
|
|
|
178
185
|
address: string;
|
|
179
186
|
icon: string;
|
|
180
187
|
decimals: number;
|
|
188
|
+
displaySymbol: string;
|
|
181
189
|
verified: boolean;
|
|
190
|
+
isTest: boolean;
|
|
182
191
|
price: number | null;
|
|
183
192
|
}[];
|
|
184
193
|
Protocols: {
|
|
@@ -239,7 +248,9 @@ export declare abstract class OpportunityRepository {
|
|
|
239
248
|
address: string;
|
|
240
249
|
icon: string;
|
|
241
250
|
decimals: number;
|
|
251
|
+
displaySymbol: string;
|
|
242
252
|
verified: boolean;
|
|
253
|
+
isTest: boolean;
|
|
243
254
|
price: number | null;
|
|
244
255
|
};
|
|
245
256
|
CampaignStatus: {
|
|
@@ -287,7 +298,9 @@ export declare abstract class OpportunityRepository {
|
|
|
287
298
|
address: string;
|
|
288
299
|
icon: string;
|
|
289
300
|
decimals: number;
|
|
301
|
+
displaySymbol: string;
|
|
290
302
|
verified: boolean;
|
|
303
|
+
isTest: boolean;
|
|
291
304
|
price: number | null;
|
|
292
305
|
};
|
|
293
306
|
} & {
|
|
@@ -319,12 +332,73 @@ export declare abstract class OpportunityRepository {
|
|
|
319
332
|
apr: number;
|
|
320
333
|
dailyRewards: number;
|
|
321
334
|
})[]>;
|
|
322
|
-
static findMany(query:
|
|
335
|
+
static findMany(query: GetOpportunitiesQueryModel): Promise<{
|
|
336
|
+
name: string;
|
|
337
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
|
338
|
+
id: string;
|
|
339
|
+
status: import("../../../../database/api/.generated").$Enums.Status;
|
|
340
|
+
tags: string[];
|
|
341
|
+
identifier: string;
|
|
342
|
+
chainId: number;
|
|
343
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
|
344
|
+
mainProtocolId: string | null;
|
|
345
|
+
tvl: number;
|
|
346
|
+
apr: number;
|
|
347
|
+
dailyRewards: number;
|
|
348
|
+
}[]>;
|
|
349
|
+
static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
|
|
323
350
|
Chain: {
|
|
324
351
|
name: string;
|
|
325
352
|
id: number;
|
|
326
353
|
icon: string;
|
|
327
354
|
};
|
|
355
|
+
Campaigns: ({
|
|
356
|
+
ComputeChain: {
|
|
357
|
+
name: string;
|
|
358
|
+
id: number;
|
|
359
|
+
icon: string;
|
|
360
|
+
};
|
|
361
|
+
DistributionChain: {
|
|
362
|
+
name: string;
|
|
363
|
+
id: number;
|
|
364
|
+
icon: string;
|
|
365
|
+
};
|
|
366
|
+
RewardToken: {
|
|
367
|
+
symbol: string;
|
|
368
|
+
name: string | null;
|
|
369
|
+
id: string;
|
|
370
|
+
chainId: number;
|
|
371
|
+
address: string;
|
|
372
|
+
icon: string;
|
|
373
|
+
decimals: number;
|
|
374
|
+
displaySymbol: string;
|
|
375
|
+
verified: boolean;
|
|
376
|
+
isTest: boolean;
|
|
377
|
+
price: number | null;
|
|
378
|
+
};
|
|
379
|
+
CampaignStatus: {
|
|
380
|
+
error: string;
|
|
381
|
+
details: Prisma.JsonValue;
|
|
382
|
+
status: import("../../../../database/api/.generated").$Enums.RunStatus;
|
|
383
|
+
campaignId: string;
|
|
384
|
+
computedUntil: bigint;
|
|
385
|
+
processingStarted: bigint;
|
|
386
|
+
}[];
|
|
387
|
+
} & {
|
|
388
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
|
389
|
+
id: string;
|
|
390
|
+
params: Prisma.JsonValue;
|
|
391
|
+
subType: number | null;
|
|
392
|
+
startTimestamp: bigint;
|
|
393
|
+
endTimestamp: bigint;
|
|
394
|
+
computeChainId: number;
|
|
395
|
+
distributionChainId: number;
|
|
396
|
+
campaignId: string;
|
|
397
|
+
rewardTokenId: string;
|
|
398
|
+
amount: string;
|
|
399
|
+
opportunityId: string;
|
|
400
|
+
creatorAddress: string;
|
|
401
|
+
})[];
|
|
328
402
|
Tokens: {
|
|
329
403
|
symbol: string;
|
|
330
404
|
name: string | null;
|
|
@@ -333,7 +407,9 @@ export declare abstract class OpportunityRepository {
|
|
|
333
407
|
address: string;
|
|
334
408
|
icon: string;
|
|
335
409
|
decimals: number;
|
|
410
|
+
displaySymbol: string;
|
|
336
411
|
verified: boolean;
|
|
412
|
+
isTest: boolean;
|
|
337
413
|
price: number | null;
|
|
338
414
|
}[];
|
|
339
415
|
Protocols: {
|
|
@@ -394,7 +470,9 @@ export declare abstract class OpportunityRepository {
|
|
|
394
470
|
address: string;
|
|
395
471
|
icon: string;
|
|
396
472
|
decimals: number;
|
|
473
|
+
displaySymbol: string;
|
|
397
474
|
verified: boolean;
|
|
475
|
+
isTest: boolean;
|
|
398
476
|
price: number | null;
|
|
399
477
|
};
|
|
400
478
|
CampaignStatus: {
|
|
@@ -432,7 +510,7 @@ export declare abstract class OpportunityRepository {
|
|
|
432
510
|
apr: number;
|
|
433
511
|
dailyRewards: number;
|
|
434
512
|
})[]>;
|
|
435
|
-
static countMany(query:
|
|
513
|
+
static countMany(query: GetOpportunitiesQueryModel): Promise<number>;
|
|
436
514
|
static getAllIdsForDynamicOpp(): Promise<{
|
|
437
515
|
id: string;
|
|
438
516
|
}[]>;
|
|
@@ -520,7 +598,7 @@ export declare abstract class OpportunityRepository {
|
|
|
520
598
|
apr: number;
|
|
521
599
|
dailyRewards: number;
|
|
522
600
|
}>;
|
|
523
|
-
static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query:
|
|
524
|
-
sum:
|
|
601
|
+
static aggregateSum(field: keyof Prisma.OpportunitySumAggregateInputType, query: GetOpportunitiesQueryModel): Promise<{
|
|
602
|
+
sum: number | null;
|
|
525
603
|
}>;
|
|
526
604
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { apiDbClient } from "../../../utils/prisma";
|
|
2
2
|
import { Status } from "../../../../database/api/.generated";
|
|
3
|
+
import moment from "moment";
|
|
3
4
|
import { AprService } from "../apr";
|
|
4
5
|
import { RewardService } from "../reward";
|
|
5
6
|
import { TvlService } from "../tvl";
|
|
@@ -128,6 +129,7 @@ export class OpportunityRepository {
|
|
|
128
129
|
const protocols = query.mainProtocolId?.split(",");
|
|
129
130
|
const sort = (query.sort === "rewards" ? "dailyRewards" : query.sort) ?? "dailyRewards";
|
|
130
131
|
const order = query.order ?? "desc";
|
|
132
|
+
const test = query.test ?? false;
|
|
131
133
|
const noFilters = Object.values(filters).every(v => v === undefined);
|
|
132
134
|
const tokensFilters = tokens?.map(symbol => ({
|
|
133
135
|
Tokens: { some: { symbol: { equals: symbol, mode: "insensitive" } } },
|
|
@@ -153,6 +155,7 @@ export class OpportunityRepository {
|
|
|
153
155
|
status: !status ? undefined : { in: status },
|
|
154
156
|
},
|
|
155
157
|
{ mainProtocolId: !protocols ? undefined : { in: protocols } },
|
|
158
|
+
test ? undefined : { Campaigns: { some: { RewardToken: { isTest: false } } } },
|
|
156
159
|
],
|
|
157
160
|
},
|
|
158
161
|
};
|
|
@@ -176,6 +179,34 @@ export class OpportunityRepository {
|
|
|
176
179
|
...args,
|
|
177
180
|
});
|
|
178
181
|
}
|
|
182
|
+
static async findLiveWithFirstCampaign(chainId) {
|
|
183
|
+
const now = moment().unix();
|
|
184
|
+
return await apiDbClient.opportunity.findMany({
|
|
185
|
+
include: {
|
|
186
|
+
...OpportunityRepository.#getRecordInclusion(),
|
|
187
|
+
Campaigns: {
|
|
188
|
+
include: { RewardToken: true, ComputeChain: true, DistributionChain: true, CampaignStatus: true },
|
|
189
|
+
take: 1,
|
|
190
|
+
orderBy: { endTimestamp: "desc" },
|
|
191
|
+
},
|
|
192
|
+
MainProtocol: true,
|
|
193
|
+
Chain: true,
|
|
194
|
+
Protocols: true,
|
|
195
|
+
Tokens: true,
|
|
196
|
+
},
|
|
197
|
+
where: {
|
|
198
|
+
status: "LIVE",
|
|
199
|
+
Chain: { id: chainId },
|
|
200
|
+
Campaigns: {
|
|
201
|
+
some: {
|
|
202
|
+
endTimestamp: {
|
|
203
|
+
gt: now,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
179
210
|
static async countMany(query) {
|
|
180
211
|
const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
|
|
181
212
|
return await apiDbClient.opportunity.count(args);
|