@merkl/api 0.17.33 → 0.17.35

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 (101) hide show
  1. package/dist/src/backgroundJobs/jobs/opportunityUpdater.d.ts +0 -2
  2. package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +2 -54
  3. package/dist/src/eden/index.d.ts +5 -5
  4. package/dist/src/factories/metadataFactory/factory.d.ts +3 -0
  5. package/dist/src/factories/metadataFactory/factory.js +56 -0
  6. package/dist/src/factories/metadataFactory/implementations/Ajna.d.ts +15 -0
  7. package/dist/src/factories/metadataFactory/implementations/Ajna.js +52 -0
  8. package/dist/src/factories/metadataFactory/implementations/Ambiant.d.ts +15 -0
  9. package/dist/src/factories/metadataFactory/implementations/Ambiant.js +31 -0
  10. package/dist/src/factories/metadataFactory/implementations/Badger.d.ts +15 -0
  11. package/dist/src/factories/metadataFactory/implementations/Badger.js +25 -0
  12. package/dist/src/factories/metadataFactory/implementations/Clamm.d.ts +15 -0
  13. package/dist/src/factories/metadataFactory/implementations/Clamm.js +50 -0
  14. package/dist/src/factories/metadataFactory/implementations/Compound.d.ts +16 -0
  15. package/dist/src/factories/metadataFactory/implementations/Compound.js +20 -0
  16. package/dist/src/factories/metadataFactory/implementations/Default.d.ts +13 -0
  17. package/dist/src/factories/metadataFactory/implementations/Default.js +11 -0
  18. package/dist/src/factories/metadataFactory/implementations/Dolomite.d.ts +15 -0
  19. package/dist/src/factories/metadataFactory/implementations/Dolomite.js +17 -0
  20. package/dist/src/factories/metadataFactory/implementations/EigenLayer.d.ts +15 -0
  21. package/dist/src/factories/metadataFactory/implementations/EigenLayer.js +11 -0
  22. package/dist/src/factories/metadataFactory/implementations/Encompassing.d.ts +15 -0
  23. package/dist/src/factories/metadataFactory/implementations/Encompassing.js +37 -0
  24. package/dist/src/factories/metadataFactory/implementations/Erc20.d.ts +15 -0
  25. package/dist/src/factories/metadataFactory/implementations/Erc20.js +71 -0
  26. package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.d.ts +14 -0
  27. package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.js +10 -0
  28. package/dist/src/factories/metadataFactory/implementations/Euler.d.ts +15 -0
  29. package/dist/src/factories/metadataFactory/implementations/Euler.js +34 -0
  30. package/dist/src/factories/metadataFactory/implementations/EventBased.d.ts +20 -0
  31. package/dist/src/factories/metadataFactory/implementations/EventBased.js +45 -0
  32. package/dist/src/factories/metadataFactory/implementations/Hyperdrive.d.ts +15 -0
  33. package/dist/src/factories/metadataFactory/implementations/Hyperdrive.js +21 -0
  34. package/dist/src/factories/metadataFactory/implementations/Invalid.d.ts +11 -0
  35. package/dist/src/factories/metadataFactory/implementations/Invalid.js +10 -0
  36. package/dist/src/factories/metadataFactory/implementations/Ion.d.ts +16 -0
  37. package/dist/src/factories/metadataFactory/implementations/Ion.js +15 -0
  38. package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.d.ts +15 -0
  39. package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.js +38 -0
  40. package/dist/src/factories/metadataFactory/implementations/Morpho.d.ts +15 -0
  41. package/dist/src/factories/metadataFactory/implementations/Morpho.js +21 -0
  42. package/dist/src/factories/metadataFactory/implementations/Radiant.d.ts +15 -0
  43. package/dist/src/factories/metadataFactory/implementations/Radiant.js +11 -0
  44. package/dist/src/factories/metadataFactory/implementations/Silo.d.ts +15 -0
  45. package/dist/src/factories/metadataFactory/implementations/Silo.js +15 -0
  46. package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.d.ts +15 -0
  47. package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.js +28 -0
  48. package/dist/src/factories/metadataFactory/implementations/Vest.d.ts +15 -0
  49. package/dist/src/factories/metadataFactory/implementations/Vest.js +12 -0
  50. package/dist/src/index.d.ts +1 -1
  51. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -1
  52. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -11
  53. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +4 -4
  54. package/dist/src/modules/v4/opportunity/opportunity.service.js +10 -86
  55. package/dist/src/modules/v4/router.d.ts +1 -1
  56. package/dist/src/routes/v3/opportunity.d.ts +0 -14
  57. package/dist/src/routes/v3/opportunity.js +2 -43
  58. package/dist/tsconfig.package.tsbuildinfo +1 -1
  59. package/package.json +1 -1
  60. package/dist/src/entities/opportunity.d.ts +0 -22
  61. package/dist/src/entities/opportunity.js +0 -1073
  62. package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.d.ts +0 -3
  63. package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +0 -50
  64. package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.d.ts +0 -3
  65. package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.js +0 -29
  66. package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.d.ts +0 -3
  67. package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +0 -23
  68. package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.d.ts +0 -3
  69. package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +0 -48
  70. package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.d.ts +0 -3
  71. package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.js +0 -18
  72. package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.d.ts +0 -3
  73. package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +0 -15
  74. package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.d.ts +0 -3
  75. package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.js +0 -9
  76. package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.d.ts +0 -3
  77. package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.js +0 -35
  78. package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.d.ts +0 -5
  79. package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +0 -69
  80. package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.d.ts +0 -3
  81. package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +0 -8
  82. package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.d.ts +0 -3
  83. package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +0 -34
  84. package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.d.ts +0 -3
  85. package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.js +0 -43
  86. package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +0 -3
  87. package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +0 -19
  88. package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.d.ts +0 -3
  89. package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.js +0 -13
  90. package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.d.ts +0 -3
  91. package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +0 -36
  92. package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.d.ts +0 -3
  93. package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +0 -19
  94. package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.d.ts +0 -3
  95. package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +0 -9
  96. package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.d.ts +0 -3
  97. package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +0 -13
  98. package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.d.ts +0 -3
  99. package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.js +0 -26
  100. package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.d.ts +0 -3
  101. package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.js +0 -10
