@merkl/api 0.10.168 → 0.10.169
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/cache/declaration.d.ts +0 -30
- package/dist/src/cache/declaration.js +0 -30
- package/dist/src/eden/index.d.ts +59 -12
- package/dist/src/index.d.ts +23 -4
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +2 -2
- 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 +2 -2
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +6 -5
- package/dist/src/modules/v4/campaign/campaign.service.js +10 -2
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +159 -0
- package/dist/src/modules/v4/opportunity/opportunity.repository.js +29 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +131 -3
- 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/reward/reward.service.d.ts +5 -0
- package/dist/src/modules/v4/reward/reward.service.js +5 -2
- package/dist/src/modules/v4/router.d.ts +23 -4
- package/dist/src/modules/v4/router.js +3 -1
- package/dist/src/routes/v1/prices.js +2 -4
- package/dist/src/routes/v3/blacklist.d.ts +23 -4
- package/dist/src/routes/v3/campaigns.d.ts +24 -5
- package/dist/src/routes/v3/campaignsInfo.d.ts +23 -4
- package/dist/src/routes/v3/multiChainPositions.d.ts +23 -4
- package/dist/src/routes/v3/opportunity.d.ts +23 -4
- package/dist/src/routes/v3/positions.d.ts +23 -4
- 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 +23 -4
- package/dist/src/routes/v3/updates.d.ts +23 -4
- package/dist/src/routes/v3/userRewards.d.ts +23 -4
- package/dist/src/utils/prices/services/erc4626Service.js +4 -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));
         | 
| @@ -75,7 +75,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, { | |
| 75 75 | 
             
                            };
         | 
| 76 76 | 
             
                            headers: unknown;
         | 
| 77 77 | 
             
                            response: {
         | 
| 78 | 
            -
                                200:  | 
| 78 | 
            +
                                200: {
         | 
| 79 79 | 
             
                                    params: any;
         | 
| 80 80 | 
             
                                    chain: {
         | 
| 81 81 | 
             
                                        name: string;
         | 
| @@ -118,7 +118,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, { | |
| 118 118 | 
             
                                    amount: string;
         | 
| 119 119 | 
             
                                    opportunityId: string;
         | 
| 120 120 | 
             
                                    creatorAddress: string;
         | 
| 121 | 
            -
                                } | 
| 121 | 
            +
                                }[];
         | 
| 122 122 | 
             
                            };
         | 
| 123 123 | 
             
                        };
         | 
| 124 124 | 
             
                    };
         | 
| @@ -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;
         | 
| @@ -71,7 +71,7 @@ export declare abstract class CampaignService { | |
| 71 71 | 
             
                    amount: string;
         | 
| 72 72 | 
             
                    opportunityId: string;
         | 
| 73 73 | 
             
                    creatorAddress: string;
         | 
| 74 | 
            -
                } | 
| 74 | 
            +
                }[]>;
         | 
| 75 75 | 
             
                /**
         | 
| 76 76 | 
             
                 * Counts the number of campaigns that complies to query
         | 
| 77 77 | 
             
                 * @description used for pagination purposes
         | 
| @@ -160,7 +160,7 @@ export declare abstract class CampaignService { | |
| 160 160 | 
             
                 * @returns A list of opportunities
         | 
| 161 161 | 
             
                 * TODO: remove this function in favor of prisma client extensions
         | 
| 162 162 | 
             
                 */
         | 
