@merkl/api 0.19.31 → 0.19.33

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.
@@ -50,5 +50,6 @@ const map = {
50
50
  [Campaign.M0]: new DefaultDynamicData(), // TODO
51
51
  [Campaign.MORPHOSUPPLY]: new DefaultDynamicData(), // TODO
52
52
  [Campaign.SYNCSWAP_VAULT]: new DefaultDynamicData(), // TODO
53
+ [Campaign.MAVERICK_BP]: new DefaultDynamicData(), // TODO
53
54
  };
54
55
  export const dynamicDataBuilderFactory = (campaignType) => map[campaignType];
@@ -53,5 +53,6 @@ const map = {
53
53
  [Campaign.ENCOMPASSING]: new EncompassingMetadata(),
54
54
  [Campaign.EVENT_BASED]: new EventBasedMetadata(),
55
55
  [Campaign.ERC20REBASEFIXAPR]: new Erc20Metadata(),
56
+ [Campaign.MAVERICK_BP]: new DefaultMetadata(), // TODO
56
57
  };
57
58
  export const metadataBuilderFactory = (campaignType) => map[campaignType];
@@ -76,13 +76,15 @@ export class ClammMetadata {
76
76
  mainProtocolId = "stryke";
77
77
  else if (mainProtocolId?.includes("quickswap"))
78
78
  mainProtocolId = "quickswap";
79
- // Make sure the protocol exist in the correct type
80
- const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
81
- if (!!protocol) {
82
- mainProtocolId = protocol?.id;
83
- }
84
- if (mainProtocolId === "unknown") {
85
- mainProtocolId = undefined;
79
+ if (!!mainProtocolId) {
80
+ // Make sure the protocol exist in the correct type
81
+ const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
82
+ if (!!protocol) {
83
+ mainProtocolId = protocol?.id;
84
+ }
85
+ if (mainProtocolId === "unknown") {
86
+ mainProtocolId = undefined;
87
+ }
86
88
  }
87
89
  if (!mainProtocolId || !protocolIdList.includes(mainProtocolId))
88
90
  log.warn(`protocol not found for ${AMM[params.amm]}`);
@@ -22,7 +22,7 @@ export class Erc20Metadata {
22
22
  action = dynamicData?.typeInfo?.action ?? action;
23
23
  name = dynamicData?.typeInfo?.cardName;
24
24
  mainProtocolId = dynamicData?.typeInfo?.protocol?.toLowerCase().replace(" ", "");
25
- const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
25
+ const protocol = !!mainProtocolId ? (await ProtocolService.findMany({ id: mainProtocolId }))?.[0] : undefined;
26
26
  if (!!protocol) {
27
27
  mainProtocolId = protocol?.id;
28
28
  }
@@ -40,7 +40,6 @@ export async function getClamsInfo(chainIds, AMMs, user, onlyLive) {
40
40
  const result = {};
41
41
  const promises = chainIds.map((chainId, index) => (async () => {
42
42
  if (!cachedData[index]) {
43
- log.error("Merkl cache", `Data for ${NETWORK_LABELS[chainId]} not found in cache`);
44
43
  return;
45
44
  }
46
45
  log.local(`Redis: ${Object.keys(cachedData[index]?.pools ?? {}).length} pools found on ${NETWORK_LABELS[chainId]}`);
@@ -152,10 +152,14 @@ export class OpportunityRepository {
152
152
  newOpp.action = "LEND";
153
153
  }
154
154
  const toDisconnect = {
155
+ mainProtocol: "",
155
156
  protocols: [],
156
157
  tokens: [],
157
158
  };
158
159
  if (!!previousOpportunity) {
160
+ if (previousOpportunity.mainProtocolId !== newOpp.mainProtocol) {
161
+ toDisconnect.mainProtocol = previousOpportunity.mainProtocolId ?? "";
162
+ }
159
163
  for (const protocol of previousOpportunity.Protocols) {
160
164
  if (!newOpp.protocols || !newOpp.protocols.includes(protocol.id)) {
161
165
  toDisconnect.protocols.push(protocol.id);
@@ -203,7 +207,11 @@ export class OpportunityRepository {
203
207
  status: newOpp.status,
204
208
  type: newOpp.type,
205
209
  Chain: { connect: { id: newOpp.chainId } },
206
- MainProtocol: !!newOpp.mainProtocol ? { connect: { id: newOpp.mainProtocol } } : undefined,
210
+ MainProtocol: !!newOpp.mainProtocol
211
+ ? { connect: { id: newOpp.mainProtocol } }
212
+ : !!previousOpportunity?.mainProtocolId
213
+ ? { disconnect: { id: previousOpportunity?.mainProtocolId } }
214
+ : undefined,
207
215
  Protocols: {
208
216
  connect: (newOpp.protocols ?? []).map((protocol) => {
209
217
  return { id: protocol };
@@ -5,27 +5,6 @@ import { ProtocolRepository } from "./protocol.repository";
5
5
  // ─── Protocols Services ──────────────────────────────────────────────────────
6
6
  export class ProtocolService {
7
7
  static async findMany(query) {
8
- if (process.env.CLEAN_PROTOCOLS === "true") {
9
- await ProtocolRepository.changeId("uniswap-v3", "uniswap");
10
- await ProtocolRepository.changeId("balancerpool", "balancer");
11
- await ProtocolRepository.changeId("syncswap-v3", "syncswap");
12
- await ProtocolRepository.changeId("akronv2", "akron");
13
- await ProtocolRepository.changeId("aerodromev2", "aerodrome");
14
- await ProtocolRepository.changeId("velodromev2", "velodrome");
15
- await ProtocolRepository.changeId("fenixv2", "fenix");
16
- await ProtocolRepository.changeId("supswap-v3", "supswap");
17
- await ProtocolRepository.changeId("stryke-sushi", "stryke");
18
- await ProtocolRepository.changeId("stryke-pcs", "stryke");
19
- await ProtocolRepository.changeId("quickswap-algebra-v1_2", "quickswap");
20
- await ProtocolRepository.changeId("quickswap-uni", "quickswap");
21
- await ProtocolRepository.changeId("quickswap-algebra", "quickswap");
22
- await ProtocolRepository.changeId("quickswap-2", "quickswap");
23
- await ProtocolRepository.changeId("pancake-swap-v3", "pancakeswap");
24
- await ProtocolRepository.changeId("baseswapv2", "base-swap");
25
- await ProtocolRepository.changeId("baseswap", "base-swap");
26
- await ProtocolRepository.changeId("sushi-swap-v3", "sushi-swap");
27
- await ProtocolRepository.changeId("sushiswap", "sushi-swap");
28
- }
29
8
  const protocols = await ProtocolRepository.findMany(query);
30
9
  const enrichedProtocols = protocols.map(({ MainOpportunities, ...protocol }) => ({
31
10
  ...protocol,