@merkl/api 0.10.388 → 0.10.389
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/eden/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/libs/campaigns/campaignTypes/CLAMMDynamicData.js +6 -9
- package/dist/src/modules/v4/campaign/campaign.service.js +4 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.js +2 -2
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +4 -0
- package/dist/src/modules/v4/opportunity/opportunity.model.js +7 -0
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +25 -1
- package/dist/src/modules/v4/opportunity/opportunity.service.js +32 -2
- package/dist/src/modules/v4/opportunity/subservices/getClammMetadata.service.js +2 -2
- package/dist/src/modules/v4/router.d.ts +1 -0
- package/dist/src/utils/generateCardName.js +9 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
package/dist/src/index.d.ts
CHANGED
@@ -599,16 +599,13 @@ export async function CLAMMDynamicData(chainId, campaigns) {
|
|
599
599
|
blacklistedBalance1 = poolBalanceToken1;
|
600
600
|
blacklistedLiquidity = poolTotalLiquidity;
|
601
601
|
// Get all beefy staker is whitelisted, get a list of all senders
|
602
|
-
|
603
|
-
const
|
604
|
-
|
605
|
-
|
606
|
-
let targetToMatch = "";
|
607
|
-
for (const alm of almDetails.filter(a => a.type === ALM.BeefyStaker)) {
|
608
|
-
if (alm.sender === c.campaignParameters.whitelist[0]) {
|
609
|
-
targetToMatch = alm.target;
|
610
|
-
}
|
602
|
+
let targetToMatch = "";
|
603
|
+
for (const alm of almDetails.filter(a => a.type === ALM.BeefyStaker)) {
|
604
|
+
if (c.campaignParameters.whitelist.includes(alm.sender)) {
|
605
|
+
targetToMatch = alm.target;
|
611
606
|
}
|
607
|
+
}
|
608
|
+
if (targetToMatch !== "") {
|
612
609
|
for (const alm of almDetails.filter(a => a.type === ALM.Beefy)) {
|
613
610
|
if (targetToMatch === alm.sender.toLowerCase()) {
|
614
611
|
c.campaignParameters.whitelist.push(alm.owner);
|
@@ -92,6 +92,10 @@ export class CampaignService {
|
|
92
92
|
await OpportunityService.createFromCampaign(campaign);
|
93
93
|
campaignsToInsert.push({ id, ...campaign });
|
94
94
|
}
|
95
|
+
// } else {
|
96
|
+
// console.log("Updating status from campaign");
|
97
|
+
// await OpportunityService.updateStatusFromCampaign(campaign);
|
98
|
+
// }
|
95
99
|
}
|
96
100
|
catch (err) {
|
97
101
|
log.error(`Cannot get Opportunity metadata for campaign ${campaign.campaignId} of type ${campaign.type}`, err);
|
@@ -3,7 +3,7 @@ import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
|
3
3
|
import { AuthorizationHeadersDto, TokenAuthGuard } from "../../../guards/TokenAuth.guard";
|
4
4
|
import Elysia, { t } from "elysia";
|
5
5
|
import { GetCampaignQueryDto } from "../campaign";
|
6
|
-
import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityIdDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
|
6
|
+
import { CreateOpportunityDto, GetOpportunitiesQueryDto, GetOpportunityQueryDto, OpportunityAggregateFieldDto, OpportunityIdDto, OpportunityResourceDto, OpportunityUniqueDto, OpportunityUniqueUpdateDto, OpportunityWithCampaignsResourceDto, UpdateOpportunityDto, } from "./opportunity.model";
|
7
7
|
import { OpportunityService } from "./opportunity.service";
|
8
8
|
import { transformId } from "./transform-id.pipe";
|
9
9
|
import { validateId } from "./validate-id.pipe";
|
@@ -41,7 +41,7 @@ export const OpportunityController = new Elysia({
|
|
41
41
|
}, {
|
42
42
|
beforeHandle: BackOfficeGuard,
|
43
43
|
headers: AuthorizationHeadersDto,
|
44
|
-
params:
|
44
|
+
params: OpportunityUniqueUpdateDto,
|
45
45
|
detail: { hide: true },
|
46
46
|
})
|
47
47
|
// ─── Get All Opportunities ───────────────────────────────────────────
|
@@ -272,6 +272,10 @@ export declare const OpportunityWithCampaignsResourceDto: import("@sinclair/type
|
|
272
272
|
export declare const OpportunityUniqueDto: import("@sinclair/typebox").TObject<{
|
273
273
|
id: import("@sinclair/typebox").TString;
|
274
274
|
}>;
|
275
|
+
export declare const OpportunityUniqueUpdateDto: import("@sinclair/typebox").TObject<{
|
276
|
+
id: import("@sinclair/typebox").TString;
|
277
|
+
campaignId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
278
|
+
}>;
|
275
279
|
export declare const AggregationResourceDto: import("@sinclair/typebox").TObject<{
|
276
280
|
sum: import("@sinclair/typebox").TNumber;
|
277
281
|
}>;
|
@@ -38,6 +38,13 @@ export const OpportunityUniqueDto = t.Object({
|
|
38
38
|
description: "The id of the opportunity. You can find opportunities including their id at [GET /v4/opportunities](#tag/opportunities/GET/v4/opportunities/)",
|
39
39
|
}),
|
40
40
|
});
|
41
|
+
export const OpportunityUniqueUpdateDto = t.Object({
|
42
|
+
id: t.String({
|
43
|
+
pattern: "(([0-9]*)-([0-9A-Z]*)-(0x([0-9A-Za-z])*))|([0-9]{1,20})",
|
44
|
+
description: "The id of the opportunity. You can find opportunities including their id at [GET /v4/opportunities](#tag/opportunities/GET/v4/opportunities/)",
|
45
|
+
}),
|
46
|
+
campaignId: t.Optional(t.String({ description: "The id of the campaign you want to reparse with" })),
|
47
|
+
});
|
41
48
|
export const AggregationResourceDto = t.Object({
|
42
49
|
sum: t.Number(),
|
43
50
|
});
|
@@ -63,10 +63,34 @@ export declare abstract class OpportunityService {
|
|
63
63
|
depositUrl: any;
|
64
64
|
tags: string[];
|
65
65
|
}>;
|
66
|
+
static updateStatusFromCampaign(campaign: Omit<CreateCampaignModel, "id">, upsert?: boolean): Promise<{
|
67
|
+
id: string;
|
68
|
+
chainId: number;
|
69
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
70
|
+
identifier: string;
|
71
|
+
name: string;
|
72
|
+
status: "PAST" | "LIVE" | "SOON";
|
73
|
+
action: import("../../../../database/api/.generated").$Enums.OpportunityAction;
|
74
|
+
tokens: {
|
75
|
+
price?: number | null | undefined;
|
76
|
+
symbol: string;
|
77
|
+
name: string | null;
|
78
|
+
id: string;
|
79
|
+
icon: string;
|
80
|
+
chainId: number;
|
81
|
+
address: string;
|
82
|
+
decimals: number;
|
83
|
+
verified: boolean;
|
84
|
+
isTest: boolean;
|
85
|
+
}[];
|
86
|
+
mainProtocol: "morpho" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "euler" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | undefined;
|
87
|
+
depositUrl: string | undefined;
|
88
|
+
tags: string[];
|
89
|
+
}>;
|
66
90
|
/**
|
67
91
|
* deletes and recreates an opportunity with fresh data
|
68
92
|
*/
|
69
|
-
static recreate(opportunityId: string | OpportunityUnique): Promise<{
|
93
|
+
static recreate(opportunityId: string | OpportunityUnique, campaignId?: string): Promise<{
|
70
94
|
id: string;
|
71
95
|
chainId: number;
|
72
96
|
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
@@ -152,15 +152,45 @@ export class OpportunityService {
|
|
152
152
|
await OpportunityRepository.create(opportunity, upsert);
|
153
153
|
return opportunity;
|
154
154
|
}
|
155
|
+
static async updateStatusFromCampaign(campaign, upsert = true) {
|
156
|
+
const campaignType = CampaignService.getTypeFromV3(campaign.type);
|
157
|
+
const metadata = await OpportunityService.#getMetadata(campaign);
|
158
|
+
const opportunityId = OpportunityService.hashId({
|
159
|
+
chainId: campaign.computeChainId,
|
160
|
+
identifier: campaign.opportunityIdentifier,
|
161
|
+
type: campaignType,
|
162
|
+
});
|
163
|
+
const currentOpportunity = await OpportunityService.getUniqueOrThrow(opportunityId, true);
|
164
|
+
const now = moment().unix();
|
165
|
+
const opportunity = {
|
166
|
+
id: opportunityId,
|
167
|
+
chainId: campaign.computeChainId,
|
168
|
+
type: campaignType,
|
169
|
+
identifier: campaign.opportunityIdentifier, // mainParameter
|
170
|
+
name: currentOpportunity.name,
|
171
|
+
status: now >= +campaign.startTimestamp && now < +campaign.endTimestamp
|
172
|
+
? Status.LIVE
|
173
|
+
: now > +campaign.endTimestamp
|
174
|
+
? Status.PAST
|
175
|
+
: Status.SOON,
|
176
|
+
action: metadata.action,
|
177
|
+
tokens: currentOpportunity.tokens,
|
178
|
+
mainProtocol: metadata.mainProtocol,
|
179
|
+
depositUrl: currentOpportunity.depositUrl,
|
180
|
+
tags: currentOpportunity.tags,
|
181
|
+
};
|
182
|
+
await OpportunityRepository.create(opportunity, upsert);
|
183
|
+
return opportunity;
|
184
|
+
}
|
155
185
|
/**
|
156
186
|
* deletes and recreates an opportunity with fresh data
|
157
187
|
*/
|
158
|
-
static async recreate(opportunityId) {
|
188
|
+
static async recreate(opportunityId, campaignId) {
|
159
189
|
const id = typeof opportunityId === "string" ? opportunityId : OpportunityService.hashId(opportunityId);
|
160
190
|
const opportunity = await OpportunityRepository.findUnique(id);
|
161
191
|
if (!opportunity)
|
162
192
|
throw new NotFoundError();
|
163
|
-
const firstCampaign = opportunity?.Campaigns[0];
|
193
|
+
const firstCampaign = opportunity?.Campaigns.filter(campaign => campaignId ? campaign.campaignId === campaignId : true)[0];
|
164
194
|
return await OpportunityService.createFromCampaign({
|
165
195
|
...firstCampaign,
|
166
196
|
type: campaignTypeToEnumMap[firstCampaign.type],
|
@@ -26,13 +26,13 @@ export const getClammMetadata = (chainId, params) => {
|
|
26
26
|
if (params.whitelist.length > 0) {
|
27
27
|
for (const whitelist of params.whitelist) {
|
28
28
|
if (whitelistNameString.length > 0) {
|
29
|
-
whitelistNameString += "or
|
29
|
+
whitelistNameString += "or";
|
30
30
|
}
|
31
31
|
const forwarder = params.forwarders.find(x => getAddress(x.sender) === getAddress(whitelist));
|
32
32
|
const forwarderType = forwarder?.type;
|
33
33
|
const forwarderName = !!forwarderType ? almName(forwarderType) : null;
|
34
34
|
if (!!forwarderName) {
|
35
|
-
whitelistNameString += ` ${forwarderName}`;
|
35
|
+
whitelistNameString += ` ${forwarderName} `;
|
36
36
|
}
|
37
37
|
}
|
38
38
|
}
|
@@ -129,6 +129,14 @@ export function generateCardName(type, typeInfo, campaign, symbols = [""]) {
|
|
129
129
|
case tokenType.cian:
|
130
130
|
return `Deposit ${typeInfo.symbolAsset} into ${typeInfo.name.replace("Ether.Fi", "Veda")}`;
|
131
131
|
default:
|
132
|
-
|
132
|
+
// OVERRIDE
|
133
|
+
switch (typeInfo.tokenAddress) {
|
134
|
+
case "0x3a8099D8FE5C072bB035381003993393072D3ec7":
|
135
|
+
return `Hold pufETH on DeSyn (dpufETH)`;
|
136
|
+
case "0x1f2aa9680910aC5a4527FA72001dC249943f60b4 ":
|
137
|
+
return `Hold pufETH on Karak (pufETH)`;
|
138
|
+
default:
|
139
|
+
return `Hold ${typeInfo.name} (${campaign.campaignParameters.symbolTargetToken})`;
|
140
|
+
}
|
133
141
|
}
|
134
142
|
}
|