@merkl/api 0.20.163 → 0.20.164
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/database/index.js +1 -1
- package/dist/src/engine/deprecated/erc20SubTypeProcessors/helpers/getCrossCurveTokenPrice.d.ts +1 -0
- package/dist/src/engine/deprecated/erc20SubTypeProcessors/helpers/getCrossCurveTokenPrice.js +13 -0
- package/dist/src/engine/deprecated/erc20SubTypeProcessors/implementations/curveNPoolProcessor.js +7 -3
- package/dist/src/modules/v4/opportunity/opportunity.service.js +5 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/database/index.js
CHANGED
@@ -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 ? "
|
7
|
+
url: `${process.env.DATABASE_API_URL}&connection_limit=${!!process.env.BACKOFFICE_SECRET ? "300" : "10"}&pool_timeout=60`,
|
8
8
|
},
|
9
9
|
},
|
10
10
|
}).$extends(drizzle());
|
package/dist/src/engine/deprecated/erc20SubTypeProcessors/helpers/getCrossCurveTokenPrice.d.ts
ADDED
@@ -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
|
+
}
|
package/dist/src/engine/deprecated/erc20SubTypeProcessors/implementations/curveNPoolProcessor.js
CHANGED
@@ -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
|
-
|
70
|
-
price = (await pricer.get({ symbol: parsedSymbol })) ?? 0;
|
70
|
+
price = await getCrossCurveTokenPrice(typeInfo[`token${i}`]);
|
71
71
|
if (price === 0) {
|
72
|
-
|
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({
|