@merkl/api 0.10.362 → 0.10.377

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 (84) hide show
  1. package/README.md +78 -14
  2. package/dist/database/api/.generated/edge.js +21 -6
  3. package/dist/database/api/.generated/index-browser.js +18 -3
  4. package/dist/database/api/.generated/index.d.ts +1746 -256
  5. package/dist/database/api/.generated/index.js +21 -6
  6. package/dist/database/api/.generated/package.json +1 -1
  7. package/dist/database/api/.generated/schema.prisma +12 -2
  8. package/dist/database/api/.generated/wasm.js +18 -3
  9. package/dist/src/eden/index.d.ts +1041 -140
  10. package/dist/src/entities/campaign.js +2 -1
  11. package/dist/src/entities/opportunity.js +169 -3
  12. package/dist/src/index.d.ts +340 -9
  13. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +45 -54
  14. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +3 -1
  15. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +4 -0
  16. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/ERC4626Processor.d.ts +34 -0
  17. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/ERC4626Processor.js +36 -0
  18. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +3 -0
  19. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +4 -1
  20. package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.d.ts +5 -0
  21. package/dist/src/libs/campaigns/campaignTypes/HyperdriveDynamicData.js +76 -0
  22. package/dist/src/libs/campaigns/campaignsDynamicData.js +8 -0
  23. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +2 -0
  24. package/dist/src/modules/v4/campaign/campaign.model.d.ts +1 -0
  25. package/dist/src/modules/v4/campaign/campaign.model.js +1 -0
  26. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +63 -1
  27. package/dist/src/modules/v4/campaign/campaign.repository.js +15 -10
  28. package/dist/src/modules/v4/computedValue/computedValue.controller.d.ts +7 -4
  29. package/dist/src/modules/v4/computedValue/computedValue.controller.js +7 -5
  30. package/dist/src/modules/v4/computedValue/computedValue.model.js +12 -4
  31. package/dist/src/modules/v4/computedValue/computedValue.repository.d.ts +8 -5
  32. package/dist/src/modules/v4/computedValue/computedValue.repository.js +7 -3
  33. package/dist/src/modules/v4/computedValue/computedValue.service.d.ts +7 -4
  34. package/dist/src/modules/v4/computedValue/computedValue.service.js +10 -0
  35. package/dist/src/modules/v4/creator/creator.controller.d.ts +118 -0
  36. package/dist/src/modules/v4/creator/creator.controller.js +30 -0
  37. package/dist/src/modules/v4/creator/creator.model.d.ts +29 -0
  38. package/dist/src/modules/v4/creator/creator.model.js +18 -0
  39. package/dist/src/modules/v4/creator/creator.repository.d.ts +40 -0
  40. package/dist/src/modules/v4/creator/creator.repository.js +63 -0
  41. package/dist/src/modules/v4/creator/creator.service.d.ts +61 -0
  42. package/dist/src/modules/v4/creator/creator.service.js +44 -0
  43. package/dist/src/modules/v4/creator/index.d.ts +3 -0
  44. package/dist/src/modules/v4/creator/index.js +3 -0
  45. package/dist/src/modules/v4/dynamicData/dynamicData.controller.d.ts +3 -4
  46. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +1 -1
  47. package/dist/src/modules/v4/dynamicData/dynamicData.model.d.ts +1 -0
  48. package/dist/src/modules/v4/dynamicData/dynamicData.model.js +1 -0
  49. package/dist/src/modules/v4/dynamicData/dynamicData.service.d.ts +6 -3
  50. package/dist/src/modules/v4/dynamicData/dynamicData.service.js +50 -9
  51. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +171 -1
  52. package/dist/src/modules/v4/opportunity/opportunity.controller.js +14 -0
  53. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -1
  54. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +185 -0
  55. package/dist/src/modules/v4/opportunity/opportunity.repository.js +41 -0
  56. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +151 -1
  57. package/dist/src/modules/v4/opportunity/opportunity.service.js +45 -2
  58. package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +1 -1
  59. package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +2 -2
  60. package/dist/src/modules/v4/programPayload/programPayload.controller.d.ts +30 -0
  61. package/dist/src/modules/v4/programPayload/programPayload.controller.js +12 -1
  62. package/dist/src/modules/v4/programPayload/programPayload.model.d.ts +21 -1
  63. package/dist/src/modules/v4/programPayload/programPayload.model.js +12 -0
  64. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +3 -2
  65. package/dist/src/modules/v4/programPayload/programPayload.repository.js +28 -2
  66. package/dist/src/modules/v4/programPayload/programPayload.service.d.ts +2 -1
  67. package/dist/src/modules/v4/programPayload/programPayload.service.js +42 -2
  68. package/dist/src/modules/v4/protocol/protocol.controller.d.ts +1 -0
  69. package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -0
  70. package/dist/src/modules/v4/protocol/protocol.model.js +1 -0
  71. package/dist/src/modules/v4/reward/reward.repository.d.ts +2 -1
  72. package/dist/src/modules/v4/reward/reward.repository.js +12 -1
  73. package/dist/src/modules/v4/reward/reward.service.js +5 -2
  74. package/dist/src/modules/v4/router.d.ts +340 -9
  75. package/dist/src/modules/v4/router.js +3 -1
  76. package/dist/src/modules/v4/user/user.controller.d.ts +28 -0
  77. package/dist/src/modules/v4/user/user.controller.js +5 -0
  78. package/dist/src/modules/v4/user/user.repository.d.ts +5 -0
  79. package/dist/src/modules/v4/user/user.service.d.ts +5 -0
  80. package/dist/src/utils/decodeCalls.js +7 -1
  81. package/dist/src/utils/encodeCalls.js +19 -1
  82. package/dist/src/utils/generateCardName.js +3 -0
  83. package/dist/tsconfig.package.tsbuildinfo +1 -1
  84. package/package.json +6 -2
