@merkl/api 0.10.209 → 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 +9 -9
- package/dist/src/entities/opportunity.js +36 -1
- package/dist/src/index.d.ts +3 -3
- 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/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -371,7 +371,7 @@ declare const eden: {
|
|
371
371
|
index: {
|
372
372
|
post: (body: {
|
373
373
|
name?: string | undefined;
|
374
|
-
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";
|
375
375
|
tokens: {
|
376
376
|
chainId: number;
|
377
377
|
address: string;
|
@@ -592,7 +592,7 @@ declare const eden: {
|
|
592
592
|
get: (options: {
|
593
593
|
headers?: Record<string, unknown> | undefined;
|
594
594
|
query: {
|
595
|
-
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;
|
596
596
|
items?: number | undefined;
|
597
597
|
subType?: number | undefined;
|
598
598
|
page?: number | undefined;
|
@@ -661,7 +661,7 @@ declare const eden: {
|
|
661
661
|
get: (options: {
|
662
662
|
headers?: Record<string, unknown> | undefined;
|
663
663
|
query: {
|
664
|
-
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;
|
665
665
|
items?: number | undefined;
|
666
666
|
subType?: number | undefined;
|
667
667
|
page?: number | undefined;
|
@@ -2824,7 +2824,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
2824
2824
|
post: {
|
2825
2825
|
body: {
|
2826
2826
|
name?: string | undefined;
|
2827
|
-
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";
|
2828
2828
|
tokens: {
|
2829
2829
|
chainId: number;
|
2830
2830
|
address: string;
|
@@ -3371,7 +3371,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3371
3371
|
body: unknown;
|
3372
3372
|
params: {};
|
3373
3373
|
query: {
|
3374
|
-
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;
|
3375
3375
|
items?: number | undefined;
|
3376
3376
|
subType?: number | undefined;
|
3377
3377
|
page?: number | undefined;
|
@@ -3443,7 +3443,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3443
3443
|
body: unknown;
|
3444
3444
|
params: {};
|
3445
3445
|
query: {
|
3446
|
-
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;
|
3447
3447
|
items?: number | undefined;
|
3448
3448
|
subType?: number | undefined;
|
3449
3449
|
page?: number | undefined;
|
@@ -6414,7 +6414,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6414
6414
|
index: {
|
6415
6415
|
post: (body: {
|
6416
6416
|
name?: string | undefined;
|
6417
|
-
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";
|
6418
6418
|
tokens: {
|
6419
6419
|
chainId: number;
|
6420
6420
|
address: string;
|
@@ -6635,7 +6635,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6635
6635
|
get: (options: {
|
6636
6636
|
headers?: Record<string, unknown> | undefined;
|
6637
6637
|
query: {
|
6638
|
-
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;
|
6639
6639
|
items?: number | undefined;
|
6640
6640
|
subType?: number | undefined;
|
6641
6641
|
page?: number | undefined;
|
@@ -6704,7 +6704,7 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
6704
6704
|
get: (options: {
|
6705
6705
|
headers?: Record<string, unknown> | undefined;
|
6706
6706
|
query: {
|
6707
|
-
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;
|
6708
6708
|
items?: number | undefined;
|
6709
6709
|
subType?: number | undefined;
|
6710
6710
|
page?: number | undefined;
|
@@ -344,7 +344,7 @@ export const extractOpportunities = {
|
|
344
344
|
return opportunity;
|
345
345
|
},
|
346
346
|
[Campaign.BADGER]: (campaign, campaigns, prices) => {
|
347
|
-
const { chainId, tvl,
|
347
|
+
const { chainId, tvl, campaignParameters: params, computeChainId } = campaign;
|
348
348
|
const { active, all } = campaigns;
|
349
349
|
const aprBreakdown = active.reduce((res, campaign) => {
|
350
350
|
res[`Campaign ${campaign.campaignId.slice(0, 8)}`] = {
|
@@ -378,6 +378,41 @@ export const extractOpportunities = {
|
|
378
378
|
};
|
379
379
|
return opportunity;
|
380
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
|
+
},
|
381
416
|
[Campaign.AJNA]: (campaign, campaigns, prices) => {
|
382
417
|
const { chainId, tvl, campaignSubType, campaignParameters: params, computeChainId } = campaign;
|
383
418
|
const { active, all } = campaigns;
|
package/dist/src/index.d.ts
CHANGED
@@ -148,7 +148,7 @@ declare const app: Elysia<"", false, {
|
|
148
148
|
post: {
|
149
149
|
body: {
|
150
150
|
name?: string | undefined;
|
151
|
-
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";
|
152
152
|
tokens: {
|
153
153
|
chainId: number;
|
154
154
|
address: string;
|
@@ -695,7 +695,7 @@ declare const app: Elysia<"", false, {
|
|
695
695
|
body: unknown;
|
696
696
|
params: {};
|
697
697
|
query: {
|
698
|
-
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;
|
699
699
|
items?: number | undefined;
|
700
700
|
subType?: number | undefined;
|
701
701
|
page?: number | undefined;
|
@@ -767,7 +767,7 @@ declare const app: Elysia<"", false, {
|
|
767
767
|
body: unknown;
|
768
768
|
params: {};
|
769
769
|
query: {
|
770
|
-
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;
|
771
771
|
items?: number | undefined;
|
772
772
|
subType?: number | undefined;
|
773
773
|
page?: number | undefined;
|
@@ -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
|
}
|
@@ -1,3 +1,42 @@
|
|
1
|
+
import type { Forwarder, ForwarderParameters } from "@sdk";
|
2
|
+
export interface BucketData {
|
3
|
+
bucket_index: number;
|
4
|
+
deposit: string;
|
5
|
+
bucket_price: string;
|
6
|
+
}
|
7
|
+
export type UserPosition = {
|
8
|
+
balance: number;
|
9
|
+
token: string;
|
10
|
+
origin: string;
|
11
|
+
totalSupply: number;
|
12
|
+
tvl: number;
|
13
|
+
};
|
14
|
+
export type PositionType = {
|
15
|
+
[mainParameter: string]: {
|
16
|
+
userPositions: UserPosition[];
|
17
|
+
decimals: number;
|
18
|
+
totalSupply: number;
|
19
|
+
userTVL: number;
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export type FetchedCampaign = {
|
23
|
+
computedtotalSupply: number;
|
24
|
+
rewardToken: string;
|
25
|
+
symbolRewardToken: string;
|
26
|
+
tvl: number;
|
27
|
+
decimals: number;
|
28
|
+
totalSupplyTargetToken: number;
|
29
|
+
amount: number;
|
30
|
+
forwarders?: {
|
31
|
+
[address: string]: ForwarderParameters<Forwarder>;
|
32
|
+
};
|
33
|
+
};
|
34
|
+
export type Res = {
|
35
|
+
userPositions: UserPosition[];
|
36
|
+
decimals: number;
|
37
|
+
totalSupply: number;
|
38
|
+
userTVL: number;
|
39
|
+
};
|
1
40
|
export type CLAMMPosition = {
|
2
41
|
userPositions: {
|
3
42
|
almAddress: string;
|
@@ -18,3 +57,19 @@ export type CLAMMPosition = {
|
|
18
57
|
userTotalLiquidity: number;
|
19
58
|
userInRangeLiquidity: number;
|
20
59
|
};
|
60
|
+
export type AjnaFetchedCampaign = FetchedCampaign & {
|
61
|
+
subtype: number;
|
62
|
+
poolId: string;
|
63
|
+
quoteToken: string;
|
64
|
+
};
|
65
|
+
export type BadgerFetchedCampaign = FetchedCampaign & {
|
66
|
+
targetToken: string;
|
67
|
+
};
|
68
|
+
export type MorphoFetchedCampaign = FetchedCampaign & {
|
69
|
+
targetToken: string;
|
70
|
+
subtype: number;
|
71
|
+
marketId?: string;
|
72
|
+
};
|
73
|
+
export type EigenLayerFetchedCampaign = FetchedCampaign & {
|
74
|
+
strategy: string;
|
75
|
+
};
|
@@ -60,7 +60,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
60
60
|
body: unknown;
|
61
61
|
params: {};
|
62
62
|
query: {
|
63
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
63
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
64
64
|
items?: number | undefined;
|
65
65
|
subType?: number | undefined;
|
66
66
|
page?: number | undefined;
|
@@ -132,7 +132,7 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
132
132
|
body: unknown;
|
133
133
|
params: {};
|
134
134
|
query: {
|
135
|
-
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | undefined;
|
135
|
+
type?: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER" | undefined;
|
136
136
|
items?: number | undefined;
|
137
137
|
subType?: number | undefined;
|
138
138
|
page?: number | undefined;
|
@@ -117,6 +117,8 @@ export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
|
|
117
117
|
AJNA: "AJNA";
|
118
118
|
EULER: "EULER";
|
119
119
|
UNISWAP_V4: "UNISWAP_V4";
|
120
|
+
ION: "ION";
|
121
|
+
EIGENLAYER: "EIGENLAYER";
|
120
122
|
}>>;
|
121
123
|
subType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
122
124
|
campaignId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
@@ -17,7 +17,7 @@ export declare const OpportunityController: Elysia<"/opportunities", false, {
|
|
17
17
|
post: {
|
18
18
|
body: {
|
19
19
|
name?: string | undefined;
|
20
|
-
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4";
|
20
|
+
type: "INVALID" | "ERC20" | "CLAMM" | "ERC20_SNAPSHOT" | "JSON_AIRDROP" | "SILO" | "RADIANT" | "MORPHO" | "DOLOMITE" | "BADGER" | "COMPOUND" | "AJNA" | "EULER" | "UNISWAP_V4" | "ION" | "EIGENLAYER";
|
21
21
|
tokens: {
|
22
22
|
chainId: number;
|
23
23
|
address: string;
|
@@ -315,6 +315,8 @@ export declare const CreateOpportunityDto: import("@sinclair/typebox").TObject<{
|
|
315
315
|
AJNA: "AJNA";
|
316
316
|
EULER: "EULER";
|
317
317
|
UNISWAP_V4: "UNISWAP_V4";
|
318
|
+
ION: "ION";
|
319
|
+
EIGENLAYER: "EIGENLAYER";
|
318
320
|
}>;
|
319
321
|
identifier: import("@sinclair/typebox").TString;
|
320
322
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|