@merkl/api 0.19.14 → 0.19.16

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 (48) hide show
  1. package/dist/src/eden/index.d.ts +656 -279
  2. package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.d.ts +3 -1
  3. package/dist/src/engine/erc20SubTypeProcessors/helpers/tokenType.js +4 -0
  4. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.d.ts +51 -0
  5. package/dist/src/engine/erc20SubTypeProcessors/implementations/BEXRewardGaugeProcessor.js +102 -0
  6. package/dist/src/engine/erc20SubTypeProcessors/implementations/processorMapping.js +3 -0
  7. package/dist/src/engine/erc20SubTypeProcessors/subtypesRound1.js +4 -0
  8. package/dist/src/engine/opportunityMetadata/factory.js +1 -1
  9. package/dist/src/engine/opportunityMetadata/implementations/Ajna.d.ts +3 -1
  10. package/dist/src/engine/opportunityMetadata/implementations/Ajna.js +6 -0
  11. package/dist/src/engine/opportunityMetadata/implementations/{Ambiant.d.ts → Ambient.d.ts} +2 -0
  12. package/dist/src/engine/opportunityMetadata/implementations/{Ambiant.js → Ambient.js} +5 -1
  13. package/dist/src/engine/opportunityMetadata/implementations/Badger.d.ts +2 -0
  14. package/dist/src/engine/opportunityMetadata/implementations/Badger.js +5 -0
  15. package/dist/src/engine/opportunityMetadata/implementations/Clamm.d.ts +27 -0
  16. package/dist/src/engine/opportunityMetadata/implementations/Clamm.js +145 -1
  17. package/dist/src/engine/opportunityMetadata/implementations/Compound.d.ts +2 -0
  18. package/dist/src/engine/opportunityMetadata/implementations/Compound.js +4 -0
  19. package/dist/src/engine/opportunityMetadata/implementations/Erc20.d.ts +2 -0
  20. package/dist/src/engine/opportunityMetadata/implementations/Erc20.js +4 -0
  21. package/dist/src/engine/opportunityMetadata/implementations/Euler.d.ts +2 -0
  22. package/dist/src/engine/opportunityMetadata/implementations/Euler.js +4 -0
  23. package/dist/src/engine/opportunityMetadata/implementations/EventBased.d.ts +3 -0
  24. package/dist/src/engine/opportunityMetadata/implementations/EventBased.js +4 -0
  25. package/dist/src/engine/opportunityMetadata/implementations/Hyperdrive.d.ts +2 -0
  26. package/dist/src/engine/opportunityMetadata/implementations/Hyperdrive.js +5 -0
  27. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.d.ts +8 -0
  28. package/dist/src/engine/opportunityMetadata/implementations/JsonAirdrop.js +4 -0
  29. package/dist/src/engine/opportunityMetadata/implementations/Morpho.d.ts +2 -0
  30. package/dist/src/engine/opportunityMetadata/implementations/Morpho.js +17 -1
  31. package/dist/src/index.d.ts +169 -0
  32. package/dist/src/jobs/set-dungeon-keeper.js +8 -1
  33. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +169 -0
  34. package/dist/src/modules/v4/campaign/campaign.controller.js +62 -0
  35. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +2 -2
  36. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +5 -4
  37. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +16 -25
  38. package/dist/src/modules/v4/opportunity/opportunity.service.js +34 -34
  39. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +3 -15
  40. package/dist/src/modules/v4/programPayload/programPayload.repository.js +3 -36
  41. package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -1
  42. package/dist/src/modules/v4/protocol/protocol.model.js +0 -1
  43. package/dist/src/modules/v4/router.d.ts +169 -0
  44. package/dist/src/utils/decodeCalls.js +9 -1
  45. package/dist/src/utils/encodeCalls.js +9 -1
  46. package/dist/src/utils/generateCardName.js +3 -0
  47. package/dist/tsconfig.package.tsbuildinfo +1 -1
  48. package/package.json +1 -1
@@ -10,6 +10,7 @@ import { Prisma, Status } from "@db/api";
10
10
  import { Campaign as CampaignEnum } from "@sdk";
