@merkl/api 0.20.163 → 0.20.165

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.
@@ -4,7 +4,7 @@ import { drizzle } from "drizzle-orm/prisma/pg";
4
4
  export const apiDbClient = new ApiPrismaClient({
5
5
  datasources: {
6
6
  db: {
7
- url: `${process.env.DATABASE_API_URL}&connection_limit=${!!process.env.BACKOFFICE_SECRET ? "200" : "10"}&pool_timeout=60`,
7
+ url: `${process.env.DATABASE_API_URL}&connection_limit=${!!process.env.BACKOFFICE_SECRET ? "300" : "25"}&pool_timeout=60`,
8
8
  },
9
9
  },
10
10
  }).$extends(drizzle());
@@ -0,0 +1 @@
1
+ export declare function getCrossCurveTokenPrice(address: string): Promise<number>;
@@ -0,0 +1,13 @@
1
+ import axios from "axios";
2
+ export async function getCrossCurveTokenPrice(address) {
3
+ const apiUrl = `https://api.crosscurve.fi/prices/${address}`;
4
+ let price = 0;
5
+ try {
6
+ const response = await axios.get(apiUrl);
7
+ if (response.data) {
8
+ price = Number(response.data);
9
+ }
10
+ }
11
+ catch (e) { }
12
+ return price;
13
+ }
@@ -1,6 +1,7 @@
1
1
  import { generateCardName } from "@/utils/generateCardName";
2
2
  import { BN2Number } from "@sdk";
3
3
  import { GenericProcessor } from "../GenericProcessor";
4
+ import { getCrossCurveTokenPrice } from "../helpers/getCrossCurveTokenPrice";
4
5
  const matchSingleNumber = (input) => {
5
6
  const regex = /^\d+$/;
6
7
  return regex.test(input);
@@ -66,10 +67,13 @@ export class CurveNPoolProcessor extends GenericProcessor {
66
67
  let price = (await pricer.get({ symbol: symbol })) ?? 0;
67
68
  if (price === 0) {
68
69
  // For cross curve
69
- const parsedSymbol = symbol.split("_")[0].slice(1);
70
- price = (await pricer.get({ symbol: parsedSymbol })) ?? 0;
70
+ price = await getCrossCurveTokenPrice(typeInfo[`token${i}`]);
71
71
  if (price === 0) {
72
- price = (await pricer.get({ symbol: hardcodedSymbol })) ?? 0;
72
+ const parsedSymbol = symbol.split("_")[0].slice(1);
73
+ price = (await pricer.get({ symbol: parsedSymbol })) ?? 0;
74
+ if (price === 0) {
75
+ price = (await pricer.get({ symbol: hardcodedSymbol })) ?? 0;
76
+ }
73
77
  }
74
78
  }
75
79
  tokensDisplay.push({ symbol: symbol, address: typeInfo[`token${i}`] });
@@ -7,7 +7,7 @@ import { TokenService } from "@/modules/v4/token/token.service";
7
7
  import { UserService } from "@/modules/v4/user/user.service";
8
8
  import { log } from "@/utils/logger";
9
9
  import { AprType, Status } from "@db/api";
10
- import { Campaign as CampaignType, numberToBigInt } from "@sdk";
10
+ import { Campaign as CampaignType, HOOK, numberToBigInt } from "@sdk";
11
11
  import moment from "moment";
12
12
  import { metadataBuilderFactory } from "../../../engine/metadata/factory";
13
13
  import { ChainService } from "../chain/chain.service";
@@ -55,6 +55,10 @@ export class OpportunityService {
55
55
  static async createFromCampaign(campaign, opportunityIdentifier, upsert = false, dryRun = false) {
56
56
  if (dryRun)
57
57
  log.info(`opportunity creation dry run for ${campaign.campaignId} of type ${campaign.type}`);
58
+ // Separate Worldchain ID only campaign opportunities
59
+ if (campaign.params.hooks?.some(hook => hook.hookType === HOOK.WORLDCHAINID)) {
60
+ opportunityIdentifier += "WORLDCHAINID";
61
+ }
58
62
  const metadata = await OpportunityService.#getMetadata(campaign, opportunityIdentifier);
59
63
  const tags = (await UserService.findUnique(campaign.creatorAddress))?.tags ?? [];
60
64
  const opportunityId = OpportunityService.hashId({