@merkl/api 0.20.113 → 0.20.115

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.
Files changed (66) hide show
  1. package/dist/src/eden/index.d.ts +5 -5
  2. package/dist/src/engine/deprecated/dynamicData/factory.js +1 -0
  3. package/dist/src/engine/deprecated/dynamicData/implementations/EventBased.js +1 -1
  4. package/dist/src/engine/deprecated/dynamicData/implementations/default.d.ts +3 -3
  5. package/dist/src/engine/deprecated/erc20SubTypeProcessors/subtypesRound1.js +3 -8
  6. package/dist/src/engine/implementations/Ajna/metadata.d.ts +2 -2
  7. package/dist/src/engine/implementations/Ambient/metadata.d.ts +2 -2
  8. package/dist/src/engine/implementations/Badger/metadata.d.ts +2 -2
  9. package/dist/src/engine/implementations/Clamm/metadata.d.ts +2 -2
  10. package/dist/src/engine/implementations/Compound/metadata.d.ts +2 -2
  11. package/dist/src/engine/implementations/CompoundV3/metadata.d.ts +2 -2
  12. package/dist/src/engine/implementations/Default/metadata.d.ts +2 -2
  13. package/dist/src/engine/implementations/Dolomite/metadata.d.ts +2 -2
  14. package/dist/src/engine/implementations/EigenLayer/metadata.d.ts +2 -2
  15. package/dist/src/engine/implementations/EigenLayer/tvl.d.ts +7 -0
  16. package/dist/src/engine/implementations/EigenLayer/tvl.js +60 -0
  17. package/dist/src/engine/implementations/Encompassing/metadata.d.ts +2 -2
  18. package/dist/src/engine/implementations/Erc20/metadata.d.ts +1 -12
  19. package/dist/src/engine/implementations/Erc20/metadata.js +3 -3
  20. package/dist/src/engine/implementations/Erc20/subTypes/factories.js +6 -0
  21. package/dist/src/engine/implementations/Erc20/subTypes/implementations/gearbox/tvl.js +1 -1
  22. package/dist/src/engine/implementations/Erc20/subTypes/implementations/superlend/metadata.d.ts +17 -0
  23. package/dist/src/engine/implementations/Erc20/subTypes/implementations/superlend/metadata.js +29 -0
  24. package/dist/src/engine/implementations/Erc20/subTypes/implementations/superlend/tvl.d.ts +6 -0
  25. package/dist/src/engine/implementations/Erc20/subTypes/implementations/superlend/tvl.js +48 -0
  26. package/dist/src/engine/implementations/Erc20/tvl.js +1 -1
  27. package/dist/src/engine/implementations/Erc20Snapshot/metadata.d.ts +2 -2
  28. package/dist/src/engine/implementations/Erc721/metadata.d.ts +2 -2
  29. package/dist/src/engine/implementations/ErcMultiToken/metadata.d.ts +2 -2
  30. package/dist/src/engine/implementations/Euler/metadata.d.ts +2 -2
  31. package/dist/src/engine/implementations/Euler/metadata.js +2 -2
  32. package/dist/src/engine/implementations/EventBased/metadata.d.ts +2 -2
  33. package/dist/src/engine/implementations/Hyperdrive/metadata.d.ts +2 -2
  34. package/dist/src/engine/implementations/Invalid/metadata.d.ts +2 -2
  35. package/dist/src/engine/implementations/Ion/metadata.d.ts +2 -2
  36. package/dist/src/engine/implementations/JsonAirdrop/metadata.d.ts +2 -2
  37. package/dist/src/engine/implementations/Morpho/metadata.d.ts +2 -2
  38. package/dist/src/engine/implementations/Radiant/metadata.d.ts +2 -2
  39. package/dist/src/engine/implementations/Silo/metadata.d.ts +2 -2
  40. package/dist/src/engine/implementations/UniswapV4/metadata.d.ts +2 -2
  41. package/dist/src/engine/implementations/Vest/metadata.d.ts +2 -2
  42. package/dist/src/engine/metadata/factory.js +1 -0
  43. package/dist/src/engine/tvl/factory.js +2 -0
  44. package/dist/src/index.d.ts +1 -1
  45. package/dist/src/jobs/update-dynamic-data.js +2 -2
  46. package/dist/src/modules/v4/campaign/campaign.model.d.ts +2 -2
  47. package/dist/src/modules/v4/campaign/campaign.service.d.ts +4 -4
  48. package/dist/src/modules/v4/campaign/campaign.service.js +3 -3
  49. package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +1 -1
  50. package/dist/src/modules/v4/campaign/campaign.test.controller.js +18 -7
  51. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +3 -3
  52. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +10 -10
  53. package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +2 -2
  54. package/dist/src/modules/v4/opportunity/opportunity.converter.js +5 -5
  55. package/dist/src/modules/v4/opportunity/opportunity.service.js +2 -2
  56. package/dist/src/modules/v4/opportunity/validate-id.pipe.js +3 -3
  57. package/dist/src/modules/v4/reward/reward.service.d.ts +2 -2
  58. package/dist/src/modules/v4/reward/reward.service.js +2 -2
  59. package/dist/src/modules/v4/router.d.ts +1 -1
  60. package/dist/src/modules/v4/token/token.service.d.ts +20 -0
  61. package/dist/src/modules/v4/token/token.service.js +19 -0
  62. package/dist/src/routes/v3/campaigns.js +3 -3
  63. package/dist/src/routes/v3/campaignsForMainParameter.js +2 -2
  64. package/dist/src/scripts/reparse-opportunities.js +2 -2
  65. package/dist/tsconfig.package.tsbuildinfo +1 -1
  66. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { Campaign as CampaignResource, CampaignWithParams } from "@/modules/v4/campaign/campaign.model";