11
11
  import moment from "moment";
12
12
  import { metadataBuilderFactory } from "../../../engine/opportunityMetadata/factory";
13
+ import { ProtocolService } from "../protocol/protocol.service";
13
14
  import { OpportunityRepository } from "./opportunity.repository";
14
15
  export class OpportunityService {
15
16
  static hashId(opportunity) {
@@ -44,17 +45,36 @@ export class OpportunityService {
44
45
  identifier: campaign.opportunityIdentifier,
45
46
  type: campaignType,
46
47
  });
48
+ const protocol = (await ProtocolService.findMany({ id: metadata.mainProtocol }))?.[0];
49
+ const tokens = await Promise.all(metadata.tokens.map(async (t) => {
50
+ return await TokenService.findMany(t);
51
+ }));
47
52
  const params = JSON.parse(campaign.params);
53
+ const now = moment().unix();
48
54
  const opportunity = {
49
55
  id: opportunityId,
50
56
  chainId: campaign.computeChainId,
51
57
  type: campaignType,
52
58
  identifier: campaign.opportunityIdentifier, // mainParameter
53
59
  name: metadata.name,
54
- status: Status.SOON,
60
+ status: now >= +campaign.startTimestamp && now < +campaign.endTimestamp
61
+ ? Status.LIVE
62
+ : now > +campaign.endTimestamp
63
+ ? Status.PAST
64
+ : Status.SOON,
55
65
  action: metadata.action,
66
+ tokens,
56
67
  mainProtocol: metadata.mainProtocol,
57
- depositUrl: !!params.url ? params.url : undefined,
68
+ // If creator has specified a deposit URL, use it
69
+ // Else if we have the specific logic to handle the deposit URL, use it
70
+ // Else if the protocol has a deposit URL, use it
71
+ depositUrl: !!params.url
72
+ ? params.url
73
+ : !!metadata.depositUrl
74
+ ? metadata.depositUrl
75
+ : !!metadata.mainProtocol && !!protocol.url
76
+ ? protocol.url
77
+ : undefined,
58
78
  tags,
59
79
  };
60
80
  return opportunity;
@@ -69,8 +89,9 @@ export class OpportunityService {
69
89
  type: campaignType,
70
90
  });
71
91
  const tokens = (await TokenService.findManyOrCreate(metadata.tokens)).filter(t => t !== undefined);
72
- const params = JSON.parse(campaign.params);
73
92
  const now = moment().unix();
