@merkl/api 0.19.31 → 0.19.32

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,9 +22,11 @@ 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];
26
- if (!!protocol) {
27
- mainProtocolId = protocol?.id;
25
+ if (!!mainProtocolId) {
26
+ const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
27
+ if (!!protocol) {
28
+ mainProtocolId = protocol?.id;
29
+ }
28
30
  }
29
31
  // Case of lending protocols and receipt tokens
30
32
  if (!!dynamicData && !!dynamicData.typeInfo?.underlying) {
@@ -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,9 @@ 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
+ : { disconnect: { id: toDisconnect.mainProtocol } },
207
213
  Protocols: {
208
214
  connect: (newOpp.protocols ?? []).map((protocol) => {
209
215
  return { id: protocol };