| 163 | 
            -
                static format(campaign: NonNullable<Awaited<ReturnType<typeof CampaignRepository.findMany>>>[number] | 
| 163 | 
            +
                static format(campaign: NonNullable<Awaited<ReturnType<typeof CampaignRepository.findMany>>>[number]): {
         | 
| 164 164 | 
             
                    params: any;
         | 
| 165 165 | 
             
                    chain: {
         | 
| 166 166 | 
             
                        name: string;
         | 
| @@ -203,7 +203,8 @@ export declare abstract class CampaignService { | |
| 203 203 | 
             
                    amount: string;
         | 
| 204 204 | 
             
                    opportunityId: string;
         | 
| 205 205 | 
             
                    creatorAddress: string;
         | 
| 206 | 
            -
                } | 
| 206 | 
            +
                };
         | 
| 207 | 
            +
                static formatAsCampaignParameters<C extends CampaignTypeV3>(campaign: Campaign["model"]): CampaignParameters<C>;
         | 
| 207 208 | 
             
                /**
         | 
| 208 209 | 
             
                 * Fetches the campaign dynamic data for a v3 campaign onchain
         | 
| 209 210 | 
             
                 * @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
         | 
| @@ -232,7 +232,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, { | |
| 232 232 | 
             
                                        tvl: number;
         | 
| 233 233 | 
             
                                        apr: number;
         | 
| 234 234 | 
             
                                        dailyRewards: number;
         | 
| 235 | 
            -
                                        campaigns:  | 
| 235 | 
            +
                                        campaigns: {
         | 
| 236 236 | 
             
                                            params: any;
         | 
| 237 237 | 
             
                                            chain: {
         | 
| 238 238 | 
             
                                                name: string;
         | 
| @@ -275,7 +275,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, { | |
| 275 275 | 
             
                                            amount: string;
         | 
| 276 276 | 
             
                                            opportunityId: string;
         | 
| 277 277 | 
             
                                            creatorAddress: string;
         | 
| 278 | 
            -
                                        } | 
| 278 | 
            +
                                        }[];
         | 
| 279 279 | 
             
                                    } | null | undefined;
         | 
| 280 280 | 
             
                                };
         | 
| 281 281 | 
             
                            };
         | 
| @@ -1,4 +1,5 @@ | |
| 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";
         | 
| @@ -432,6 +433,164 @@ export declare abstract class OpportunityRepository { | |
| 432 433 | 
             
                    apr: number;
         | 
| 433 434 | 
             
                    dailyRewards: number;
         | 
| 434 435 | 
             
                })[]>;
         | 
| 436 | 
            +
                static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
         | 
| 437 | 
            +
                    Chain: {
         | 
| 438 | 
            +
                        name: string;
         | 
| 439 | 
            +
                        id: number;
         | 
| 440 | 
            +
                        icon: string;
         | 
| 441 | 
            +
                    };
         | 
| 442 | 
            +
                    Campaigns: ({
         | 
| 443 | 
            +
                        ComputeChain: {
         | 
| 444 | 
            +
                            name: string;
         | 
| 445 | 
            +
                            id: number;
         | 
| 446 | 
            +
                            icon: string;
         | 
| 447 | 
            +
                        };
         | 
| 448 | 
            +
                        DistributionChain: {
         | 
| 449 | 
            +
                            name: string;
         | 
| 450 | 
            +
                            id: number;
         | 
| 451 | 
            +
                            icon: string;
         | 
| 452 | 
            +
                        };
         | 
| 453 | 
            +
                        RewardToken: {
         | 
| 454 | 
            +
                            symbol: string;
         | 
| 455 | 
            +
                            name: string | null;
         | 
| 456 | 
            +
                            id: string;
         | 
| 457 | 
            +
                            chainId: number;
         | 
| 458 | 
            +
                            address: string;
         | 
| 459 | 
            +
                            icon: string;
         | 
| 460 | 
            +
                            decimals: number;
         | 
| 461 | 
            +
                            verified: boolean;
         | 
| 462 | 
            +
                            price: number | null;
         | 
| 463 | 
            +
                        };
         | 
| 464 | 
            +
                        CampaignStatus: {
         | 
| 465 | 
            +
                            error: string;
         | 
| 466 | 
            +
                            details: Prisma.JsonValue;
         | 
| 467 | 
            +
                            status: import("../../../../database/api/.generated").$Enums.RunStatus;
         | 
| 468 | 
            +
                            campaignId: string;
         | 
| 469 | 
            +
                            computedUntil: bigint;
         | 
| 470 | 
            +
                            processingStarted: bigint;
         | 
| 471 | 
            +
                        }[];
         | 
| 472 | 
            +
                    } & {
         | 
| 473 | 
            +
                        type: import("../../../../database/api/.generated").$Enums.CampaignType;
         | 
| 474 | 
            +
                        id: string;
         | 
| 475 | 
            +
                        params: Prisma.JsonValue;
         | 
| 476 | 
            +
                        subType: number | null;
         | 
| 477 | 
            +
                        startTimestamp: bigint;
         | 
| 478 | 
            +
                        endTimestamp: bigint;
         | 
| 479 | 
            +
                        computeChainId: number;
         | 
| 480 | 
            +
                        distributionChainId: number;
         | 
| 481 | 
            +
                        campaignId: string;
         | 
| 482 | 
            +
                        rewardTokenId: string;
         | 
| 483 | 
            +
                        amount: string;
         | 
| 484 | 
            +
                        opportunityId: string;
         | 
| 485 | 
            +
                        creatorAddress: string;
         | 
| 486 | 
            +
                    })[];
         | 
| 487 | 
            +
                    Tokens: {
         | 
| 488 | 
            +
                        symbol: string;
         | 
| 489 | 
            +
                        name: string | null;
         | 
| 490 | 
            +
                        id: string;
         | 
| 491 | 
            +
                        chainId: number;
         | 
| 492 | 
            +
                        address: string;
         | 
| 493 | 
            +
                        icon: string;
         | 
| 494 | 
            +
                        decimals: number;
         | 
| 495 | 
            +
                        verified: boolean;
         | 
| 496 | 
            +
                        price: number | null;
         | 
| 497 | 
            +
                    }[];
         | 
| 498 | 
            +
                    Protocols: {
         | 
| 499 | 
            +
                        name: string;
         | 
| 500 | 
            +
                        url: string;
         | 
| 501 | 
            +
                        description: string;
         | 
| 502 | 
            +
                        id: string;
         | 
| 503 | 
            +
                        tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
         | 
| 504 | 
            +
                        icon: string;
         | 
| 505 | 
            +
                    }[];
         | 
| 506 | 
            +
                    MainProtocol: {
         | 
| 507 | 
            +
                        name: string;
         | 
| 508 | 
            +
                        url: string;
         | 
| 509 | 
            +
                        description: string;
         | 
| 510 | 
            +
                        id: string;
         | 
| 511 | 
            +
                        tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
         | 
| 512 | 
            +
                        icon: string;
         | 
| 513 | 
            +
                    } | null;
         | 
| 514 | 
            +
                    TvlRecords: ({
         | 
| 515 | 
            +
                        TvlBreakdown: {
         | 
| 516 | 
            +
                            type: import("../../../../database/api/.generated").$Enums.TvlType;
         | 
| 517 | 
            +
                            id: number;
         | 
| 518 | 
            +
                            identifier: string;
         | 
| 519 | 
            +
                            value: number;
         | 
| 520 | 
            +
                            tvlRecordId: string;
         | 
| 521 | 
            +
                        }[];
         | 
| 522 | 
            +
                    } & {
         | 
| 523 | 
            +
                        total: number;
         | 
| 524 | 
            +
                        id: string;
         | 
| 525 | 
            +
                        timestamp: bigint;
         | 
| 526 | 
            +
                        opportunityId: string;
         | 
| 527 | 
            +
                    })[];
         | 
| 528 | 
            +
                    AprRecords: ({
         | 
| 529 | 
            +
                        AprBreakdown: {
         | 
| 530 | 
            +
                            type: import("../../../../database/api/.generated").$Enums.AprType;
         | 
| 531 | 
            +
                            id: number;
         | 
| 532 | 
            +
                            identifier: string;
         | 
| 533 | 
            +
                            value: number;
         | 
| 534 | 
            +
                            aprRecordId: string;
         | 
| 535 | 
            +
                        }[];
         | 
| 536 | 
            +
                    } & {
         | 
| 537 | 
            +
                        id: string;
         | 
| 538 | 
            +
                        timestamp: bigint;
         | 
| 539 | 
            +
                        opportunityId: string;
         | 
| 540 | 
            +
                        cumulated: number;
         | 
| 541 | 
            +
                    })[];
         | 
| 542 | 
            +
                    DailyRewardsRecords: ({
         | 
| 543 | 
            +
                        DailyRewardsBreakdown: ({
         | 
| 544 | 
            +
                            Campaign: {
         | 
| 545 | 
            +
                                startTimestamp: bigint;
         | 
| 546 | 
            +
                                endTimestamp: bigint;
         | 
| 547 | 
            +
                                amount: string;
         | 
| 548 | 
            +
                                RewardToken: {
         | 
| 549 | 
            +
                                    symbol: string;
         | 
| 550 | 
            +
                                    name: string | null;
         | 
| 551 | 
            +
                                    id: string;
         | 
| 552 | 
            +
                                    chainId: number;
         | 
| 553 | 
            +
                                    address: string;
         | 
| 554 | 
            +
                                    icon: string;
         | 
| 555 | 
            +
                                    decimals: number;
         | 
| 556 | 
            +
                                    verified: boolean;
         | 
| 557 | 
            +
                                    price: number | null;
         | 
| 558 | 
            +
                                };
         | 
| 559 | 
            +
                                CampaignStatus: {
         | 
| 560 | 
            +
                                    error: string;
         | 
| 561 | 
            +
                                    details: Prisma.JsonValue;
         | 
| 562 | 
            +
                                    status: import("../../../../database/api/.generated").$Enums.RunStatus;
         | 
| 563 | 
            +
                                    campaignId: string;
         | 
| 564 | 
            +
                                    computedUntil: bigint;
         | 
| 565 | 
            +
                                    processingStarted: bigint;
         | 
| 566 | 
            +
                                }[];
         | 
| 567 | 
            +
                            };
         | 
| 568 | 
            +
                        } & {
         | 
| 569 | 
            +
                            id: number;
         | 
| 570 | 
            +
                            value: number;
         | 
| 571 | 
            +
                            campaignId: string;
         | 
| 572 | 
            +
                            dailyRewardsRecordId: string;
         | 
| 573 | 
            +
                        })[];
         | 
| 574 | 
            +
                    } & {
         | 
| 575 | 
            +
                        total: number;
         | 
| 576 | 
            +
                        id: string;
         | 
| 577 | 
            +
                        timestamp: bigint;
         | 
| 578 | 
            +
                        opportunityId: string;
         | 
| 579 | 
            +
                    })[];
         | 
| 580 | 
            +
                } & {
         | 
| 581 | 
            +
                    name: string;
         | 
| 582 | 
            +
                    type: import("../../../../database/api/.generated").$Enums.CampaignType;
         | 
| 583 | 
            +
                    id: string;
         | 
| 584 | 
            +
                    status: import("../../../../database/api/.generated").$Enums.Status;
         | 
| 585 | 
            +
                    tags: string[];
         | 
| 586 | 
            +
                    identifier: string;
         | 
| 587 | 
            +
                    chainId: number;
         | 
| 588 | 
            +
                    action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
         | 
| 589 | 
            +
                    mainProtocolId: string | null;
         | 
| 590 | 
            +
                    tvl: number;
         | 
| 591 | 
            +
                    apr: number;
         | 
| 592 | 
            +
                    dailyRewards: number;
         | 
| 593 | 
            +
                })[]>;
         | 
| 435 594 | 
             
                static countMany(query: GetOpportunitiesQueryEntity): Promise<number>;
         | 
| 436 595 | 
             
                static getAllIdsForDynamicOpp(): Promise<{
         | 
| 437 596 | 
             
                    id: string;
         | 
| @@ -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";
         | 
| @@ -176,6 +177,34 @@ export class OpportunityRepository { | |
| 176 177 | 
             
                        ...args,
         | 
| 177 178 | 
             
                    });
         | 
| 178 179 | 
             
                }
         | 
| 180 | 
            +
                static async findLiveWithFirstCampaign(chainId) {
         | 
| 181 | 
            +
                    const now = moment().unix();
         | 
| 182 | 
            +
                    return await apiDbClient.opportunity.findMany({
         | 
| 183 | 
            +
                        include: {
         | 
| 184 | 
            +
                            ...OpportunityRepository.#getRecordInclusion(),
         | 
| 185 | 
            +
                            Campaigns: {
         | 
| 186 | 
            +
                                include: { RewardToken: true, ComputeChain: true, DistributionChain: true, CampaignStatus: true },
         | 
| 187 | 
            +
                                take: 1,
         | 
| 188 | 
            +
                                orderBy: { endTimestamp: "desc" },
         | 
| 189 | 
            +
                            },
         | 
| 190 | 
            +
                            MainProtocol: true,
         | 
| 191 | 
            +
                            Chain: true,
         | 
| 192 | 
            +
                            Protocols: true,
         | 
| 193 | 
            +
                            Tokens: true,
         | 
| 194 | 
            +
                        },
         | 
| 195 | 
            +
                        where: {
         | 
| 196 | 
            +
                            status: "LIVE",
         | 
| 197 | 
            +
                            Chain: { id: chainId },
         | 
| 198 | 
            +
                            Campaigns: {
         | 
| 199 | 
            +
                                some: {
         | 
| 200 | 
            +
                                    endTimestamp: {
         | 
| 201 | 
            +
                                        gt: now,
         | 
| 202 | 
            +
                                    },
         | 
| 203 | 
            +
                                },
         | 
| 204 | 
            +
                            },
         | 
| 205 | 
            +
                        },
         | 
| 206 | 
            +
                    });
         | 
| 207 | 
            +
                }
         | 
| 179 208 | 
             
                static async countMany(query) {
         | 
| 180 209 | 
             
                    const args = OpportunityRepository.#transformQueryToPrismaFilters(query);
         | 
| 181 210 | 
             
                    return await apiDbClient.opportunity.count(args);
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            import { type CreateCampaignModel } from "../campaign";
         | 
| 2 2 | 
             
            import { Prisma } from "../../../../database/api/.generated";
         | 
| 3 | 
            -
            import { type ChainId } from "@sdk";
         | 
| 3 | 
            +
            import { type ChainId, type MerklChainId } 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 {
         | 
| @@ -102,7 +102,7 @@ export declare abstract class OpportunityService { | |
| 102 102 | 
             
                    apr: number;
         | 
| 103 103 | 
             
                    dailyRewards: number;
         | 
| 104 104 | 
             
                } & {
         | 
| 105 | 
            -
                    campaigns:  | 
| 105 | 
            +
                    campaigns: {
         | 
| 106 106 | 
             
                        params: any;
         | 
| 107 107 | 
             
                        chain: {
         | 
| 108 108 | 
             
                            name: string;
         | 
| @@ -145,7 +145,7 @@ export declare abstract class OpportunityService { | |
| 145 145 | 
             
                        amount: string;
         | 
| 146 146 | 
             
                        opportunityId: string;
         | 
| 147 147 | 
             
                        creatorAddress: string;
         | 
| 148 | 
            -
                    } | 
| 148 | 
            +
                    }[];
         | 
| 149 149 | 
             
                }) | null>;
         | 
| 150 150 | 
             
                static getUniqueOrThrow(opportunityId: string | OpportunityUnique): Promise<{
         | 
| 151 151 | 
             
                    aprRecord: {
         | 
| @@ -318,6 +318,134 @@ export declare abstract class OpportunityService { | |
| 318 318 | 
             
                    apr: number;
         | 
| 319 319 | 
             
                    dailyRewards: number;
         | 
| 320 320 | 
             
                } | null)[]>;
         | 
| 321 | 
            +
                static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
         | 
| 322 | 
            +
                    aprRecord: {
         | 
| 323 | 
            +
                        cumulated: number;
         | 
| 324 | 
            +
                        timestamp: bigint;
         | 
| 325 | 
            +
                        breakdowns: {
         | 
| 326 | 
            +
                            type: import("../../../../database/api/.generated").$Enums.AprType;
         | 
| 327 | 
            +
                            id: number;
         | 
| 328 | 
            +
                            identifier: string;
         | 
| 329 | 
            +
                            value: number;
         | 
| 330 | 
            +
                            aprRecordId: string;
         | 
| 331 | 
            +
                        }[];
         | 
| 332 | 
            +
                    };
         | 
| 333 | 
            +
                    tvlRecord: {
         | 
| 334 | 
            +
                        id: string;
         | 
| 335 | 
            +
                        total: number;
         | 
| 336 | 
            +
                        timestamp: bigint;
         | 
| 337 | 
            +
                        breakdowns: {
         | 
| 338 | 
            +
                            type: import("../../../../database/api/.generated").$Enums.TvlType;
         | 
| 339 | 
            +
                            id: number;
         | 
| 340 | 
            +
                            identifier: string;
         | 
| 341 | 
            +
                            value: number;
         | 
| 342 | 
            +
                            tvlRecordId: string;
         | 
| 343 | 
            +
                        }[];
         | 
| 344 | 
            +
                    };
         | 
| 345 | 
            +
                    rewardsRecord: {
         | 
| 346 | 
            +
                        id: string;
         | 
| 347 | 
            +
                        total: number;
         | 
| 348 | 
            +
                        timestamp: bigint;
         | 
| 349 | 
            +
                        breakdowns: {
         | 
| 350 | 
            +
                            id: number;
         | 
| 351 | 
            +
                            value: number;
         | 
| 352 | 
            +
                            campaignId: string;
         | 
| 353 | 
            +
                            dailyRewardsRecordId: string;
         | 
| 354 | 
            +
                            token: {
         | 
| 355 | 
            +
                                symbol: string;
         | 
| 356 | 
            +
                                name: string | null;
         | 
| 357 | 
            +
                                id: string;
         | 
| 358 | 
            +
                                chainId: number;
         | 
| 359 | 
            +
                                address: string;
         | 
| 360 | 
            +
                                icon: string;
         | 
| 361 | 
            +
                                decimals: number;
         | 
| 362 | 
            +
                                verified: boolean;
         | 
| 363 | 
            +
                                price: number | null;
         | 
| 364 | 
            +
                            };
         | 
| 365 | 
            +
                            amount: bigint;
         | 
| 366 | 
            +
                        }[];
         | 
| 367 | 
            +
                    };
         | 
| 368 | 
            +
                    id: string;
         | 
| 369 | 
            +
                    tokens: {
         | 
| 370 | 
            +
                        symbol: string;
         | 
| 371 | 
            +
                        name: string | null;
         | 
| 372 | 
            +
                        id: string;
         | 
| 373 | 
            +
                        chainId: number;
         | 
| 374 | 
            +
                        address: string;
         | 
| 375 | 
            +
                        icon: string;
         | 
| 376 | 
            +
                        decimals: number;
         | 
| 377 | 
            +
                        verified: boolean;
         | 
| 378 | 
            +
                        price: number | null;
         | 
| 379 | 
            +
                    }[];
         | 
| 380 | 
            +
                    chain: {
         | 
| 381 | 
            +
                        name: string;
         | 
| 382 | 
            +
                        id: number;
         | 
| 383 | 
            +
                        icon: string;
         | 
| 384 | 
            +
                    };
         | 
| 385 | 
            +
                    protocol: {
         | 
| 386 | 
            +
                        name: string;
         | 
| 387 | 
            +
                        url: string;
         | 
| 388 | 
            +
                        description: string;
         | 
| 389 | 
            +
                        id: string;
         | 
| 390 | 
            +
                        tags: import("../../../../database/api/.generated").$Enums.ProtocolTag[];
         | 
| 391 | 
            +
                        icon: string;
         | 
| 392 | 
            +
                    } | undefined;
         | 
| 393 | 
            +
                    name: string;
         | 
| 394 | 
            +
                    type: import("../../../../database/api/.generated").$Enums.CampaignType;
         | 
| 395 | 
            +
                    status: import("../../../../database/api/.generated").$Enums.Status;
         | 
| 396 | 
            +
                    tags: string[];
         | 
| 397 | 
            +
                    identifier: string;
         | 
| 398 | 
            +
                    chainId: number;
         | 
| 399 | 
            +
                    action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
         | 
| 400 | 
            +
                    tvl: number;
         | 
| 401 | 
            +
                    apr: number;
         | 
| 402 | 
            +
                    dailyRewards: number;
         | 
| 403 | 
            +
                } & {
         | 
| 404 | 
            +
                    campaigns: {
         | 
| 405 | 
            +
                        params: any;
         | 
| 406 | 
            +
                        chain: {
         | 
| 407 | 
            +
                            name: string;
         | 
| 408 | 
            +
                            id: number;
         | 
| 409 | 
            +
                            icon: string;
         | 
| 410 | 
            +
                        };
         | 
| 411 | 
            +
                        rewardToken: {
         | 
| 412 | 
            +
                            symbol: string;
         | 
| 413 | 
            +
                            name: string | null;
         | 
| 414 | 
            +
                            id: string;
         | 
| 415 | 
            +
                            chainId: number;
         | 
| 416 | 
            +
                            address: string;
         | 
| 417 | 
            +
                            icon: string;
         | 
| 418 | 
            +
                            decimals: number;
         | 
| 419 | 
            +
                            verified: boolean;
         | 
| 420 | 
            +
                            price: number | null;
         | 
| 421 | 
            +
                        };
         | 
| 422 | 
            +
                        distributionChain: {
         | 
| 423 | 
            +
                            name: string;
         | 
| 424 | 
            +
                            id: number;
         | 
| 425 | 
            +
                            icon: string;
         | 
| 426 | 
            +
                        } | undefined;
         | 
| 427 | 
            +
                        campaignStatus: {
         | 
| 428 | 
            +
                            error: string;
         | 
| 429 | 
            +
                            details: Prisma.JsonValue;
         | 
| 430 | 
            +
                            status: import("../../../../database/api/.generated").$Enums.RunStatus;
         | 
| 431 | 
            +
                            campaignId: string;
         | 
| 432 | 
            +
                            computedUntil: bigint;
         | 
| 433 | 
            +
                            processingStarted: bigint;
         | 
| 434 | 
            +
                        };
         | 
| 435 | 
            +
                        type: import("../../../../database/api/.generated").$Enums.CampaignType;
         | 
| 436 | 
            +
                        id: string;
         | 
| 437 | 
            +
                        subType: number | null;
         | 
| 438 | 
            +
                        startTimestamp: bigint;
         | 
| 439 | 
            +
                        endTimestamp: bigint;
         | 
| 440 | 
            +
                        computeChainId: number;
         | 
| 441 | 
            +
                        distributionChainId: number;
         | 
| 442 | 
            +
                        campaignId: string;
         | 
| 443 | 
            +
                        rewardTokenId: string;
         | 
| 444 | 
            +
                        amount: string;
         | 
| 445 | 
            +
                        opportunityId: string;
         | 
| 446 | 
            +
                        creatorAddress: string;
         | 
| 447 | 
            +
                    }[];
         | 
| 448 | 
            +
                })[]>;
         | 
| 321 449 | 
             
                static getAllIds(): Promise<{
         | 
| 322 450 | 
             
                    id: string;
         | 
| 323 451 | 
             
                }[]>;
         | 
| @@ -152,6 +152,17 @@ export class OpportunityService { | |
| 152 152 | 
             
                        }, query);
         | 
| 153 153 | 
             
                    });
         | 
| 154 154 | 
             
                }
         | 
| 155 | 
            +
                static async findLiveWithFirstCampaign(chainId) {
         | 
| 156 | 
            +
                    return record("data-layer.access", async () => {
         | 
| 157 | 
            +
                        return await CacheService.wrap(TTLPresets.MIN_10, async (chainId) => {
         | 
| 158 | 
            +
                            const opportunities = await OpportunityRepository.findLiveWithFirstCampaign(chainId);
         | 
| 159 | 
            +
                            return opportunities.map(o => {
         | 
| 160 | 
            +
                                const formatted = OpportunityService.formatResponse(o);
         | 
| 161 | 
            +
                                return Object.assign(formatted, { campaigns: o.Campaigns.map(CampaignService.format) });
         | 
| 162 | 
            +
                            });
         | 
| 163 | 
            +
                        }, chainId);
         | 
| 164 | 
            +
                    });
         | 
| 165 | 
            +
                }
         | 
| 155 166 | 
             
                static async getAllIds() {
         | 
| 156 167 | 
             
                    return await OpportunityRepository.getAllIdsForDynamicOpp();
         | 
| 157 168 | 
             
                }
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            import { type MerklChainId } from "@sdk";
         | 
| 2 | 
            +
            import type { Opportunity } from "../../opportunity";
         | 
| 3 | 
            +
            import type { PositionFetcher } from "../position.model";
         | 
| 4 | 
            +
            export declare class AjnaPositionFetcher implements PositionFetcher {
         | 
| 5 | 
            +
                fetchPositions: (chainId: MerklChainId, user: string, opportunities: Opportunity["model"][]) => Promise<import("..").PositionT[]>;
         | 
| 6 | 
            +
            }
         |