93
+ const protocol = (await ProtocolService.findMany({ id: metadata.mainProtocol }))?.[0];
94
+ const params = JSON.parse(campaign.params);
74
95
  const opportunity = {
75
96
  id: opportunityId,
76
97
  chainId: campaign.computeChainId,
@@ -85,7 +106,16 @@ export class OpportunityService {
85
106
  action: metadata.action,
86
107
  tokens,
87
108
  mainProtocol: metadata.mainProtocol,
88
- depositUrl: !!params.url ? params.url : undefined,
109
+ // If creator has specified a deposit URL, use it
110
+ // Else if we have the specific logic to handle the deposit URL, use it
111
+ // Else if the protocol has a deposit URL, use it
112
+ depositUrl: !!params.url
113
+ ? params.url
114
+ : !!metadata.depositUrl
115
+ ? metadata.depositUrl
116
+ : !!metadata.mainProtocol && !!protocol.url
117
+ ? protocol.url
118
+ : undefined,
89
119
  tags,
90
120
  };
91
121
  await OpportunityRepository.create(opportunity, upsert);
@@ -94,36 +124,6 @@ export class OpportunityService {
94
124
  static async updateStatus(opportunityId, status) {
95
125
  return await OpportunityRepository.update(opportunityId, { status });
96
126
  }
97
- static async updateStatusFromCampaign(campaign, upsert = true) {
98
- const campaignType = CampaignService.getTypeFromV3(campaign.type);
99
- const metadata = await OpportunityService.#getMetadata(campaign);
100
- const opportunityId = OpportunityService.hashId({
101
- chainId: campaign.computeChainId,
102
- identifier: campaign.opportunityIdentifier,
103
- type: campaignType,
104
- });
105
- const currentOpportunity = await OpportunityService.getUniqueOrThrow(opportunityId, true);
106
- const now = moment().unix();
107
- const opportunity = {
108
- id: opportunityId,
109
- chainId: campaign.computeChainId,
110
- type: campaignType,
111
- identifier: campaign.opportunityIdentifier, // mainParameter
112
- name: currentOpportunity.name,
113
- status: now >= +campaign.startTimestamp && now < +campaign.endTimestamp
114
- ? Status.LIVE
115
- : now > +campaign.endTimestamp
116
- ? Status.PAST
117
- : Status.SOON,
118
- action: metadata.action,
119
- tokens: currentOpportunity.tokens,
120
- mainProtocol: metadata.mainProtocol,
121
- depositUrl: currentOpportunity.depositUrl,
122
- tags: currentOpportunity.tags,
123
- };
124
- await OpportunityRepository.create(opportunity, upsert);
125
- return opportunity;
126
- }
127
127
  /**
128
128
  * deletes and recreates an opportunity with fresh data
129
129
  */
@@ -786,11 +786,7 @@ declare const EtherlinkInterfaceCampaigns: {
786
786
  };
787
787
  };
788
788
  decodeDataValue: string[];
789
- expectedChecks: {
790
- index: number;
791
- key: string;
792
- expectedValue: string;
793
- }[];
789
+ expectedChecks: never[];
794
790
  whitelist: never[];
795
791
  blacklist: string[];
796
792
  forwarders: never[];
@@ -827,11 +823,7 @@ declare const EtherlinkInterfaceCampaigns: {
827
823
  };
828
824
  };
829
825
  decodeDataValue: string[];
830
- expectedChecks: {
831
- index: number;
832
- key: string;
833
- expectedValue: string;
834
- }[];
826
+ expectedChecks: never[];
835
827
  whitelist: never[];
836
828
  blacklist: string[];
837
829
  forwarders: never[];
@@ -868,11 +860,7 @@ declare const EtherlinkInterfaceCampaigns: {
868
860
  };
869
861
  };
870
862
  decodeDataValue: string[];
871
- expectedChecks: {
872
- index: number;
873
- key: string;
874
- expectedValue: string;
875
- }[];
863
+ expectedChecks: never[];
876
864
  whitelist: never[];
877
865
  blacklist: string[];
878
866
  forwarders: never[];
@@ -673,18 +673,7 @@ const EtherlinkInterfaceCampaigns = {
673
673
  "bool",
674
674
  "bool",
675
675
  ],
676
- expectedChecks: [
677
- {
678
- index: 8,
679
- key: "data",
680
- expectedValue: "true",
681
- },
682
- {
683
- index: 9,
684
- key: "data",
685
- expectedValue: "false",
686
- },
687
- ],
676
+ expectedChecks: [],
688
677
  whitelist: [],
689
678
  blacklist: blacklistEtherlink,
690
679
  forwarders: [],
@@ -713,18 +702,7 @@ const EtherlinkInterfaceCampaigns = {
713
702
  "bool",
714
703
  "bool",
715
704
  ],
716
- expectedChecks: [
717
- {
718
- index: 8,
719
- key: "data",
720
- expectedValue: "true",
721
- },
722
- {
723
- index: 9,
724
- key: "data",
725
- expectedValue: "false",
726
- },
727
- ],
705
+ expectedChecks: [],
728
706
  whitelist: [],
729
707
  blacklist: blacklistEtherlink,
730
708
  forwarders: [],
@@ -753,18 +731,7 @@ const EtherlinkInterfaceCampaigns = {
753
731
  "bool",
754
732
  "bool",
755
733
  ],
756
- expectedChecks: [
757
- {
758
- index: 8,
759
- key: "data",
760
- expectedValue: "true",
761
- },
762
- {
763
- index: 9,
764
- key: "data",
765
- expectedValue: "false",
766
- },
767
- ],
734
+ expectedChecks: [],
768
735
  whitelist: [],