2
- import type { Campaign as CampaignEnum } from "@sdk";
2
+ import type { Campaign as CampaignType } from "@sdk";
3
3
  declare const eden: {
4
4
  derive: {};
5
5
  resolve: {};
@@ -1734,8 +1734,8 @@ declare const eden: {
1734
1734
  authorization: string;
1735
1735
  };
1736
1736
  query: {
1737
+ distributionChain?: number | undefined;
1737
1738
  campaignId: string;
1738
- distributionChain: number;
1739
1739
  };
1740
1740
  fetch?: RequestInit | undefined;
1741
1741
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -7099,8 +7099,8 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7099
7099
  body: unknown;
7100
7100
  params: {};
7101
7101
  query: {
7102
+ distributionChain?: number | undefined;
7102
7103
  campaignId: string;
7103
- distributionChain: number;
7104
7104
  };
7105
7105
  headers: {
7106
7106
  authorization: string;
@@ -12892,8 +12892,8 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12892
12892
  authorization: string;
12893
12893
  };
12894
12894
  query: {
12895
+ distributionChain?: number | undefined;
12895
12896
  campaignId: string;
12896
- distributionChain: number;
12897
12897
  };
12898
12898
  fetch?: RequestInit | undefined;
12899
12899
  }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
@@ -16118,7 +16118,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
16118
16118
  export type Opportunity = FromPromise<Api["v4"]["opportunities"]["index"]["get"]>;
16119
16119
  export type Protocol = FromPromise<Api["v4"]["protocols"]["index"]["get"]>;
16120
16120
  export type Campaign = CampaignResource["model"];
16121
- export type CampaignParams<C extends CampaignEnum> = CampaignWithParams<C>["params"];
16121
+ export type CampaignParams<C extends CampaignType> = CampaignWithParams<C>["params"];
16122
16122
  export type Chain = FromPromise<Api["v4"]["chains"]["index"]["get"]>;
16123
16123
  export type Explorer = FromPromise<Api["v4"]["chains"]["index"]["get"]>["explorers"][number];
16124
16124
  export type Token = FromPromise<Api["v4"]["tokens"]["index"]["get"]>;
@@ -61,5 +61,6 @@ const map = {
61
61
  [Campaign.ERC1155FIXAPR]: new ERCMultiTokenDynamicData(),
62
62
  [Campaign.ERC721]: new ERC721DynamicData(),
63
63
  [Campaign.ERC721FIXAPR]: new ERC721DynamicData(),
64
+ [Campaign.MULTILOG]: new DefaultDynamicData(), // TODO
64
65
  };
65
66
  export const dynamicDataBuilderFactory = (campaignType) => map[campaignType];
