@merkl/api 0.20.109 → 0.20.111
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/engine/deprecated/dynamicData/implementations/Clamm.js +0 -2
- package/dist/src/engine/implementations/Erc20/tvl.js +2 -1
- package/dist/src/engine/tvl/factory.js +4 -0
- package/dist/src/jobs/dynamic-data.js +9 -12
- package/dist/src/modules/v4/dynamicData/dynamicData.service.js +7 -3
- package/dist/src/modules/v4/token/token.service.js +2 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -3,7 +3,6 @@ import { nftPositionByIdsQuery, positionMultipleOwnersQuery } from "@/libs/posit
|
|
3
3
|
import { fetchFarmedPositions } from "@/libs/positions/clamm/thegraph/fetchFarmedPositions";
|
4
4
|
import { TokenService } from "@/modules/v4/token/token.service";
|
5
5
|
import { log } from "@/utils/logger";
|
6
|
-
import { Pricer } from "@/utils/pricer";
|
7
6
|
import { isStrykeCampaign } from "@/utils/stryke";
|
8
7
|
import { A51Factory__factory, ALM, ALMMapping, AMM, AMMAlgorithm, AMMAlgorithmMapping, BN2Number, ChainInteractionService, DecodeLiquidity, EAprBreakdownType, ERC20Interface, Forwarder, JonesDoubleRewardTracker__factory, Liquidity, NETWORK_LABELS, NitroInterface, PoolInterface, PoolState, PriorityAMM, SqrtPrice, almName, ammName, getAmountsForLiquidity, getTickAtSqrtRatio, isBlacklisted, isWhitelisted, merklSubgraphAMMEndpoints, shortenAddress, spNFTInterface, withTimeout, } from "@sdk";
|
9
8
|
import axios from "axios";
|
@@ -15,7 +14,6 @@ import { fetchA51Strategies } from "../utils/fetchA51Strategies";
|
|
15
14
|
export class ClammDynamicData {
|
16
15
|
async build(chainId, campaigns) {
|
17
16
|
const dynamicData = [];
|
18
|
-
const pricer = await Pricer.load();
|
19
17
|
const calls = [];
|
20
18
|
const A51Interface = A51Factory__factory.createInterface();
|
21
19
|
/** Dedupe pools from campaigns to build pool list */
|
@@ -12,7 +12,7 @@ export class Erc20TVLBuilder {
|
|
12
12
|
const builder = erc20SubTypeTVLBuilderFactory(subType);
|
13
13
|
const campaignsOfSubType = campaigns.filter((_campaign, index) => subTypes[index] === subType);
|
14
14
|
if (!!builder) {
|
15
|
-
log.
|
15
|
+
log.local(`building TVLs for subtype ${subType}`);
|
16
16
|
const subTypeTVLs = await builder.build(computeChainId, campaignsOfSubType);
|
17
17
|
// Impact blacklist or whitelist
|
18
18
|
const calls = [];
|
@@ -51,6 +51,7 @@ export class Erc20TVLBuilder {
|
|
51
51
|
const result = await ChainInteractionService(computeChainId).fetchState(calls);
|
52
52
|
let index = 0;
|
53
53
|
for (const [i, { campaign }] of subTypeTVLs.entries()) {
|
54
|
+
log.local(`building TVLs for subtype ${subType} using deprecated code`);
|
54
55
|
const { campaignParameters } = campaign;
|
55
56
|
const { whitelist, blacklist } = campaignParameters;
|
56
57
|
if (whitelist?.length > 0) {
|
@@ -14,6 +14,10 @@ const map = {
|
|
14
14
|
[Campaign.AMBIENTPROCESSOR]: new AmbiantTVLBuilder(),
|
15
15
|
[Campaign.UNISWAP_V4]: new UniswapV4TVLBuilder(),
|
16
16
|
[Campaign.ERC20]: new Erc20TVLBuilder(),
|
17
|
+
[Campaign.ERC20LOGPROCESSOR]: new Erc20TVLBuilder(),
|
18
|
+
[Campaign.ERC20REBASEFIXAPR]: new Erc20TVLBuilder(),
|
19
|
+
[Campaign.ERC20_FIX_APR]: new Erc20TVLBuilder(),
|
20
|
+
[Campaign.EULER]: new Erc20TVLBuilder(),
|
17
21
|
};
|
18
22
|
export const campaignTVLBuilderFactory = (campaignType) => {
|
19
23
|
if (!map[campaignType]) {
|
@@ -17,7 +17,6 @@ import moment from "moment";
|
|
17
17
|
const chainId = Number(process.env.CHAIN_ID);
|
18
18
|
if (!chainId)
|
19
19
|
throw new Error("Environment variable CHAIN_ID is required.");
|
20
|
-
const queryCampaignTypes = process.env.CAMPAIGN_TYPES ? JSON.parse(process.env.CAMPAIGN_TYPES) : [];
|
21
20
|
const highCampaignsChains = [ChainId.ARBITRUM, ChainId.POLYGON, ChainId.BLAST, ChainId.BASE];
|
22
21
|
export const main = async () => {
|
23
22
|
if (chainId === ChainId.MAINNET) {
|
@@ -57,17 +56,15 @@ export const main = async () => {
|
|
57
56
|
log.local(`Data length after filtering: ${staticData.length}`);
|
58
57
|
if (!!staticData) {
|
59
58
|
// Build list of existing campaign types for this chain
|
60
|
-
const campaignTypes =
|
61
|
-
?
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
.
|
67
|
-
|
68
|
-
|
69
|
-
return prev;
|
70
|
-
}, []);
|
59
|
+
const campaignTypes = !staticData
|
60
|
+
? []
|
61
|
+
: staticData
|
62
|
+
.map(campaign => campaign.campaignType)
|
63
|
+
.reduce((prev, campaignType) => {
|
64
|
+
if (!prev.includes(campaignType))
|
65
|
+
prev.push(campaignType);
|
66
|
+
return prev;
|
67
|
+
}, []);
|
71
68
|
// Fetch dynamic data for all these types
|
72
69
|
const promisesPerType = campaignTypes.map(async (campaignType) => {
|
73
70
|
const campaigns = staticData.filter(campaign => campaign.campaignType === campaignType);
|
@@ -10,7 +10,7 @@ import { TvlService } from "@/modules/v4/tvl/tvl.service";
|
|
10
10
|
import bigintToString from "@/utils/bigintToString";
|
11
11
|
import { log } from "@/utils/logger";
|
12
12
|
import { AprType } from "@db/api";
|
13
|
-
import { Campaign as CampaignEnum, DAY, NETWORK_LABELS, } from "@sdk";
|
13
|
+
import { Campaign as CampaignEnum, DAY, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
|
14
14
|
import moment from "moment";
|
15
15
|
import { AprService } from "../apr";
|
16
16
|
import { CampaignService } from "../campaign";
|
@@ -96,6 +96,7 @@ export class DynamicDataService {
|
|
96
96
|
let campaignDailyValue = await TokenService.getValueByTokenId(TokenService.hashId({ address: rewardTokenAddress, chainId: record.campaign.chainId }), dailyAmount);
|
97
97
|
// Fixed APR campaigns
|
98
98
|
if (hasFixedAprConfig(campaignParameters)) {
|
99
|
+
log.local(`[${NETWORK_LABELS[chainId]}][${CampaignEnum[type]}] calculating fixed APR for ${record.campaign.campaignId}`);
|
99
100
|
const { targetTokenPricing, rewardTokenPricing, apr: fixedApr } = campaignParameters;
|
100
101
|
const targetApr = Number(fixedApr);
|
101
102
|
if (targetTokenPricing && rewardTokenPricing) {
|
@@ -106,8 +107,11 @@ export class DynamicDataService {
|
|
106
107
|
if (targetTokenPricing && !rewardTokenPricing) {
|
107
108
|
// Case 2: Fixed # amount of reward per $ of liquidity
|
108
109
|
// Return 0 if reward token price is invalid
|
109
|
-
|
110
|
-
dailyAmount =
|
110
|
+
// targetApr represents a yearly # amount of reward per $ of liquidity
|
111
|
+
dailyAmount =
|
112
|
+
(BigInt(Math.floor((targetApr * tvl.total * 10 ** 6) / 365)) * 10n ** BigInt(rewardToken.decimals)) /
|
113
|
+
10n ** 6n;
|
114
|
+
campaignDailyValue = bigIntToNumber(dailyAmount, rewardToken.decimals) * (rewardToken.price ?? 1);
|
111
115
|
}
|
112
116
|
}
|
113
117
|
dailyRewards.total += campaignDailyValue;
|
@@ -199,7 +199,8 @@ export class TokenService {
|
|
199
199
|
static async getPrice(query) {
|
200
200
|
const tokensFound = (await TokenRepository.findMany(query)).map(TokenService.format);
|
201
201
|
if (tokensFound.length === 0) {
|
202
|
-
|
202
|
+
log.warn(`TokenService.getPrice: No token found for ${query.address} on ${query.chainId ? NETWORK_LABELS[query.chainId] : "unknwon"}. Returning 0 as price.`);
|
203
|
+
return 0;
|
203
204
|
}
|
204
205
|
// In the case of points, we want to be able to compute X points distributed per $ of TVL, hence returning 1.
|
205
206
|
const priceToken = tokensFound[0].isPoint ? 1 : (tokensFound[0].price ?? 0);
|