769
736
  blacklist: blacklistEtherlink,
770
737
  forwarders: [],
@@ -9,7 +9,7 @@ export type Protocol = Resource<"Protocol", undefined, {
9
9
  numberOfLiveCampaigns?: number;
10
10
  opportunityLiveTags?: string[];
11
11
  }>;
12
- declare const protocolTypes: readonly ["uniswap", "ambient", "arthswap", "baseswap", "camelot", "crust", "fenix", "horiza", "izumi", "kim", "pancakeswap", "quickswap", "ramses", "retro", "stryke", "sushiswap", "swapr", "thruster", "voltage", "zero", "koi", "supswap", "zkswap", "thirdtrade", "velodrome", "aerodrome", "balancer", "curve", "cross_curve", "curveNPool", "aura", "akron", "beefy", "dragonswap", "poolside", "koi", "syncswap", "neptune", "zkSwapThreePool", "syncswap", "rfx", "radiant", "aave", "euler", "gearbox", "compound", "sturdy", "frax", "ionic", "moonwell", "fluid", "silo", "morpho", "coumpound", "dolomite", "badger", "ajna", "layerbank", "ion", "venus", "woofi", "reactor_fusion", "eigenlayer", "vest", "zerolend", "hyperdrive", "gamma", "oku", "hourglass", "veda", "kyo", "sonex", "quickswap-algebra", "velodrome"];
12
+ declare const protocolTypes: readonly ["uniswap", "ambient", "arthswap", "baseswap", "camelot", "crust", "fenix", "horiza", "izumi", "kim", "pancakeswap", "quickswap", "ramses", "retro", "stryke", "sushiswap", "swapr", "thruster", "voltage", "zero", "koi", "supswap", "zkswap", "thirdtrade", "velodrome", "aerodrome", "balancer", "curve", "cross_curve", "curveNPool", "aura", "akron", "beefy", "dragonswap", "poolside", "koi", "syncswap", "neptune", "zkSwapThreePool", "syncswap", "rfx", "radiant", "aave", "euler", "gearbox", "compound", "sturdy", "frax", "ionic", "moonwell", "fluid", "silo", "morpho", "coumpound", "dolomite", "badger", "ajna", "layerbank", "ion", "venus", "woofi", "reactor_fusion", "eigenlayer", "vest", "zerolend", "hyperdrive", "gamma", "oku", "hourglass", "veda", "kyo", "sonex", "velodrome"];
13
13
  export type ProtocolId = (typeof protocolTypes)[number];
14
14
  export declare const ProtocolResourceDto: import("@sinclair/typebox").TObject<{
15
15
  id: import("@sinclair/typebox").TString;
@@ -75,7 +75,6 @@ const protocolTypes = [
75
75
  "veda",
76
76
  "kyo",
77
77
  "sonex",
78
- "quickswap-algebra",
79
78
  "velodrome",
80
79
  ];
81
80
  // ─── DTOs ────────────────────────────────────────────────────────────────────
@@ -1116,6 +1116,175 @@ export declare const v4: Elysia<"/v4", false, {
1116
1116
  };
1117
1117
  };
1118
1118
  };
