@merkl/api 0.17.4 → 0.17.6
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/jobs/etl/update-dynamic-data.js +12 -0
- package/dist/src/modules/v4/opportunity/opportunity.converter.d.ts +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.converter.js +7 -7
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +49 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +51 -0
- package/dist/src/modules/v4/token/token.repository.js +3 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -15,6 +15,18 @@ if (!chainId)
|
|
15
15
|
// ─── Update Dynamic Data (APR / TVL / Daily Rewards) ─────────────────────────
|
16
16
|
async function updateDynamicData(liveCampaigns, campaignType) {
|
17
17
|
try {
|
18
|
+
// Input: list of campaigns of same type
|
19
|
+
// Output: for each campaign, APR, TVL, Daily Rewards
|
20
|
+
// Constraint: needs to use multicalls to reduce RPC calls and speed
|
21
|
+
// - Needs to be robust to a single campaign's call failing
|
22
|
+
// - Needs to be quite easy for the engine team to setup new campaign types
|
23
|
+
// abstract GenericDynamicDataComputer
|
24
|
+
// compute(chainId, type, campaigns) => { apr, tvl, dailyRewards } with breakdowns
|
25
|
+
// UNISWAP V4
|
26
|
+
// Round 1 - (chainId, type, campaigns) -> tokens of the pools
|
27
|
+
// Round 2 - (chainId, type, campaigns, output of previous round) -> balance in tokens of forwarders
|
28
|
+
// Round 3 - ...
|
29
|
+
// Round Final - (chainId, type, campaigns, output of previous round) -> { apr, tvl, dailyRewards }
|
18
30
|
const dynamicData = await executeSimple(chainId, campaignsDynamicData(chainId, liveCampaigns, campaignType));
|
19
31
|
const oppMap = {};
|
20
32
|
for (const data of dynamicData) {
|
@@ -2,7 +2,7 @@ import { type CampaignParameters, type Opportunity as OpportunityV3, type ValidC
|
|
2
2
|
import { OpportunityService } from "./opportunity.service";
|
3
3
|
export declare abstract class OpportunityConvertorService {
|
4
4
|
#private;
|
5
|
-
static convertV4CampaignToV3<C extends ValidCampaign>(campaignType: C, campaign: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"][number], opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]): CampaignParameters<C>;
|
5
|
+
static convertV4CampaignToV3<C extends ValidCampaign>(campaignType: C, campaign: Exclude<Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]["campaigns"], undefined>[number], opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number]): CampaignParameters<C>;
|
6
6
|
static convertV4toV3(opportunity: Awaited<ReturnType<(typeof OpportunityService)["findMany"]>>[number], withCampaigns?: boolean): OpportunityV3;
|
7
7
|
static setV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<{}>;
|
8
8
|
static logKeyAndTTLV3Opportunities(showCampaigns: boolean, test: boolean | undefined, identifier: string | undefined, chainId: string | undefined): Promise<void>;
|
@@ -108,23 +108,23 @@ export class OpportunityConvertorService {
|
|
108
108
|
: undefined,
|
109
109
|
tags: opportunity.tags,
|
110
110
|
rewardTokenIcons: opportunity.campaigns
|
111
|
-
|
111
|
+
?.map(campaign => campaign.rewardToken.symbol)
|
112
112
|
.reduce((acc, curr) => {
|
113
113
|
if (!acc.includes(curr))
|
114
114
|
acc.push(curr);
|
115
115
|
return acc;
|
116
|
-
}, []),
|
116
|
+
}, []) ?? [],
|
117
117
|
campaigns: {
|
118
118
|
type: CampaignEnum[opportunity.type],
|
119
|
-
ids: opportunity.campaigns
|
119
|
+
ids: opportunity.campaigns?.map(campaign => campaign.campaignId) ?? [],
|
120
120
|
active: withCampaigns
|
121
121
|
? opportunity.campaigns
|
122
|
-
|
122
|
+
?.filter(campaign => campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp)
|
123
123
|
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
|
124
124
|
: undefined,
|
125
125
|
inactive: withCampaigns
|
126
126
|
? opportunity.campaigns
|
127
|
-
|
127
|
+
?.filter(campaign => !(campaign.startTimestamp < BigInt(now) && BigInt(now) < campaign.endTimestamp))
|
128
128
|
.map(campaign => OpportunityConvertorService.convertV4CampaignToV3(CampaignEnum[campaign.type], campaign, opportunity))
|
129
129
|
: undefined,
|
130
130
|
},
|
@@ -160,13 +160,13 @@ export class OpportunityConvertorService {
|
|
160
160
|
return res;
|
161
161
|
}
|
162
162
|
static async setV3Opportunities(showCampaigns, test, identifier, chainId) {
|
163
|
-
return await CacheService.set(TTLPresets.
|
163
|
+
return await CacheService.set(TTLPresets.MIN_30, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
164
164
|
}
|
165
165
|
static async logKeyAndTTLV3Opportunities(showCampaigns, test, identifier, chainId) {
|
166
166
|
const [key, ttl] = await CacheService.keyAndTTL(OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
167
167
|
log.info(`Args: ${showCampaigns}, ${test}, ${identifier}, ${chainId}, Key: ${key}, TTL: ${ttl}`);
|
168
168
|
}
|
169
169
|
static async wrapV3Opportunities(showCampaigns, test, identifier, chainId) {
|
170
|
-
return await CacheService.wrap(TTLPresets.
|
170
|
+
return await CacheService.wrap(TTLPresets.MIN_5, OpportunityConvertorService.#extractV3Opportunities, showCampaigns, test, identifier, chainId);
|
171
171
|
}
|
172
172
|
}
|
@@ -9,7 +9,13 @@ export declare enum program {
|
|
9
9
|
Beets = "Beets",
|
10
10
|
Celo = "Celo",
|
11
11
|
Swapx = "Swapx",
|
12
|
-
Etherlink = "Etherlink"
|
12
|
+
Etherlink = "Etherlink",
|
13
|
+
Angles = "Angles"
|
14
|
+
}
|
15
|
+
export declare enum anglesCampaigns {
|
16
|
+
Angles_supply_in_angles_liquid = "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D",
|
17
|
+
hold_anS = "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987",
|
18
|
+
hold_wANS = "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70"
|
13
19
|
}
|
14
20
|
export declare enum etherlinkCampaigns {
|
15
21
|
Superlend_Supply_WBTC_Etherlink = "Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA",
|
@@ -381,6 +387,47 @@ export declare enum modeCampaigns {
|
|
381
387
|
Bedrock_Ionic_Supply_ionuniBTC_Mode = "Bedrock Ionic Supply uniBTC 0xa48750877a83f7dec11f722178c317b54a44d142",
|
382
388
|
Bedrock_Ironclad_Supply_uniBTC_Mode = "Bedrock Ironclad Supply uniBTC 0x0F041cf2ae959f39215EFfB50d681Df55D4d90B1"
|
383
389
|
}
|
390
|
+
declare const AnglesInterfaceCampaigns: {
|
391
|
+
"0x15E96CDecA34B9DE1B31586c1206206aDb92E69D": {
|
392
|
+
campaignType: any;
|
393
|
+
computeChainId: any;
|
394
|
+
hooks: never[];
|
395
|
+
targetToken: string;
|
396
|
+
whitelist: never[];
|
397
|
+
blacklist: never[];
|
398
|
+
targetTokenPricing: boolean;
|
399
|
+
rewardTokenPricing: boolean;
|
400
|
+
apr: string;
|
401
|
+
url: string;
|
402
|
+
forwarders: never[];
|
403
|
+
};
|
404
|
+
"0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987": {
|
405
|
+
campaignType: any;
|
406
|
+
computeChainId: any;
|
407
|
+
hooks: never[];
|
408
|
+
targetToken: string;
|
409
|
+
whitelist: never[];
|
410
|
+
blacklist: never[];
|
411
|
+
targetTokenPricing: boolean;
|
412
|
+
rewardTokenPricing: boolean;
|
413
|
+
apr: string;
|
414
|
+
url: string;
|
415
|
+
forwarders: never[];
|
416
|
+
};
|
417
|
+
"0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70": {
|
418
|
+
campaignType: any;
|
419
|
+
computeChainId: any;
|
420
|
+
hooks: never[];
|
421
|
+
targetToken: string;
|
422
|
+
whitelist: never[];
|
423
|
+
blacklist: never[];
|
424
|
+
targetTokenPricing: boolean;
|
425
|
+
rewardTokenPricing: boolean;
|
426
|
+
apr: string;
|
427
|
+
url: string;
|
428
|
+
forwarders: never[];
|
429
|
+
};
|
430
|
+
};
|
384
431
|
declare const EtherlinkInterfaceCampaigns: {
|
385
432
|
"Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA": {
|
386
433
|
campaignType: any;
|
@@ -533,6 +580,6 @@ declare const PufferInterfaceCampaigns: {
|
|
533
580
|
[key in pufferCampaigns]: partialConfig;
|
534
581
|
};
|
535
582
|
export declare const MerklInterfaceCampaigns: {
|
536
|
-
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns;
|
583
|
+
[key in program]: typeof PufferInterfaceCampaigns | typeof ZkSyncInterfaceCampaigns | typeof ModeInterfaceCampaigns | typeof VicunaInterfaceCampaigns | typeof SonicmarketInterfaceCampaigns | typeof ReserveInterfaceCampaigns | typeof BeetsInterfaceCampaigns | typeof CeloInterfaceCampaigns | typeof EtherlinkInterfaceCampaigns | typeof SwapxInterfaceCampaigns | typeof AnglesInterfaceCampaigns;
|
537
584
|
};
|
538
585
|
export {};
|
@@ -11,7 +11,16 @@ export var program;
|
|
11
11
|
program["Celo"] = "Celo";
|
12
12
|
program["Swapx"] = "Swapx";
|
13
13
|
program["Etherlink"] = "Etherlink";
|
14
|
+
program["Angles"] = "Angles";
|
14
15
|
})(program || (program = {}));
|
16
|
+
export var anglesCampaigns;
|
17
|
+
(function (anglesCampaigns) {
|
18
|
+
anglesCampaigns["Angles_supply_in_angles_liquid"] = "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D";
|
19
|
+
anglesCampaigns["hold_anS"] = "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987";
|
20
|
+
anglesCampaigns["hold_wANS"] = "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70";
|
21
|
+
// pendle_lp =
|
22
|
+
// pendle PT
|
23
|
+
})(anglesCampaigns || (anglesCampaigns = {}));
|
15
24
|
export var etherlinkCampaigns;
|
16
25
|
(function (etherlinkCampaigns) {
|
17
26
|
etherlinkCampaigns["Superlend_Supply_WBTC_Etherlink"] = "Superlend Supply WBTC Etherlink 0xfCA0802cb10b3b134a91e07f03965f63eF4B23eA";
|
@@ -392,6 +401,47 @@ export var modeCampaigns;
|
|
392
401
|
modeCampaigns["Bedrock_Ionic_Supply_ionuniBTC_Mode"] = "Bedrock Ionic Supply uniBTC 0xa48750877a83f7dec11f722178c317b54a44d142";
|
393
402
|
modeCampaigns["Bedrock_Ironclad_Supply_uniBTC_Mode"] = "Bedrock Ironclad Supply uniBTC 0x0F041cf2ae959f39215EFfB50d681Df55D4d90B1";
|
394
403
|
})(modeCampaigns || (modeCampaigns = {}));
|
404
|
+
const AnglesInterfaceCampaigns = {
|
405
|
+
[anglesCampaigns.Angles_supply_in_angles_liquid]: {
|
406
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
407
|
+
computeChainId: ChainId.SONIC,
|
408
|
+
hooks: [],
|
409
|
+
targetToken: "0x15E96CDecA34B9DE1B31586c1206206aDb92E69D",
|
410
|
+
whitelist: [],
|
411
|
+
blacklist: [],
|
412
|
+
targetTokenPricing: false,
|
413
|
+
rewardTokenPricing: false,
|
414
|
+
apr: "1095",
|
415
|
+
url: "https://sonicscan.org/token/0x15E96CDecA34B9DE1B31586c1206206aDb92E69D#readContract",
|
416
|
+
forwarders: [],
|
417
|
+
},
|
418
|
+
[anglesCampaigns.hold_anS]: {
|
419
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
420
|
+
computeChainId: ChainId.SONIC,
|
421
|
+
hooks: [],
|
422
|
+
targetToken: "0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987",
|
423
|
+
whitelist: [],
|
424
|
+
blacklist: [],
|
425
|
+
targetTokenPricing: false,
|
426
|
+
rewardTokenPricing: false,
|
427
|
+
apr: "365",
|
428
|
+
url: "https://sonicscan.org/token/0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987#readContract",
|
429
|
+
forwarders: [],
|
430
|
+
},
|
431
|
+
[anglesCampaigns.hold_wANS]: {
|
432
|
+
campaignType: Campaign.ERC20_FIX_APR,
|
433
|
+
computeChainId: ChainId.SONIC,
|
434
|
+
hooks: [],
|
435
|
+
targetToken: "0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70",
|
436
|
+
whitelist: [],
|
437
|
+
blacklist: [],
|
438
|
+
targetTokenPricing: false,
|
439
|
+
rewardTokenPricing: false,
|
440
|
+
apr: "365",
|
441
|
+
url: "https://sonicscan.org/token/0xfA85Fe5A8F5560e9039C04f2b0a90dE1415aBD70#readContract",
|
442
|
+
forwarders: [],
|
443
|
+
},
|
444
|
+
};
|
395
445
|
const EtherlinkInterfaceCampaigns = {
|
396
446
|
[etherlinkCampaigns.Superlend_Supply_WBTC_Etherlink]: {
|
397
447
|
campaignType: Campaign.ERC20,
|
@@ -5099,4 +5149,5 @@ export const MerklInterfaceCampaigns = {
|
|
5099
5149
|
[program.Celo]: CeloInterfaceCampaigns,
|
5100
5150
|
[program.Swapx]: SwapxInterfaceCampaigns,
|
5101
5151
|
[program.Etherlink]: EtherlinkInterfaceCampaigns,
|
5152
|
+
[program.Angles]: AnglesInterfaceCampaigns,
|
5102
5153
|
};
|
@@ -50,7 +50,9 @@ export class TokenRepository {
|
|
50
50
|
{ displaySymbol: { equals: query.displaySymbol, mode: "insensitive" } },
|
51
51
|
...ids,
|
52
52
|
]
|
53
|
-
:
|
53
|
+
: ids.length
|
54
|
+
? [...ids]
|
55
|
+
: undefined,
|
54
56
|
address: query.address ? { equals: query.address, mode: "insensitive" } : undefined,
|
55
57
|
chainId: query.chainId ? { equals: query.chainId } : undefined,
|
56
58
|
name: query.name ? { contains: query.name, mode: "insensitive" } : undefined,
|