@merkl/api 0.21.35 → 0.21.37

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 (24) hide show
  1. package/dist/src/eden/index.d.ts +1277 -878
  2. package/dist/src/engine/implementations/Erc20/subTypes/detect.js +105 -98
  3. package/dist/src/engine/implementations/Erc20/subTypes/implementations/aave/metadata.d.ts +1 -1
  4. package/dist/src/engine/implementations/JsonAirdrop/metadata.d.ts +2 -2
  5. package/dist/src/index.d.ts +399 -254
  6. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -1
  7. package/dist/src/modules/v4/campaign/campaign.service.d.ts +5 -1
  8. package/dist/src/modules/v4/campaign/campaign.service.js +41 -2
  9. package/dist/src/modules/v4/campaign/campaign.test.controller.d.ts +385 -240
  10. package/dist/src/modules/v4/campaign/campaign.test.controller.js +39 -13
  11. package/dist/src/modules/v4/creator/creator.controller.d.ts +8 -8
  12. package/dist/src/modules/v4/creator/creator.controller.js +9 -9
  13. package/dist/src/modules/v4/creator/creator.model.d.ts +2 -2
  14. package/dist/src/modules/v4/creator/creator.model.js +2 -2
  15. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +2 -2
  16. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +3 -3
  17. package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +100 -0
  18. package/dist/src/modules/v4/programPayload/programPayload.repository.js +44 -0
  19. package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -1
  20. package/dist/src/modules/v4/protocol/protocol.model.js +1 -0
  21. package/dist/src/modules/v4/reward/reward.repository.js +1 -1
  22. package/dist/src/modules/v4/router.d.ts +399 -254
  23. package/dist/tsconfig.package.tsbuildinfo +1 -1
  24. package/package.json +1 -1