1119
+ } & {
1120
+ "dry-run": {
1121
+ ":campaignId": {
1122
+ "dynamic-data": {
1123
+ get: {
1124
+ body: unknown;
1125
+ params: {
1126
+ campaignId: string;
1127
+ };
1128
+ query: unknown;
1129
+ headers: {
1130
+ authorization: string;
1131
+ };
1132
+ response: {
1133
+ 200: unknown[];
1134
+ };
1135
+ };
1136
+ };
1137
+ };
1138
+ };
1139
+ } & {
1140
+ "dry-run": {
1141
+ ":campaignId": {
1142
+ "meta-data": {
1143
+ get: {
1144
+ body: unknown;
1145
+ params: {
1146
+ campaignId: string;
1147
+ };
1148
+ query: unknown;
1149
+ headers: {
1150
+ authorization: string;
1151
+ };
1152
+ response: {
1153
+ 200: {
1154
+ id: string;
1155
+ chainId: number;
1156
+ type: string;
1157
+ identifier: string;
1158
+ name: string;
1159
+ status: "PAST" | "LIVE" | "SOON";
1160
+ action: any;
1161
+ tokens: ({
1162
+ symbol: string;
1163
+ id: string;
1164
+ name: string | null;
1165
+ icon: string;
1166
+ address: string;
1167
+ chainId: number;
1168
+ decimals: number;
1169
+ verified: boolean;
1170
+ isTest: boolean;
1171
+ isPoint: boolean;
1172
+ isNative: boolean;
1173
+ } & {
1174
+ price?: number | null | undefined;
1175
+ })[][];
1176
+ mainProtocol: string | undefined;
1177
+ depositUrl: any;
1178
+ tags: string[];
1179
+ };
1180
+ };
1181
+ };
1182
+ };
1183
+ };
1184
+ };
1185
+ } & {
1186
+ index: {
1187
+ get: {
1188
+ body: unknown;
1189
+ params: {};
1190
+ query: {
1191
+ type?: string | undefined;
1192
+ status?: "NONE" | "PAST" | "LIVE" | "SOON" | undefined;
1193
+ items?: number | undefined;
1194
+ subType?: number | undefined;
1195
+ page?: number | undefined;
1196
+ types?: string[] | undefined;
1197
+ campaignId?: string | undefined;
1198
+ opportunityId?: string | undefined;
1199
+ startTimestamp?: string | undefined;
1200
+ endTimestamp?: string | undefined;
1201
+ creatorAddress?: string | undefined;
1202
+ chainId?: number | undefined;
1203
+ creatorId?: string | undefined;
1204
+ mainParameter?: string | undefined;
1205
+ point?: boolean | undefined;
1206
+ tokenAddress?: string | undefined;
1207
+ test?: boolean | undefined;
1208
+ creatorTag?: string | undefined;
1209
+ distributionChainIds?: number[] | undefined;
1210
+ tokenSymbol?: string | undefined;
1211
+ withOpportunity?: boolean | undefined;
1212
+ createdAfter?: Date | null | undefined;
1213
+ };
1214
+ headers: unknown;
1215
+ response: {
1216
+ 200: {
1217
+ params: any;
1218
+ chain: {
1219
+ id: number;
1220
+ name: string;
1221
+ icon: string;
1222
+ };
1223
+ endTimestamp: number;
1224
+ startTimestamp: number;
1225
+ rewardToken: {
1226
+ symbol: string;
1227
+ id: string;
1228
+ name: string | null;
1229
+ icon: string;
1230
+ address: string;
1231
+ chainId: number;
1232
+ decimals: number;
1233
+ verified: boolean;
1234
+ isTest: boolean;
1235
+ isPoint: boolean;
1236
+ isNative: boolean;
1237
+ } & {
1238
+ price?: number | null | undefined;
1239
+ };
1240
+ distributionChain: {
1241
+ id: number;
1242
+ name: string;
1243
+ icon: string;
1244
+ } | undefined;
1245
+ campaignStatus: {
1246
+ computedUntil: number;
1247
+ processingStarted: number;
1248
+ error: string;
1249
+ status: import("@db/api").$Enums.RunStatus;
1250
+ details: import("database/api/.generated/runtime/library").JsonValue;
1251
+ campaignId: string;
1252
+ } | undefined;
1253
+ creatorAddress: string;
1254
+ creator: {
1255
+ tags: string[];
1256
+ address: string;
1257
+ creatorId: string | null;
1258
+ };
1259
+ createdAt: string;
1260
+ Opportunity: {
1261
+ id: string;
1262
+ name: string;
1263
+ type: string;
1264
+ status: import("@db/api").$Enums.Status;
1265
+ tags: string[];
1266
+ identifier: string;
1267
+ action: import("@db/api").$Enums.OpportunityAction;
1268
+ chainId: number;
1269
+ depositUrl: string | null;
1270
+ mainProtocolId: string | null;
1271
+ tvl: number;
1272
+ apr: number;
1273
+ dailyRewards: number;
1274
+ };
1275
+ id: string;
1276
+ type: string;
1277
+ subType: number | null;
1278
+ computeChainId: number;
1279
+ distributionChainId: number;
1280
+ campaignId: string;
1281
+ rewardTokenId: string;
1282
+ amount: string;
1283
+ opportunityId: string;
1284
+ }[];
1285
+ };
1286
+ };
1287
+ };
1119
1288
  } & {
1120
1289
  ":id": {
1121
1290
  get: {
@@ -47,7 +47,13 @@ export function decodeReturnValue(returnData, key, type) {
47
47
  case "token1":
48
48
  return UniswapV2PoolInterface.decodeFunctionResult("token1", returnData)[0];
49
49
  case "lp_token":
50
- return BalancerGaugeInterface.decodeFunctionResult("lp_token", returnData)[0];
50
+ switch (type) {
51
+ case tokenType.beraborrow_gauge:
52
+ case tokenType.beratrax_vault:
53
+ return ERC4626Interface.decodeFunctionResult("asset", returnData)[0];
54
+ default:
55
+ return BalancerGaugeInterface.decodeFunctionResult("lp_token", returnData)[0];
56
+ }
51
57
  case "operator":
52
58
  return AuraInterface.decodeFunctionResult("operator", returnData)[0];
53
59
  case "pid":
@@ -200,6 +206,8 @@ export function decodeReturnValue(returnData, key, type) {
200
206
  case tokenType.anglesLiquid:
201
207
  case tokenType.cian:
202
208
  case tokenType.rfx_slv:
209
+ case tokenType.beratrax_vault:
210
+ case tokenType.beraborrow_gauge:
203
211
  case tokenType.metamorpho:
204
212
  return ERC4626Interface.decodeFunctionResult("totalAssets", returnData)[0];
205
213
  case tokenType.concrete:
@@ -49,7 +49,13 @@ export function createCall(target, key, type, metaData) {
49
49
  case "pid":
50
50
  return { allowFailure: true, callData: AuraInterface.encodeFunctionData("pid"), target };
51
51
  case "lp_token":
52
- return { allowFailure: true, callData: BalancerGaugeInterface.encodeFunctionData("lp_token"), target };
52
+ switch (type) {
53
+ case tokenType.beraborrow_gauge:
54
+ case tokenType.beratrax_vault:
55
+ return { allowFailure: true, callData: ERC4626Interface.encodeFunctionData("asset"), target };
56
+ default:
57
+ return { allowFailure: true, callData: BalancerGaugeInterface.encodeFunctionData("lp_token"), target };
58
+ }
53
59
  case "stakingToken":
54
60
  return { allowFailure: true, callData: OneInchStakingInterface.encodeFunctionData("stakingToken"), target };
55
61
  case "eVault":
@@ -271,6 +277,8 @@ export function createCall(target, key, type, metaData) {
271
277
  case tokenType.cian:
272
278
  case tokenType.rfx_slv:
273
279
  case tokenType.metamorpho:
280
+ case tokenType.beratrax_vault:
281
+ case tokenType.beraborrow_gauge:
274
282
  return {
275
283
  allowFailure: true,
276
284
  callData: ERC4626Interface.encodeFunctionData("totalAssets"),
@@ -46,6 +46,9 @@ export function generateCardName(type, typeInfo, campaign, symbols = [""], displ
46
46
  return `Provide ${typeInfo.symbolUnderlyingToken} on ${typeInfo.protocol}`;
47
47
  case tokenType.balancerGauge:
48
48
  return `${typeInfo.protocol} ${symbols.join("-")}`;
49
+ case tokenType.beraborrow_gauge:
50
+ case tokenType.beratrax_vault:
51
+ return `Deposit ${symbols.join("-")} on ${typeInfo.protocol}`;
49
52
  case tokenType.balancerPool: {
50
53
  if (campaign.computeChainId === ChainId.SONIC) {
51
54
  typeInfo.protocol = "Beets";