@@ -14,67 +14,58 @@ export async function ERC20DynamicData(chainId, campaigns) {
14
14
  const currentRoot = (await merklChainDataWithCache(chainId)).merkleRoot;
15
15
  // Round 1: Get the high level type for each token (will need to be refined lated with more calls)
16
16
  const callsRounds1 = [];
17
- for (const campaign of campaigns) {
18
- // Keep this commented, only use for tests
19
- // if (campaign.campaignId === "0xf09492c6d3bd475e269e9f90c92d7e11a671a8fc43470b424ccbb0eea67b762e") {
20
- // // Filament test
21
- // campaign.campaignParameters.targetToken = "0xe855B8018C22A05F84724e93693caf166912aDD5";
22
- // }
23
- if ([
24
- "0xb9bf1ace04e702363bd76b5828ca64a00984af9118672be96c1c200943da941f",
25
- "0x1ad188dd597199ca8e6d6a01d5af362769f46bb749da5c08d27eaec4397f53b5",
26
- ].includes(campaign.campaignId)) {
27
- campaign.campaignParameters.url = "https://moonwell.fi/markets/supply/base/usdc";
28
- }
29
- if ([
30
- "0x2d3ae0a97c6f73ad37c1a9cc5e360f72b206ee61d96952fe772b3ab02f8a5713",
31
- "0x653ec2bd4aa79b74a2d6c3240ebe3bc4afb679ea6963c2c8afceef69c7c914f9",
32
- "0x6cddb42d99fe4df7d3783f7eb25044bf141084ff99882a2dde931880efc7793d",
33
- ].includes(campaign.campaignId)) {
34
- campaign.campaignParameters.url =
35
- "https://app.zerolend.xyz/reserve-overview/?underlyingAsset=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&marketName=proto_mainnet_rwa_v3&utm_source=Merkle&utm_medium=Website&utm_campaign=MerklMagic30";
36
- }
37
- callsRounds1.push({
38
- allowFailure: true,
39
- callData: FactoryInterface.encodeFunctionData("factory"),
40
- target: campaign.campaignParameters.targetToken,
41
- }, {
42
- allowFailure: true,
43
- callData: MetamorphoInterface.encodeFunctionData("MORPHO"),
44
- target: campaign.campaignParameters.targetToken,
45
- }, {
46
- allowFailure: true,
47
- callData: ERC20Interface.encodeFunctionData("name"),
48
- target: campaign.campaignParameters.targetToken,
49
- }, {
50
- allowFailure: true,
51
- callData: BalancerPoolInterface.encodeFunctionData("getPoolId"),
52
- target: campaign.campaignParameters.targetToken,
53
- }, {
54
- allowFailure: true,
55
- callData: EnzymeInterface.encodeFunctionData("getCreator"),
56
- target: campaign.campaignParameters.targetToken,
57
- }, {
58
- allowFailure: true,
59
- callData: LayerBankERC20Interface.encodeFunctionData("owner"),
60
- target: campaign.campaignParameters.targetToken,
61
- });
62
- }
63
- const resultRound1 = await ChainInteractionService(chainId).fetchState(callsRounds1);
64
17
  const tokenTypesByCampaign = {};
65
- // Round 2: Decode result from round 1 and get some additional info for the types before the final calls
66
- const callsRounds2 = [];
67
- let i = 0;
68
18
  for (const campaign of campaigns) {
69
- let typeStruct = {
19
+ const typeStruct = {
70
20
  type: tokenType.unknown,
71
21
  calls: [],
72
22
  typeInfo: {},
73
23
  };
74
- typeStruct = getTokenTypeRound1(resultRound1, campaign.campaignParameters.targetToken, i, campaign);
75
- i += 6;
24
+ const targetToken = campaign.campaignParameters.targetToken;
25
+ typeStruct.calls = [
26
+ {
27
+ allowFailure: true,
28
+ callData: FactoryInterface.encodeFunctionData("factory"),
29
+ target: targetToken,
30
+ },
31
+ {
32
+ allowFailure: true,
33
+ callData: MetamorphoInterface.encodeFunctionData("MORPHO"),
34
+ target: targetToken,
35
+ },
36
+ {
37
+ allowFailure: true,
38
+ callData: ERC20Interface.encodeFunctionData("name"),
39
+ target: targetToken,
40
+ },
41
+ {
42
+ allowFailure: true,
43
+ callData: BalancerPoolInterface.encodeFunctionData("getPoolId"),
44
+ target: targetToken,
45
+ },
46
+ {
47
+ allowFailure: true,
48
+ callData: EnzymeInterface.encodeFunctionData("getCreator"),
49
+ target: targetToken,
50
+ },
51
+ {
52
+ allowFailure: true,
53
+ callData: LayerBankERC20Interface.encodeFunctionData("owner"),
54
+ target: targetToken,
55
+ },
56
+ ];
57
+ callsRounds1.push(...typeStruct.calls);
76
58
  tokenTypesByCampaign[campaign.campaignId] = typeStruct;
77
- callsRounds2.push(...typeStruct.calls);
59
+ }
60
+ const resultRound1 = await ChainInteractionService(chainId).fetchState(callsRounds1);
61
+ // Round 2: Decode result from round 1 and get some additional info for the types before the final calls
62
+ const callsRounds2 = [];
63
+ let i = 0;
64
+ for (const campaign of campaigns) {
65
+ const callsForCampaign = tokenTypesByCampaign[campaign.campaignId].calls.length;
66
+ tokenTypesByCampaign[campaign.campaignId] = getTokenTypeRound1(resultRound1, campaign.campaignParameters.targetToken, i, campaign);
67
+ i += callsForCampaign;
68
+ callsRounds2.push(...tokenTypesByCampaign[campaign.campaignId].calls);
78
69
  }
79
70
  const resultRound2 = await ChainInteractionService(chainId).fetchState(callsRounds2);
80
71
  // Round 3: Decode result from round 2 and get some additional info for the types before the final calls
@@ -72,7 +72,9 @@ export declare enum tokenType {
72
72
  satlayer = "satlayer",
73
73
  veda = "veda",
74
74
  superlend_borrowing = "superlend_borrowing",
75
- superlend_lending = "superlend_lending"
75
+ superlend_lending = "superlend_lending",
76
+ cian = "cian",
77
+ concrete = "concrete"
76
78
  }
77
79
  export declare const tokenTypeToProtocol: {
78
80
  [key in tokenType]: {
@@ -74,6 +74,8 @@ export var tokenType;
74
74
  tokenType["veda"] = "veda";
75
75
  tokenType["superlend_borrowing"] = "superlend_borrowing";
76
76
  tokenType["superlend_lending"] = "superlend_lending";
77
+ tokenType["cian"] = "cian";
78
+ tokenType["concrete"] = "concrete";
77
79
  })(tokenType || (tokenType = {}));
78
80
  export const tokenTypeToProtocol = {
79
81
  [tokenType.aave_borrowing]: { protocol: "Aave" },
@@ -179,4 +181,6 @@ export const tokenTypeToProtocol = {
179
181
  [tokenType.veda]: { protocol: "Veda" },
180
182
  [tokenType.superlend_borrowing]: { protocol: "Superlend" },
181
183
  [tokenType.superlend_lending]: { protocol: "Superlend" },
184
+ [tokenType.cian]: { protocol: "Cian" },
185
+ [tokenType.concrete]: { protocol: "Concrete" },
182
186
  };
@@ -0,0 +1,34 @@
1
+ import type { Pricer } from "../../../../../utils/pricer";
2
+ import { type Campaign, type CampaignParameters } from "@sdk";
3
+ import type { tokenType } from "../helpers/tokenType";
4
+ import { GenericProcessor, type dataType, type mandatoryCallKeys } from "./GenericProcessor";
5
+ type callType = {
6
+ key: keyof dataRawERC4626;
7
+ call: string;
8
+ target: keyof callKeysERC4626;
9
+ metaData?: any;
10
+ };
11
+ type callKeysERC4626 = mandatoryCallKeys & {
12
+ asset: string;
13
+ decimalsAsset: string;
14
+ name: string;
15
+ symbolAsset: string;
16
+ totalAssets: string;
17
+ };
18
+ type dataRawERC4626 = callKeysERC4626 & {};
19
+ type dataTypeERC4626 = dataType & {
20
+ asset: string;
21
+ decimalsAsset: string;
22
+ symbolAsset: string;
23
+ totalAssets: string;
24
+ };
25
+ export declare class ERC4626Processor extends GenericProcessor<callKeysERC4626, dataRawERC4626, dataTypeERC4626> {
26
+ rounds: {
27
+ round1: callType[];
28
+ round2: callType[];
29
+ round3: callType[];
30
+ round4: callType[];
31
+ };
32
+ processingRound5(_index: number, type: tokenType, typeInfo: dataRawERC4626, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, pricer: Pricer): Promise<dataTypeERC4626>;
33
+ }
34
+ export {};
@@ -0,0 +1,36 @@
1
+ import { generateCardName } from "../../../../../utils/generateCardName";
2
+ import { BN2Number } from "@sdk";
3
+ import { GenericProcessor } from "./GenericProcessor";
4
+ export class ERC4626Processor extends GenericProcessor {
5
+ rounds = {
6
+ round1: [{ key: "asset", call: "asset", target: "tokenAddress" }],
7
+ round2: [
8
+ { key: "decimalsAsset", call: "decimals", target: "asset" },
9
+ { key: "symbolAsset", call: "symbol", target: "asset" },
10
+ ],
11
+ round3: [],
12
+ round4: [
13
+ { key: "totalSupply", call: "totalSupply", target: "tokenAddress" },
14
+ { key: "totalAssets", call: "totalAssets", target: "tokenAddress" },
15
+ ],
16
+ };
17
+ async processingRound5(_index, type, typeInfo, _calls, campaign, pricer) {
18
+ const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
19
+ const priceAsset = (await pricer.get({
20
+ symbol: typeInfo.symbolAsset,
21
+ })) ?? 0;
22
+ const decimalsAsset = Number.parseInt(typeInfo.decimalsAsset);
23
+ const amountAsset = BN2Number(typeInfo.totalAssets, decimalsAsset);
24
+ const tvl = priceAsset * amountAsset;
25
+ const priceTargetToken = tvl / totalSupply;
26
+ return {
27
+ ...typeInfo,
28
+ totalSupply,
29
+ tvl,
30
+ whitelistedSupplyTargetToken,
31
+ blacklistedSupply,
32
+ priceTargetToken,
33
+ cardName: generateCardName(type, typeInfo, campaign),
34
+ };
35
+ }
36
+ }
@@ -6,6 +6,7 @@ import { BalancerGaugeProcessor } from "./BalancerGaugeProcessor";
6
6
  import { BalancerPoolProcessor } from "./BalancerPoolProcessor";
7
7
  import { BeefyProcessor } from "./BeefyProcessor";
8
8
  import { CompoundProcessor } from "./CompoundProcessor";
9
+ import { ERC4626Processor } from "./ERC4626Processor";
9
10
  import { EnzymeProcessor } from "./EnzymeProcessor";
10
11
  import { EulerBorrowProcessor } from "./EulerBorrowProcessor";
11
12
  import { EulerLendProcessor } from "./EulerLendProcessor";
@@ -109,4 +110,6 @@ export const processorMapping = {
109
110
  [tokenType.veda]: NoLinkVaultProcessor,
110
111
  [tokenType.superlend_lending]: AaveProcessor,
111
112
  [tokenType.superlend_borrowing]: AaveProcessor,
113
+ [tokenType.cian]: ERC4626Processor,
114
+ [tokenType.concrete]: ERC4626Processor,
112
115
  };
@@ -120,6 +120,10 @@ function satisfiesNameConditions(name, type) {
120
120
  return lowerCaseName.includes("superlend") && lowerCaseName.includes("debt");
121
121
  case tokenType.superlend_lending:
122
122
  return lowerCaseName.includes("superlend");
123
+ case tokenType.cian:
124
+ return lowerCaseName.includes("cian");
125
+ case tokenType.concrete:
126
+ return lowerCaseName.includes("concrete");
123
127
  default:
124
128
  return false;
125
129
  }
@@ -156,7 +160,6 @@ function parseForFactory(calls, targetToken) {
156
160
  const factory = decodeReturnValue(calls.factory, "factory");
157
161
  const name = decodeReturnValue(calls.name, "name");
158
162
  const type = getTypeFromFactoryAddress(factory);
159
- console.log("factory: ", factory);
160
163
  if (type !== tokenType.unknown)
161
164
  return generateResult(type, name, targetToken, { factory });
162
165
  }
@@ -0,0 +1,5 @@
1
+ import { type Campaign, type CampaignDynamicData, type CampaignParameters, type MerklChainId } from "@sdk";
2
+ import type { UncachedResult } from "../../../utils/execute";
3
+ type ReturnType = CampaignDynamicData<Campaign.HYPERDRIVELOGPROCESSOR | Campaign.HYPERDRIVELOGFIXPROCESSOR>[];
4
+ export declare function HyperdriveDynamicData(chainId: MerklChainId, campaigns: CampaignParameters<Campaign.HYPERDRIVELOGPROCESSOR | Campaign.HYPERDRIVELOGFIXPROCESSOR>[]): Promise<UncachedResult<Partial<ReturnType>>>;
5
+ export {};
@@ -0,0 +1,76 @@
1
+ import { BN2Number, HyperdriveTargetInterface, } from "@sdk";
2
+ import { Pricer } from "../../../utils/pricer";
3
+ export async function HyperdriveDynamicData(chainId, campaigns) {
4
+ const pricer = await Pricer.load();
5
+ const calls = [];
6
+ for (const campaign of campaigns) {
7
+ calls.push({
8
+ allowFailure: false,
9
+ callData: HyperdriveTargetInterface.encodeFunctionData("getPoolInfo"),
10
+ target: campaign.campaignParameters.targetToken,
11
+ }, {
12
+ allowFailure: false,
13
+ callData: HyperdriveTargetInterface.encodeFunctionData("getPoolConfig"),
14
+ target: campaign.campaignParameters.targetToken,
15
+ }, {
16
+ allowFailure: false,
17
+ callData: HyperdriveTargetInterface.encodeFunctionData("totalSupply", [campaign.campaignParameters.tokenId]),
18
+ target: campaign.campaignParameters.targetToken,
19
+ });
20
+ }
21
+ return {
22
+ cached: false,
23
+ call: {
24
+ callData: calls,
25
+ handler: () => { },
26
+ reducer: async (result) => {
27
+ let i = 0;
28
+ const dynamicData = [];
29
+ for (const campaign of campaigns) {
30
+ const poolInfo = HyperdriveTargetInterface.decodeFunctionResult("getPoolInfo", result[i++])[0];
31
+ const poolConfig = HyperdriveTargetInterface.decodeFunctionResult("getPoolConfig", result[i++])[0];
32
+ const totalSupplyVaultToken = BN2Number(HyperdriveTargetInterface.decodeFunctionResult("totalSupply", result[i++])[0]);
33
+ const priceRewardToken = (await pricer.get({
34
+ address: campaign.rewardToken,
35
+ chainId,
36
+ symbol: campaign.campaignParameters.symbolRewardToken,
37
+ })) ?? 0;
38
+ const priceTargetToken = (await pricer.get({
39
+ address: campaign.campaignParameters.targetToken,
40
+ chainId,
41
+ symbol: campaign.campaignParameters.symbolTargetToken,
42
+ })) ?? 0;
43
+ const priceBaseToken = (await pricer.get({
44
+ address: campaign.campaignParameters.baseToken,
45
+ chainId,
46
+ symbol: campaign.campaignParameters.baseTokenSymbol,
47
+ })) ?? 0;
48
+ const supply = totalSupplyVaultToken;
49
+ dynamicData.push({
50
+ ...campaign,
51
+ totalSupplyTargetToken: supply,
52
+ tvl: 0,
53
+ apr: 0,
54
+ priceRewardToken: priceRewardToken,
55
+ });
56
+ }
57
+ return dynamicData;
58
+ },
59
+ },
60
+ };
61
+ }
62
+ // enum AssetIdPrefix {
63
+ // LP = 0,
64
+ // Long = 1,
65
+ // Short = 2,
66
+ // WithdrawalShare = 3,
67
+ // }
68
+ // function encodeAssetId(prefix: AssetIdPrefix, timestamp: bigint): bigint {
69
+ // // Check if the timestamp is within the valid range
70
+ // const maxTimestamp = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
71
+ // if (timestamp > maxTimestamp) {
72
+ // throw new Error("InvalidTimestamp");
73
+ // }
74
+ // // Encode the asset ID
75
+ // return (BigInt(prefix) << BigInt(248)) | timestamp;
76
+ // }
@@ -9,6 +9,7 @@ import { ERC20DynamicData } from "./campaignTypes/ERC20DynamicData";
9
9
  import { ERC20_SNAPSHOTDynamicData } from "./campaignTypes/ERC20_SNAPSHOTDynamicData";
10
10
  import { EigenLayerDynamicData } from "./campaignTypes/EigenLayerDynamicData";
11
11
  import { EulerDynamicData } from "./campaignTypes/EulerDynamicData";
12
+ import { HyperdriveDynamicData } from "./campaignTypes/HyperdriveDynamicData";
12
13
  import { JSON_AIRDROPDynamicData } from "./campaignTypes/JSON_AIRDROPDynamicData";
13
14
  import { MORPHODynamicData } from "./campaignTypes/MORPHODynamicData";
14
15
  import { RadiantDynamicData } from "./campaignTypes/RadiantDynamicData";
@@ -71,6 +72,13 @@ export async function campaignsDynamicData(chainId, campaigns, type) {
71
72
  case Campaign.VEST: {
72
73
  return VestDynamicData(chainId, campaigns);
73
74
  }
75
+ case Campaign.ERC20_FIX_APR: {
76
+ return ERC20DynamicData(chainId, campaigns);
77
+ }
78
+ case Campaign.HYPERDRIVELOGPROCESSOR:
79
+ case Campaign.HYPERDRIVELOGFIXPROCESSOR: {
80
+ return HyperdriveDynamicData(chainId, campaigns);
81
+ }
74
82
  }
75
83
  return {
76
84
  cached: false,
@@ -123,6 +123,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
123
123
  mainParameter?: string | undefined;
124
124
  campaignId?: string | undefined;
125
125
  opportunityId?: string | undefined;
126
+ creatorId?: string | undefined;
126
127
  test?: boolean | undefined;
127
128
  creatorTag?: string | undefined;
128
129
  tokenSymbol?: string | undefined;
@@ -195,6 +196,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
195
196
  mainParameter?: string | undefined;
196
197
  campaignId?: string | undefined;
197
198
  opportunityId?: string | undefined;
199
+ creatorId?: string | undefined;
198
200
  test?: boolean | undefined;
199
201
  creatorTag?: string | undefined;
200
202
  tokenSymbol?: string | undefined;
@@ -122,6 +122,7 @@ export declare const UpdateMetaDataCampaignDto: import("@sinclair/typebox").TObj
122
122
  }>;
123
123
  export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
124
124
  creatorTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
125
+ creatorId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
125
126
  chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
126
127
  type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
127
128
  INVALID: "INVALID";
@@ -83,6 +83,7 @@ export const UpdateMetaDataCampaignDto = t.Object({
83
83
  });
84
84
  export const GetCampaignQueryDto = t.Object({
85
85
  creatorTag: t.Optional(t.String({ description: "Filter campaigns created by a user who has a specific tag" })),
86
+ creatorId: t.Optional(t.String({ description: "Filter campaigns created by a user who is registered as a merkl creator" })),
86
87
  chainId: t.Optional(t.Numeric({
87
88
  description: "Filter by chain.<br>You can get the list of all supported chains by calling [GET /v4/chains](#tag/chains/GET/v4/chains/)",
88
89
  })),
@@ -2,7 +2,69 @@ import type { CampaignUnique, CreateCampaignModel, GetCampaignQueryModel, extend
2
2
  import { Prisma } from "../../../../database/api/.generated";
3
3
  import { type ChainId } from "@sdk";
4
4
  export declare abstract class CampaignRepository {
5
- #private;
5
+ static transformQueryToPrismaFilters(query: GetCampaignQueryModel): {
6
+ where: {
7
+ computeChainId: number | undefined;
8
+ endTimestamp: {
9
+ gte: number;
10
+ } | undefined;
11
+ opportunityId: string | undefined;
12
+ campaignId: string | undefined;
13
+ Opportunity: {
14
+ identifier: string | undefined;
15
+ };
16
+ startTimestamp: {
17
+ gte: number;
18
+ } | undefined;
19
+ subType: number | undefined;
20
+ type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | "ERC20TRANSFERS" | "ERC20LOGPROCESSOR" | "ERC20REBASELOGPROCESSOR" | "VEST" | "ERC20_FIX_APR" | "HYPERDRIVELOGPROCESSOR" | "HYPERDRIVELOGFIXPROCESSOR" | undefined;
21
+ RewardToken: {
22
+ address: string | undefined;
23
+ symbol: string | undefined;
24
+ OR: ({
25
+ symbol: {
26
+ equals: string;
27
+ mode: "insensitive";
28
+ };
29
+ displaySymbol?: undefined;
30
+ } | {
31
+ displaySymbol: {
32
+ equals: string;
33
+ mode: "insensitive";
34
+ };
35
+ symbol?: undefined;
36
+ })[] | undefined;
37
+ isTest: false | undefined;
38
+ };
39
+ Creator: {
40
+ OR: ({
41
+ Creator: {
42
+ id: string;
43
+ };
44
+ tags?: undefined;
45
+ } | {
46
+ tags: {
47
+ has: string;
48
+ };
49
+ Creator?: undefined;
50
+ })[];
51
+ Creator?: undefined;
52
+ tags?: undefined;
53
+ } | {
54
+ Creator: {
55
+ id: string;
56
+ };
57
+ OR?: undefined;
58
+ tags?: undefined;
59
+ } | {
60
+ tags: {
61
+ has: string;
62
+ };
63
+ OR?: undefined;
64
+ Creator?: undefined;
65
+ } | undefined;
66
+ };
67
+ };
6
68
  static upsert(campaign: CreateCampaignModel): Promise<{
7
69
  type: import("../../../../database/api/.generated").$Enums.CampaignType;
8
70
  id: string;
@@ -8,9 +8,18 @@ import moment from "moment";
8
8
  import { OpportunityService } from "../opportunity";
9
9
  import { TokenService } from "../token";
10
10
  export class CampaignRepository {
11
- // ─── Private Methods ─────────────────────────────────────────────────
12
- static #transformQueryToPrismaFilters(query) {
13
- const { creatorTag, chainId, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, subType, type, tokenAddress, tokenSymbol, test, } = query;
11
+ static transformQueryToPrismaFilters(query) {
12
+ const { creatorTag, creatorId, chainId, endTimestamp, opportunityId, mainParameter, campaignId, startTimestamp, subType, type, tokenAddress, tokenSymbol, test, } = query;
13
+ const getTagFilter = () => {
14
+ if (creatorTag && creatorId)
15
+ return {
16
+ OR: [{ Creator: { id: creatorId } }, { tags: { has: creatorTag } }],
17
+ };
18
+ if (creatorId)
19
+ return { Creator: { id: creatorId } };
20
+ if (creatorTag)
21
+ return { tags: { has: creatorTag } };
22
+ };
14
23
  return {
15
24
  where: {
16
25
  computeChainId: chainId,
@@ -34,11 +43,7 @@ export class CampaignRepository {
34
43
  : undefined,
35
44
  isTest: !test ? false : undefined,
36
45
  },
37
- Creator: creatorTag
38
- ? {
39
- tags: { has: creatorTag },
40
- }
41
- : undefined,
46
+ Creator: getTagFilter(),
42
47
  },
43
48
  };
44
49
  }
@@ -274,7 +279,7 @@ export class CampaignRepository {
274
279
  const { page: _page, items: _items, ...filters } = query;
275
280
  const page = _page ? _page : 0;
276
281
  const items = _items ? _items : 20;
277
- const args = CampaignRepository.#transformQueryToPrismaFilters(query);
282
+ const args = CampaignRepository.transformQueryToPrismaFilters(query);
278
283
  return await apiDbClient.campaign.findMany({
279
284
  take: items,
280
285
  skip: page * items,
@@ -291,7 +296,7 @@ export class CampaignRepository {
291
296
  });
292
297
  }
293
298
  static async countMany(query) {
294
- const args = CampaignRepository.#transformQueryToPrismaFilters(query);
299
+ const args = CampaignRepository.transformQueryToPrismaFilters(query);
295
300
  return await apiDbClient.campaign.count(args);
296
301
  }
297
302
  static async findManyCampaignId(chainId) {
@@ -26,8 +26,9 @@ export declare const ComputedValueController: Elysia<"/value", false, {
26
26
  headers: unknown;
27
27
  response: {
28
28
  200: {
29
- [x: string]: File;
30
- [x: number]: File;
29
+ averageBoost: number | null;
30
+ totalDistributedInUSD: number | null;
31
+ forfeitingBoost: number | null;
31
32
  } | null;
32
33
  };
33
34
  };
@@ -50,8 +51,10 @@ export declare const ComputedValueController: Elysia<"/value", false, {
50
51
  headers: unknown;
51
52
  response: {
52
53
  200: {
53
- [x: string]: never;
54
- [x: number]: never;
54
+ reason: string;
55
+ id: number;
56
+ campaignId: string;
57
+ boost: number | null;
55
58
  }[];
56
59
  };
57
60
  };
@@ -5,20 +5,22 @@ import { GetCampaignComputedValue, GetUserComputedValues, UpsertCampaignComputed
5
5
  import { ComputedValueService } from "./computedValue.service";
6
6
  export const ComputedValueController = new Elysia({
7
7
  prefix: "/value",
8
- detail: { tags: ["Engine"], hide: true },
8
+ detail: { tags: ["Value"] },
9
9
  })
10
10
  // ─── Get a Campaign Value ──────────────────────────────────────
11
11
  .get("/campaign/:campaignId/:field", async ({ params }) => ComputedValueService.findCampaignValue(params), {
12
12
  params: GetCampaignComputedValue,
13
- detail: { hide: true },
13
+ detail: { description: "Gets campaign-level values computed by Merkl Engine (for example average boost)" },
14
14
  })
15
15
  // ─── Get user Values ──────────────────────────────────────
16
16
  .get("/user/:address/:field", async ({ params }) => ComputedValueService.findUserValues(params), {
17
17
  params: GetUserComputedValues,
18
18
  beforeHandle: ({ params }) => {
19
- throwOnInvalidRequiredAddress(params.address);
19
+ params.address = throwOnInvalidRequiredAddress(params.address);
20
+ },
21
+ detail: {
22
+ description: "Gets campaign-level values computed by Merkl Engine (for example position specific boosts)",
20
23
  },
21
- detail: { hide: true },
22
24
  })
23
25
  // ─── Update a Campaign Value ──────────────────────────────────────
24
26
  .post("/engine/campaign", async ({ body }) => await ComputedValueService.upsertCampaignComputedValue(body), {
@@ -36,7 +38,7 @@ export const ComputedValueController = new Elysia({
36
38
  beforeHandle: ({ headers, body }) => {
37
39
  EngineGuard({ headers });
38
40
  for (const item of body) {
39
- throwOnInvalidRequiredAddress(item.address);
41
+ item.address = throwOnInvalidRequiredAddress(item.address);
40
42
  }
41
43
  },
42
44
  detail: { hide: true },
@@ -1,8 +1,12 @@
1
1
  import { t } from "elysia";
2
2
  // ─── DTOs ────────────────────────────────────────────────────────────────────
3
3
  export const GetCampaignComputedValue = t.Object({
4
- campaignId: t.String(),
5
- field: t.String(),
4
+ campaignId: t.String({
5
+ description: "The campaign Id to get the computed value for. Can be either of the for '0x1234...5678' (solidity id) or '0x1234...5678_<DISTRIBUTION_CHAIN>' or '22222' (Database id).",
6
+ }),
7
+ field: t.String({
8
+ description: "The field you're querying for. Example includes 'averageBoost', 'totalDistributedInUSD', 'forfeitingBoost'. Note that these aren't always available and depend on the campaign type.",
9
+ }),
6
10
  });
7
11
  export const UpsertCampaignComputedValue = t.Object({
8
12
  campaignId: t.String(),
@@ -10,8 +14,12 @@ export const UpsertCampaignComputedValue = t.Object({
10
14
  field: t.String(),
11
15
  });
12
16
  export const GetUserComputedValues = t.Object({
13
- address: t.String(),
14
- field: t.String(),
17
+ address: t.String({
18
+ description: "The user's address to get the computed values for.",
19
+ }),
20
+ field: t.String({
21
+ description: "The field you're querying for. Example includes 'boost'.",
22
+ }),
15
23
  });
16
24
  export const UpsertUserComputedValues = t.Array(t.Object({
17
25
  campaignId: t.String(),
@@ -1,13 +1,16 @@
1
1
  import type { GetCampaignComputedValueModel, GetUserComputedValuesModel, UpsertCampaignComputedValueModel, UpsertUserComputedValuesModel } from "./computedValue.model";
2
2
  export declare class ComputedValueRepository {
3
3
  static findCampaignValue(params: GetCampaignComputedValueModel): Promise<{
4
- [x: string]: never;
5
- [x: number]: never;
4
+ averageBoost: number | null;
5
+ totalDistributedInUSD: number | null;
6
+ forfeitingBoost: number | null;
6
7
  } | null>;
7
8
  static upsertCampaignComputedValue(data: UpsertCampaignComputedValueModel): Promise<void>;
8
- static findUserValues(params: GetUserComputedValuesModel): Promise<{
9
- [x: string]: never;
10
- [x: number]: never;
9
+ static findUserValues(data: GetUserComputedValuesModel): Promise<{
10
+ reason: string;
11
+ id: number;
12
+ campaignId: string;
13
+ boost: number | null;
11
14
  }[]>;
12
15
  static upsertUserComputedValues(data: UpsertUserComputedValuesModel): Promise<void>;
13
16
  }
@@ -16,10 +16,14 @@ export class ComputedValueRepository {
16
16
  },
17
17
  });
18
18
  }
19
- static async findUserValues(params) {
19
+ static async findUserValues(data) {
20
20
  return await apiDbClient.userComputedValue.findMany({
21
- where: { address: params.address },
22
- select: { [params.field]: true },
21
+ where: { address: data.address },
22
+ select: {
23
+ campaignId: true,
24
+ reason: true,
25
+ [data.field]: true,
26
+ },
23
27
  });
24
28
  }
25
29
  static async upsertUserComputedValues(data) {