@merkl/api 0.20.58 → 0.20.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/eden/index.d.ts +24 -12
- package/dist/src/engine/dynamicData/implementations/Erc20.d.ts +1 -1
- package/dist/src/engine/dynamicData/implementations/Erc20.js +4 -12
- package/dist/src/engine/dynamicData/utils/getFixedApr.d.ts +9 -0
- package/dist/src/engine/dynamicData/utils/getFixedApr.js +35 -0
- package/dist/src/index.d.ts +8 -4
- package/dist/src/routes/v3/router.d.ts +8 -4
- package/dist/src/routes/v3/uniswapv4.d.ts +8 -4
- package/dist/src/routes/v3/uniswapv4.js +5 -5
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -8730,8 +8730,9 @@ declare const eden: {
|
|
8730
8730
|
query?: Record<string, unknown> | undefined;
|
8731
8731
|
fetch?: RequestInit | undefined;
|
8732
8732
|
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
8733
|
-
|
8734
|
-
|
8733
|
+
200: {
|
8734
|
+
[x: string]: any;
|
8735
|
+
} | undefined;
|
8735
8736
|
}>>;
|
8736
8737
|
}) & {
|
8737
8738
|
index: {
|
@@ -8740,8 +8741,11 @@ declare const eden: {
|
|
8740
8741
|
query?: Record<string, unknown> | undefined;
|
8741
8742
|
fetch?: RequestInit | undefined;
|
8742
8743
|
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
8743
|
-
|
8744
|
-
|
8744
|
+
200: {
|
8745
|
+
[x: string]: {
|
8746
|
+
[poolId: string]: UniswapV4PoolType;
|
8747
|
+
} | undefined;
|
8748
|
+
} | null;
|
8745
8749
|
}>>;
|
8746
8750
|
};
|
8747
8751
|
pool: ((params: {
|
@@ -14691,8 +14695,11 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
14691
14695
|
query: unknown;
|
14692
14696
|
headers: unknown;
|
14693
14697
|
response: {
|
14694
|
-
|
14695
|
-
|
14698
|
+
200: {
|
14699
|
+
[x: string]: {
|
14700
|
+
[poolId: string]: UniswapV4PoolType;
|
14701
|
+
} | undefined;
|
14702
|
+
} | null;
|
14696
14703
|
};
|
14697
14704
|
};
|
14698
14705
|
};
|
@@ -14706,8 +14713,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
14706
14713
|
query: unknown;
|
14707
14714
|
headers: unknown;
|
14708
14715
|
response: {
|
14709
|
-
|
14710
|
-
|
14716
|
+
200: {
|
14717
|
+
[x: string]: any;
|
14718
|
+
} | undefined;
|
14711
14719
|
};
|
14712
14720
|
};
|
14713
14721
|
};
|
@@ -23467,8 +23475,9 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
23467
23475
|
query?: Record<string, unknown> | undefined;
|
23468
23476
|
fetch?: RequestInit | undefined;
|
23469
23477
|
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
23470
|
-
|
23471
|
-
|
23478
|
+
200: {
|
23479
|
+
[x: string]: any;
|
23480
|
+
} | undefined;
|
23472
23481
|
}>>;
|
23473
23482
|
}) & {
|
23474
23483
|
index: {
|
@@ -23477,8 +23486,11 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
23477
23486
|
query?: Record<string, unknown> | undefined;
|
23478
23487
|
fetch?: RequestInit | undefined;
|
23479
23488
|
} | undefined) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
23480
|
-
|
23481
|
-
|
23489
|
+
200: {
|
23490
|
+
[x: string]: {
|
23491
|
+
[poolId: string]: UniswapV4PoolType;
|
23492
|
+
} | undefined;
|
23493
|
+
} | null;
|
23482
23494
|
}>>;
|
23483
23495
|
};
|
23484
23496
|
pool: ((params: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
|
1
|
+
import { type Campaign, type CampaignParameters, type MerklChainId } from "@sdk";
|
2
2
|
import type { DynamicDataBuilder } from "../interface";
|
3
3
|
export type ERC20SupportedCampaignType = Campaign.ERC20 | Campaign.ERC20LOGPROCESSOR | Campaign.ERC20REBASELOGPROCESSOR | Campaign.EULER | Campaign.ERC20_FIX_APR;
|
4
4
|
export declare class Erc20DynamicData implements DynamicDataBuilder<ERC20SupportedCampaignType> {
|
@@ -9,7 +9,8 @@ import { TokenRepository } from "@/modules/v4/token/token.repository";
|
|
9
9
|
import { TokenService } from "@/modules/v4/token/token.service";
|
10
10
|
import { log } from "@/utils/logger";
|
11
11
|
import { Pricer } from "@/utils/pricer";
|
12
|
-
import { BN2Number, BalancerPoolInterface, BalancerV3StablePoolInterface,
|
12
|
+
import { BN2Number, BalancerPoolInterface, BalancerV3StablePoolInterface, ChainId, ChainInteractionService, ERC20Interface, EnzymeInterface, FactoryInterface, LayerBankERC20Interface, MetamorphoInterface, YEAR, getEnv, } from "@sdk";
|
13
|
+
import { getFixedApr, hasFixedAprConfig } from "../utils/getFixedApr";
|
13
14
|
export class Erc20DynamicData {
|
14
15
|
async build(chainId, campaigns) {
|
15
16
|
const pricer = await Pricer.load();
|
@@ -160,17 +161,8 @@ export class Erc20DynamicData {
|
|
160
161
|
if (rewardToken.isPoint) {
|
161
162
|
apr = apr / 365 / 100;
|
162
163
|
}
|
163
|
-
else if (campaign.
|
164
|
-
|
165
|
-
if (campaign.campaignParameters.symbolTargetToken === "tacBTC") {
|
166
|
-
apr = 27.92;
|
167
|
-
}
|
168
|
-
else if (campaign.campaignParameters.symbolTargetToken === "tacETH") {
|
169
|
-
apr = 32.58;
|
170
|
-
}
|
171
|
-
else if (campaign.campaignParameters.symbolTargetToken === "tacUSD") {
|
172
|
-
apr = 46.54;
|
173
|
-
}
|
164
|
+
else if (hasFixedAprConfig(campaign.campaignParameters)) {
|
165
|
+
apr = getFixedApr(campaign, priceRewardToken, priceTargetToken);
|
174
166
|
}
|
175
167
|
if (campaign.chainId === ChainId.ETHERLINK) {
|
176
168
|
whitelistedSupplyTargetToken = tokenTypesByCampaign[campaign.campaignId].typeInfo.totalSupply;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { Campaign, CampaignParameters } from "@sdk";
|
2
|
+
export type BaseFixAPRConfig = {
|
3
|
+
apr: string;
|
4
|
+
targetTokenPricing: boolean;
|
5
|
+
rewardTokenPricing: boolean;
|
6
|
+
};
|
7
|
+
export type FixedAprCampaignType = Campaign.ERC20_FIX_APR | Campaign.HYPERDRIVELOGFIXPROCESSOR;
|
8
|
+
export declare function hasFixedAprConfig<T>(params: T): params is T & BaseFixAPRConfig;
|
9
|
+
export declare function getFixedApr(campaignParameters: CampaignParameters<FixedAprCampaignType>, priceRewardToken: number, priceTargetToken: number): number;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// Type guard to check if campaign parameters have fixed APR config
|
2
|
+
export function hasFixedAprConfig(params) {
|
3
|
+
return (typeof params === "object" &&
|
4
|
+
params !== null &&
|
5
|
+
"targetTokenPricing" in params &&
|
6
|
+
"rewardTokenPricing" in params &&
|
7
|
+
"apr" in params);
|
8
|
+
}
|
9
|
+
// TODO: Enhance APR display for non-dollar denominations when front-end is ready.
|
10
|
+
// This should handle cases where one or both token price are unavailable, showing the APR as a direct ratio
|
11
|
+
// (e.g., X reward tokens per Y target tokens) instead of dollar values.
|
12
|
+
export function getFixedApr(campaignParameters, priceRewardToken, priceTargetToken) {
|
13
|
+
const { targetTokenPricing, rewardTokenPricing, apr: fixedApr } = campaignParameters.campaignParameters;
|
14
|
+
const targetApr = Number(fixedApr);
|
15
|
+
// Handle all pricing configurations
|
16
|
+
if (targetTokenPricing && rewardTokenPricing) {
|
17
|
+
// Case 1: Fixed $ amount of reward per $ of liquidity
|
18
|
+
return targetApr * 100;
|
19
|
+
}
|
20
|
+
if (targetTokenPricing && !rewardTokenPricing) {
|
21
|
+
// Case 2: Fixed # amount of reward per $ of liquidity
|
22
|
+
// Return 0 if reward token price is invalid
|
23
|
+
return !priceRewardToken ? 0 : targetApr * priceRewardToken * 100;
|
24
|
+
}
|
25
|
+
if (!targetTokenPricing && rewardTokenPricing) {
|
26
|
+
// Case 3: Fixed $ amount of reward per # of liquidity
|
27
|
+
// Return 0 if target token price is invalid
|
28
|
+
return !priceTargetToken || priceTargetToken === 0 ? 0 : targetApr * (1 / priceTargetToken) * 100;
|
29
|
+
}
|
30
|
+
// Case 4: Fixed # amount of reward per # of liquidity
|
31
|
+
// Return 0 if either price is invalid
|
32
|
+
return !priceRewardToken || !priceTargetToken || priceTargetToken === 0
|
33
|
+
? 0
|
34
|
+
: targetApr * (priceRewardToken / priceTargetToken) * 100;
|
35
|
+
}
|
package/dist/src/index.d.ts
CHANGED
@@ -5924,8 +5924,11 @@ declare const app: Elysia<"", false, {
|
|
5924
5924
|
query: unknown;
|
5925
5925
|
headers: unknown;
|
5926
5926
|
response: {
|
5927
|
-
|
5928
|
-
|
5927
|
+
200: {
|
5928
|
+
[x: string]: {
|
5929
|
+
[poolId: string]: UniswapV4PoolType;
|
5930
|
+
} | undefined;
|
5931
|
+
} | null;
|
5929
5932
|
};
|
5930
5933
|
};
|
5931
5934
|
};
|
@@ -5939,8 +5942,9 @@ declare const app: Elysia<"", false, {
|
|
5939
5942
|
query: unknown;
|
5940
5943
|
headers: unknown;
|
5941
5944
|
response: {
|
5942
|
-
|
5943
|
-
|
5945
|
+
200: {
|
5946
|
+
[x: string]: any;
|
5947
|
+
} | undefined;
|
5944
5948
|
};
|
5945
5949
|
};
|
5946
5950
|
};
|
@@ -776,8 +776,11 @@ export declare const v3: Elysia<"/v3", false, {
|
|
776
776
|
query: unknown;
|
777
777
|
headers: unknown;
|
778
778
|
response: {
|
779
|
-
|
780
|
-
|
779
|
+
200: {
|
780
|
+
[x: string]: {
|
781
|
+
[poolId: string]: UniswapV4PoolType;
|
782
|
+
} | undefined;
|
783
|
+
} | null;
|
781
784
|
};
|
782
785
|
};
|
783
786
|
};
|
@@ -791,8 +794,9 @@ export declare const v3: Elysia<"/v3", false, {
|
|
791
794
|
query: unknown;
|
792
795
|
headers: unknown;
|
793
796
|
response: {
|
794
|
-
|
795
|
-
|
797
|
+
200: {
|
798
|
+
[x: string]: any;
|
799
|
+
} | undefined;
|
796
800
|
};
|
797
801
|
};
|
798
802
|
};
|
@@ -20,8 +20,11 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
|
|
20
20
|
query: unknown;
|
21
21
|
headers: unknown;
|
22
22
|
response: {
|
23
|
-
|
24
|
-
|
23
|
+
200: {
|
24
|
+
[x: string]: {
|
25
|
+
[poolId: string]: UniswapV4PoolType;
|
26
|
+
} | undefined;
|
27
|
+
} | null;
|
25
28
|
};
|
26
29
|
};
|
27
30
|
};
|
@@ -35,8 +38,9 @@ declare const _default: (app: Elysia) => Elysia<"", false, {
|
|
35
38
|
query: unknown;
|
36
39
|
headers: unknown;
|
37
40
|
response: {
|
38
|
-
|
39
|
-
|
41
|
+
200: {
|
42
|
+
[x: string]: any;
|
43
|
+
} | undefined;
|
40
44
|
};
|
41
45
|
};
|
42
46
|
};
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import { CacheService } from "@/modules/v4/cache";
|
2
2
|
import { ChainUniqueDto } from "@/modules/v4/chain/chain.model";
|
3
|
-
import { Bytes32Dto, UniV4ChainIdArray } from "@/modules/v4/uniswap/uniswap.model";
|
3
|
+
import { Bytes32Dto, UniV4ChainIdArray, } from "@/modules/v4/uniswap/uniswap.model";
|
4
4
|
import { UniswapService } from "@/modules/v4/uniswap/uniswap.service";
|
5
5
|
import { UnsupportedNetwork } from "@/utils/error";
|
6
6
|
export default (app) => app.group("/uniswapv4", router => router
|
7
7
|
.get("/", async () => {
|
8
|
-
return await
|
8
|
+
return await CacheService.get(UniswapService.getUniswapV4Pools, []);
|
9
9
|
}, {
|
10
10
|
tags: ["uniswapv4"],
|
11
11
|
})
|
12
12
|
.get("/:chainId", async ({ params }) => {
|
13
|
-
return (await
|
13
|
+
return (await CacheService.get(UniswapService.getUniswapV4Pools, []))?.[params.chainId];
|
14
14
|
}, {
|
15
15
|
params: ChainUniqueDto,
|
16
16
|
beforeHandle: ({ params }) => {
|
@@ -20,7 +20,7 @@ export default (app) => app.group("/uniswapv4", router => router
|
|
20
20
|
tags: ["uniswapv4"],
|
21
21
|
})
|
22
22
|
.get("/pool/:poolId", async ({ params }) => {
|
23
|
-
return Object.values((await
|
23
|
+
return Object.values((await CacheService.get(UniswapService.getUniswapV4Pools, [])))
|
24
24
|
.flatMap(x => (x ? Object.values(x) : []))
|
25
25
|
.filter(p => p.poolId === params.poolId);
|
26
26
|
}, {
|