@merkl/api 0.10.208 → 0.10.210
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/api/.generated/edge.js +6 -4
- package/dist/database/api/.generated/index-browser.js +3 -1
- package/dist/database/api/.generated/index.d.ts +3 -1
- package/dist/database/api/.generated/index.js +6 -4
- package/dist/database/api/.generated/package.json +1 -1
- package/dist/database/api/.generated/schema.prisma +2 -0
- package/dist/database/api/.generated/wasm.js +3 -1
- package/dist/database/api/seeder/resources/protocol.d.ts +12 -0
- package/dist/database/api/seeder/resources/protocol.js +2 -0
- package/dist/src/eden/index.d.ts +39 -9
- package/dist/src/entities/opportunity.js +37 -1
- package/dist/src/index.d.ts +15 -3
- package/dist/src/index.js +1 -1
- package/dist/src/libs/campaigns/campaignTypes/EigenLayerDynamicData.d.ts +3 -0
- package/dist/src/libs/campaigns/campaignTypes/EigenLayerDynamicData.js +67 -0
- package/dist/src/libs/campaigns/campaignsDynamicData.js +4 -0
- package/dist/src/libs/positions/EigenLayer/index.d.ts +6 -0
- package/dist/src/libs/positions/EigenLayer/index.js +53 -0
- package/dist/src/libs/positions/ajna/index.d.ts +4 -39
- package/dist/src/libs/positions/ajna/index.js +2 -2
- package/dist/src/libs/positions/badger/index.d.ts +3 -24
- package/dist/src/libs/positions/badger/index.js +1 -1
- package/dist/src/libs/positions/index.js +4 -0
- package/dist/src/libs/positions/morpho/index.d.ts +4 -38
- package/dist/src/libs/positions/prepareFetch.js +29 -1
- package/dist/src/libs/positions/types.d.ts +55 -0
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +2 -2
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +2 -0
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +2 -0
- package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -1
- package/dist/src/modules/v4/protocol/protocol.model.js +2 -0
- package/dist/src/modules/v4/router.d.ts +3 -3
- package/dist/src/utils/generateCardName.js +1 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
import type { Campaign as CampaignResource } from "../modules/v4";
|
2
2
|
import type { CampaignType } from "../../database/api/.generated";
|
3
3
|
declare const eden: {
|
4
|
+
index: {
|
5
|
+
get: (options?: {
|
6
|
+
headers?: Record<string, unknown> | undefined;
|
7
|
+
query?: Record<string, unknown> | undefined;
|
8
|
+
fetch?: RequestInit | undefined;
|
9
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
10
|
+
200: string;
|
11
|
+
}>>;
|
12
|
+
};
|
4
13
|
v1: {
|
5
14
|
allowances: {
|
6
15
|
get: (options: {
|
@@ -362,7 +371,7 @@ declare const eden: {
|
|
362
371
|
index: {
|
363
372
|
post: (body: {
|
364
373
|
name?: string | undefined;
|
365
|
-
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4";
|
374
|
+
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
|
366
375
|
tokens: {
|
367
376
|
chainId: number;
|
368
377
|
address: string;
|
@@ -583,7 +592,7 @@ declare const eden: {
|
|
583
592
|
get: (options: {
|
584
593
|
headers?: Record<string, unknown> | undefined;
|
585
594
|
query: {
|
586
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
595
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
587
596
|
items?: number | undefined;
|
588
597
|
subType?: number | undefined;
|
589
598
|
page?: number | undefined;
|
@@ -652,7 +661,7 @@ declare const eden: {
|
|
652
661
|
get: (options: {
|
653
662
|
headers?: Record<string, unknown> | undefined;
|
654
663
|
query: {
|
655
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
664
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
656
665
|
items?: number | undefined;
|
657
666
|
subType?: number | undefined;
|
658
667
|
page?: number | undefined;
|
@@ -2691,6 +2700,18 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2691
2700
|
macro: {};
|
2692
2701
|
macroFn: {};
|
2693
2702
|
}, {
|
2703
|
+
index: {
|
2704
|
+
get: {
|
2705
|
+
body: unknown;
|
2706
|
+
params: {};
|
2707
|
+
query: unknown;
|
2708
|
+
headers: unknown;
|
2709
|
+
response: {
|
2710
|
+
200: string;
|
2711
|
+
};
|
2712
|
+
};
|
2713
|
+
};
|
2714
|
+
} & {
|
2694
2715
|
v1: {
|
2695
2716
|
allowances: {
|
2696
2717
|
get: {
|
@@ -2803,7 +2824,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2803
2824
|
post: {
|
2804
2825
|
body: {
|
2805
2826
|
name?: string | undefined;
|
2806
|
-
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4";
|
2827
|
+
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
|
2807
2828
|
tokens: {
|
2808
2829
|
chainId: number;
|
2809
2830
|
address: string;
|
@@ -3350,7 +3371,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3350
3371
|
body: unknown;
|
3351
3372
|
params: {};
|
3352
3373
|
query: {
|
3353
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
3374
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
3354
3375
|
items?: number | undefined;
|
3355
3376
|
subType?: number | undefined;
|
3356
3377
|
page?: number | undefined;
|
@@ -3422,7 +3443,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3422
3443
|
body: unknown;
|
3423
3444
|
params: {};
|
3424
3445
|
query: {
|
3425
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
3446
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
3426
3447
|
items?: number | undefined;
|
3427
3448
|
subType?: number | undefined;
|
3428
3449
|
page?: number | undefined;
|
@@ -6023,6 +6044,15 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6023
6044
|
resolve: {};
|
6024
6045
|
schema: {};
|
6025
6046
|
}>, config?: import("@elysiajs/eden").Treaty.Config) => {
|
6047
|
+
index: {
|
6048
|
+
get: (options?: {
|
6049
|
+
headers?: Record<string, unknown> | undefined;
|
6050
|
+
query?: Record<string, unknown> | undefined;
|
6051
|
+
fetch?: RequestInit | undefined;
|
6052
|
+
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
6053
|
+
200: string;
|
6054
|
+
}>>;
|
6055
|
+
};
|
6026
6056
|
v1: {
|
6027
6057
|
allowances: {
|
6028
6058
|
get: (options: {
|
@@ -6384,7 +6414,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6384
6414
|
index: {
|
6385
6415
|
post: (body: {
|
6386
6416
|
name?: string | undefined;
|
6387
|
-
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4";
|
6417
|
+
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
|
6388
6418
|
tokens: {
|
6389
6419
|
chainId: number;
|
6390
6420
|
address: string;
|
@@ -6605,7 +6635,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6605
6635
|
get: (options: {
|
6606
6636
|
headers?: Record<string, unknown> | undefined;
|
6607
6637
|
query: {
|
6608
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
6638
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
6609
6639
|
items?: number | undefined;
|
6610
6640
|
subType?: number | undefined;
|
6611
6641
|
page?: number | undefined;
|
@@ -6674,7 +6704,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6674
6704
|
get: (options: {
|
6675
6705
|
headers?: Record<string, unknown> | undefined;
|
6676
6706
|
query: {
|
6677
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
6707
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
6678
6708
|
items?: number | undefined;
|
6679
6709
|
subType?: number | undefined;
|
6680
6710
|
page?: number | undefined;
|
@@ -210,6 +210,7 @@ export const extractOpportunities = {
|
|
210
210
|
"poolside",
|
211
211
|
"koi",
|
212
212
|
"pancakeswap",
|
213
|
+
"tempest",
|
213
214
|
],
|
214
215
|
borrow: ["radiant_borrow", "aave_borrowing", "euler_borrow"],
|
215
216
|
lend: [
|
@@ -343,7 +344,7 @@ export const extractOpportunities = {
|
|
343
344
|
return opportunity;
|
344
345
|
},
|
345
346
|
[Campaign.BADGER]: (campaign, campaigns, prices) => {
|
346
|
-
const { chainId, tvl,
|
347
|
+
const { chainId, tvl, campaignParameters: params, computeChainId } = campaign;
|
347
348
|
const { active, all } = campaigns;
|
348
349
|
const aprBreakdown = active.reduce((res, campaign) => {
|
349
350
|
res[`Campaign ${campaign.campaignId.slice(0, 8)}`] = {
|
@@ -377,6 +378,41 @@ export const extractOpportunities = {
|
|
377
378
|
};
|
378
379
|
return opportunity;
|
379
380
|
},
|
381
|
+
[Campaign.EIGENLAYER]: (campaign, campaigns, prices) => {
|
382
|
+
const { chainId, tvl, campaignParameters: params, computeChainId } = campaign;
|
383
|
+
const { active, all } = campaigns;
|
384
|
+
const aprBreakdown = active.reduce((res, campaign) => {
|
385
|
+
res[`Campaign ${campaign.campaignId.slice(0, 8)}`] = {
|
386
|
+
value: campaign.apr ?? 0,
|
387
|
+
address: campaign.campaignId,
|
388
|
+
type: EAprBreakdownType.DETAILS,
|
389
|
+
};
|
390
|
+
return res;
|
391
|
+
}, {});
|
392
|
+
// @Hugo WIP todo for aprBreakdown2
|
393
|
+
const aprBreakdown2 = getCampaignsApr(active);
|
394
|
+
const opportunity = {
|
395
|
+
id: `${Campaign.EIGENLAYER}_${campaign.mainParameter}`,
|
396
|
+
platform: "EigenLayer strategy",
|
397
|
+
name: ["EigenLayer", "strategy", params.symbolUnderlyingToken].join(" "),
|
398
|
+
chainId: !computeChainId ? chainId : computeChainId,
|
399
|
+
distributionChainId: chainId,
|
400
|
+
tvl,
|
401
|
+
action: "lend",
|
402
|
+
subtype: 0,
|
403
|
+
status: getStatus(all),
|
404
|
+
tags: getTags(campaigns.all),
|
405
|
+
dailyrewards: getDailyRewards(active, prices),
|
406
|
+
tokenIcons: [params.symbolUnderlyingToken],
|
407
|
+
campaigns: { ...campaigns, type: Campaign.EIGENLAYER, ids: campaigns.all.map(c => c.campaignId) },
|
408
|
+
rewardTokenIcons: getRewardTokenIcons(campaigns.active),
|
409
|
+
dailyRewardTokens: getRewardTokens(campaigns.active),
|
410
|
+
apr: getApr(active),
|
411
|
+
aprBreakdown,
|
412
|
+
aprBreakdown2,
|
413
|
+
};
|
414
|
+
return opportunity;
|
415
|
+
},
|
380
416
|
[Campaign.AJNA]: (campaign, campaigns, prices) => {
|
381
417
|
const { chainId, tvl, campaignSubType, campaignParameters: params, computeChainId } = campaign;
|
382
418
|
const { active, all } = campaigns;
|
package/dist/src/index.d.ts
CHANGED
@@ -24,6 +24,18 @@ declare const app: Elysia<"", false, {
|
|
24
24
|
macro: {};
|
25
25
|
macroFn: {};
|
26
26
|
}, {
|
27
|
+
index: {
|
28
|
+
get: {
|
29
|
+
body: unknown;
|
30
|
+
params: {};
|
31
|
+
query: unknown;
|
32
|
+
headers: unknown;
|
33
|
+
response: {
|
34
|
+
200: string;
|
35
|
+
};
|
36
|
+
};
|
37
|
+
};
|
38
|
+
} & {
|
27
39
|
v1: {
|
28
40
|
allowances: {
|
29
41
|
get: {
|
@@ -136,7 +148,7 @@ declare const app: Elysia<"", false, {
|
|
136
148
|
post: {
|
137
149
|
body: {
|
138
150
|
name?: string | undefined;
|
139
|
-
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4";
|
151
|
+
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
|
140
152
|
tokens: {
|
141
153
|
chainId: number;
|
142
154
|
address: string;
|
@@ -683,7 +695,7 @@ declare const app: Elysia<"", false, {
|
|
683
695
|
body: unknown;
|
684
696
|
params: {};
|
685
697
|
query: {
|
686
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
698
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
687
699
|
items?: number | undefined;
|
688
700
|
subType?: number | undefined;
|
689
701
|
page?: number | undefined;
|
@@ -755,7 +767,7 @@ declare const app: Elysia<"", false, {
|
|
755
767
|
body: unknown;
|
756
768
|
params: {};
|
757
769
|
query: {
|
758
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
770
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
759
771
|
items?: number | undefined;
|
760
772
|
subType?: number | undefined;
|
761
773
|
page?: number | undefined;
|
package/dist/src/index.js
CHANGED
@@ -0,0 +1,3 @@
|
|
1
|
+
import { type Campaign, type CampaignDynamicData, type CampaignParameters, type MerklChainId } from "@sdk";
|
2
|
+
import type { UncachedResult } from "../../../utils/execute";
|
3
|
+
export declare function EigenLayerDynamicData(_chainId: MerklChainId, campaigns: CampaignParameters<Campaign.EIGENLAYER>[]): Promise<UncachedResult<Partial<CampaignDynamicData<Campaign.EIGENLAYER>[]>>>;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { BN2Number, ChainInteractionService, EigenLayerStrategyInterface, EigenLayerStrategy__factory, YEAR, } from "@sdk";
|
2
|
+
import { log } from "../../../utils/logger";
|
3
|
+
import { Pricer } from "../../../utils/pricer";
|
4
|
+
export async function EigenLayerDynamicData(_chainId, campaigns) {
|
5
|
+
const pricer = await Pricer.load();
|
6
|
+
const calls = [];
|
7
|
+
for (const campaign of campaigns) {
|
8
|
+
calls.push({
|
9
|
+
allowFailure: true,
|
10
|
+
callData: EigenLayerStrategyInterface.encodeFunctionData("totalShares"),
|
11
|
+
target: campaign.campaignParameters.strategy,
|
12
|
+
});
|
13
|
+
}
|
14
|
+
return {
|
15
|
+
cached: false,
|
16
|
+
call: {
|
17
|
+
callData: calls,
|
18
|
+
handler: () => { },
|
19
|
+
reducer: async (result) => {
|
20
|
+
let i = 0;
|
21
|
+
const dynamicData = [];
|
22
|
+
for (const campaign of campaigns) {
|
23
|
+
let totalSupplyShares;
|
24
|
+
let totalSupplyStrategy;
|
25
|
+
try {
|
26
|
+
totalSupplyShares = EigenLayerStrategyInterface.decodeFunctionResult("totalShares", result[i++])[0];
|
27
|
+
}
|
28
|
+
catch {
|
29
|
+
log.warn(`Error getting totalShares for campaign ${campaign.campaignId} and strategy ${campaign.campaignParameters.strategy}`);
|
30
|
+
totalSupplyShares = 0.0000001;
|
31
|
+
}
|
32
|
+
try {
|
33
|
+
totalSupplyStrategy = BN2Number(await EigenLayerStrategy__factory.connect(campaign.campaignParameters.strategy, ChainInteractionService(campaign.computeChainId).provider()).sharesToUnderlying(totalSupplyShares), campaign.campaignParameters.decimalsUnderlyingToken);
|
34
|
+
}
|
35
|
+
catch {
|
36
|
+
log.warn(`Error getting totalSupply for campaign ${campaign.campaignId} and strategy ${campaign.campaignParameters.strategy}`);
|
37
|
+
totalSupplyStrategy = 0.0000001;
|
38
|
+
}
|
39
|
+
const priceRewardToken = (await pricer.get({
|
40
|
+
address: campaign.rewardToken,
|
41
|
+
chainId: campaign.chainId,
|
42
|
+
symbol: campaign.campaignParameters.symbolRewardToken,
|
43
|
+
})) ?? 0;
|
44
|
+
const priceTargetToken = (await pricer.get({
|
45
|
+
address: campaign.campaignParameters.underlyingToken,
|
46
|
+
chainId: campaign.computeChainId,
|
47
|
+
symbol: campaign.campaignParameters.symbolUnderlyingToken,
|
48
|
+
})) ?? 0;
|
49
|
+
const tvl = totalSupplyStrategy * priceTargetToken;
|
50
|
+
dynamicData.push({
|
51
|
+
...campaign,
|
52
|
+
apr: (priceRewardToken *
|
53
|
+
BN2Number(campaign.amount, campaign.campaignParameters.decimalsRewardToken) *
|
54
|
+
YEAR *
|
55
|
+
100) /
|
56
|
+
campaign.campaignParameters.duration /
|
57
|
+
(totalSupplyStrategy * priceTargetToken),
|
58
|
+
totalSupplyTargetToken: totalSupplyStrategy,
|
59
|
+
tvl,
|
60
|
+
priceRewardToken: priceRewardToken,
|
61
|
+
});
|
62
|
+
}
|
63
|
+
return dynamicData;
|
64
|
+
},
|
65
|
+
},
|
66
|
+
};
|
67
|
+
}
|
@@ -8,6 +8,7 @@ import { CompoundDynamicData } from "./campaignTypes/CompoundDynamicData";
|
|
8
8
|
import { DolomiteDynamicData } from "./campaignTypes/DolomiteDynamicData";
|
9
9
|
import { ERC20DynamicData } from "./campaignTypes/ERC20DynamicData";
|
10
10
|
import { ERC20_SNAPSHOTDynamicData } from "./campaignTypes/ERC20_SNAPSHOTDynamicData";
|
11
|
+
import { EigenLayerDynamicData } from "./campaignTypes/EigenLayerDynamicData";
|
11
12
|
import { EulerDynamicData } from "./campaignTypes/EulerDynamicData";
|
12
13
|
import { JSON_AIRDROPDynamicData } from "./campaignTypes/JSON_AIRDROPDynamicData";
|
13
14
|
import { MORPHODynamicData } from "./campaignTypes/MORPHODynamicData";
|
@@ -61,6 +62,9 @@ export async function campaignsDynamicData(chainId, campaigns, type) {
|
|
61
62
|
case Campaign.COMPOUND: {
|
62
63
|
return CompoundDynamicData(chainId, campaigns);
|
63
64
|
}
|
65
|
+
case Campaign.EIGENLAYER: {
|
66
|
+
return EigenLayerDynamicData(chainId, campaigns);
|
67
|
+
}
|
64
68
|
}
|
65
69
|
return {
|
66
70
|
cached: false,
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { type MerklChainId } from "@sdk";
|
2
|
+
import type { UncachedResult } from "../../../utils/execute";
|
3
|
+
import type { EigenLayerFetchedCampaign, PositionType } from "../types";
|
4
|
+
export declare function getEigenLayerUserPositions(user: string, _chainId: MerklChainId, campaigns: {
|
5
|
+
[mainparameter: string]: EigenLayerFetchedCampaign;
|
6
|
+
}): Promise<UncachedResult<PositionType>>;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { BN2Number, ChainInteractionService, EigenLayerStrategyInterface, EigenLayerStrategy__factory, } from "@sdk";
|
2
|
+
export async function getEigenLayerUserPositions(user, _chainId, campaigns) {
|
3
|
+
/**
|
4
|
+
* Fetch user positions
|
5
|
+
*/
|
6
|
+
const calls = [];
|
7
|
+
for (const mainParameter of Object.keys(campaigns)) {
|
8
|
+
calls.push({
|
9
|
+
allowFailure: true,
|
10
|
+
callData: EigenLayerStrategyInterface.encodeFunctionData("shares", [user]),
|
11
|
+
target: campaigns[mainParameter].strategy,
|
12
|
+
});
|
13
|
+
}
|
14
|
+
return {
|
15
|
+
cached: false,
|
16
|
+
call: {
|
17
|
+
callData: calls,
|
18
|
+
handler: () => { },
|
19
|
+
reducer: async (result) => {
|
20
|
+
let j = 0;
|
21
|
+
const finalRes = {};
|
22
|
+
for (const campaignId of Object.keys(campaigns)) {
|
23
|
+
let userShares = 0;
|
24
|
+
let userSupply = 0;
|
25
|
+
const strategy = campaigns[campaignId].strategy;
|
26
|
+
userShares = EigenLayerStrategyInterface.decodeFunctionResult("shares", result[j++])[0];
|
27
|
+
userSupply = BN2Number(await EigenLayerStrategy__factory.connect(strategy, ChainInteractionService(_chainId).provider()).sharesToUnderlying(userShares), campaigns[campaignId].decimals);
|
28
|
+
const res = {
|
29
|
+
userPositions: [],
|
30
|
+
decimals: campaigns[campaignId].decimals,
|
31
|
+
totalSupply: BN2Number(campaigns[campaignId].totalSupplyTargetToken, campaigns[campaignId].decimals),
|
32
|
+
userTVL: 0,
|
33
|
+
};
|
34
|
+
if (userSupply > 0) {
|
35
|
+
res.userPositions.push({
|
36
|
+
balance: userSupply,
|
37
|
+
token: strategy,
|
38
|
+
origin: "Direct",
|
39
|
+
totalSupply: campaigns.campaignId.totalSupplyTargetToken,
|
40
|
+
tvl: campaigns[campaignId].tvl,
|
41
|
+
});
|
42
|
+
// to modify
|
43
|
+
}
|
44
|
+
// Add to final result if there are positions
|
45
|
+
if (res.userPositions.length > 0) {
|
46
|
+
finalRes[`14_${campaignId}`] = { ...res };
|
47
|
+
}
|
48
|
+
}
|
49
|
+
return finalRes;
|
50
|
+
},
|
51
|
+
},
|
52
|
+
};
|
53
|
+
}
|
@@ -1,41 +1,6 @@
|
|
1
|
-
import { type
|
1
|
+
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { UncachedResult } from "../../../utils/execute";
|
3
|
-
|
4
|
-
balance: number;
|
5
|
-
token: string;
|
6
|
-
origin: string;
|
7
|
-
totalSupply: number;
|
8
|
-
tvl: number;
|
9
|
-
};
|
10
|
-
export type FetchedCampaign = {
|
11
|
-
rewardToken: string;
|
12
|
-
targetToken: string;
|
13
|
-
symbolRewardToken: string;
|
14
|
-
subtype: number;
|
15
|
-
tvl: number;
|
16
|
-
poolId: string;
|
17
|
-
decimals: number;
|
18
|
-
totalSupplyTargetToken: number;
|
19
|
-
computedtotalSupply: number;
|
20
|
-
amount: number;
|
21
|
-
forwarders?: {
|
22
|
-
[address: string]: ForwarderParameters<Forwarder>;
|
23
|
-
};
|
24
|
-
};
|
25
|
-
export type MorphoPositionType = {
|
26
|
-
[mainParameter: string]: {
|
27
|
-
userPositions: UserPosition[];
|
28
|
-
decimals: number;
|
29
|
-
totalSupply: number;
|
30
|
-
userTVL: number;
|
31
|
-
};
|
32
|
-
};
|
33
|
-
export type Res = {
|
34
|
-
userPositions: UserPosition[];
|
35
|
-
decimals: number;
|
36
|
-
totalSupply: number;
|
37
|
-
userTVL: number;
|
38
|
-
};
|
3
|
+
import type { AjnaFetchedCampaign, PositionType } from "../types";
|
39
4
|
export declare function getAjnaUserPositions(user: string, _chainId: MerklChainId, campaigns: {
|
40
|
-
[mainparameter: string]:
|
41
|
-
}): Promise<UncachedResult<
|
5
|
+
[mainparameter: string]: AjnaFetchedCampaign;
|
6
|
+
}): Promise<UncachedResult<PositionType>>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { batchMulticallCallWithRetry } from "../../../utils/generic";
|
2
|
-
import { AjnaSubCampaignType, BN2Number, NETWORK_LABELS, PoolInfoUtilsInterface
|
2
|
+
import { AjnaSubCampaignType, BN2Number, NETWORK_LABELS, PoolInfoUtilsInterface } from "@sdk";
|
3
3
|
import { POOL_INFO_UTILS } from "@sdk";
|
4
4
|
import axios from "axios";
|
5
5
|
export async function getAjnaUserPositions(user, _chainId, campaigns) {
|
@@ -28,7 +28,7 @@ export async function getAjnaUserPositions(user, _chainId, campaigns) {
|
|
28
28
|
call: {
|
29
29
|
callData: calls,
|
30
30
|
handler: () => { },
|
31
|
-
reducer: async (
|
31
|
+
reducer: async (_result) => {
|
32
32
|
const finalRes = {};
|
33
33
|
const resCalls = await batchMulticallCallWithRetry(_chainId, {
|
34
34
|
calls,
|
@@ -1,27 +1,6 @@
|
|
1
1
|
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { UncachedResult } from "../../../utils/execute";
|
3
|
-
import type {
|
4
|
-
export type UserPosition = {
|
5
|
-
balance: number;
|
6
|
-
token: string;
|
7
|
-
origin: string;
|
8
|
-
totalSupply: number;
|
9
|
-
tvl: number;
|
10
|
-
};
|
11
|
-
export type MorphoPositionType = {
|
12
|
-
[mainParameter: string]: {
|
13
|
-
userPositions: UserPosition[];
|
14
|
-
decimals: number;
|
15
|
-
totalSupply: number;
|
16
|
-
userTVL: number;
|
17
|
-
};
|
18
|
-
};
|
19
|
-
export type Res = {
|
20
|
-
userPositions: UserPosition[];
|
21
|
-
decimals: number;
|
22
|
-
totalSupply: number;
|
23
|
-
userTVL: number;
|
24
|
-
};
|
3
|
+
import type { BadgerFetchedCampaign, PositionType } from "../types";
|
25
4
|
export declare function getBadgerUserPositions(user: string, _chainId: MerklChainId, campaigns: {
|
26
|
-
[mainparameter: string]:
|
27
|
-
}): Promise<UncachedResult<
|
5
|
+
[mainparameter: string]: BadgerFetchedCampaign;
|
6
|
+
}): Promise<UncachedResult<PositionType>>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Campaign, withTimeout } from "@sdk";
|
2
2
|
import { MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT } from "../../constants";
|
3
3
|
import { executeSimple } from "../../utils/execute";
|
4
|
+
import { getEigenLayerUserPositions } from "./EigenLayer";
|
4
5
|
import { getAjnaUserPositions } from "./ajna";
|
5
6
|
import { getBadgerUserPositions } from "./badger";
|
6
7
|
import { getClammUserPositions } from "./clamm";
|
@@ -42,6 +43,9 @@ chainId, user) {
|
|
42
43
|
break;
|
43
44
|
case Campaign.COMPOUND:
|
44
45
|
promises.push(withTimeout(executeSimple(chainId, getCompoundUserPositions(user, chainId, positionsToCheck[numkey])), MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT));
|
46
|
+
break;
|
47
|
+
case Campaign.EIGENLAYER:
|
48
|
+
promises.push(withTimeout(executeSimple(chainId, getEigenLayerUserPositions(user, chainId, positionsToCheck[numkey])), MERKL_USER_POSITION_FETCHING_GLOBAL_TIMEOUT));
|
45
49
|
}
|
46
50
|
}
|
47
51
|
return Object.assign({}, ...(await Promise.all(promises)));
|
@@ -1,40 +1,6 @@
|
|
1
|
-
import { type
|
1
|
+
import { type MerklChainId } from "@sdk";
|
2
2
|
import type { UncachedResult } from "../../../utils/execute";
|
3
|
-
|
4
|
-
[mainParameter: string]: {
|
5
|
-
userPositions: UserPosition[];
|
6
|
-
decimals: number;
|
7
|
-
totalSupply: number;
|
8
|
-
userTVL: number;
|
9
|
-
};
|
10
|
-
};
|
11
|
-
export type FetchedCampaign = {
|
12
|
-
rewardToken: string;
|
13
|
-
targetToken: string;
|
14
|
-
symbolRewardToken: string;
|
15
|
-
subtype: number;
|
16
|
-
tvl: number;
|
17
|
-
marketId: string;
|
18
|
-
decimals: number;
|
19
|
-
totalSupplyTargetToken: number;
|
20
|
-
amount: number;
|
21
|
-
forwarders?: {
|
22
|
-
[address: string]: ForwarderParameters<Forwarder>;
|
23
|
-
};
|
24
|
-
};
|
25
|
-
export type UserPosition = {
|
26
|
-
balance: number;
|
27
|
-
token: string;
|
28
|
-
origin: string;
|
29
|
-
totalSupply: number;
|
30
|
-
tvl: number;
|
31
|
-
};
|
32
|
-
export type Res = {
|
33
|
-
userPositions: UserPosition[];
|
34
|
-
decimals: number;
|
35
|
-
totalSupply: number;
|
36
|
-
userTVL: number;
|
37
|
-
};
|
3
|
+
import type { MorphoFetchedCampaign, PositionType } from "../types";
|
38
4
|
export declare function getMorphoUserPositions(user: string, _chainId: MerklChainId, campaigns: {
|
39
|
-
[mainparameter: string]:
|
40
|
-
}): Promise<UncachedResult<
|
5
|
+
[mainparameter: string]: MorphoFetchedCampaign;
|
6
|
+
}): Promise<UncachedResult<PositionType>>;
|
@@ -312,8 +312,34 @@ function prepareCompoundFetch(previous, campaign) {
|
|
312
312
|
};
|
313
313
|
return previous;
|
314
314
|
}
|
315
|
+
function prepareEigenLayerFetch(previous, campaign) {
|
316
|
+
if (campaign.campaignType !== Campaign.EIGENLAYER) {
|
317
|
+
return previous;
|
318
|
+
}
|
319
|
+
const forwarders = {};
|
320
|
+
if (campaign.campaignParameters.forwarders && campaign.campaignParameters.forwarders.length > 0) {
|
321
|
+
for (const forwarder of campaign.campaignParameters.forwarders) {
|
322
|
+
forwarders[utils.getAddress(forwarder.sender)] = forwarder;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
previous[campaign.mainParameter] = {
|
326
|
+
rewardToken: campaign.rewardToken,
|
327
|
+
symbolRewardToken: campaign.campaignParameters.symbolRewardToken,
|
328
|
+
tvl: campaign.tvl,
|
329
|
+
forwarders: forwarders,
|
330
|
+
targetToken: campaign.campaignParameters.strategy,
|
331
|
+
decimalsTargetToken: campaign.campaignParameters.decimalsUnderlyingToken,
|
332
|
+
totalSupplyTargetToken: campaign.totalSupplyTargetToken,
|
333
|
+
underlyingToken: campaign.campaignParameters.underlyingToken,
|
334
|
+
symbolUnderlyingToken: campaign.campaignParameters.symbolUnderlyingToken,
|
335
|
+
decimals: campaign.campaignParameters.decimalsUnderlyingToken,
|
336
|
+
amount: Number.parseFloat((BigInt(campaign.amount) / BigInt(10 ** campaign.campaignParameters.decimalsRewardToken)).toString()),
|
337
|
+
};
|
338
|
+
return previous;
|
339
|
+
}
|
315
340
|
export function prepareFetch(type, previous, // FIXME
|
316
|
-
campaign
|
341
|
+
campaign //FIXME
|
342
|
+
) {
|
317
343
|
switch (type) {
|
318
344
|
case Campaign.CLAMM:
|
319
345
|
return prepareClammFetch(previous, campaign);
|
@@ -333,6 +359,8 @@ campaign) {
|
|
333
359
|
return prepareAjnaFetch(previous, campaign);
|
334
360
|
case Campaign.COMPOUND:
|
335
361
|
return prepareCompoundFetch(previous, campaign);
|
362
|
+
case Campaign.EIGENLAYER:
|
363
|
+
return prepareEigenLayerFetch(previous, campaign);
|
336
364
|
default:
|
337
365
|
return previous;
|
338
366
|
}
|