@merkl/api 0.19.32 → 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.
@@ -22,11 +22,9 @@ 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
- if (!!mainProtocolId) {
26
- const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
27
- if (!!protocol) {
28
- mainProtocolId = protocol?.id;
29
- }
25
+ const protocol = !!mainProtocolId ? (await ProtocolService.findMany({ id: mainProtocolId }))?.[0] : undefined;
26
+ if (!!protocol) {
27
+ mainProtocolId = protocol?.id;
30
28
  }
31
29
  // Case of lending protocols and receipt tokens
32
30
  if (!!dynamicData && !!dynamicData.typeInfo?.underlying) {
@@ -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]}`);
@@ -209,7 +209,9 @@ export class OpportunityRepository {
209
209
  Chain: { connect: { id: newOpp.chainId } },
210
210
  MainProtocol: !!newOpp.mainProtocol
211
211
  ? { connect: { id: newOpp.mainProtocol } }
212
- : { disconnect: { id: toDisconnect.mainProtocol } },
212
+ : !!previousOpportunity?.mainProtocolId
213
+ ? { disconnect: { id: previousOpportunity?.mainProtocolId } }
214
+ : undefined,
213
215
  Protocols: {
214
216
  connect: (newOpp.protocols ?? []).map((protocol) => {
215
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,