@@ -1,6 +1,4 @@
1
1
  import type Elysia from "elysia";
2
- export declare const OPPORTUNITY_CACHE = "Opportunities_All";
3
- export declare const OPPORTUNITY_CACHE_TEST = "Opportunities_Test";
4
2
  export declare const opportunityUpdater: (app: Elysia) => Elysia<"", false, {
5
3
  decorator: {};
6
4
  store: {};
@@ -1,68 +1,16 @@
1
- import { Redis } from "../../cache";
2
1
  import { OpportunityConvertorService } from "../../modules/v4/opportunity/opportunity.converter";
3
- import { ANGLE_NETWORKS } from "@sdk";
4
- import { extractIds, getCampaignsFor, splitCampaigns } from "../../entities/campaign";
5
- import { extractOpportunities } from "../../entities/opportunity";
6
2
  import { log } from "../../utils/logger";
7
- import { Pricer } from "../../utils/pricer";
8
- export const OPPORTUNITY_CACHE = "Opportunities_All";
9
- export const OPPORTUNITY_CACHE_TEST = "Opportunities_Test";
10
- const reduceOpportunities = async (showTest = false) => {
11
- const campaigns = await getCampaignsFor(ANGLE_NETWORKS.merkl.map(c => c));
12
- const pricer = await Pricer.load();
13
- const opportunityIds = extractIds(campaigns);
14
- const opportunityCampaigns = splitCampaigns(campaigns, opportunityIds, showTest);
15
- const opportunities = {};
16
- for (const { id, ...opportunity } of opportunityCampaigns) {
17
- const [_, type, mainParameter] = id.split("_");
18
- if (!extractOpportunities[type])
19
- continue;
20
- const { campaigns: oppCampaigns, ...extracted } = extractOpportunities[type](opportunity?.all?.[0], {
21
- all: opportunity?.all ?? [],
22
- active: opportunity.active ?? [],
23
- inactive: opportunity.inactive ?? [],
24
- }, pricer?.prices);
25
- opportunities[`${type}_${mainParameter}`] = {
26
- ...extracted,
27
- campaigns: {
28
- type: Number.parseInt(type),
29
- ids: opportunity?.all?.map(({ campaignId }) => campaignId).filter(c => c),
30
- },
31
- };
32
- }
33
- return opportunities;
34
- };
35
- const getUpdateBreakdown = (opportunities) => {
36
- const total = Object.keys(opportunities)?.length;
37
- const totalByChain = Object.entries(opportunities).reduce((prev, [_, { chainId }]) => {
38
- prev[chainId] += 1;
39
- return prev;
40
- }, ANGLE_NETWORKS.merkl.reduce((allChains, chain) => Object.assign(allChains, { [chain]: 0 }), {}));
41
- const breakdown = Object.entries(totalByChain).reduce((prev, [chain, count]) => {
42
- if (count === 0)
43
- return prev;
44
- prev[chain] = count;
45
- return prev;
46
- }, {});
47
- return { total, breakdown };
48
- };
49
3
  export const opportunityUpdater = (app) => {
50
4
  return app.get("/v3/updateOpportunities", async () => {
51
- const opportunities = await reduceOpportunities(false);
52
- const opportunitiesWithTest = await reduceOpportunities(true);
53
- await Redis.safeSet("Opportunities", opportunities);
54
- await Redis.safeSet("OpportunitiesWithTest", opportunitiesWithTest);
55
5
  log.info("✅ opportunity cache updated successfully");
56
- await OpportunityConvertorService.logKeyAndTTLV3Opportunities(true, false, undefined, undefined);
6
+ await OpportunityConvertorService.logKeyAndTTLV3Opportunities(false, false, undefined, undefined);
57
7
  await OpportunityConvertorService.setV3Opportunities(false, false, undefined, undefined);
58
8
  log.info("✅ opportunity v3 cache updated successfully");
59
- await OpportunityConvertorService.logKeyAndTTLV3Opportunities(true, true, undefined, undefined);
9
+ await OpportunityConvertorService.logKeyAndTTLV3Opportunities(false, true, undefined, undefined);
60
10
  await OpportunityConvertorService.setV3Opportunities(false, true, undefined, undefined);
61
11
  log.info("✅ opportunity v3 test cache updated successfully");
62
12
  return new Response(JSON.stringify({
63
13
  status: "success",
64
- all: getUpdateBreakdown(opportunities),
65
- test: getUpdateBreakdown(opportunitiesWithTest),
66
14
  }), {
67
15
  status: 200,
68
16
  });
@@ -114,7 +114,7 @@ declare const eden: {
114
114
  identifier: string;
115
115
  name: string;
116
116
  status: "PAST" | "LIVE" | "SOON";
117
- action: import("../../database/api/.generated").$Enums.OpportunityAction;
117
+ action: any;
118
118
  tokens: ({
119
119
  symbol: string;
120
120
  name: string | null;
@@ -3531,7 +3531,7 @@ declare const eden: {
3531
3531
  identifier: string;
3532
3532
  name: string;
3533
3533
  status: "PAST" | "LIVE" | "SOON";
3534
- action: import("../../database/api/.generated").$Enums.OpportunityAction;
3534
+ action: any;
3535
3535
  tokens: ({
3536
3536
  symbol: string;
3537
3537
  name: string | null;
@@ -7725,7 +7725,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
7725
7725
  identifier: string;
7726
7726
  name: string;
7727
7727
  status: "PAST" | "LIVE" | "SOON";
7728
- action: import("../../database/api/.generated").$Enums.OpportunityAction;
7728
+ action: any;
7729
7729
  tokens: ({
7730
7730
  symbol: string;
7731
7731
  name: string | null;
@@ -12648,7 +12648,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
12648
12648
  identifier: string;
12649
12649
  name: string;
12650
12650
  status: "PAST" | "LIVE" | "SOON";
12651
- action: import("../../database/api/.generated").$Enums.OpportunityAction;
12651
+ action: any;
12652
12652
  tokens: ({
12653
12653
  symbol: string;
12654
12654
  name: string | null;
@@ -16065,7 +16065,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
16065
16065
  identifier: string;
16066
16066
  name: string;
16067
16067
  status: "PAST" | "LIVE" | "SOON";
16068
- action: import("../../database/api/.generated").$Enums.OpportunityAction;
16068
+ action: any;
16069
16069
  tokens: ({
16070
16070
  symbol: string;
16071
16071
  name: string | null;
@@ -0,0 +1,3 @@
1
+ import { Campaign } from "@sdk";
2
+ import type { MetadataBuilder } from "./interface";
3
+ export declare const metadataBuilderFactory: (campaignType: Campaign) => MetadataBuilder<typeof campaignType>;
@@ -0,0 +1,56 @@
1
+ import { Campaign } from "@sdk";
2
+ import { AjnaMetadata } from "./implementations/Ajna";
3
+ import { AmbientMetadata } from "./implementations/Ambiant";
4
+ import { BadgerMetadata } from "./implementations/Badger";
5
+ import { ClammMetadata } from "./implementations/Clamm";
6
+ import { CompoundMetadata } from "./implementations/Compound";
7
+ import { DefaultMetadata } from "./implementations/Default";
8
+ import { DolomiteMetadata } from "./implementations/Dolomite";
9
+ import { EigenLayerMetadata } from "./implementations/EigenLayer";
10
+ import { EncompassingMetadata } from "./implementations/Encompassing";
11
+ import { Erc20Metadata } from "./implementations/Erc20";
12
+ import { EulerMetadata } from "./implementations/Euler";
13
+ import { EventBasedMetadata } from "./implementations/EventBased";
14
+ import { HyperdriveMetadata } from "./implementations/Hyperdrive";
15
+ import { InvalidMetadata } from "./implementations/Invalid";
16
+ import { IonMetadata } from "./implementations/Ion";
17
+ import { JsonAirdropMetadata } from "./implementations/JsonAirdrop";
18
+ import { MorphoMetadata } from "./implementations/Morpho";
19
+ import { RadiantMetadata } from "./implementations/Radiant";
20
+ import { SiloMetadata } from "./implementations/Silo";
21
+ import { UniswapV4Metadata } from "./implementations/UniswapV4Metadata";
22
+ import { VestMetadata } from "./implementations/Vest";
23
+ // @dev Casts are made to enforce type safety
24
+ // @dev A type error must be thrown if a new campaign type is added and the corresponding metadata builder is not implemented
25
+ const map = {
26
+ [Campaign.INVALID]: new InvalidMetadata(),
27
+ [Campaign.ERC20]: new Erc20Metadata(),
28
+ [Campaign.CLAMM]: new ClammMetadata(),
29
+ [Campaign.ERC20_SNAPSHOT]: new Erc20Metadata(),
30
+ [Campaign.JSON_AIRDROP]: new JsonAirdropMetadata(),
31
+ [Campaign.SILO]: new SiloMetadata(),
32
+ [Campaign.RADIANT]: new RadiantMetadata(),
33
+ [Campaign.DOLOMITE]: new DolomiteMetadata(),
34
+ [Campaign.BADGER]: new BadgerMetadata(),
35
+ [Campaign.AJNA]: new AjnaMetadata(),
36
+ [Campaign.EULER]: new EulerMetadata(),
37
+ [Campaign.COMPOUND]: new CompoundMetadata(),
38
+ [Campaign.ION]: new IonMetadata(),
39
+ [Campaign.MORPHO]: new MorphoMetadata(),
40
+ [Campaign.HYPERDRIVELOGFIXPROCESSOR]: new HyperdriveMetadata(),
41
+ [Campaign.HYPERDRIVELOGPROCESSOR]: new HyperdriveMetadata(),
42
+ [Campaign.ERC20_FIX_APR]: new Erc20Metadata(),
43
+ [Campaign.UNISWAP_V4]: new UniswapV4Metadata(),
44
+ [Campaign.EIGENLAYER]: new EigenLayerMetadata(),
45
+ [Campaign.VEST]: new VestMetadata(),
46
+ [Campaign.ERC20LOGPROCESSOR]: new Erc20Metadata(),
47
+ [Campaign.ERC20REBASELOGPROCESSOR]: new Erc20Metadata(),
48
+ [Campaign.ERC20TRANSFERS]: new DefaultMetadata(), // TODO
49
+ [Campaign.M0]: new DefaultMetadata(), // TODO
50
+ [Campaign.MORPHOSUPPLY]: new DefaultMetadata(), // TODO
51
+ [Campaign.SYNCSWAP_VAULT]: new DefaultMetadata(), // TODO
52
+ [Campaign.AMBIENTPROCESSOR]: new AmbientMetadata(),
53
+ [Campaign.ENCOMPASSING]: new EncompassingMetadata(),
54
+ [Campaign.EVENT_BASED]: new EventBasedMetadata(),
55
+ };
56
+ export const metadataBuilderFactory = (campaignType) => map[campaignType];
@@ -0,0 +1,15 @@
1
+ import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.AJNA;
4
+ export declare class AjnaMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], subType: CampaignParameters<campaignType>["campaignSubType"]): Promise<{
6
+ action: "LEND" | "BORROW";
7
+ name: `Supply ${any} on ${string}` | `Borrow ${any} on ${string}`;
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,52 @@
1
+ import { TokenService } from "../../../modules/v4/token/token.service";
2
+ import { OpportunityAction } from "../../../../database/api/.generated";
3
+ export class AjnaMetadata {
4
+ async getMetadata(computeChainId, params, subType) {
5
+ try {
6
+ const [collateral, quote] = await TokenService.getManyOrCreate([
7
+ {
8
+ chainId: computeChainId,
9
+ address: params.collateralToken,
10
+ },
11
+ {
12
+ chainId: computeChainId,
13
+ address: params.quoteToken,
14
+ },
15
+ ]);
16
+ if (!collateral || !quote)
17
+ throw new Error("Failed to fetch tokens");
18
+ const market = `${params.symbolQuoteToken}/${collateral?.symbol}`;
19
+ const subtypes = [
20
+ { name: `Supply ${collateral?.symbol} on ${market}`, action: OpportunityAction.LEND },
21
+ { name: `Borrow ${quote?.symbol} on ${market}`, action: OpportunityAction.BORROW },
22
+ ];
23
+ const subtype = subtypes[subType];
24
+ return {
25
+ action: subtype.action,
26
+ name: subtype.name,
27
+ tokens: [
28
+ { chainId: computeChainId, address: collateral.address },
29
+ { chainId: computeChainId, address: quote.address },
30
+ ],
31
+ mainProtocol: "ajna",
32
+ };
33
+ }
34
+ catch (_err) {
35
+ const market = `${params.symbolQuoteToken}/${params.symbolCollateralToken}`;
36
+ const subtypes = [
37
+ { name: `Supply ${params.symbolCollateralToken} on ${market}`, action: OpportunityAction.LEND },
38
+ { name: `Borrow ${params.symbolQuoteToken} on ${market}`, action: OpportunityAction.BORROW },
39
+ ];
40
+ const subtype = subtypes[subType];
41
+ return {
42
+ action: subtype.action,
43
+ name: subtype.name,
44
+ tokens: [
45
+ { chainId: computeChainId, address: params.collateralToken },
46
+ { chainId: computeChainId, address: params.quoteToken },
47
+ ],
48
+ mainProtocol: "ajna",
49
+ };
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,15 @@
1
+ import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.AMBIENTPROCESSOR;
4
+ export declare class AmbientMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], _subType: CampaignParameters<campaignType>["campaignSubType"]): Promise<{
6
+ name: string;
7
+ action: "POOL";
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,31 @@
1
+ import { OpportunityAction } from "../../../../database/api/.generated";
2
+ import { almName, } from "@sdk";
3
+ import { getAddress } from "viem";
4
+ export class AmbientMetadata {
5
+ async getMetadata(computeChainId, params, _subType) {
6
+ const platform = "Ambient";
7
+ let whitelistNameString = "";
8
+ if (params.whitelist.length > 0) {
9
+ for (const whitelist of params.whitelist) {
10
+ if (whitelistNameString.length > 0) {
11
+ whitelistNameString += "or";
12
+ }
13
+ const forwarder = params.forwarders.find(x => getAddress(x.sender) === getAddress(whitelist));
14
+ const forwarderType = forwarder?.type;
15
+ const forwarderName = !!forwarderType ? almName(forwarderType) : null;
16
+ if (!!forwarderName) {
17
+ whitelistNameString += ` ${forwarderName} `;
18
+ }
19
+ }
20
+ }
21
+ return {
22
+ name: `Provide liquidity to ${whitelistNameString} ${platform} ${params.baseToken}-${params.quoteToken}`,
23
+ action: OpportunityAction.POOL,
24
+ tokens: [
25
+ { chainId: computeChainId, address: params.baseToken },
26
+ { chainId: computeChainId, address: params.quoteToken },
27
+ ],
28
+ mainProtocol: "ambient",
29
+ };
30
+ }
31
+ }
@@ -0,0 +1,15 @@
1
+ import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.BADGER;
4
+ export declare class BadgerMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): Promise<{
6
+ action: "BORROW";
7
+ name: string;
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,25 @@
1
+ import { TokenService } from "../../../modules/v4/token/token.service";
2
+ import { OpportunityAction } from "../../../../database/api/.generated";
3
+ export class BadgerMetadata {
4
+ async getMetadata(computeChainId, params) {
5
+ try {
6
+ const [token] = await TokenService.getManyOrCreate([{ chainId: computeChainId, address: params.targetToken }]);
7
+ if (!token)
8
+ throw new Error("Failed to fetch tokens");
9
+ return {
10
+ action: OpportunityAction.BORROW,
11
+ name: `Borrow ${token.symbol}`,
12
+ tokens: [{ chainId: computeChainId, address: token?.address }],
13
+ mainProtocol: "badger",
14
+ };
15
+ }
16
+ catch {
17
+ return {
18
+ action: OpportunityAction.BORROW,
19
+ name: `Borrow ${params.symbolTargetToken}`,
20
+ tokens: [{ chainId: computeChainId, address: params.targetToken }],
21
+ mainProtocol: "badger",
22
+ };
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,15 @@
1
+ import { type Campaign as CampaignEnum, type CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.CLAMM;
4
+ export declare class ClammMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): Promise<{
6
+ name: string;
7
+ action: "POOL";
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,50 @@
1
+ import { camelToKebabCase } from "../../../utils/camelToKebabCase";
2
+ import { OpportunityAction } from "../../../../database/api/.generated";
3
+ import { AMM, ChainId, almName, ammName, } from "@sdk";
4
+ import { getAddress } from "viem";
5
+ export class ClammMetadata {
6
+ async getMetadata(computeChainId, params) {
7
+ let platform = ammName(params.amm);
8
+ if (platform === "BaseSwap") {
9
+ switch (computeChainId) {
10
+ case ChainId.MODE:
11
+ platform = "SwapMode";
12
+ break;
13
+ case ChainId.ARBITRUM:
14
+ platform = "Arbitex";
15
+ break;
16
+ case ChainId.OPTIMISM:
17
+ platform = "SuperSwap";
18
+ }
19
+ }
20
+ if (platform === "Izumi") {
21
+ if (computeChainId === ChainId.ROOTSTOCK)
22
+ platform = "WoodSwap";
23
+ else
24
+ platform = "iZUMi";
25
+ }
26
+ let whitelistNameString = "";
27
+ if (params.whitelist.length > 0) {
28
+ for (const whitelist of params.whitelist) {
29
+ if (whitelistNameString.length > 0) {
30
+ whitelistNameString += "or";
31
+ }
32
+ const forwarder = params.forwarders.find(x => getAddress(x.sender) === getAddress(whitelist));
33
+ const forwarderType = forwarder?.type;
34
+ const forwarderName = !!forwarderType ? almName(forwarderType) : null;
35
+ if (!!forwarderName) {
36
+ whitelistNameString += ` ${forwarderName} `;
37
+ }
38
+ }
39
+ }
40
+ return {
41
+ name: `Provide liquidity to ${whitelistNameString} ${platform} ${params.symbolToken0}-${params.symbolToken1}${params.poolFee ? ` ${params.poolFee}%` : ""}`,
42
+ action: OpportunityAction.POOL,
43
+ tokens: [
44
+ { chainId: computeChainId, address: params.token0 },
45
+ { chainId: computeChainId, address: params.token1 },
46
+ ],
47
+ mainProtocol: camelToKebabCase(AMM[params.amm]),
48
+ };
49
+ }
50
+ }
@@ -0,0 +1,16 @@
1
+ import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
2
+ import type { ProtocolId } from "../../../modules/v4/protocol";
3
+ import type { MetadataBuilder } from "../interface";
4
+ type campaignType = CampaignEnum.COMPOUND;
5
+ export declare class CompoundMetadata implements MetadataBuilder<campaignType> {
6
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], subType: CampaignParameters<campaignType>["campaignSubType"]): Promise<{
7
+ action: "LEND" | "BORROW";
8
+ name: string;
9
+ tokens: {
10
+ chainId: ChainId;
11
+ address: any;
12
+ }[];
13
+ mainProtocol: ProtocolId;
14
+ }>;
15
+ }
16
+ export {};
@@ -0,0 +1,20 @@
1
+ import { OpportunityAction } from "../../../../database/api/.generated";
2
+ import { CompFork, CompoundSubCampaignType, } from "@sdk";
3
+ export class CompoundMetadata {
4
+ async getMetadata(computeChainId, params, subType) {
5
+ return {
6
+ action: subType === CompoundSubCampaignType.supply ? OpportunityAction.LEND : OpportunityAction.BORROW,
7
+ name: [
8
+ subType === CompoundSubCampaignType.supply
9
+ ? `Supply ${params.symbolUnderlyingToken} on`
10
+ : `Borrow ${params.symbolUnderlyingToken} on`,
11
+ CompFork[params.compFork],
12
+ ].join(" "),
13
+ tokens: [
14
+ { chainId: computeChainId, address: params.underlyingToken },
15
+ { chainId: computeChainId, address: params.targetToken },
16
+ ],
17
+ mainProtocol: CompFork[params.compFork].toLowerCase(),
18
+ };
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ import type { Campaign as CampaignEnum } from "@sdk";
2
+ import type { CampaignParameters, ChainId } from "@sdk";
3
+ import type { MetadataBuilder } from "../interface";
4
+ type campaignType = CampaignEnum;
5
+ export declare class DefaultMetadata implements MetadataBuilder<campaignType> {
6
+ getMetadata(_computeChainId: ChainId, _params: CampaignParameters<campaignType>["campaignParameters"]): Promise<{
7
+ action: "HOLD";
8
+ name: string;
9
+ tokens: never[];
10
+ mainProtocol: string;
11
+ }>;
12
+ }
13
+ export {};
@@ -0,0 +1,11 @@
1
+ import { OpportunityAction } from "../../../../database/api/.generated";
2
+ export class DefaultMetadata {
3
+ async getMetadata(_computeChainId, _params) {
4
+ return {
5
+ action: OpportunityAction.HOLD,
6
+ name: "Reward Opportunity",
7
+ tokens: [],
8
+ mainProtocol: "",
9
+ };
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.DOLOMITE;
4
+ export declare class DolomiteMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], subType: CampaignParameters<campaignType>["campaignSubType"]): Promise<{
6
+ action: "LEND" | "BORROW";
7
+ tokens: {
8
+ chainId: ChainId;
9
+ address: any;
10
+ }[];
11
+ name: string;
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,17 @@
1
+ import { OpportunityAction } from "../../../../database/api/.generated";
2
+ export class DolomiteMetadata {
3
+ async getMetadata(computeChainId, params, subType) {
4
+ const subtypes = [
5
+ { name: "Supply (delta)", action: OpportunityAction.LEND },
6
+ { name: "Supply", action: OpportunityAction.LEND },
7
+ { name: "Borrow", action: OpportunityAction.BORROW },
8
+ ];
9
+ const subtype = subtypes[subType];
10
+ return {
11
+ action: subtype.action,
12
+ tokens: [{ chainId: computeChainId, address: params.targetToken }],
13
+ name: `${subtype.name} ${params.symbolTargetToken}`,
14
+ mainProtocol: "dolomite",
15
+ };
16
+ }
17
+ }
@@ -0,0 +1,15 @@
1
+ import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.EIGENLAYER;
4
+ export declare class EigenLayerMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): Promise<{
6
+ action: "LEND";
7
+ name: string;
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: string;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,11 @@
1
+ import { OpportunityAction } from "../../../../database/api/.generated";
2
+ export class EigenLayerMetadata {
3
+ async getMetadata(computeChainId, params) {
4
+ return {
5
+ action: OpportunityAction.LEND,
6
+ name: ["EigenLayer", "strategy for", params.symbolUnderlyingToken].join(" "),
7
+ tokens: [{ chainId: computeChainId, address: params.underlyingToken }],
8
+ mainProtocol: "eigenlayer",
9
+ };
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ import type { Campaign as CampaignEnum, CampaignParameters, ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.ENCOMPASSING;
4
+ export declare class EncompassingMetadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], _subType: CampaignParameters<campaignType>["campaignSubType"], rewardTokenAddress: string): Promise<{
6
+ action: "DROP";
7
+ name: any;
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: string;
11
+ }[];
12
+ mainProtocol: any;
13
+ }>;
14
+ }
15
+ export {};
@@ -0,0 +1,37 @@
1
+ import { log } from "../../../utils/logger";
2
+ import { OpportunityAction } from "../../../../database/api/.generated";
3
+ export class EncompassingMetadata {
4
+ async getMetadata(computeChainId, params, _subType, rewardTokenAddress) {
5
+ try {
6
+ const dataResponse = await fetch(params.dataUrl);
7
+ if (!dataResponse.ok)
8
+ throw new Error(`Response status: ${dataResponse.status}`);
9
+ const data = await dataResponse.json();
10
+ return {
11
+ action: OpportunityAction.DROP,
12
+ name: data.opportunityName ?? `Distribution of ${params.symbolRewardToken}`,
13
+ tokens: [
14
+ {
15
+ chainId: computeChainId,
16
+ address: rewardTokenAddress,
17
+ },
18
+ ],
19
+ mainProtocol: data.mainProtocol ?? undefined,
20
+ };
21
+ }
22
+ catch (err) {
23
+ log.error("failed to fetch data from dataUrl", err);
24
+ return {
25
+ action: OpportunityAction.DROP,
26
+ name: `Distribution of ${params.symbolRewardToken}`,
27
+ tokens: [
28
+ {
29
+ chainId: computeChainId,
30
+ address: rewardTokenAddress,
31
+ },
32
+ ],
33
+ mainProtocol: undefined,
34
+ };
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ import { Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
2
+ import type { MetadataBuilder } from "../interface";
3
+ type campaignType = CampaignEnum.ERC20;
4
+ export declare class Erc20Metadata implements MetadataBuilder<campaignType> {
5
+ getMetadata(computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"], _subType: CampaignParameters<campaignType>["campaignSubType"], rewardTokenAddress: string, distributionChainId: ChainId, campaignId: string): Promise<{
6
+ action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
7
+ name: string;
8
+ tokens: {
9
+ chainId: ChainId;
10
+ address: any;
11
+ }[];
12
+ mainProtocol: any;
13
+ }>;
14
+ }
15
+ export {};