@defisaver/positions-sdk 2.1.142-dev → 2.1.143
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/cjs/aaveV3/merkl.js +4 -7
- package/cjs/aaveV4/merkl.js +5 -6
- package/cjs/claiming/aaveV3.d.ts +2 -1
- package/cjs/claiming/aaveV3.js +13 -4
- package/cjs/compoundV3/merkl.js +4 -6
- package/cjs/fluid/index.d.ts +9 -1
- package/cjs/fluid/index.js +10 -4
- package/cjs/fluid/merkl.d.ts +7 -4
- package/cjs/fluid/merkl.js +22 -16
- package/cjs/helpers/fluidHelpers/index.d.ts +3 -1
- package/cjs/helpers/fluidHelpers/index.js +37 -4
- package/cjs/morphoBlue/index.d.ts +1 -1
- package/cjs/morphoBlue/index.js +2 -2
- package/cjs/morphoBlue/merkl.d.ts +6 -4
- package/cjs/morphoBlue/merkl.js +17 -16
- package/cjs/portfolio/index.js +5 -5
- package/cjs/services/merkl.d.ts +6 -0
- package/cjs/services/merkl.js +39 -0
- package/cjs/types/claiming.d.ts +12 -1
- package/cjs/types/claiming.js +2 -0
- package/cjs/types/common.d.ts +4 -0
- package/cjs/types/common.js +5 -1
- package/cjs/types/fluid.d.ts +2 -0
- package/esm/aaveV3/merkl.js +5 -8
- package/esm/aaveV4/merkl.js +5 -6
- package/esm/claiming/aaveV3.d.ts +2 -1
- package/esm/claiming/aaveV3.js +12 -4
- package/esm/compoundV3/merkl.js +5 -7
- package/esm/fluid/index.d.ts +9 -1
- package/esm/fluid/index.js +9 -3
- package/esm/fluid/merkl.d.ts +7 -4
- package/esm/fluid/merkl.js +19 -15
- package/esm/helpers/fluidHelpers/index.d.ts +3 -1
- package/esm/helpers/fluidHelpers/index.js +38 -6
- package/esm/morphoBlue/index.d.ts +1 -1
- package/esm/morphoBlue/index.js +1 -1
- package/esm/morphoBlue/merkl.d.ts +6 -4
- package/esm/morphoBlue/merkl.js +16 -15
- package/esm/portfolio/index.js +6 -6
- package/esm/services/merkl.d.ts +6 -0
- package/esm/services/merkl.js +35 -0
- package/esm/types/claiming.d.ts +12 -1
- package/esm/types/claiming.js +2 -0
- package/esm/types/common.d.ts +4 -0
- package/esm/types/common.js +4 -0
- package/esm/types/fluid.d.ts +2 -0
- package/package.json +1 -1
- package/src/aaveV3/merkl.ts +5 -8
- package/src/aaveV4/merkl.ts +5 -5
- package/src/claiming/aaveV3.ts +19 -7
- package/src/compoundV3/merkl.ts +5 -6
- package/src/fluid/index.ts +9 -3
- package/src/fluid/merkl.ts +18 -13
- package/src/helpers/fluidHelpers/index.ts +68 -6
- package/src/morphoBlue/index.ts +1 -1
- package/src/morphoBlue/merkl.ts +16 -15
- package/src/portfolio/index.ts +6 -6
- package/src/services/merkl.ts +31 -0
- package/src/types/claiming.ts +13 -0
- package/src/types/common.ts +5 -0
- package/src/types/fluid.ts +3 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MerklOpportunity } from '../types';
|
|
2
|
+
import { LONGER_TIMEOUT } from './utils';
|
|
3
|
+
|
|
4
|
+
const MERKL_OPPORTUNITIES_URL = 'https://fe.defisaver.com/api/merkl/opportunities';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Fetches every page matching the query. Merkl returns 20 opportunities by default, so omitting
|
|
8
|
+
* `items` and advancing `page` avoids imposing a client-side maximum on the result set.
|
|
9
|
+
*/
|
|
10
|
+
export const fetchAllMerklOpportunities = async (query: Record<string, string>): Promise<MerklOpportunity[]> => {
|
|
11
|
+
const opportunities: MerklOpportunity[] = [];
|
|
12
|
+
let page = 0;
|
|
13
|
+
let pageOpportunities: MerklOpportunity[];
|
|
14
|
+
|
|
15
|
+
do {
|
|
16
|
+
const searchParams = new URLSearchParams({ ...query, page: page.toString() });
|
|
17
|
+
const res = await fetch(`${MERKL_OPPORTUNITIES_URL}?${searchParams}`, { // eslint-disable-line no-await-in-loop
|
|
18
|
+
signal: AbortSignal.timeout(LONGER_TIMEOUT),
|
|
19
|
+
});
|
|
20
|
+
if (!res.ok) throw new Error(`Failed to fetch Merkl opportunities page ${page}`);
|
|
21
|
+
|
|
22
|
+
const data = await res.json(); // eslint-disable-line no-await-in-loop
|
|
23
|
+
if (!Array.isArray(data)) throw new Error(`Invalid Merkl opportunities response on page ${page}`);
|
|
24
|
+
|
|
25
|
+
pageOpportunities = data as MerklOpportunity[];
|
|
26
|
+
opportunities.push(...pageOpportunities);
|
|
27
|
+
page += 1;
|
|
28
|
+
} while (pageOpportunities.length > 0);
|
|
29
|
+
|
|
30
|
+
return opportunities;
|
|
31
|
+
};
|
package/src/types/claiming.ts
CHANGED
|
@@ -5,6 +5,8 @@ export enum ClaimType {
|
|
|
5
5
|
AAVE_REWARDS = 'AAVE_REWARDS',
|
|
6
6
|
/** Merit rewards from AAVE (various tokens) */
|
|
7
7
|
AAVE_MERIT_REWARDS = 'AAVE_MERIT_REWARDS',
|
|
8
|
+
/** Rewards distributed through Merkl across supported protocols */
|
|
9
|
+
MERKL_REWARDS = 'MERKL_REWARDS',
|
|
8
10
|
/** Rewards from Compound V3 (only in COMP) */
|
|
9
11
|
COMPOUND_V3_COMP = 'COMPOUND_V3_COMP',
|
|
10
12
|
/** Rewards from Spark (wstETH only for now) */
|
|
@@ -47,6 +49,16 @@ export type AaveMeritRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
|
|
52
|
+
export type MerklRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
53
|
+
claimType: ClaimType.MERKL_REWARDS;
|
|
54
|
+
additionalClaimFields: {
|
|
55
|
+
accumulated: string;
|
|
56
|
+
proof: string[];
|
|
57
|
+
decimals: string;
|
|
58
|
+
unclaimed: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
50
62
|
export type SparkRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
51
63
|
claimType: ClaimType.SPARK_REWARDS;
|
|
52
64
|
additionalClaimFields: {
|
|
@@ -102,6 +114,7 @@ export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
|
102
114
|
export type ClaimableToken =
|
|
103
115
|
AaveRewardsClaimableToken
|
|
104
116
|
| AaveMeritRewardsClaimableToken
|
|
117
|
+
| MerklRewardsClaimableToken
|
|
105
118
|
| CompoundV3CompClaimableToken
|
|
106
119
|
| SparkRewardsClaimableToken
|
|
107
120
|
| KingRewardsClaimableToken
|
package/src/types/common.ts
CHANGED
|
@@ -8,6 +8,10 @@ export enum IncentiveSide {
|
|
|
8
8
|
Borrow = 'borrow',
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export enum IncentiveSource {
|
|
12
|
+
Merkl = 'merkl',
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
export enum IncentiveEligibilityId {
|
|
12
16
|
AaveV3EthenaLiquidLeverage = '0x0dC599DBB180E64E42b87332FDeC3a551445ea44BORROW_BL',
|
|
13
17
|
AaveV3ArbitrumEthSupply = '0x5d16261c6715a653248269861bbacf68a9774cde',
|
|
@@ -29,6 +33,7 @@ export interface IncentiveData {
|
|
|
29
33
|
token: string,
|
|
30
34
|
apy: string,
|
|
31
35
|
incentiveKind?: IncentiveKind;
|
|
36
|
+
source?: IncentiveSource;
|
|
32
37
|
description?: string;
|
|
33
38
|
eligibilityId?: IncentiveEligibilityId;
|
|
34
39
|
}
|
package/src/types/fluid.ts
CHANGED
|
@@ -340,6 +340,8 @@ export interface FluidAggregatedVaultData {
|
|
|
340
340
|
leftToBorrowUsd: string,
|
|
341
341
|
netApy: string,
|
|
342
342
|
incentiveUsd: string,
|
|
343
|
+
merklSupplyIncentives: IncentiveData[],
|
|
344
|
+
merklBorrowIncentives: IncentiveData[],
|
|
343
345
|
ratio: string,
|
|
344
346
|
collRatio: string,
|
|
345
347
|
minRatio: string,
|
|
@@ -484,4 +486,4 @@ export interface FluidFTokenDataStructOutput {
|
|
|
484
486
|
supplyRate: bigint;
|
|
485
487
|
rewardsRate: bigint;
|
|
486
488
|
withdrawable: bigint;
|
|
487
|
-
}
|
|
489
|
+
}
|