@merkl/api 0.10.182 → 0.10.184
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/eden/index.d.ts +62 -9
- package/dist/src/index.d.ts +24 -3
- package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.js +0 -3
- package/dist/src/libs/campaigns/campaignsDynamicData.js +1 -4
- package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.js +1 -4
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +3 -3
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +4 -4
- package/dist/src/modules/v4/opportunity/opportunity.service.js +0 -2
- package/dist/src/modules/v4/reward/reward.controller.d.ts +21 -0
- package/dist/src/modules/v4/reward/reward.controller.js +15 -2
- package/dist/src/modules/v4/reward/reward.model.d.ts +7 -0
- package/dist/src/modules/v4/reward/reward.model.js +6 -0
- package/dist/src/modules/v4/reward/reward.repository.d.ts +1 -0
- package/dist/src/modules/v4/reward/reward.repository.js +15 -0
- package/dist/src/modules/v4/reward/reward.service.d.ts +2 -1
- package/dist/src/modules/v4/reward/reward.service.js +14 -0
- package/dist/src/modules/v4/router.d.ts +24 -3
- package/dist/src/modules/v4/token/token.repository.js +6 -2
- package/dist/src/routes/v3/blacklist.d.ts +24 -3
- package/dist/src/routes/v3/campaigns.d.ts +24 -3
- package/dist/src/routes/v3/campaignsInfo.d.ts +24 -3
- package/dist/src/routes/v3/multiChainPositions.d.ts +24 -3
- package/dist/src/routes/v3/opportunity.d.ts +24 -3
- package/dist/src/routes/v3/positions.d.ts +24 -3
- package/dist/src/routes/v3/rewards.d.ts +24 -3
- package/dist/src/routes/v3/updates.d.ts +24 -3
- package/dist/src/routes/v3/userRewards.d.ts +24 -3
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -106,7 +106,7 @@ declare const eden: {
|
|
106
106
|
tvl: number;
|
107
107
|
apr: number;
|
108
108
|
dailyRewards: number;
|
109
|
-
} |
|
109
|
+
} | undefined;
|
110
110
|
}>>;
|
111
111
|
campaigns: {
|
112
112
|
get: (options?: {
|
@@ -317,7 +317,7 @@ declare const eden: {
|
|
317
317
|
};
|
318
318
|
fetch?: RequestInit | undefined;
|
319
319
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
320
|
-
200:
|
320
|
+
200: {
|
321
321
|
aprRecord: {
|
322
322
|
cumulated: number;
|
323
323
|
timestamp: bigint;
|
@@ -403,7 +403,7 @@ declare const eden: {
|
|
403
403
|
tvl: number;
|
404
404
|
apr: number;
|
405
405
|
dailyRewards: number;
|
406
|
-
}
|
406
|
+
}[];
|
407
407
|
}>>;
|
408
408
|
};
|
409
409
|
count: {
|
@@ -898,6 +898,22 @@ declare const eden: {
|
|
898
898
|
} | undefined;
|
899
899
|
}>>;
|
900
900
|
};
|
901
|
+
claims: {
|
902
|
+
post: (body: {
|
903
|
+
token: string;
|
904
|
+
chainId: number;
|
905
|
+
recipient: string;
|
906
|
+
root: string;
|
907
|
+
}[], options: {
|
908
|
+
headers: {
|
909
|
+
authorization: string;
|
910
|
+
};
|
911
|
+
query?: Record<string, unknown> | undefined;
|
912
|
+
fetch?: RequestInit | undefined;
|
913
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
914
|
+
200: void;
|
915
|
+
}>>;
|
916
|
+
};
|
901
917
|
pendings: {
|
902
918
|
post: (body: {
|
903
919
|
distributionChainId: number;
|
@@ -2102,7 +2118,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2102
2118
|
tvl: number;
|
2103
2119
|
apr: number;
|
2104
2120
|
dailyRewards: number;
|
2105
|
-
} |
|
2121
|
+
} | undefined;
|
2106
2122
|
};
|
2107
2123
|
};
|
2108
2124
|
};
|
@@ -2280,7 +2296,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2280
2296
|
};
|
2281
2297
|
headers: unknown;
|
2282
2298
|
response: {
|
2283
|
-
200:
|
2299
|
+
200: {
|
2284
2300
|
aprRecord: {
|
2285
2301
|
cumulated: number;
|
2286
2302
|
timestamp: bigint;
|
@@ -2366,7 +2382,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2366
2382
|
tvl: number;
|
2367
2383
|
apr: number;
|
2368
2384
|
dailyRewards: number;
|
2369
|
-
}
|
2385
|
+
}[];
|
2370
2386
|
};
|
2371
2387
|
};
|
2372
2388
|
};
|
@@ -3006,6 +3022,27 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3006
3022
|
};
|
3007
3023
|
};
|
3008
3024
|
};
|
3025
|
+
} & {
|
3026
|
+
engine: {
|
3027
|
+
claims: {
|
3028
|
+
post: {
|
3029
|
+
body: {
|
3030
|
+
token: string;
|
3031
|
+
chainId: number;
|
3032
|
+
recipient: string;
|
3033
|
+
root: string;
|
3034
|
+
}[];
|
3035
|
+
params: {};
|
3036
|
+
query: unknown;
|
3037
|
+
headers: {
|
3038
|
+
authorization: string;
|
3039
|
+
};
|
3040
|
+
response: {
|
3041
|
+
200: void;
|
3042
|
+
};
|
3043
|
+
};
|
3044
|
+
};
|
3045
|
+
};
|
3009
3046
|
} & {
|
3010
3047
|
engine: {
|
3011
3048
|
pendings: {
|
@@ -4456,7 +4493,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4456
4493
|
tvl: number;
|
4457
4494
|
apr: number;
|
4458
4495
|
dailyRewards: number;
|
4459
|
-
} |
|
4496
|
+
} | undefined;
|
4460
4497
|
}>>;
|
4461
4498
|
campaigns: {
|
4462
4499
|
get: (options?: {
|
@@ -4667,7 +4704,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4667
4704
|
};
|
4668
4705
|
fetch?: RequestInit | undefined;
|
4669
4706
|
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
4670
|
-
200:
|
4707
|
+
200: {
|
4671
4708
|
aprRecord: {
|
4672
4709
|
cumulated: number;
|
4673
4710
|
timestamp: bigint;
|
@@ -4753,7 +4790,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
4753
4790
|
tvl: number;
|
4754
4791
|
apr: number;
|
4755
4792
|
dailyRewards: number;
|
4756
|
-
}
|
4793
|
+
}[];
|
4757
4794
|
}>>;
|
4758
4795
|
};
|
4759
4796
|
count: {
|
@@ -5248,6 +5285,22 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
5248
5285
|
} | undefined;
|
5249
5286
|
}>>;
|
5250
5287
|
};
|
5288
|
+
claims: {
|
5289
|
+
post: (body: {
|
5290
|
+
token: string;
|
5291
|
+
chainId: number;
|
5292
|
+
recipient: string;
|
5293
|
+
root: string;
|
5294
|
+
}[], options: {
|
5295
|
+
headers: {
|
5296
|
+
authorization: string;
|
5297
|
+
};
|
5298
|
+
query?: Record<string, unknown> | undefined;
|
5299
|
+
fetch?: RequestInit | undefined;
|
5300
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
5301
|
+
200: void;
|
5302
|
+
}>>;
|
5303
|
+
};
|
5251
5304
|
pendings: {
|
5252
5305
|
post: (body: {
|
5253
5306
|
distributionChainId: number;
|
package/dist/src/index.d.ts
CHANGED
@@ -164,7 +164,7 @@ declare const app: Elysia<"", false, {
|
|
164
164
|
tvl: number;
|
165
165
|
apr: number;
|
166
166
|
dailyRewards: number;
|
167
|
-
} |
|
167
|
+
} | undefined;
|
168
168
|
};
|
169
169
|
};
|
170
170
|
};
|
@@ -342,7 +342,7 @@ declare const app: Elysia<"", false, {
|
|
342
342
|
};
|
343
343
|
headers: unknown;
|
344
344
|
response: {
|
345
|
-
200:
|
345
|
+
200: {
|
346
346
|
aprRecord: {
|
347
347
|
cumulated: number;
|
348
348
|
timestamp: bigint;
|
@@ -428,7 +428,7 @@ declare const app: Elysia<"", false, {
|
|
428
428
|
tvl: number;
|
429
429
|
apr: number;
|
430
430
|
dailyRewards: number;
|
431
|
-
}
|
431
|
+
}[];
|
432
432
|
};
|
433
433
|
};
|
434
434
|
};
|
@@ -1068,6 +1068,27 @@ declare const app: Elysia<"", false, {
|
|
1068
1068
|
};
|
1069
1069
|
};
|
1070
1070
|
};
|
1071
|
+
} & {
|
1072
|
+
engine: {
|
1073
|
+
claims: {
|
1074
|
+
post: {
|
1075
|
+
body: {
|
1076
|
+
token: string;
|
1077
|
+
chainId: number;
|
1078
|
+
recipient: string;
|
1079
|
+
root: string;
|
1080
|
+
}[];
|
1081
|
+
params: {};
|
1082
|
+
query: unknown;
|
1083
|
+
headers: {
|
1084
|
+
authorization: string;
|
1085
|
+
};
|
1086
|
+
response: {
|
1087
|
+
200: void;
|
1088
|
+
};
|
1089
|
+
};
|
1090
|
+
};
|
1091
|
+
};
|
1071
1092
|
} & {
|
1072
1093
|
engine: {
|
1073
1094
|
pendings: {
|
@@ -182,10 +182,8 @@ function parseForBalancer(calls, index, targetToken, name) {
|
|
182
182
|
function parseForStaking(campaign, calls, index, targetToken) {
|
183
183
|
try {
|
184
184
|
const whitelist = campaign.campaignParameters.whitelist;
|
185
|
-
console.log("whitelist", whitelist, whitelist.length);
|
186
185
|
if (whitelist.length === 1) {
|
187
186
|
const forwarders = campaign.campaignParameters.forwarders;
|
188
|
-
console.log("forwarders", forwarders);
|
189
187
|
if (forwarders.length === 1) {
|
190
188
|
if (forwarders[0].sender === whitelist[0]) {
|
191
189
|
const name = decodeCall(calls, index + 2, "name");
|
@@ -210,7 +208,6 @@ export function getTokenTypeRound1(calls, targetToken, index, campaign) {
|
|
210
208
|
result = parseForMetamorpho(returnValueOfCalls, index, targetToken);
|
211
209
|
if (result)
|
212
210
|
return result;
|
213
|
-
console.log("parsing for staking");
|
214
211
|
result = parseForStaking(campaign, returnValueOfCalls, index, targetToken);
|
215
212
|
if (result)
|
216
213
|
return result;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { log } from "../../utils/logger";
|
2
1
|
import { engineDbClient } from "../../utils/prisma";
|
3
2
|
import { Campaign } from "@sdk";
|
4
3
|
import { getAddress } from "ethers/lib/utils";
|
@@ -25,9 +24,7 @@ export async function campaignsDynamicData(chainId, campaigns, type) {
|
|
25
24
|
campaign.tags = tags[getAddress(campaign.creator)] || [];
|
26
25
|
}
|
27
26
|
}
|
28
|
-
catch (_err) {
|
29
|
-
log.warn("No tags assigned to creator address in database");
|
30
|
-
}
|
27
|
+
catch (_err) { }
|
31
28
|
switch (type) {
|
32
29
|
case Campaign.ERC20: {
|
33
30
|
const switchRefacto = process.env.SWITCH_REFACTO_SUBTYPES_ERC20 !== undefined ? process.env.SWITCH_REFACTO_SUBTYPES_ERC20 : false;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { engineDbClient } from "../../utils/prisma";
|
2
2
|
import { Campaign } from "@sdk";
|
3
3
|
import { getAddress } from "ethers/lib/utils";
|
4
|
-
import { log } from "../../utils/logger";
|
5
4
|
import { AjnaDynamicData } from "./campaignTypes/AjnaDynamicData";
|
6
5
|
import { BadgerDynamicData } from "./campaignTypes/BadgerDynamicData";
|
7
6
|
import { CLAMMDynamicData } from "./campaignTypes/CLAMMDynamicData";
|
@@ -24,9 +23,7 @@ export async function campaignsDynamicDataRefacto(chainId, campaigns, type, next
|
|
24
23
|
campaign.tags = tags[getAddress(campaign.creator)] || [];
|
25
24
|
}
|
26
25
|
}
|
27
|
-
catch (e) {
|
28
|
-
log.warn("No tags assigned to creator address in database");
|
29
|
-
}
|
26
|
+
catch (e) { }
|
30
27
|
switch (type) {
|
31
28
|
case Campaign.ERC20: {
|
32
29
|
return ERC20DynamicDataRefacto(chainId, campaigns);
|
@@ -137,7 +137,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
137
137
|
tvl: number;
|
138
138
|
apr: number;
|
139
139
|
dailyRewards: number;
|
140
|
-
} |
|
140
|
+
} | undefined;
|
141
141
|
};
|
142
142
|
};
|
143
143
|
};
|
@@ -315,7 +315,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
315
315
|
};
|
316
316
|
headers: unknown;
|
317
317
|
response: {
|
318
|
-
200:
|
318
|
+
200: {
|
319
319
|
aprRecord: {
|
320
320
|
cumulated: number;
|
321
321
|
timestamp: bigint;
|
@@ -401,7 +401,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
401
401
|
tvl: number;
|
402
402
|
apr: number;
|
403
403
|
dailyRewards: number;
|
404
|
-
}
|
404
|
+
}[];
|
405
405
|
};
|
406
406
|
};
|
407
407
|
};
|
@@ -239,13 +239,13 @@ export declare abstract class OpportunityService {
|
|
239
239
|
tvl: number;
|
240
240
|
apr: number;
|
241
241
|
dailyRewards: number;
|
242
|
-
}
|
242
|
+
}>;
|
243
243
|
/**
|
244
244
|
* Get the list of opportunities satisfying the query
|
245
245
|
* @param query
|
246
246
|
* @returns A list of opportunities
|
247
247
|
*/
|
248
|
-
static getMany(query: GetOpportunitiesQueryModel): Promise<
|
248
|
+
static getMany(query: GetOpportunitiesQueryModel): Promise<{
|
249
249
|
aprRecord: {
|
250
250
|
cumulated: number;
|
251
251
|
timestamp: bigint;
|
@@ -331,7 +331,7 @@ export declare abstract class OpportunityService {
|
|
331
331
|
tvl: number;
|
332
332
|
apr: number;
|
333
333
|
dailyRewards: number;
|
334
|
-
}
|
334
|
+
}[]>;
|
335
335
|
static findLiveWithFirstCampaign(chainId: MerklChainId): Promise<({
|
336
336
|
aprRecord: {
|
337
337
|
cumulated: number;
|
@@ -562,7 +562,7 @@ export declare abstract class OpportunityService {
|
|
562
562
|
tvl: number;
|
563
563
|
apr: number;
|
564
564
|
dailyRewards: number;
|
565
|
-
}
|
565
|
+
};
|
566
566
|
static formatResponseBase(opportunity: LightOpportunityFromDB): {
|
567
567
|
id: string;
|
568
568
|
tokens: ({
|
@@ -175,8 +175,6 @@ export class OpportunityService {
|
|
175
175
|
return await OpportunityRepository.countMany(query);
|
176
176
|
}
|
177
177
|
static formatResponse(opportunity) {
|
178
|
-
if (opportunity === null)
|
179
|
-
return null;
|
180
178
|
const { DailyRewardsRecords, AprRecords, TvlRecords, ...opp } = opportunity;
|
181
179
|
return {
|
182
180
|
...OpportunityService.formatResponseBase(opp),
|
@@ -104,6 +104,27 @@ export declare const RewardController: Elysia<"/rewards", false, {
|
|
104
104
|
};
|
105
105
|
};
|
106
106
|
};
|
107
|
+
} & {
|
108
|
+
engine: {
|
109
|
+
claims: {
|
110
|
+
post: {
|
111
|
+
body: {
|
112
|
+
token: string;
|
113
|
+
chainId: number;
|
114
|
+
recipient: string;
|
115
|
+
root: string;
|
116
|
+
}[];
|
117
|
+
params: {};
|
118
|
+
query: unknown;
|
119
|
+
headers: {
|
120
|
+
authorization: string;
|
121
|
+
};
|
122
|
+
response: {
|
123
|
+
200: void;
|
124
|
+
};
|
125
|
+
};
|
126
|
+
};
|
127
|
+
};
|
107
128
|
} & {
|
108
129
|
engine: {
|
109
130
|
pendings: {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
2
|
import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
|
3
|
-
import { throwOnUnsupportedChainId } from "../../../utils/throw";
|
3
|
+
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
|
4
4
|
import Elysia from "elysia";
|
5
|
-
import { CampaignIdDto, CampaignIdWithoutPageDto, CreateManyBreakdownDto, CreateManyRewardDto, UpdatePendingDto, } from "./reward.model";
|
5
|
+
import { CampaignIdDto, CampaignIdWithoutPageDto, CreateManyBreakdownDto, CreateManyRewardDto, RegisterClaimsDto, UpdatePendingDto, } from "./reward.model";
|
6
6
|
import { RewardService } from "./reward.service";
|
7
7
|
// ─── Rewards Controller ──────────────────────────────────────────────────────
|
8
8
|
export const RewardController = new Elysia({ prefix: "/rewards", detail: { tags: ["Rewards"] } })
|
@@ -31,6 +31,19 @@ export const RewardController = new Elysia({ prefix: "/rewards", detail: { tags:
|
|
31
31
|
headers: AuthorizationHeadersDto,
|
32
32
|
body: CreateManyBreakdownDto,
|
33
33
|
beforeHandle: EngineGuard,
|
34
|
+
})
|
35
|
+
// ─── Register new claims ──────────────────────────────────────────────
|
36
|
+
.post("/engine/claims", async ({ body }) => await RewardService.registerClaims(body), {
|
37
|
+
headers: AuthorizationHeadersDto,
|
38
|
+
body: RegisterClaimsDto,
|
39
|
+
beforeHandle: ({ headers, body }) => {
|
40
|
+
EngineGuard({ headers });
|
41
|
+
for (const claim of body) {
|
42
|
+
throwOnUnsupportedChainId(claim.chainId);
|
43
|
+
claim.token = throwOnInvalidRequiredAddress(claim.token);
|
44
|
+
claim.recipient = throwOnInvalidRequiredAddress(claim.recipient);
|
45
|
+
}
|
46
|
+
},
|
34
47
|
})
|
35
48
|
// ─── Create Many Pending Rewards ─────────────────────────────────────
|
36
49
|
.post("/engine/pendings", async ({ body }) => await RewardService.updatePendings(body), {
|
@@ -65,6 +65,12 @@ export declare const CreateManyRewardDto: import("@sinclair/typebox").TArray<imp
|
|
65
65
|
rewardToken: import("@sinclair/typebox").TString;
|
66
66
|
proofs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
67
67
|
}>>;
|
68
|
+
export declare const RegisterClaimsDto: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
69
|
+
chainId: import("@sinclair/typebox").TNumber;
|
70
|
+
recipient: import("@sinclair/typebox").TString;
|
71
|
+
token: import("@sinclair/typebox").TString;
|
72
|
+
root: import("@sinclair/typebox").TString;
|
73
|
+
}>>;
|
68
74
|
declare const PendingDto: import("@sinclair/typebox").TObject<{
|
69
75
|
recipient: import("@sinclair/typebox").TString;
|
70
76
|
reason: import("@sinclair/typebox").TString;
|
@@ -163,6 +169,7 @@ export type CreateManyRewardModel = typeof CreateManyRewardDto.static;
|
|
163
169
|
export type CreateManyBreakdownModel = typeof CreateManyBreakdownDto.static;
|
164
170
|
export type RewardEntity = typeof RewardDto.static;
|
165
171
|
export type RewardPerChainModel = typeof RewardsPerChainDto.static;
|
172
|
+
export type RegisterClaimsModel = typeof RegisterClaimsDto.static;
|
166
173
|
export type UpdatePendingModel = typeof UpdatePendingDto.static;
|
167
174
|
export type PendingEntity = typeof PendingDto.static;
|
168
175
|
export type CampaignIdWithoutPageModel = {
|
@@ -25,6 +25,12 @@ const RewardDto = t.Object({
|
|
25
25
|
proofs: t.Array(t.String()),
|
26
26
|
});
|
27
27
|
export const CreateManyRewardDto = t.Array(RewardDto);
|
28
|
+
export const RegisterClaimsDto = t.Array(t.Object({
|
29
|
+
chainId: t.Numeric(),
|
30
|
+
recipient: t.String(),
|
31
|
+
token: t.String(),
|
32
|
+
root: t.String(),
|
33
|
+
}));
|
28
34
|
const PendingDto = t.Object({
|
29
35
|
recipient: t.String(),
|
30
36
|
reason: t.String(),
|
@@ -123,6 +123,7 @@ export declare abstract class RewardRepository {
|
|
123
123
|
_all: number;
|
124
124
|
};
|
125
125
|
})[]>;
|
126
|
+
static updateClaimed(recipient: string, rewardTokenId: string, campaignId: string, reason: string, amount: string): Promise<Prisma.BatchPayload>;
|
126
127
|
static updatePendings(rewardTokenId: string, root: string, campaignId: string, toUpdate: PendingEntity[]): Promise<{
|
127
128
|
reason: string;
|
128
129
|
pending: string;
|
@@ -118,6 +118,21 @@ export class RewardRepository {
|
|
118
118
|
_count: { _all: true },
|
119
119
|
});
|
120
120
|
}
|
121
|
+
static async updateClaimed(recipient, rewardTokenId, campaignId, reason, amount) {
|
122
|
+
return await apiDbClient.rewardBreakdown.updateMany({
|
123
|
+
where: {
|
124
|
+
campaignId,
|
125
|
+
reason,
|
126
|
+
Reward: {
|
127
|
+
recipient,
|
128
|
+
rewardTokenId,
|
129
|
+
},
|
130
|
+
},
|
131
|
+
data: {
|
132
|
+
claimed: amount,
|
133
|
+
},
|
134
|
+
});
|
135
|
+
}
|
121
136
|
static async updatePendings(rewardTokenId, root, campaignId, toUpdate) {
|
122
137
|
return await apiDbClient.$transaction(toUpdate.map(x => {
|
123
138
|
return apiDbClient.rewardBreakdown.update({
|
@@ -2,7 +2,7 @@ import type { CacheKeys } from "../../../cache/keys";
|
|
2
2
|
import type { Chain } from "../../../../database/api/.generated";
|
3
3
|
import { Campaign, type CampaignDynamicData, type ChainId } from "@sdk";
|
4
4
|
import { type LightOpportunityFromDB, type Opportunity } from "../opportunity";
|
5
|
-
import type { CampaignIdModel, CampaignIdWithoutPageModel, CreateManyBreakdownModel, CreateManyRewardModel, DailyRewardsRecord, RewardBreakdown, UpdatePendingModel } from "./reward.model";
|
5
|
+
import type { CampaignIdModel, CampaignIdWithoutPageModel, CreateManyBreakdownModel, CreateManyRewardModel, DailyRewardsRecord, RegisterClaimsModel, RewardBreakdown, UpdatePendingModel } from "./reward.model";
|
6
6
|
import { RewardRepository } from "./reward.repository";
|
7
7
|
export declare abstract class RewardService {
|
8
8
|
static hashId(root: string, recipient: string, rewardTokenId: string): string;
|
@@ -541,6 +541,7 @@ export declare abstract class RewardService {
|
|
541
541
|
chain: Chain;
|
542
542
|
rewards: Awaited<ReturnType<(typeof RewardService)["format"]>>;
|
543
543
|
}[]>;
|
544
|
+
static registerClaims(claims: RegisterClaimsModel): Promise<void>;
|
544
545
|
static updatePendings(data: UpdatePendingModel): Promise<boolean>;
|
545
546
|
static countAllchains(): Promise<Record<string, {
|
546
547
|
breakdown: number;
|
@@ -205,6 +205,20 @@ export class RewardService {
|
|
205
205
|
}
|
206
206
|
return res;
|
207
207
|
}
|
208
|
+
static async registerClaims(claims) {
|
209
|
+
for (const claim of claims) {
|
210
|
+
const tokenId = TokenService.hashId({
|
211
|
+
chainId: claim.chainId,
|
212
|
+
address: claim.token,
|
213
|
+
});
|
214
|
+
const rewards = await RewardRepository.getByChainRecipientToken(claim.recipient, claim.root, tokenId);
|
215
|
+
if (!rewards)
|
216
|
+
continue;
|
217
|
+
for (const breakdown of rewards.Breakdown) {
|
218
|
+
await RewardRepository.updateClaimed(claim.recipient, tokenId, breakdown.campaignId, breakdown.reason, breakdown.amount);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
208
222
|
static async updatePendings(data) {
|
209
223
|
const rewardTokenId = await TokenService.hashId({ address: data.rewardToken, chainId: data.distributionChainId });
|
210
224
|
const campaignId = await CampaignService.hashId({
|
@@ -146,7 +146,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
146
146
|
tvl: number;
|
147
147
|
apr: number;
|
148
148
|
dailyRewards: number;
|
149
|
-
} |
|
149
|
+
} | undefined;
|
150
150
|
};
|
151
151
|
};
|
152
152
|
};
|
@@ -324,7 +324,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
324
324
|
};
|
325
325
|
headers: unknown;
|
326
326
|
response: {
|
327
|
-
200:
|
327
|
+
200: {
|
328
328
|
aprRecord: {
|
329
329
|
cumulated: number;
|
330
330
|
timestamp: bigint;
|
@@ -410,7 +410,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
410
410
|
tvl: number;
|
411
411
|
apr: number;
|
412
412
|
dailyRewards: number;
|
413
|
-
}
|
413
|
+
}[];
|
414
414
|
};
|
415
415
|
};
|
416
416
|
};
|
@@ -1050,6 +1050,27 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1050
1050
|
};
|
1051
1051
|
};
|
1052
1052
|
};
|
1053
|
+
} & {
|
1054
|
+
engine: {
|
1055
|
+
claims: {
|
1056
|
+
post: {
|
1057
|
+
body: {
|
1058
|
+
token: string;
|
1059
|
+
chainId: number;
|
1060
|
+
recipient: string;
|
1061
|
+
root: string;
|
1062
|
+
}[];
|
1063
|
+
params: {};
|
1064
|
+
query: unknown;
|
1065
|
+
headers: {
|
1066
|
+
authorization: string;
|
1067
|
+
};
|
1068
|
+
response: {
|
1069
|
+
200: void;
|
1070
|
+
};
|
1071
|
+
};
|
1072
|
+
};
|
1073
|
+
};
|
1053
1074
|
} & {
|
1054
1075
|
engine: {
|
1055
1076
|
pendings: {
|
@@ -34,8 +34,12 @@ export class TokenRepository {
|
|
34
34
|
static #transformQueryToPrismaFilters(query) {
|
35
35
|
return {
|
36
36
|
where: {
|
37
|
-
|
38
|
-
|
37
|
+
OR: query.symbol
|
38
|
+
? [
|
39
|
+
{ symbol: { equals: query.symbol, mode: "insensitive" } },
|
40
|
+
{ displaySymbol: { equals: query.symbol, mode: "insensitive" } },
|
41
|
+
]
|
42
|
+
: undefined,
|
39
43
|
address: query.address ? { equals: query.address, mode: "insensitive" } : undefined,
|
40
44
|
chainId: query.chainId ? { equals: query.chainId } : undefined,
|
41
45
|
name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
|
@@ -170,7 +170,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
|
|
170
170
|
tvl: number;
|
171
171
|
apr: number;
|
172
172
|
dailyRewards: number;
|
173
|
-
} |
|
173
|
+
} | undefined;
|
174
174
|
};
|
175
175
|
};
|
176
176
|
};
|
@@ -348,7 +348,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
|
|
348
348
|
};
|
349
349
|
headers: unknown;
|
350
350
|
response: {
|
351
|
-
200:
|
351
|
+
200: {
|
352
352
|
aprRecord: {
|
353
353
|
cumulated: number;
|
354
354
|
timestamp: bigint;
|
@@ -434,7 +434,7 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
|
|
434
434
|
tvl: number;
|
435
435
|
apr: number;
|
436
436
|
dailyRewards: number;
|
437
|
-
}
|
437
|
+
}[];
|
438
438
|
};
|
439
439
|
};
|
440
440
|
};
|
@@ -1074,6 +1074,27 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
|
|
1074
1074
|
};
|
1075
1075
|
};
|
1076
1076
|
};
|
1077
|
+
} & {
|
1078
|
+
engine: {
|
1079
|
+
claims: {
|
1080
|
+
post: {
|
1081
|
+
body: {
|
1082
|
+
token: string;
|
1083
|
+
chainId: number;
|
1084
|
+
recipient: string;
|
1085
|
+
root: string;
|
1086
|
+
}[];
|
1087
|
+
params: {};
|
1088
|
+
query: unknown;
|
1089
|
+
headers: {
|
1090
|
+
authorization: string;
|
1091
|
+
};
|
1092
|
+
response: {
|
1093
|
+
200: void;
|
1094
|
+
};
|
1095
|
+
};
|
1096
|
+
};
|
1097
|
+
};
|
1077
1098
|
} & {
|
1078
1099
|
engine: {
|
1079
1100
|
pendings: {
|