@merkl/api 0.15.38 → 0.15.39

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.
@@ -1,7 +1,7 @@
1
1
  import { merklChainDataWithCache } from "../../merklChainData";
2
2
  import { TokenRepository } from "../../../modules/v4/token/token.repository";
3
3
  import { log } from "../../../utils/logger";
4
- import { BN2Number, BalancerPoolInterface, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, } from "@sdk";
4
+ import { BN2Number, BalancerPoolInterface, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, getEnv, } from "@sdk";
5
5
  import { Pricer } from "../../../utils/pricer";
6
6
  import { getLastEligibilityRatio } from "../utils/getLastEligibilityRatio";
7
7
  import { getTVL } from "./ERC20SubTypes/helpers/getTVL";
@@ -118,7 +118,7 @@ export async function ERC20DynamicData(chainId, campaigns) {
118
118
  const callsForCampaign = tokenTypesByCampaign[campaign.campaignId].calls.length;
119
119
  tokenTypesByCampaign[campaign.campaignId] = await getTokenPricesInfo(i, tokenTypesByCampaign[campaign.campaignId].type, tokenTypesByCampaign[campaign.campaignId].typeInfo, result, campaign, pricer);
120
120
  try {
121
- if (!!tokenTypesByCampaign[campaign.campaignId]?.typeInfo.priceTargetToken)
121
+ if (!!tokenTypesByCampaign[campaign.campaignId]?.typeInfo.priceTargetToken && getEnv() === "prod")
122
122
  await TokenRepository.updateAddressPrices(campaign.campaignParameters.targetToken, tokenTypesByCampaign[campaign.campaignId]?.typeInfo.priceTargetToken);
123
123
  }
124
124
  catch (e) {
@@ -1,6 +1,14 @@
1
1
  import { generateCardName } from "../../../../../utils/generateCardName";
2
2
  import axios from "axios";
3
3
  import { GenericProcessor } from "./GenericProcessor";
4
+ const findTvlByVaultAddress = (data, targetVaultAddress) => {
5
+ for (const key in data) {
6
+ if (data[key].vaultAddress.toLowerCase() === targetVaultAddress.toLowerCase()) {
7
+ return data[key].tvl;
8
+ }
9
+ }
10
+ return null;
11
+ };
4
12
  export class VicunaProcessor extends GenericProcessor {
5
13
  rounds = {
6
14
  round1: [],
@@ -10,39 +18,10 @@ export class VicunaProcessor extends GenericProcessor {
10
18
  };
11
19
  async processingRound5(_index, type, typeInfo, _calls, campaign, _pricer) {
12
20
  const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
13
- const vicunaTVL = (await axios("https://vicuna.orthae.xyz/tvl")).data;
14
- const parsedName = typeInfo.name.toLowerCase().split(" ");
15
- parsedName.shift();
16
- let parsedNameForAPI = parsedName.join("-");
17
- const mapping = {
18
- "swapx-os-ws": "swapx-ichi-ws-os-ws",
19
- "swapx-scusd-usdc": "swapx-ichi-usdc-scusd-usdc",
20
- "swapx-sts-ws": "swapx-ichi-ws-sts-ws",
21
- "swapx-sacra-ws": "swapx-ichi-ws-sacra-sacra",
22
- "solidly-swapx-ws-eco": "swapx-ws-eco",
23
- "solidly-swapx-ws-goglz": "swapx-ws-goglz",
24
- "solidly-swapx-ws-hedgy": "swapx-ws-hedgy",
25
- "solidly-swapx-ws-tysg": "swapx-ws-tysg",
26
- "solidly-swapx-ws-sdog": "swapx-ws-sdog",
27
- "solidly-swapx-ws-shiba": "swapx-ws-shiba",
28
- "balancer-ws-sts": "beets-ws-sts",
29
- "balancer-scusd-sts": "beets-usdc-scusd",
30
- "swapx-ws-swpx": "swapx-ichi-ws-swapx-ws",
31
- "swapx-ws-usdc": "swapx-ichi-ws-usdc-ws",
32
- "swapx-ws-sceth": "swapx-ichi-ws-sceth-ws",
33
- "swapx-ws-sts": "swapx-ichi-ws-sts-sts",
34
- "swapx-ws-weth": "swapx-ichi-ws-weth-ws",
35
- "swapx-ws-os": "swapx-ichi-ws-os-os",
36
- "swapx-usdc-swpx": "swapx-ichi-usdc-swapx-usdc",
37
- "swapx-usdc-weth": "swapx-ichi-usdc-weth-weth",
38
- "swapx-usdc-scusd": "swapx-ichi-usdc-scusd-usdc",
39
- "swapx-usdc-sts": "swapx-ichi-usdc-sts-usdc",
40
- "swapx-weth-usdc": "swapx-ichi-usdc-weth-usdc",
41
- };
42
- if (!!mapping[parsedNameForAPI]) {
43
- parsedNameForAPI = mapping[parsedNameForAPI];
44
- }
45
- const tvl = vicunaTVL[campaign.computeChainId][parsedNameForAPI];
21
+ const vicunaTVL = (await axios("https://vicuna.orthae.xyz/tvl/details")).data;
22
+ // find the entry that matches the vault address
23
+ const tvl = findTvlByVaultAddress(vicunaTVL[campaign.chainId], typeInfo.tokenAddress) ?? 0;
24
+ console.log("tvl", tvl);
46
25
  const priceTargetToken = tvl / totalSupply;
47
26
  return {
48
27
  ...typeInfo,
@@ -3611,7 +3611,7 @@ const PufferInterfaceCampaigns = {
3611
3611
  marketId: "0xa42ba90e4d3013dee8eb0d7bb7ae0817297337eeecd525dbdd48c7b5c5e6988d",
3612
3612
  },
3613
3613
  [pufferCampaigns.pufETH_hold]: {
3614
- campaignType: Campaign.ERC20,
3614
+ campaignType: Campaign.ERC20LOGPROCESSOR,
3615
3615
  computeChainId: ChainId.MAINNET,
3616
3616
  hooks: [],
3617
3617
  targetToken: "0xD9A442856C234a39a81a089C06451EBAa4306a72",
@@ -149,8 +149,8 @@ export function generateCardName(type, typeInfo, campaign, symbols = [""], displ
149
149
  switch (typeInfo.tokenAddress) {
150
150
  case "0x3a8099D8FE5C072bB035381003993393072D3ec7":
151
151
  return "Hold pufETH on DeSyn (dpufETH)";
152
- case "0x1f2aa9680910aC5a4527FA72001dC249943f60b4 ":
153
- return "Hold pufETH on Karak (pufETH)";
152
+ case "0x1f2aa9680910aC5a4527FA72001dC249943f60b4":
153
+ return "Hold pufETH on Karak";
154
154
  default:
155
155
  return `Hold ${typeInfo.name} (${campaign.campaignParameters.symbolTargetToken})`;
156
156
  }
@@ -7,6 +7,6 @@ export default class CoingeckoService implements PriceFetcher {
7
7
  private baseUrl;
8
8
  getPrice(tickers: PriceSource[]): Promise<ResponsePriceType[]>;
9
9
  private buildUrl;
10
- private fetchprices;
10
+ private fetchPrices;
11
11
  private formatResponse;
12
12
  }
@@ -9,7 +9,7 @@ export default class CoingeckoService {
9
9
  const filteredTokens = tickers.filter(tokenPriceSource => tokenPriceSource.method === PriceSourceMethod.COINGECKO);
10
10
  if (filteredTokens.length === 0)
11
11
  return [];
12
- return await this.fetchprices(filteredTokens);
12
+ return await this.fetchPrices(filteredTokens);
13
13
  }
14
14
  buildUrl(tokens) {
15
15
  const tikerParams = tokens
@@ -22,15 +22,23 @@ export default class CoingeckoService {
22
22
  .join(",");
23
23
  return this.baseUrl.concat(tikerParams);
24
24
  }
25
- async fetchprices(tickers) {
26
- const url = this.buildUrl(tickers);
27
- return axios
28
- .get(url, { timeout: 10000 })
29
- .then(res => this.formatResponse(res, tickers))
30
- .catch(err => {
31
- log.error("❌ CoingeckoService not responding", err);
32
- throw "❌ CoingeckoService not responding";
33
- });
25
+ async fetchPrices(tickers) {
26
+ const chunkSize = 200;
27
+ const chunks = [];
28
+ for (let i = 0; i < tickers.length; i += chunkSize) {
29
+ chunks.push(tickers.slice(i, Math.min(tickers.length, i + chunkSize)));
30
+ }
31
+ const promises = await Promise.all(chunks.map(async (chunk) => {
32
+ const url = this.buildUrl(chunk);
33
+ return axios
34
+ .get(url, { timeout: 10000 })
35
+ .then(res => this.formatResponse(res, chunk))
36
+ .catch(err => {
37
+ log.error("❌ CoingeckoService not responding", err);
38
+ throw "❌ CoingeckoService not responding";
39
+ });
40
+ }));
41
+ return promises.reduce((acc, val) => acc.concat(val), []);
34
42
  }
35
43
  // biome-ignore lint/suspicious/noExplicitAny: <explanation> Need to be typed according to coinguekko answer type
36
44
  formatResponse(data, tokens) {
@@ -7,6 +7,6 @@ export default class DefillamaService implements PriceFetcher {
7
7
  private baseUrl;
8
8
  getPrice(sources: PriceSource[]): Promise<ResponsePriceType[]>;
9
9
  private buildUrl;
10
- private fetchprices;
10
+ private fetchPrices;
11
11
  private formatResponse;
12
12
  }
@@ -9,7 +9,7 @@ export default class DefillamaService {
9
9
  const filteredTokens = sources.filter(tokenPriceSource => tokenPriceSource.method === PriceSourceMethod.DEFILLAMA);
10
10
  if (filteredTokens.length === 0)
11
11
  return [];
12
- return await this.fetchprices(filteredTokens);
12
+ return await this.fetchPrices(filteredTokens);
13
13
  }
14
14
  buildUrl(tokens) {
15
15
  const tikerParams = tokens
@@ -22,7 +22,7 @@ export default class DefillamaService {
22
22
  .join(",");
23
23
  return this.baseUrl.concat(tikerParams);
24
24
  }
25
- async fetchprices(sources) {
25
+ async fetchPrices(sources) {
26
26
  const url = this.buildUrl(sources);
27
27
  return axios
28
28
  .get(url, { timeout: 10000 })