@merkl/api 0.17.33 → 0.17.35
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.
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.d.ts +0 -2
- package/dist/src/backgroundJobs/jobs/opportunityUpdater.js +2 -54
- package/dist/src/eden/index.d.ts +5 -5
- package/dist/src/factories/metadataFactory/factory.d.ts +3 -0
- package/dist/src/factories/metadataFactory/factory.js +56 -0
- package/dist/src/factories/metadataFactory/implementations/Ajna.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Ajna.js +52 -0
- package/dist/src/factories/metadataFactory/implementations/Ambiant.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Ambiant.js +31 -0
- package/dist/src/factories/metadataFactory/implementations/Badger.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Badger.js +25 -0
- package/dist/src/factories/metadataFactory/implementations/Clamm.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Clamm.js +50 -0
- package/dist/src/factories/metadataFactory/implementations/Compound.d.ts +16 -0
- package/dist/src/factories/metadataFactory/implementations/Compound.js +20 -0
- package/dist/src/factories/metadataFactory/implementations/Default.d.ts +13 -0
- package/dist/src/factories/metadataFactory/implementations/Default.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Dolomite.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Dolomite.js +17 -0
- package/dist/src/factories/metadataFactory/implementations/EigenLayer.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/EigenLayer.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Encompassing.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Encompassing.js +37 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20.js +71 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.d.ts +14 -0
- package/dist/src/factories/metadataFactory/implementations/Erc20Snapshot.js +10 -0
- package/dist/src/factories/metadataFactory/implementations/Euler.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Euler.js +34 -0
- package/dist/src/factories/metadataFactory/implementations/EventBased.d.ts +20 -0
- package/dist/src/factories/metadataFactory/implementations/EventBased.js +45 -0
- package/dist/src/factories/metadataFactory/implementations/Hyperdrive.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Hyperdrive.js +21 -0
- package/dist/src/factories/metadataFactory/implementations/Invalid.d.ts +11 -0
- package/dist/src/factories/metadataFactory/implementations/Invalid.js +10 -0
- package/dist/src/factories/metadataFactory/implementations/Ion.d.ts +16 -0
- package/dist/src/factories/metadataFactory/implementations/Ion.js +15 -0
- package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/JsonAirdrop.js +38 -0
- package/dist/src/factories/metadataFactory/implementations/Morpho.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Morpho.js +21 -0
- package/dist/src/factories/metadataFactory/implementations/Radiant.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Radiant.js +11 -0
- package/dist/src/factories/metadataFactory/implementations/Silo.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Silo.js +15 -0
- package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/UniswapV4Metadata.js +28 -0
- package/dist/src/factories/metadataFactory/implementations/Vest.d.ts +15 -0
- package/dist/src/factories/metadataFactory/implementations/Vest.js +12 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +0 -11
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +4 -4
- package/dist/src/modules/v4/opportunity/opportunity.service.js +10 -86
- package/dist/src/modules/v4/router.d.ts +1 -1
- package/dist/src/routes/v3/opportunity.d.ts +0 -14
- package/dist/src/routes/v3/opportunity.js +2 -43
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/entities/opportunity.d.ts +0 -22
- package/dist/src/entities/opportunity.js +0 -1073
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +0 -50
- package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getAmbientMetadata.service.js +0 -29
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +0 -23
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +0 -48
- package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getCompoundMetadata.service.js +0 -18
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getDolomiteMetadata.service.js +0 -15
- package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEigenLayerMetadata.service.js +0 -9
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.js +0 -35
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.d.ts +0 -5
- package/dist/src/modules/v4/opportunity/subservices/getErc20Metadata.service.js +0 -69
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getErc20SnapshotMetadata.service.js +0 -8
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEulerMetadata.service.js +0 -34
- package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getEventBasedMetadata.service.ts.js +0 -43
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getHyperdriveMetadata.service.js +0 -19
- package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getIonMetadata.service.js +0 -13
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getJsonAirDropMetadata.service.js +0 -36
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getMorphoMetadata.service.js +0 -19
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getRadiantMetadata.service.js +0 -9
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getSiloMetadata.service.js +0 -13
- package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getUniswapV4Metadata.service.js +0 -26
- package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.d.ts +0 -3
- package/dist/src/modules/v4/opportunity/subservices/getVestMetadata.service.js +0 -10
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { AjnaCampaign, ChainId } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getAjnaMetadata: (chainId: ChainId, campaignSubType: AjnaCampaign["campaignSubType"], params: AjnaCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { TokenService } from "../../token/token.service";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
export const getAjnaMetadata = async (chainId, campaignSubType, params) => {
|
4
|
-
try {
|
5
|
-
const [collateral, quote] = await TokenService.getManyOrCreate([
|
6
|
-
{
|
7
|
-
chainId,
|
8
|
-
address: params.collateralToken,
|
9
|
-
},
|
10
|
-
{
|
11
|
-
chainId,
|
12
|
-
address: params.quoteToken,
|
13
|
-
},
|
14
|
-
]);
|
15
|
-
if (!collateral || !quote)
|
16
|
-
throw new Error("Failed to fetch tokens");
|
17
|
-
const market = `${params.symbolQuoteToken}/${collateral?.symbol}`;
|
18
|
-
const subtypes = [
|
19
|
-
{ name: `Supply ${collateral?.symbol} on ${market}`, action: OpportunityAction.LEND },
|
20
|
-
{ name: `Borrow ${quote?.symbol} on ${market}`, action: OpportunityAction.BORROW },
|
21
|
-
];
|
22
|
-
const subtype = subtypes[campaignSubType];
|
23
|
-
return {
|
24
|
-
action: subtype.action,
|
25
|
-
name: subtype.name,
|
26
|
-
tokens: [
|
27
|
-
{ chainId, address: collateral.address },
|
28
|
-
{ chainId, address: quote.address },
|
29
|
-
],
|
30
|
-
mainProtocol: "ajna",
|
31
|
-
};
|
32
|
-
}
|
33
|
-
catch (_err) {
|
34
|
-
const market = `${params.symbolQuoteToken}/${params.symbolCollateralToken}`;
|
35
|
-
const subtypes = [
|
36
|
-
{ name: `Supply ${params.symbolCollateralToken} on ${market}`, action: OpportunityAction.LEND },
|
37
|
-
{ name: `Borrow ${params.symbolQuoteToken} on ${market}`, action: OpportunityAction.BORROW },
|
38
|
-
];
|
39
|
-
const subtype = subtypes[campaignSubType];
|
40
|
-
return {
|
41
|
-
action: subtype.action,
|
42
|
-
name: subtype.name,
|
43
|
-
tokens: [
|
44
|
-
{ chainId, address: params.collateralToken },
|
45
|
-
{ chainId, address: params.quoteToken },
|
46
|
-
],
|
47
|
-
mainProtocol: "ajna",
|
48
|
-
};
|
49
|
-
}
|
50
|
-
};
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
import { almName } from "@sdk";
|
3
|
-
import { getAddress } from "viem";
|
4
|
-
export const getAmbientMetadata = (chainId, params) => {
|
5
|
-
const platform = "Ambient";
|
6
|
-
let whitelistNameString = "";
|
7
|
-
if (params.whitelist.length > 0) {
|
8
|
-
for (const whitelist of params.whitelist) {
|
9
|
-
if (whitelistNameString.length > 0) {
|
10
|
-
whitelistNameString += "or";
|
11
|
-
}
|
12
|
-
const forwarder = params.forwarders.find(x => getAddress(x.sender) === getAddress(whitelist));
|
13
|
-
const forwarderType = forwarder?.type;
|
14
|
-
const forwarderName = !!forwarderType ? almName(forwarderType) : null;
|
15
|
-
if (!!forwarderName) {
|
16
|
-
whitelistNameString += ` ${forwarderName} `;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
return {
|
21
|
-
name: `Provide liquidity to ${whitelistNameString} ${platform} ${params.baseToken}-${params.quoteToken}`,
|
22
|
-
action: OpportunityAction.POOL,
|
23
|
-
tokens: [
|
24
|
-
{ chainId, address: params.baseToken },
|
25
|
-
{ chainId, address: params.quoteToken },
|
26
|
-
],
|
27
|
-
mainProtocol: "ambient",
|
28
|
-
};
|
29
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { TokenService } from "../../token/token.service";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
export const getBadgerMetadata = async (chainId, params) => {
|
4
|
-
try {
|
5
|
-
const [token] = await TokenService.getManyOrCreate([{ chainId, address: params.targetToken }]);
|
6
|
-
if (!token)
|
7
|
-
throw new Error("Failed to fetch tokens");
|
8
|
-
return {
|
9
|
-
action: OpportunityAction.BORROW,
|
10
|
-
name: `Borrow ${token.symbol}`,
|
11
|
-
tokens: [{ chainId, address: token?.address }],
|
12
|
-
mainProtocol: "badger",
|
13
|
-
};
|
14
|
-
}
|
15
|
-
catch (err) {
|
16
|
-
return {
|
17
|
-
action: OpportunityAction.BORROW,
|
18
|
-
name: `Borrow ${params.symbolTargetToken}`,
|
19
|
-
tokens: [{ chainId, address: params.targetToken }],
|
20
|
-
mainProtocol: "badger",
|
21
|
-
};
|
22
|
-
}
|
23
|
-
};
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { camelToKebabCase } from "../../../../utils/camelToKebabCase";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
import { AMM, ChainId, almName, ammName } from "@sdk";
|
4
|
-
import { getAddress } from "viem";
|
5
|
-
export const getClammMetadata = (chainId, params) => {
|
6
|
-
let platform = ammName(params.amm);
|
7
|
-
if (platform === "BaseSwap") {
|
8
|
-
switch (chainId) {
|
9
|
-
case ChainId.MODE:
|
10
|
-
platform = "SwapMode";
|
11
|
-
break;
|
12
|
-
case ChainId.ARBITRUM:
|
13
|
-
platform = "Arbitex";
|
14
|
-
break;
|
15
|
-
case ChainId.OPTIMISM:
|
16
|
-
platform = "SuperSwap";
|
17
|
-
}
|
18
|
-
}
|
19
|
-
if (platform === "Izumi") {
|
20
|
-
if (chainId === ChainId.ROOTSTOCK)
|
21
|
-
platform = "WoodSwap";
|
22
|
-
else
|
23
|
-
platform = "iZUMi";
|
24
|
-
}
|
25
|
-
let whitelistNameString = "";
|
26
|
-
if (params.whitelist.length > 0) {
|
27
|
-
for (const whitelist of params.whitelist) {
|
28
|
-
if (whitelistNameString.length > 0) {
|
29
|
-
whitelistNameString += "or";
|
30
|
-
}
|
31
|
-
const forwarder = params.forwarders.find(x => getAddress(x.sender) === getAddress(whitelist));
|
32
|
-
const forwarderType = forwarder?.type;
|
33
|
-
const forwarderName = !!forwarderType ? almName(forwarderType) : null;
|
34
|
-
if (!!forwarderName) {
|
35
|
-
whitelistNameString += ` ${forwarderName} `;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
return {
|
40
|
-
name: `Provide liquidity to ${whitelistNameString} ${platform} ${params.symbolToken0}-${params.symbolToken1}${params.poolFee ? ` ${params.poolFee}%` : ""}`,
|
41
|
-
action: OpportunityAction.POOL,
|
42
|
-
tokens: [
|
43
|
-
{ chainId, address: params.token0 },
|
44
|
-
{ chainId, address: params.token1 },
|
45
|
-
],
|
46
|
-
mainProtocol: camelToKebabCase(AMM[params.amm]),
|
47
|
-
};
|
48
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { type ChainId, type CompoundCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getCompoundMetadata: (chainId: ChainId, campaignSubType: CompoundCampaign["campaignSubType"], params: CompoundCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
import { CompFork, CompoundSubCampaignType } from "@sdk";
|
3
|
-
export const getCompoundMetadata = (chainId, campaignSubType, params) => {
|
4
|
-
return {
|
5
|
-
action: campaignSubType === CompoundSubCampaignType.supply ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
6
|
-
name: [
|
7
|
-
params.subCampaignType === CompoundSubCampaignType.supply
|
8
|
-
? `Supply ${params.symbolUnderlyingToken} on`
|
9
|
-
: `Borrow ${params.symbolUnderlyingToken} on`,
|
10
|
-
CompFork[params.compFork],
|
11
|
-
].join(" "),
|
12
|
-
tokens: [
|
13
|
-
{ chainId, address: params.underlyingToken },
|
14
|
-
{ chainId, address: params.targetToken },
|
15
|
-
],
|
16
|
-
mainProtocol: CompFork[params.compFork].toLowerCase(),
|
17
|
-
};
|
18
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ChainId, DolomiteCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getDolomiteMetadata: (chainId: ChainId, campaignSubType: DolomiteCampaign["campaignSubType"], params: DolomiteCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getDolomiteMetadata = (chainId, campaignSubType, params) => {
|
3
|
-
const subtypes = [
|
4
|
-
{ name: "Supply (delta)", action: OpportunityAction.LEND },
|
5
|
-
{ name: "Supply", action: OpportunityAction.LEND },
|
6
|
-
{ name: "Borrow", action: OpportunityAction.BORROW },
|
7
|
-
];
|
8
|
-
const subtype = subtypes[campaignSubType];
|
9
|
-
return {
|
10
|
-
action: subtype.action,
|
11
|
-
tokens: [{ chainId, address: params.targetToken }],
|
12
|
-
name: `${subtype.name} ${params.symbolTargetToken}`,
|
13
|
-
mainProtocol: "dolomite",
|
14
|
-
};
|
15
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getEigenLayerMetadata = async (chainId, params) => {
|
3
|
-
return {
|
4
|
-
action: OpportunityAction.LEND,
|
5
|
-
name: ["EigenLayer", "strategy for", params.symbolUnderlyingToken].join(" "),
|
6
|
-
tokens: [{ chainId, address: params.underlyingToken }],
|
7
|
-
mainProtocol: "eigenlayer",
|
8
|
-
};
|
9
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ChainId, EncompassingCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getEncompassingMetadata: (chainId: ChainId, rewardTokenAddress: string, params: EncompassingCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { log } from "../../../../utils/logger";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
export const getEncompassingMetadata = async (chainId, rewardTokenAddress, params) => {
|
4
|
-
try {
|
5
|
-
const dataResponse = await fetch(params.dataUrl);
|
6
|
-
if (!dataResponse.ok)
|
7
|
-
throw new Error(`Response status: ${dataResponse.status}`);
|
8
|
-
const data = await dataResponse.json();
|
9
|
-
return {
|
10
|
-
action: OpportunityAction.DROP,
|
11
|
-
name: data.opportunityName ?? `Distribution of ${params.symbolRewardToken}`,
|
12
|
-
tokens: [
|
13
|
-
{
|
14
|
-
chainId,
|
15
|
-
address: rewardTokenAddress,
|
16
|
-
},
|
17
|
-
],
|
18
|
-
mainProtocol: data.mainProtocol ?? undefined,
|
19
|
-
};
|
20
|
-
}
|
21
|
-
catch (err) {
|
22
|
-
log.error("failed to fetch data from dataUrl", err);
|
23
|
-
return {
|
24
|
-
action: OpportunityAction.DROP,
|
25
|
-
name: `Distribution of ${params.symbolRewardToken}`,
|
26
|
-
tokens: [
|
27
|
-
{
|
28
|
-
chainId,
|
29
|
-
address: rewardTokenAddress,
|
30
|
-
},
|
31
|
-
],
|
32
|
-
mainProtocol: undefined,
|
33
|
-
};
|
34
|
-
}
|
35
|
-
};
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { OpportunityMetadata } from "..";
|
2
|
-
import { type ChainId, type ERC20Campaign } from "@sdk";
|
3
|
-
import type { ERC20FixAPRCampaign, ERC20LogCampaign } from "libs/sdk/src/types/merkl/campaignTypes/erc20Log";
|
4
|
-
import type { ERC20RebaseLogCampaign } from "libs/sdk/src/types/merkl/campaignTypes/erc20RebaseLog";
|
5
|
-
export declare const getErc20Metadata: (computeChainId: ChainId, distributionChainId: ChainId, campaignId: string, rewardToken: string, amount: string, params: ERC20Campaign["campaignParameters"] | ERC20LogCampaign["campaignParameters"] | ERC20RebaseLogCampaign["campaignParameters"] | ERC20FixAPRCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import { log } from "../../../../utils/logger";
|
2
|
-
import { Campaign as CampaignEnum } from "@sdk";
|
3
|
-
import { CampaignService } from "../../campaign";
|
4
|
-
import { ProtocolService } from "../../protocol";
|
5
|
-
export const getErc20Metadata = async (computeChainId, distributionChainId, campaignId, rewardToken, amount, params) => {
|
6
|
-
let action = "HOLD";
|
7
|
-
let name = `Hold ${params.symbolTargetToken}`;
|
8
|
-
let mainProtocolId = undefined;
|
9
|
-
const tokens = [{ chainId: computeChainId, address: params.targetToken }];
|
10
|
-
try {
|
11
|
-
const [dynamicData] = await CampaignService.fetchDynamicData(computeChainId, CampaignEnum[CampaignEnum.ERC20], [
|
12
|
-
{
|
13
|
-
campaignId,
|
14
|
-
rewardToken,
|
15
|
-
amount,
|
16
|
-
chainId: distributionChainId,
|
17
|
-
computeChainId,
|
18
|
-
campaignParameters: params,
|
19
|
-
},
|
20
|
-
]);
|
21
|
-
action = dynamicData?.typeInfo?.action ?? action;
|
22
|
-
name = dynamicData?.typeInfo?.cardName;
|
23
|
-
mainProtocolId = dynamicData?.typeInfo?.protocol?.toLowerCase().replace(" ", "");
|
24
|
-
const protocol = (await ProtocolService.findMany({ id: mainProtocolId }))?.[0];
|
25
|
-
if (!!protocol) {
|
26
|
-
mainProtocolId = protocol?.id;
|
27
|
-
}
|
28
|
-
// Case of lending protocols and receipt tokens
|
29
|
-
if (!!dynamicData && !!dynamicData.typeInfo?.underlying) {
|
30
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.underlying });
|
31
|
-
}
|
32
|
-
// Case of perps protocols
|
33
|
-
if (!!dynamicData && !!dynamicData.typeInfo?.shortToken && !!dynamicData.typeInfo?.longToken) {
|
34
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.shortToken });
|
35
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.longToken });
|
36
|
-
}
|
37
|
-
// Case of weird AMMs
|
38
|
-
if (!!dynamicData && !!dynamicData.typeInfo?.tokenA && !!dynamicData.typeInfo?.tokenB) {
|
39
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.tokenA });
|
40
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.tokenB });
|
41
|
-
}
|
42
|
-
// Case of AMMs
|
43
|
-
if (!!dynamicData && !!dynamicData.typeInfo?.token0 && !!dynamicData.typeInfo?.token1) {
|
44
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.token0 });
|
45
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.token1 });
|
46
|
-
}
|
47
|
-
// Case of tripools
|
48
|
-
if (!!dynamicData &&
|
49
|
-
!!dynamicData.typeInfo?.token0Address &&
|
50
|
-
!!dynamicData.typeInfo?.token1Address &&
|
51
|
-
!!dynamicData.typeInfo?.token2Address) {
|
52
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.token0Address });
|
53
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.token1Address });
|
54
|
-
tokens.push({ chainId: computeChainId, address: dynamicData.typeInfo.token2Address });
|
55
|
-
}
|
56
|
-
}
|
57
|
-
catch {
|
58
|
-
log.warn(`failed to fetch dynamic data for ERC20 campaign ${campaignId}`);
|
59
|
-
}
|
60
|
-
if (mainProtocolId === "unknown") {
|
61
|
-
mainProtocolId = undefined;
|
62
|
-
}
|
63
|
-
return {
|
64
|
-
action,
|
65
|
-
name,
|
66
|
-
tokens,
|
67
|
-
mainProtocol: mainProtocolId,
|
68
|
-
};
|
69
|
-
};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getErc20SnapshotMetadata = (chainId, params) => {
|
3
|
-
return {
|
4
|
-
name: ["Get", params.symbolTargetToken, "airdrop"].join(" "),
|
5
|
-
action: OpportunityAction.DROP,
|
6
|
-
tokens: [{ chainId, address: params.targetToken }],
|
7
|
-
};
|
8
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { type ChainId, type EulerCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getEulerMetadata: (chainId: ChainId, campaignId: string, campaignSubType: EulerCampaign["campaignSubType"], rewardToken: string, amount: string, params: EulerCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { log } from "../../../../utils/logger";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
import { Campaign as CampaignEnum } from "@sdk";
|
4
|
-
import { CampaignService } from "../../campaign";
|
5
|
-
export const getEulerMetadata = async (chainId, campaignId, campaignSubType, rewardToken, amount, params
|
6
|
-
// campaign: CampaignParameters<ConvertedCampaignType<"EULER">>
|
7
|
-
) => {
|
8
|
-
let name = `Hold ${params.symbolTargetToken}`;
|
9
|
-
try {
|
10
|
-
const [dynamicData] = await CampaignService.fetchDynamicData(chainId, CampaignEnum[CampaignEnum.EULER], [
|
11
|
-
{
|
12
|
-
campaignSubType,
|
13
|
-
campaignParameters: params,
|
14
|
-
computeChainId: chainId,
|
15
|
-
campaignId,
|
16
|
-
rewardToken,
|
17
|
-
amount,
|
18
|
-
},
|
19
|
-
]);
|
20
|
-
name = dynamicData?.typeInfo?.cardName;
|
21
|
-
}
|
22
|
-
catch {
|
23
|
-
log.warn(`failed to fetch dynamic data for ERC20 campaign ${campaignId}`);
|
24
|
-
}
|
25
|
-
return {
|
26
|
-
name,
|
27
|
-
tokens: [
|
28
|
-
{ chainId, address: params.targetToken },
|
29
|
-
{ chainId, address: params.addressAsset },
|
30
|
-
],
|
31
|
-
action: [OpportunityAction.LEND, OpportunityAction.BORROW, OpportunityAction.BORROW][campaignSubType],
|
32
|
-
mainProtocol: "euler",
|
33
|
-
};
|
34
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { OpportunityMetadata } from "..";
|
2
|
-
import type { ChainId, EventBasedCampaign } from "@sdk";
|
3
|
-
export declare const getEventBasedMetadata: (computeChainId: ChainId, _distributionChainId: ChainId, _campaignId: string, _rewardToken: string, _amount: string, params: EventBasedCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,43 +0,0 @@
|
|
1
|
-
export const getEventBasedMetadata = async (computeChainId, _distributionChainId, _campaignId, _rewardToken, _amount, params) => {
|
2
|
-
try {
|
3
|
-
const action = "INVALID";
|
4
|
-
const mainProtocolId = "Hanji";
|
5
|
-
let name = `${params.eventID.split("(")[0]} on ${mainProtocolId}`;
|
6
|
-
let tokens = [{ chainId: computeChainId, address: params.contract }];
|
7
|
-
if (params.contract === "0xd0bc067cf877f7b76ceb331891331d9e6acda1a7") {
|
8
|
-
name = `Trade USDC/XTZ on ${mainProtocolId}`;
|
9
|
-
tokens = [
|
10
|
-
{ chainId: computeChainId, address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9" },
|
11
|
-
{ chainId: computeChainId, address: "0xc9B53AB2679f573e480d01e0f49e2B5CFB7a3EAb" },
|
12
|
-
];
|
13
|
-
}
|
14
|
-
if (params.contract === "0x65ea4dd7f789c71c0f57ed84b3bdc3062898d3cb") {
|
15
|
-
name = `Trade USDC/ETH on ${mainProtocolId}`;
|
16
|
-
tokens = [
|
17
|
-
{ chainId: computeChainId, address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9" },
|
18
|
-
{ chainId: computeChainId, address: "0xfc24f770F94edBca6D6f885E12d4317320BcB401" },
|
19
|
-
];
|
20
|
-
}
|
21
|
-
if (params.contract === "0xbb6b01d94e3f6ebae8647cb56d544f57928ab758") {
|
22
|
-
name = `Trade USDC/BTC on ${mainProtocolId}`;
|
23
|
-
tokens = [
|
24
|
-
{ chainId: computeChainId, address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9" },
|
25
|
-
{ chainId: computeChainId, address: "0xbFc94CD2B1E55999Cfc7347a9313e88702B83d0F" },
|
26
|
-
];
|
27
|
-
}
|
28
|
-
return {
|
29
|
-
action,
|
30
|
-
name,
|
31
|
-
tokens,
|
32
|
-
mainProtocol: mainProtocolId,
|
33
|
-
};
|
34
|
-
}
|
35
|
-
catch (error) {
|
36
|
-
return {
|
37
|
-
action: "INVALID",
|
38
|
-
name: "Event Based Campaign",
|
39
|
-
tokens: [],
|
40
|
-
mainProtocol: undefined,
|
41
|
-
};
|
42
|
-
}
|
43
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { type ChainId, type HyperDriveLogCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getHyperdriveMetadata: (chainId: ChainId, campaignSubType: HyperDriveLogCampaign["campaignSubType"], params: HyperDriveLogCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
import { HyperDriveSubCampaignType } from "@sdk";
|
3
|
-
export const getHyperdriveMetadata = (chainId, campaignSubType, params) => {
|
4
|
-
const subtypes = [
|
5
|
-
{ name: "Add Liquidity on", action: OpportunityAction.POOL },
|
6
|
-
{ name: "Open Long on", action: OpportunityAction.LONG },
|
7
|
-
{ name: "Open Short on", action: OpportunityAction.SHORT },
|
8
|
-
];
|
9
|
-
if (campaignSubType === HyperDriveSubCampaignType.LP) {
|
10
|
-
campaignSubType = 0;
|
11
|
-
}
|
12
|
-
const subtype = subtypes[campaignSubType];
|
13
|
-
return {
|
14
|
-
action: subtype.action,
|
15
|
-
name: [subtype.name, params.symbolTargetToken].join(" "),
|
16
|
-
tokens: [{ chainId, address: params.targetToken }],
|
17
|
-
mainProtocol: "hyperdrive",
|
18
|
-
};
|
19
|
-
};
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getIonMetadata = async (chainId, params) => {
|
3
|
-
// TODO this is not finalized at all
|
4
|
-
return {
|
5
|
-
action: OpportunityAction.LEND,
|
6
|
-
name: ["Ion", "strategy for", params.symbolBorrowToken].join(" "),
|
7
|
-
tokens: [
|
8
|
-
{ chainId, address: params.borrowToken },
|
9
|
-
{ chainId, address: params.collateralToken },
|
10
|
-
],
|
11
|
-
mainProtocol: "ion",
|
12
|
-
};
|
13
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ChainId, JSON_AIRDROPCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getJsonAirdropMetadata: (chainId: ChainId, creator: string, params: JSON_AIRDROPCampaign["campaignParameters"]) => Promise<OpportunityMetadata>;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { log } from "../../../../utils/logger";
|
2
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
3
|
-
export const getJsonAirdropMetadata = async (chainId, creator, params) => {
|
4
|
-
const ACI = "0xdeadD8aB03075b7FBA81864202a2f59EE25B312b".toLowerCase();
|
5
|
-
const aaveDAO = "0x5300A1a15135EA4dc7aD5a167152C01EFc9b192A".toLowerCase();
|
6
|
-
const aciPrefix = creator.toLowerCase() === ACI && "Get Merit rewards -";
|
7
|
-
const aavePrefix = creator.toLowerCase() === aaveDAO && "Get aAMPL distribution -";
|
8
|
-
const prefix = aavePrefix ? aavePrefix : aciPrefix ? aciPrefix : "Get airdrop in";
|
9
|
-
let tokenAddress;
|
10
|
-
try {
|
11
|
-
const res = await fetch(params.jsonUrl);
|
12
|
-
if (!res.ok)
|
13
|
-
throw new Error(`Response status: ${res.status}`);
|
14
|
-
tokenAddress = (await res.json()).rewardToken;
|
15
|
-
return {
|
16
|
-
action: OpportunityAction.DROP,
|
17
|
-
name: `${prefix} ${params.symbolRewardToken}`,
|
18
|
-
tokens: [
|
19
|
-
{
|
20
|
-
chainId,
|
21
|
-
address: tokenAddress, // TODO: Make sure targetToken is set
|
22
|
-
},
|
23
|
-
],
|
24
|
-
mainProtocol: aavePrefix || aciPrefix ? "aave" : undefined,
|
25
|
-
};
|
26
|
-
}
|
27
|
-
catch (err) {
|
28
|
-
log.error("failed to fetch token address on IPFS", err);
|
29
|
-
return {
|
30
|
-
action: OpportunityAction.DROP,
|
31
|
-
name: `${prefix} ${params.symbolRewardToken}`,
|
32
|
-
tokens: [],
|
33
|
-
mainProtocol: aavePrefix || aciPrefix ? "aave" : undefined,
|
34
|
-
};
|
35
|
-
}
|
36
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { OpportunityMetadata } from "..";
|
2
|
-
import { type ChainId, type MorphoCampaign, type MorphoSubCampaignType } from "@sdk";
|
3
|
-
export declare const getMorphoMetadata: (chainId: ChainId, campaignSubType: MorphoCampaign<MorphoSubCampaignType>["campaignSubType"], params: MorphoCampaign<MorphoSubCampaignType>["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
import { BN2Number } from "@sdk";
|
3
|
-
export const getMorphoMetadata = (chainId, campaignSubType, params) => {
|
4
|
-
const morphoParams = params;
|
5
|
-
const market = `${morphoParams.symbolLoanToken}/${morphoParams.symbolBorrowToken} ${morphoParams?.LLTV && BN2Number(morphoParams?.LLTV, 16)}%`;
|
6
|
-
const subtypes = [
|
7
|
-
{ name: `Deposit in ${morphoParams.nameTargetToken} - Metamorpho`, action: OpportunityAction.LEND },
|
8
|
-
{ name: `Supply ${morphoParams.symbolLoanToken} on ${market}`, action: OpportunityAction.LEND },
|
9
|
-
{ name: `Borrow ${morphoParams.symbolLoanToken} on ${market}`, action: OpportunityAction.BORROW },
|
10
|
-
{ name: `Lend ${morphoParams.symbolBorrowToken} on ${market}`, action: OpportunityAction.LEND },
|
11
|
-
];
|
12
|
-
const subtype = subtypes[campaignSubType];
|
13
|
-
return {
|
14
|
-
action: subtype.action,
|
15
|
-
tokens: [{ chainId, address: params.targetToken }],
|
16
|
-
name: subtype.name,
|
17
|
-
mainProtocol: "morpho",
|
18
|
-
};
|
19
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ChainId, RadiantCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getRadiantMetadata: (chainId: ChainId, campaignSubType: RadiantCampaign["campaignSubType"], params: RadiantCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getRadiantMetadata = (chainId, campaignSubType, params) => {
|
3
|
-
return {
|
4
|
-
action: campaignSubType <= 1 ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
5
|
-
name: [campaignSubType <= 1 ? "Lend" : "Borrow", params.symbolTargetToken].join(" "),
|
6
|
-
tokens: [{ chainId, address: params.targetToken }],
|
7
|
-
mainProtocol: "radiant",
|
8
|
-
};
|
9
|
-
};
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import type { ChainId, SILOCampaign } from "@sdk";
|
2
|
-
import type { OpportunityMetadata } from "../opportunity.model";
|
3
|
-
export declare const getSiloMetadata: (chainId: ChainId, campaignSubType: SILOCampaign["campaignSubType"], params: SILOCampaign["campaignParameters"]) => OpportunityMetadata;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { OpportunityAction } from "../../../../../database/api/.generated";
|
2
|
-
export const getSiloMetadata = (chainId, campaignSubType, params) => {
|
3
|
-
let suffix = ["Deposit", "Protected Deposit", "Debt"][campaignSubType];
|
4
|
-
const assetSymbol = params.symbolTargetToken;
|
5
|
-
if (params.forwarders.length === 1 && assetSymbol)
|
6
|
-
suffix += ` (${assetSymbol} Market)`;
|
7
|
-
return {
|
8
|
-
action: campaignSubType <= 1 ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
9
|
-
name: [campaignSubType <= 1 ? "Lend" : "Borrow", params.symbolTargetToken, suffix].join(" "),
|
10
|
-
tokens: [{ chainId, address: params.targetToken }],
|
11
|
-
mainProtocol: "silo",
|
12
|
-
};
|
13
|
-
};
|