@@ -69,7 +69,7 @@ export class EventBasedDynamicData {
69
69
  const { distributedRewards } = await computeEventBasedPoolRewardsFromMostRecentStateSave(chainId, campaign.campaignId, priceToken, decimalsCurrency0);
70
70
  const c = campaign;
71
71
  const amount = BN2Number(c.amount, c.campaignParameters.decimalsRewardToken);
72
- const multiplier = BN2Number(c.campaignParameters.topicToData[0].multiplier, 12 + 9);
72
+ const multiplier = BN2Number(c.campaignParameters.topicToData[0].multipliers[0], 12 + 9);
73
73
  const startTimestamp = BN2Number(c.startTimestamp, 0);
74
74
  const endTimestamp = BN2Number(c.endTimestamp, 0);
75
75
  const isLive = moment().unix() > startTimestamp && moment().unix() < endTimestamp;
@@ -1,5 +1,5 @@
1
- import type { Campaign as CampaignEnum, CampaignParameters, MerklChainId } from "@sdk";
1
+ import type { CampaignParameters, Campaign as CampaignType, MerklChainId } from "@sdk";
2
2
  import type { DynamicDataBuilder } from "../interface";
3
- export declare class DefaultDynamicData implements DynamicDataBuilder<CampaignEnum> {
4
- build(_chainId: MerklChainId, campaigns: CampaignParameters<CampaignEnum>[]): Promise<CampaignParameters<CampaignEnum>[]>;
3
+ export declare class DefaultDynamicData implements DynamicDataBuilder<CampaignType> {
4
+ build(_chainId: MerklChainId, campaigns: CampaignParameters<CampaignType>[]): Promise<CampaignParameters<CampaignType>[]>;
5
5
  }
@@ -190,18 +190,13 @@ function generateResult(type, name, targetToken, typeInfo, campaign) {
190
190
  };
191
191
  return processorObject.computeRound1(type, typeInfo);
192
192
  }
193
- function processNamingConditions(type, name, targetToken, campaign) {
194
- if (satisfiesNameConditions(name, type)) {
195
- return generateResult(type, name, targetToken, {}, campaign);
196
- }
197
- }
198
193
  export function processNamingConditionsInOrder(name, targetToken, campaign) {
199
194
  // Order matters
200
195
  const types = Object.values(Erc20SubType).filter(value => typeof value === "string");
201
196
  for (const type of types) {
202
- const result = processNamingConditions(type, name, targetToken, campaign);
203
- if (result)
204
- return result;
197
+ if (satisfiesNameConditions(name, type)) {
198
+ return generateResult(type, name, targetToken, {}, campaign);
199
+ }
205
200
  }
206
201
  }
207
202
  function parseForFactory(calls, targetToken, campaign) {
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
5
- type campaignType = CampaignEnum.AJNA;
4
+ import { type CampaignParameters, type Campaign as CampaignType, type ChainId } from "@sdk";
5
+ type campaignType = CampaignType.AJNA;
6
6
  export declare class AjnaMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND" | "BORROW";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
5
- type campaignType = CampaignEnum.AMBIENTPROCESSOR;
4
+ import { type CampaignParameters, type Campaign as CampaignType, type ChainId } from "@sdk";
5
+ type campaignType = CampaignType.AMBIENTPROCESSOR;
6
6
  export declare class AmbientMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  name: string;
@@ -1,8 +1,8 @@
1
1
  import type { CampaignWithParams } from "@/modules/v4/campaign";
2
2
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
3
- import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
3
+ import type { CampaignParameters, Campaign as CampaignType, ChainId } from "@sdk";
4
4
  import type { MetadataBuilder } from "../../metadata/interface";
5
- type campaignType = CampaignEnum.BADGER;
5
+ type campaignType = CampaignType.BADGER;
6
6
  export declare class BadgerMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "BORROW";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import { type ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { type Campaign as CampaignEnum, type CampaignParameters, ChainId } from "@sdk";
5
- type campaignType = CampaignEnum.CLAMM;
4
+ import { type CampaignParameters, type Campaign as CampaignType, ChainId } from "@sdk";
5
+ type campaignType = CampaignType.CLAMM;
6
6
  export declare const uniswapV3OkuChains: {
7
7
  [ChainId.BLAST]: string;
8
8
  [ChainId.SCROLL]: string;
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import { type Campaign as CampaignEnum } from "@sdk";
3
+ import { type Campaign as CampaignType } from "@sdk";
4
4
  import type { ProtocolId } from "../../../modules/v4/protocol/protocol.model";
5
- type campaignType = CampaignEnum.COMPOUND;
5
+ type campaignType = CampaignType.COMPOUND;
6
6
  export declare class CompoundMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND" | "BORROW";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import { type Campaign as CampaignEnum } from "@sdk";
3
+ import { type Campaign as CampaignType } from "@sdk";
4
4
  import type { ProtocolId } from "../../../modules/v4/protocol/protocol.model";
5
- type campaignType = CampaignEnum.COMPOUND_V3;
5
+ type campaignType = CampaignType.COMPOUND_V3;
6
6
  export declare class CompoundV3Metadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND" | "BORROW";
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum } from "@sdk";
4
- type campaignType = CampaignEnum;
3
+ import type { Campaign as CampaignType } from "@sdk";
4
+ type campaignType = CampaignType;
5
5
  export declare class DefaultMetadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  action: "HOLD";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import type { Campaign as CampaignEnum } from "@sdk";
5
- type campaignType = CampaignEnum.DOLOMITE;
4
+ import type { Campaign as CampaignType } from "@sdk";
5
+ type campaignType = CampaignType.DOLOMITE;
6
6
  export declare class DolomiteMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND" | "BORROW";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import type { Campaign as CampaignEnum } from "@sdk";
5
- type campaignType = CampaignEnum.EIGENLAYER;
4
+ import type { Campaign as CampaignType } from "@sdk";
5
+ type campaignType = CampaignType.EIGENLAYER;
6
6
  export declare class EigenLayerMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND";
@@ -0,0 +1,7 @@
1
+ import type { TVLBuilder, TVLData } from "@/engine/tvl/interface";
2
+ import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
3
+ type campaignType = Campaign.EIGENLAYER;
4
+ export declare class EigenLayerTVLBuilder implements TVLBuilder<campaignType> {
5
+ build(computeChainId: MerklChainId, campaigns: CampaignParameters<campaignType>[]): Promise<TVLData<Campaign.EIGENLAYER>>;
6
+ }
7
+ export {};
@@ -0,0 +1,60 @@
1
+ import { TokenService } from "@/modules/v4/token/token.service";
2
+ import { log } from "@/utils/logger";
3
+ import { TvlType } from "@db/api";
4
+ import { ChainInteractionService, EigenLayerStrategyInterface, bigIntToNumber, } from "@sdk";
5
+ export class EigenLayerTVLBuilder {
6
+ async build(computeChainId, campaigns) {
7
+ const tvls = [];
8
+ const firstRound = await ChainInteractionService(computeChainId).fetchAndDecodeObject(campaigns.flatMap(campaign => {
9
+ const { campaignId, campaignParameters } = campaign;
10
+ const { strategy } = campaignParameters;
11
+ return [
12
+ {
13
+ callData: EigenLayerStrategyInterface.encodeFunctionData("totalShares"),
14
+ target: strategy,
15
+ key: `${campaignId}_totalShares`,
16
+ decoder: (data) => BigInt(EigenLayerStrategyInterface.decodeFunctionResult("totalShares", data)[0].toString()),
17
+ },
18
+ ];
19
+ }));
20
+ const secondRound = await ChainInteractionService(computeChainId).fetchAndDecodeObject(campaigns.flatMap(campaign => {
21
+ const { campaignId, campaignParameters } = campaign;
22
+ const { strategy } = campaignParameters;
23
+ let totalShares = firstRound[`${campaignId}_totalShares`];
24
+ if (!totalShares) {
25
+ log.warn(`Error getting totalShares for campaign ${campaign.campaignId} and strategy ${campaign.campaignParameters.strategy}`);
26
+ totalShares = 10n;
27
+ }
28
+ return [
29
+ {
30
+ callData: EigenLayerStrategyInterface.encodeFunctionData("sharesToUnderlying", [totalShares]),
31
+ target: strategy,
32
+ key: `${campaignId}_totalUnderlying`,
33
+ decoder: (data) => BigInt(EigenLayerStrategyInterface.decodeFunctionResult("sharesToUnderlying", data)[0].toString()),
34
+ },
35
+ ];
36
+ }));
37
+ for (const campaign of campaigns) {
38
+ const { campaignId, campaignParameters } = campaign;
39
+ const { underlyingToken: underlyingTokenAddress } = campaignParameters;
40
+ const totalUnderlying = secondRound[`${campaignId}_totalUnderlying`];
41
+ // We don't fetch token data everytime, we use the database and the associated service
42
+ const underlyingToken = await TokenService.findUniqueFillOrThrow({
43
+ chainId: computeChainId,
44
+ address: underlyingTokenAddress,
45
+ });
46
+ tvls.push({
47
+ campaign,
48
+ tvl: (bigIntToNumber(totalUnderlying, underlyingToken.decimals) ?? 0) * (underlyingToken.price ?? 0),
49
+ tvlBreakdown: [
50
+ {
51
+ identifier: underlyingToken.id,
52
+ type: TvlType.TOKEN,
53
+ value: bigIntToNumber(totalUnderlying, underlyingToken.decimals),
54
+ },
55
+ ],
56
+ });
57
+ }
58
+ return tvls;
59
+ }
60
+ }
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum } from "@sdk";
4
- type campaignType = CampaignEnum.ENCOMPASSING;
3
+ import type { Campaign as CampaignType } from "@sdk";
4
+ type campaignType = CampaignType.ENCOMPASSING;
5
5
  export declare class EncompassingMetadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  action: "DROP";
@@ -1,20 +1,9 @@
1
1
  import type { Erc20LikeCampaignEnum } from "@/engine/implementations/Erc20/subTypes";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { OpportunityAction } from "@db/api";
4
3
  import type { MetadataBuilder } from "../../metadata/interface";
5
4
  type campaignType = Erc20LikeCampaignEnum;
6
5
  export declare class Erc20Metadata implements MetadataBuilder<campaignType> {
7
- build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">, opportunityIdentifier: string): Promise<{
8
- name: string;
9
- action: OpportunityAction;
10
- tokens: {
11
- chainId: number;
12
- address: string;
13
- }[];
14
- mainProtocol?: import("../../../modules/v4/protocol/protocol.model").ProtocolId;
15
- depositUrl?: string;
16
- explorerAddress?: string;
17
- } | {
6
+ build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">, opportunityIdentifier: string): Promise<import("../../metadata/interface").Metadata | {
18
7
  action: import("@db/api").$Enums.OpportunityAction;
19
8
  name: string;
20
9
  tokens: {
@@ -1,7 +1,7 @@
1
1
  import { dynamicDataBuilderFactory } from "@/engine/deprecated/dynamicData/factory";
2
2
  import { OpportunityConvertorService } from "@/modules/v4/opportunity/opportunity.converter";
3
3
  import { log } from "@/utils/logger";
4
- import { Campaign as CampaignEnum } from "@sdk";
4
+ import { Campaign as CampaignType } from "@sdk";
5
5
  import { getAddress } from "viem";
6
6
  import { ProtocolService } from "../../../modules/v4/protocol/protocol.service";
7
7
  import { detectSubType } from "./subTypes/detect";
@@ -10,7 +10,7 @@ export class Erc20Metadata {
10
10
  async build(campaign, opportunityIdentifier) {
11
11
  const { params, computeChainId, campaignId, rewardToken, distributionChainId, type } = campaign;
12
12
  const [subType] = await detectSubType(computeChainId, [
13
- OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[type], campaign, opportunityIdentifier),
13
+ OpportunityConvertorService.convertV4CampaignToV3(CampaignType[type], campaign, opportunityIdentifier),
14
14
  ]);
15
15
  log.info(`building metadata for subtype ${subType}`);
16
16
  const builder = erc20SubTypeMetadataBuilderFactory(subType);
@@ -24,7 +24,7 @@ export class Erc20Metadata {
24
24
  const depositUrl = params?.url;
25
25
  let tokens = [{ chainId: computeChainId, address: params.targetToken }];
26
26
  try {
27
- const [dynamicData] = await dynamicDataBuilderFactory(CampaignEnum.ERC20).build(computeChainId, [
27
+ const [dynamicData] = await dynamicDataBuilderFactory(CampaignType.ERC20).build(computeChainId, [
28
28
  {
29
29
  campaignId,
30
30
  rewardToken: rewardToken.address,
@@ -1,6 +1,8 @@
1
1
  import { Erc20SubType } from ".";
2
2
  import { GearboxMetadata } from "./implementations/gearbox/metadata";
3
3
  import { GearboxTVLBuilder } from "./implementations/gearbox/tvl";
4
+ import { SuperlendMetadata } from "./implementations/superlend/metadata";
5
+ import { SuperlendTVLBuilder } from "./implementations/superlend/tvl";
4
6
  /**
5
7
  * @dev TYPE SAFETY DISABLED FOR NOW AS WE DON'T HAVE ALL THE CAMPAIGNS IMPLEMENTED
6
8
  *
@@ -9,6 +11,8 @@ import { GearboxTVLBuilder } from "./implementations/gearbox/tvl";
9
11
  */
10
12
  const tvlMap = {
11
13
  [Erc20SubType.gearbox]: new GearboxTVLBuilder(),
14
+ [Erc20SubType.superlend_borrowing]: new SuperlendTVLBuilder(),
15
+ [Erc20SubType.superlend_lending]: new SuperlendTVLBuilder(),
12
16
  };
13
17
  export const erc20SubTypeTVLBuilderFactory = (erc20Subtype) => {
14
18
  if (!tvlMap[erc20Subtype]) {
@@ -24,6 +28,8 @@ export const erc20SubTypeTVLBuilderFactory = (erc20Subtype) => {
24
28
  */
25
29
  const metadataMap = {
26
30
  [Erc20SubType.gearbox]: new GearboxMetadata(),
31
+ [Erc20SubType.superlend_borrowing]: new SuperlendMetadata(),
32
+ [Erc20SubType.superlend_lending]: new SuperlendMetadata(),
27
33
  };
28
34
  export const erc20SubTypeMetadataBuilderFactory = (erc20Subtype) => {
29
35
  if (!metadataMap[erc20Subtype]) {
@@ -21,7 +21,7 @@ export class GearboxTVLBuilder {
21
21
  for (const [index, campaign] of campaigns.entries()) {
22
22
  const underlyingTokenAddress = GearboxVaultInterface.decodeFunctionResult("underlyingToken", result[2 * index].returnData)[0];
23
23
  const totalAssets = ERC4626Interface.decodeFunctionResult("totalAssets", result[2 * index + 1].returnData)[0];
24
- const underlyingToken = await TokenService.findUniqueOrThrow({
24
+ const underlyingToken = await TokenService.findUniqueFillOrThrow({
25
25
  chainId: computeChainId,
26
26
  address: underlyingTokenAddress,
27
27
  });
@@ -0,0 +1,17 @@
1
+ import type { MetadataBuilder } from "@/engine/metadata/interface";
2
+ import type { CampaignWithParams } from "@/modules/v4/campaign";
3
+ import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
+ import type { Erc20LikeCampaignEnum } from "../..";
5
+ export declare class SuperlendMetadata implements MetadataBuilder<Erc20LikeCampaignEnum> {
6
+ build(campaign: Omit<CampaignWithParams<Erc20LikeCampaignEnum>, "manualOverrides">): Promise<{
7
+ action: "LEND" | "BORROW";
8
+ protocol: ProtocolId;
9
+ name: string;
10
+ tokens: {
11
+ chainId: number;
12
+ address: any;
13
+ }[];
14
+ depositUrl: string;
15
+ explorerAddress: any;
16
+ }>;
17
+ }
@@ -0,0 +1,29 @@
1
+ import { TokenService } from "@/modules/v4/token/token.service";
2
+ import { OpportunityAction } from "@db/api";
3
+ import { Aave__factory, ChainInteractionService, TokenInteractionService } from "@sdk";
4
+ export class SuperlendMetadata {
5
+ async build(campaign) {
6
+ const { params, computeChainId } = campaign;
7
+ const { targetToken } = params;
8
+ const targetTokenInfo = await TokenService.fetchOnChain({
9
+ chainId: computeChainId,
10
+ address: targetToken,
11
+ });
12
+ const underlyingToken = await Aave__factory.connect(targetToken, ChainInteractionService(computeChainId).provider()).UNDERLYING_ASSET_ADDRESS();
13
+ const underlyingTokenSymbol = await TokenInteractionService(computeChainId).symbol(underlyingToken);
14
+ const action = targetTokenInfo?.name?.toLowerCase().includes("debt")
15
+ ? OpportunityAction.BORROW
16
+ : OpportunityAction.LEND;
17
+ return {
18
+ action,
19
+ protocol: "superlend",
20
+ name: `${action === OpportunityAction.BORROW ? "Borrow" : "Supply"} ${underlyingTokenSymbol} on Superlend`,
21
+ tokens: [
22
+ { chainId: computeChainId, address: targetToken },
23
+ { chainId: computeChainId, address: underlyingToken },
24
+ ],
25
+ depositUrl: `https://markets.superlend.xyz/reserve-overview/?underlyingAsset=${underlyingToken}`,
26
+ explorerAddress: params.targetToken,
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,6 @@
1
+ import type { Erc20LikeCampaignEnum } from "@/engine/implementations/Erc20/subTypes";
2
+ import type { TVLBuilder, TVLData } from "@/engine/tvl/interface";
3
+ import { type CampaignParameters, type MerklChainId } from "@sdk";
4
+ export declare class SuperlendTVLBuilder implements TVLBuilder<Erc20LikeCampaignEnum> {
5
+ build(computeChainId: MerklChainId, campaigns: CampaignParameters<Erc20LikeCampaignEnum>[]): Promise<TVLData<any>>;
6
+ }
@@ -0,0 +1,48 @@
1
+ import { TokenService } from "@/modules/v4/token/token.service";
2
+ import { TvlType } from "@db/api";
3
+ import { AaveInterface, ChainInteractionService, ERC20Interface, bigIntToNumber, } from "@sdk";
4
+ export class SuperlendTVLBuilder {
5
+ async build(computeChainId, campaigns) {
6
+ const tvls = [];
7
+ const firstRound = await ChainInteractionService(computeChainId).fetchAndDecodeObject(campaigns.flatMap(campaign => {
8
+ const { campaignId, campaignParameters } = campaign;
9
+ const { targetToken } = campaignParameters;
10
+ return [
11
+ {
12
+ callData: AaveInterface.encodeFunctionData("UNDERLYING_ASSET_ADDRESS"),
13
+ target: targetToken,
14
+ key: `${campaignId}_underlyingToken`,
15
+ decoder: (data) => AaveInterface.decodeFunctionResult("UNDERLYING_ASSET_ADDRESS", data)[0],
16
+ },
17
+ {
18
+ callData: ERC20Interface.encodeFunctionData("totalSupply"),
19
+ target: targetToken,
20
+ key: `${campaignId}_totalSupply`,
21
+ decoder: (data) => BigInt(ERC20Interface.decodeFunctionResult("totalSupply", data)[0].toString()),
22
+ },
23
+ ];
24
+ }));
25
+ for (const campaign of campaigns) {
26
+ const { campaignId } = campaign;
27
+ const underlyingTokenAddress = firstRound[`${campaignId}_underlyingToken`];
28
+ const totalSupply = firstRound[`${campaignId}_totalSupply`];
29
+ // We don't fetch token data everytime, we use the database and the associated service
30
+ const underlyingToken = await TokenService.findUniqueFillOrThrow({
31
+ chainId: computeChainId,
32
+ address: underlyingTokenAddress,
33
+ });
34
+ tvls.push({
35
+ campaign,
36
+ tvl: (bigIntToNumber(totalSupply, underlyingToken.decimals) ?? 0) * (underlyingToken.price ?? 0),
37
+ tvlBreakdown: [
38
+ {
39
+ identifier: underlyingToken.id,
40
+ type: TvlType.TOKEN,
41
+ value: bigIntToNumber(totalSupply, underlyingToken.decimals),
42
+ },
43
+ ],
44
+ });
45
+ }
46
+ return tvls;
47
+ }
48
+ }
@@ -93,7 +93,7 @@ export class Erc20TVLBuilder {
93
93
  for (const subType of new Set(subTypes)) {
94
94
  promises.push(processSubtype(subType));
95
95
  }
96
- await Promise.allSettled(promises);
96
+ await Promise.all(promises);
97
97
  return tvls;
98
98
  }
99
99
  }
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum } from "@sdk";
4
- type campaignType = CampaignEnum.ERC20_SNAPSHOT;
3
+ import type { Campaign as CampaignType } from "@sdk";
4
+ type campaignType = CampaignType.ERC20_SNAPSHOT;
5
5
  export declare class Erc20SnapshotMetadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  name: string;
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum } from "@sdk";
4
- type campaignType = CampaignEnum.ERC721 | CampaignEnum.ERC721FIXAPR;
3
+ import type { Campaign as CampaignType } from "@sdk";
4
+ type campaignType = CampaignType.ERC721 | CampaignType.ERC721FIXAPR;
5
5
  export declare class Erc721Metadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  action: "HOLD";
@@ -1,8 +1,8 @@
1
1
  import type { CampaignWithParams } from "@/modules/v4/campaign";
2
2
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
3
- import { type Campaign as CampaignEnum } from "@sdk";
3
+ import { type Campaign as CampaignType } from "@sdk";
4
4
  import type { MetadataBuilder } from "../../metadata/interface";
5
- type campaignType = CampaignEnum.ERC1155 | CampaignEnum.ERC1155FIXAPR | CampaignEnum.ERC6909 | CampaignEnum.ERC6909FIXAPR;
5
+ type campaignType = CampaignType.ERC1155 | CampaignType.ERC1155FIXAPR | CampaignType.ERC6909 | CampaignType.ERC6909FIXAPR;
6
6
  export declare class ErcMultiTokenMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "HOLD";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
5
- type campaignType = CampaignEnum.EULER;
4
+ import { type CampaignParameters, Campaign as CampaignType, type ChainId } from "@sdk";
5
+ type campaignType = CampaignType.EULER;
6
6
  export declare class EulerMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  name: string;
@@ -2,14 +2,14 @@ import { dynamicDataBuilderFactory } from "@/engine/deprecated/dynamicData/facto
2
2
  import { log } from "@/utils/logger";
3
3
  import { sanitizeChainName } from "@/utils/sanitizeChain";
4
4
  import { OpportunityAction } from "@db/api";
5
- import { Campaign as CampaignEnum } from "@sdk";
5
+ import { Campaign as CampaignType } from "@sdk";
6
6
  import { getAddress } from "viem";
7
7
  export class EulerMetadata {
8
8
  async build(campaign) {
9
9
  const { params, computeChainId, campaignId, rewardToken, distributionChainId, subType } = campaign;
10
10
  let name = `Hold ${params.symbolTargetToken}`;
11
11
  try {
12
- const [dynamicData] = await dynamicDataBuilderFactory(CampaignEnum.EULER).build(computeChainId, [
12
+ const [dynamicData] = await dynamicDataBuilderFactory(CampaignType.EULER).build(computeChainId, [
13
13
  {
14
14
  campaignId,
15
15
  rewardToken: rewardToken.address,
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
4
- type campaignType = CampaignEnum.EVENT_BASED;
3
+ import type { CampaignParameters, Campaign as CampaignType, ChainId } from "@sdk";
4
+ type campaignType = CampaignType.EVENT_BASED;
5
5
  export declare class EventBasedMetadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  action: "SWAP";
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
5
- type campaignType = CampaignEnum.HYPERDRIVELOGPROCESSOR | CampaignEnum.HYPERDRIVELOGFIXPROCESSOR;
4
+ import { type CampaignParameters, type Campaign as CampaignType, type ChainId } from "@sdk";
5
+ type campaignType = CampaignType.HYPERDRIVELOGPROCESSOR | CampaignType.HYPERDRIVELOGFIXPROCESSOR;
6
6
  export declare class HyperdriveMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "POOL" | "LONG" | "SHORT";
@@ -1,6 +1,6 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
- import type { Campaign as CampaignEnum } from "@sdk";
3
- type campaignType = CampaignEnum.INVALID;
2
+ import type { Campaign as CampaignType } from "@sdk";
3
+ type campaignType = CampaignType.INVALID;
4
4
  export declare class InvalidMetadata implements MetadataBuilder<campaignType> {
5
5
  build(): Promise<{
6
6
  name: string;
@@ -1,8 +1,8 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
3
  import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
4
- import type { Campaign as CampaignEnum } from "@sdk";
5
- type campaignType = CampaignEnum.ION;
4
+ import type { Campaign as CampaignType } from "@sdk";
5
+ type campaignType = CampaignType.ION;
6
6
  export declare class IonMetadata implements MetadataBuilder<campaignType> {
7
7
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
8
8
  action: "LEND";
@@ -1,7 +1,7 @@
1
1
  import type { MetadataBuilder } from "@/engine/metadata/interface";
2
2
  import type { CampaignWithParams } from "@/modules/v4/campaign";
3
- import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
4
- type campaignType = CampaignEnum.JSON_AIRDROP;
3
+ import type { CampaignParameters, Campaign as CampaignType, ChainId } from "@sdk";
4
+ type campaignType = CampaignType.JSON_AIRDROP;
5
5
  export declare class JsonAirdropMetadata implements MetadataBuilder<campaignType> {
6
6
  build(campaign: Omit<CampaignWithParams<campaignType>, "manualOverrides">): Promise<{
7
7
  action: "DROP";