@@ -13,93 +13,111 @@ import { BalancerPoolInterface, BalancerV3StablePoolInterface, ChainInteractionS
13
13
  */
14
14
  export const detectSubType = async (chainId, campaigns) => {
15
15
  // 1. Do a generic multicall per campaign to see which functions are supported
16
- const callsPerCampaign = 8;
17
- const calls = [];
18
- for (const [index, campaign] of campaigns.entries()) {
16
+ const detectionCalls = await ChainInteractionService(chainId).fetchAndDecodeObject(campaigns.flatMap(campaign => {
19
17
  const { targetToken } = campaign.campaignParameters;
20
- calls.push({
21
- allowFailure: true,
22
- callData: FactoryInterface.encodeFunctionData("factory"),
23
- target: targetToken,
24
- }, {
25
- allowFailure: true,
26
- callData: MetamorphoInterface.encodeFunctionData("MORPHO"),
27
- target: targetToken,
28
- }, {
29
- allowFailure: true,
30
- callData: ERC20Interface.encodeFunctionData("name"),
31
- target: targetToken,
32
- }, {
33
- allowFailure: true,
34
- callData: BalancerPoolInterface.encodeFunctionData("getPoolId"),
35
- target: targetToken,
36
- }, {
37
- allowFailure: true,
38
- callData: EnzymeInterface.encodeFunctionData("getCreator"),
39
- target: targetToken,
40
- }, {
41
- allowFailure: true,
42
- callData: LayerBankERC20Interface.encodeFunctionData("owner"),
43
- target: targetToken,
44
- }, {
45
- allowFailure: true,
46
- callData: BalancerV3StablePoolInterface.encodeFunctionData("getVault"),
47
- target: targetToken,
48
- }, {
49
- allowFailure: true,
50
- callData: IonPoolInterface.encodeFunctionData("treasury"),
51
- target: targetToken,
52
- });
53
- if (calls.length !== callsPerCampaign * (index + 1))
54
- throw new Error("computeSubTypes: calls.length !== callsPerCampaign * index");
55
- }
56
- const callResult = await ChainInteractionService(chainId).fetchState(calls);
18
+ return [
19
+ {
20
+ callData: FactoryInterface.encodeFunctionData("factory"),
21
+ target: targetToken,
22
+ key: `${campaign.campaignId}_factory`,
23
+ decoder: (data) => FactoryInterface.decodeFunctionResult("factory", data)[0],
24
+ },
25
+ {
26
+ callData: MetamorphoInterface.encodeFunctionData("MORPHO"),
27
+ target: targetToken,
28
+ key: `${campaign.campaignId}_metamorpho`,
29
+ decoder: (data) => MetamorphoInterface.decodeFunctionResult("MORPHO", data)[0],
30
+ },
31
+ {
32
+ callData: ERC20Interface.encodeFunctionData("name"),
33
+ target: targetToken,
34
+ key: `${campaign.campaignId}_name`,
35
+ decoder: (data) => ERC20Interface.decodeFunctionResult("name", data)[0],
36
+ },
37
+ {
38
+ callData: BalancerPoolInterface.encodeFunctionData("getPoolId"),
39
+ target: targetToken,
40
+ key: `${campaign.campaignId}_getPoolId`,
41
+ decoder: (data) => BalancerPoolInterface.decodeFunctionResult("getPoolId", data)[0],
42
+ },
43
+ {
44
+ callData: EnzymeInterface.encodeFunctionData("getCreator"),
45
+ target: targetToken,
46
+ key: `${campaign.campaignId}_getCreator`,
47
+ decoder: (data) => EnzymeInterface.decodeFunctionResult("getCreator", data)[0],
48
+ },
49
+ {
50
+ callData: LayerBankERC20Interface.encodeFunctionData("owner"),
51
+ target: targetToken,
52
+ key: `${campaign.campaignId}_owner`,
53
+ decoder: (data) => LayerBankERC20Interface.decodeFunctionResult("owner", data)[0],
54
+ },
55
+ {
56
+ callData: BalancerV3StablePoolInterface.encodeFunctionData("getVault"),
57
+ target: targetToken,
58
+ key: `${campaign.campaignId}_getVault`,
59
+ decoder: (data) => BalancerV3StablePoolInterface.decodeFunctionResult("getVault", data)[0],
60
+ },
61
+ {
62
+ callData: IonPoolInterface.encodeFunctionData("treasury"),
63
+ target: targetToken,
64
+ key: `${campaign.campaignId}_treasury`,
65
+ decoder: (data) => IonPoolInterface.decodeFunctionResult("treasury", data)[0],
66
+ },
67
+ {
68
+ callData: "0x038f6f61", // Factory call for Pinto protocol
69
+ target: targetToken,
70
+ key: `${campaign.campaignId}_pinto`,
71
+ decoder: (data) => FactoryInterface.decodeFunctionResult("factory", data)[0],
72
+ },
73
+ ];
74
+ }));
57
75
  // 2. Decode result from the multicalls and using try catch, try to interprete the result
58
76
  const res = [];
59
- let index = -callsPerCampaign;
60
77
  for (const campaign of campaigns) {
61
78
  const { targetToken } = campaign.campaignParameters;
62
- index += callsPerCampaign;
63
- const values = {
64
- factory: callResult[index].returnData,
65
- metamorpho: callResult[index + 1].returnData,
66
- name: callResult[index + 2].returnData,
67
- poolId: callResult[index + 3].returnData,
68
- creator: callResult[index + 4].returnData,
69
- owner: callResult[index + 5].returnData,
70
- vault: callResult[index + 6].returnData,
71
- treasury: callResult[index + 7].returnData,
72
- };
79
+ const factory = detectionCalls[`${campaign.campaignId}_factory`];
80
+ const metamorpho = detectionCalls[`${campaign.campaignId}_metamorpho`];
81
+ const name = detectionCalls[`${campaign.campaignId}_name`];
82
+ const poolId = detectionCalls[`${campaign.campaignId}_getPoolId`];
83
+ const vault = detectionCalls[`${campaign.campaignId}_getVault`];
84
+ const creator = detectionCalls[`${campaign.campaignId}_getCreator`];
85
+ const owner = detectionCalls[`${campaign.campaignId}_owner`];
86
+ const treasury = detectionCalls[`${campaign.campaignId}_treasury`];
87
+ const pintoFactory = detectionCalls[`${campaign.campaignId}_pinto`];
73
88
  // Get erc20SubType from factory address
74
- try {
75
- const factory = decodeReturnValue(values.factory, "factory");
76
- const type = getTypeFromFactoryAddress(factory);
77
- if (type !== Erc20SubType.unknown) {
78
- res.push(type);
79
- continue;
89
+ if (!!factory || !!creator || !!pintoFactory) {
90
+ try {
91
+ const type = getTypeFromFactoryAddress((factory ?? creator ?? pintoFactory));
92
+ if (type !== Erc20SubType.unknown) {
93
+ res.push(type);
94
+ continue;
95
+ }
80
96
  }
97
+ catch { }
81
98
  }
82
- catch { }
83
99
  // Get erc20SubType from treasury address
84
- try {
85
- const treasury = decodeReturnValue(values.treasury, "treasury");
86
- const type = getTypeFromTreasuryAddress(treasury);
87
- if (type !== Erc20SubType.unknown) {
88
- res.push(type);
89
- continue;
100
+ if (!!treasury) {
101
+ try {
102
+ const type = getTypeFromTreasuryAddress(treasury);
103
+ if (type !== Erc20SubType.unknown) {
104
+ res.push(type);
105
+ continue;
106
+ }
90
107
  }
108
+ catch { }
91
109
  }
92
- catch { }
93
110
  // Get erc20SubType from owner address
94
- try {
95
- const owner = decodeReturnValue(values.owner, "owner");
96
- const type = getTypeFromOwnerAddress(owner);
97
- if (type !== Erc20SubType.unknown) {
98
- res.push(type);
99
- continue;
111
+ if (!!owner) {
112
+ try {
113
+ const type = getTypeFromOwnerAddress(owner);
114
+ if (type !== Erc20SubType.unknown) {
115
+ res.push(type);
116
+ continue;
117
+ }
100
118
  }
119
+ catch { }
101
120
  }
102
- catch { }
103
121
  // Get erc20SubType from address
104
122
  try {
105
123
  const type = getTypeFromAddressChain(chainId, targetToken);
@@ -109,44 +127,33 @@ export const detectSubType = async (chainId, campaigns) => {
109
127
  }
110
128
  }
111
129
  catch { }
112
- // Get erc20SubType for enzyme (factory is replaced by dispatcher)
113
- try {
114
- const factory = decodeReturnValue(values.creator, "getCreator");
115
- const type = getTypeFromFactoryAddress(factory);
116
- if (type !== Erc20SubType.unknown) {
117
- res.push(type);
130
+ // Get erc20SubType for morpho
131
+ if (!!metamorpho) {
132
+ try {
133
+ decodeReturnValue(metamorpho, "MORPHO");
134
+ res.push(Erc20SubType.metamorpho);
118
135
  continue;
119
136
  }
137
+ catch { }
120
138
  }
121
- catch { }
122
- // Get erc20SubType for morpho
123
- try {
124
- decodeReturnValue(values.metamorpho, "MORPHO");
125
- res.push(Erc20SubType.metamorpho);
126
- continue;
127
- }
128
- catch { }
129
139
  // Starting from this point, assume the name is working
130
140
  try {
131
- const name = decodeReturnValue(values.name, "name");
132
141
  // Get erc20SubType for balancer
133
- try {
134
- decodeReturnValue(values.poolId, "getPoolId");
142
+ if (!!poolId) {
135
143
  res.push(Erc20SubType.balancerPool);
136
144
  continue;
137
145
  }
138
- catch { }
139
- try {
140
- decodeReturnValue(values.vault, "getVault");
146
+ if (!!vault) {
141
147
  res.push(Erc20SubType.balancerPool);
142
148
  continue;
143
149
  }
144
- catch { }
145
150
  // Get erc20SubType by parsing information from the erc20 name
146
- const typeInfoFromName = processNamingConditionsInOrder(name, targetToken, campaign);
147
- if (!!typeInfoFromName) {
148
- res.push(typeInfoFromName.type);
149
- continue;
151
+ if (!!name) {
152
+ const typeInfoFromName = processNamingConditionsInOrder(name, targetToken, campaign);
153
+ if (!!typeInfoFromName) {
154
+ res.push(typeInfoFromName.type);
155
+ continue;
156
+ }
150
157
  }
151
158
  }
152
159
  catch { }
@@ -18,7 +18,7 @@ export declare class AaveMetadata implements MetadataBuilder<Erc20LikeCampaignEn
18
18
  constructor(mainProtocol: ProtocolId, protocolName: string, depositUrl: (underlyingToken: string) => string);
19
19
  build(campaign: Omit<CampaignWithParams<Erc20LikeCampaignEnum>, "manualOverrides">, _opportunityIdentifier: string): Promise<{
20
20
  action: "LEND" | "BORROW";
21
- mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer";
21
+ mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "pinto" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer";
22
22
  name: string;
23
23
  tokens: {
24
24
  chainId: number;
@@ -10,13 +10,13 @@ export declare class JsonAirdropMetadata implements MetadataBuilder<campaignType
10
10
  chainId: number;
11
11
  address: string;
12
12
  }[];
13
- mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer" | undefined;
13
+ mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "pinto" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer" | undefined;
14
14
  depositUrl?: undefined;
15
15
  } | {
16
16
  action: "DROP";
17
17
  name: string;
18
18
  tokens: never[];
19
- mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer" | undefined;
19
+ mainProtocol: "splice" | "reserve" | "morpho" | "quickswap" | "euler" | "uniswap" | "ambient" | "arthswap" | "base-swap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancake-swap" | "ramses" | "retro" | "stryke" | "sushi-swap" | "swapr" | "thruster" | "voltage" | "zero" | "koi" | "supswap" | "zk-swap" | "thirdtrade" | "swap-x" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap" | "neptune" | "zkSwapThreePool" | "rfx" | "ra" | "maverick" | "trader-joe" | "hanji" | "pinto" | "radiant" | "aave" | "fraxlend" | "ironclad" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "lnd" | "dlend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | "lendle" | "tako-tako" | "equalizer" | "spectra" | "beraborrow" | "superlend" | "avalon" | "iguana" | "xlend" | "sake" | "sonicmarket" | "stability" | "angles" | "enzyme" | "toros" | "vicuna" | "bunni" | "beratrax" | "concrete" | "cian" | "pendle" | "yei" | "termmax" | "filament" | "gammaswap" | "maha" | "tempest" | "uranium" | "holdstation" | "katana" | "punchswap" | "satlayer" | "puffer" | undefined;
20
20
  depositUrl: any;
21
21
  }>;
22
22
  static generateUrl(_computeChainId: ChainId, params: CampaignParameters<campaignType>["campaignParameters"]): any;