@defisaver/positions-sdk 2.1.161-portfolio-api-1-dev → 2.1.161-portfolio-api-2-dev
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/index.d.ts +2 -12
- package/cjs/aaveV3/sgho.d.ts +2 -16
- package/cjs/claiming/aaveV3.d.ts +2 -2
- package/cjs/claiming/ethena.d.ts +2 -1
- package/cjs/claiming/king.d.ts +2 -1
- package/cjs/claiming/spark.d.ts +2 -2
- package/cjs/fluid/index.d.ts +5 -49
- package/cjs/liquity/index.d.ts +2 -12
- package/cjs/liquityV2/index.d.ts +3 -23
- package/cjs/portfolio/index.d.ts +4 -4
- package/cjs/portfolio/index.js +46 -33
- package/cjs/types/aave.d.ts +83 -0
- package/cjs/types/fluid.d.ts +13 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquity.d.ts +12 -0
- package/cjs/types/liquityV2.d.ts +24 -0
- package/cjs/types/portfolio.d.ts +68 -5
- package/cjs/umbrella/index.d.ts +2 -3
- package/esm/aaveV3/index.d.ts +2 -12
- package/esm/aaveV3/sgho.d.ts +2 -16
- package/esm/claiming/aaveV3.d.ts +2 -2
- package/esm/claiming/aaveV3.js +1 -1
- package/esm/claiming/ethena.d.ts +2 -1
- package/esm/claiming/king.d.ts +2 -1
- package/esm/claiming/spark.d.ts +2 -2
- package/esm/claiming/spark.js +1 -1
- package/esm/fluid/index.d.ts +5 -49
- package/esm/liquity/index.d.ts +2 -12
- package/esm/liquityV2/index.d.ts +3 -23
- package/esm/portfolio/index.d.ts +4 -4
- package/esm/portfolio/index.js +46 -33
- package/esm/types/aave.d.ts +83 -0
- package/esm/types/fluid.d.ts +13 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquity.d.ts +12 -0
- package/esm/types/liquityV2.d.ts +24 -0
- package/esm/types/portfolio.d.ts +68 -5
- package/esm/umbrella/index.d.ts +2 -3
- package/package.json +1 -1
- package/src/aaveV3/index.ts +2 -1
- package/src/aaveV3/sgho.ts +2 -17
- package/src/claiming/aaveV3.ts +4 -2
- package/src/claiming/ethena.ts +5 -5
- package/src/claiming/king.ts +3 -3
- package/src/claiming/spark.ts +6 -4
- package/src/fluid/index.ts +4 -3
- package/src/liquity/index.ts +2 -2
- package/src/liquityV2/index.ts +3 -3
- package/src/portfolio/index.ts +69 -53
- package/src/types/aave.ts +86 -0
- package/src/types/fluid.ts +14 -0
- package/src/types/index.ts +2 -1
- package/src/types/liquity.ts +13 -1
- package/src/types/liquityV2.ts +26 -1
- package/src/types/portfolio.ts +86 -5
- package/src/umbrella/index.ts +2 -1
package/esm/types/aave.d.ts
CHANGED
|
@@ -198,3 +198,86 @@ export interface AaveHelperCommon {
|
|
|
198
198
|
selectedMarket: Partial<AaveMarketInfo>;
|
|
199
199
|
network?: NetworkNumber;
|
|
200
200
|
}
|
|
201
|
+
export interface SghoUserData {
|
|
202
|
+
shares: string;
|
|
203
|
+
balance: string;
|
|
204
|
+
maxDeposit: string;
|
|
205
|
+
maxWithdraw: string;
|
|
206
|
+
underlyingBalance: string;
|
|
207
|
+
}
|
|
208
|
+
export interface SghoData {
|
|
209
|
+
totalAssets: string;
|
|
210
|
+
totalSupply: string;
|
|
211
|
+
supplyCap: string;
|
|
212
|
+
/** Target savings rate as an APY percent (e.g. "4.25" for 4.25%). */
|
|
213
|
+
targetRate: string;
|
|
214
|
+
paused: boolean;
|
|
215
|
+
user: SghoUserData;
|
|
216
|
+
}
|
|
217
|
+
/** stkAAVE, stkGHO and sGHO of an address, from getStakeAaveData. */
|
|
218
|
+
export interface StakeAaveData {
|
|
219
|
+
activatedCooldown: string;
|
|
220
|
+
activatedCooldownAmount: string;
|
|
221
|
+
stkAaveRewardsBalance: string;
|
|
222
|
+
aaveRewardsBalance: string;
|
|
223
|
+
stkAaveBalance: string;
|
|
224
|
+
stkGhoBalance: string;
|
|
225
|
+
ghoMeritApy: string;
|
|
226
|
+
stkAaveApy: string;
|
|
227
|
+
sgho: SghoData;
|
|
228
|
+
}
|
|
229
|
+
export interface UmbrellaTokenInfo {
|
|
230
|
+
token: EthAddress;
|
|
231
|
+
/** USD, converted from the oracle's 8 decimals. */
|
|
232
|
+
price: string;
|
|
233
|
+
name: string;
|
|
234
|
+
symbol: string;
|
|
235
|
+
decimals: number;
|
|
236
|
+
}
|
|
237
|
+
export interface UmbrellaRewardTokenData {
|
|
238
|
+
rewardTokenData: UmbrellaTokenInfo;
|
|
239
|
+
maxEmissionPerSecond: bigint;
|
|
240
|
+
distributionEnd: bigint;
|
|
241
|
+
}
|
|
242
|
+
export interface UmbrellaStakingAccountData {
|
|
243
|
+
stakeUserBalance: string;
|
|
244
|
+
rewardsTokenUserData: {
|
|
245
|
+
reward: EthAddress;
|
|
246
|
+
currentReward: string;
|
|
247
|
+
}[];
|
|
248
|
+
userCooldownAmount: string;
|
|
249
|
+
userEndOfCooldown: bigint | string;
|
|
250
|
+
userWithdrawalWindow: bigint | string;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* One Umbrella stake token of an address, from getUmbrellaData: the view contracts' structs merged, with the amounts
|
|
254
|
+
* the app reads converted to decimal strings. The bigint fields are the views' raw values, as the SDK passes them.
|
|
255
|
+
*/
|
|
256
|
+
export interface UmbrellaStakingTokenData {
|
|
257
|
+
stakeTokenData: UmbrellaTokenInfo;
|
|
258
|
+
totalAssets: string;
|
|
259
|
+
targetLiquidity: string;
|
|
260
|
+
isStakeConfigured: boolean;
|
|
261
|
+
rewardsTokenData: UmbrellaRewardTokenData[];
|
|
262
|
+
stakeToken: EthAddress;
|
|
263
|
+
stakeUserBalance: bigint;
|
|
264
|
+
rewardsTokenUserData: {
|
|
265
|
+
reward: EthAddress;
|
|
266
|
+
currentReward: bigint;
|
|
267
|
+
}[];
|
|
268
|
+
stkToken: EthAddress;
|
|
269
|
+
totalShares: string;
|
|
270
|
+
stkUnderlyingToken: EthAddress;
|
|
271
|
+
aToken: EthAddress;
|
|
272
|
+
cooldownPeriod: bigint;
|
|
273
|
+
unstakeWindow: bigint;
|
|
274
|
+
stkTokenToWaTokenRate: string;
|
|
275
|
+
waTokenToATokenRate: string;
|
|
276
|
+
rewardsEmissionRates: string[];
|
|
277
|
+
userCooldownAmount: bigint;
|
|
278
|
+
userEndOfCooldown: bigint;
|
|
279
|
+
userWithdrawalWindow: bigint;
|
|
280
|
+
account: UmbrellaStakingAccountData;
|
|
281
|
+
}
|
|
282
|
+
/** Keyed by Umbrella stake (UmbrellaGHO, UmbrellaUSDC, UmbrellaUSDT, UmbrellaETH). */
|
|
283
|
+
export type UmbrellaStakingData = Record<string, UmbrellaStakingTokenData>;
|
package/esm/types/fluid.d.ts
CHANGED
|
@@ -458,3 +458,16 @@ export interface FluidFTokenDataStructOutput {
|
|
|
458
458
|
rewardsRate: bigint;
|
|
459
459
|
withdrawable: bigint;
|
|
460
460
|
}
|
|
461
|
+
/** One Fluid lending (fToken) deposit of an address, from getAllUserEarnPositionsWithFTokens and getFluidDepositData. */
|
|
462
|
+
export interface FluidEarnPositionData {
|
|
463
|
+
fTokenAddress: string | undefined;
|
|
464
|
+
fTokenSymbol: string;
|
|
465
|
+
decimals: string;
|
|
466
|
+
totalDeposited: string;
|
|
467
|
+
withdrawable: string;
|
|
468
|
+
apy: string;
|
|
469
|
+
depositRate: string;
|
|
470
|
+
withdrawRate: string;
|
|
471
|
+
deposited: string;
|
|
472
|
+
depositedShares: string;
|
|
473
|
+
}
|
package/esm/types/index.d.ts
CHANGED
package/esm/types/index.js
CHANGED
package/esm/types/liquity.d.ts
CHANGED
|
@@ -28,3 +28,15 @@ export interface LiquityTroveInfo {
|
|
|
28
28
|
debtInFront: string;
|
|
29
29
|
exposure: string;
|
|
30
30
|
}
|
|
31
|
+
/** LQTY staking and the LUSD stability pool deposit of an address, from getLiquityStakingData. */
|
|
32
|
+
export interface LiquityStakingData {
|
|
33
|
+
totalLUSDDeposited: string;
|
|
34
|
+
totalLQTYStaked: string;
|
|
35
|
+
stakedLQTY: string;
|
|
36
|
+
stakedLUSDBalance: string;
|
|
37
|
+
rewardETH: string;
|
|
38
|
+
rewardLUSD: string;
|
|
39
|
+
stabilityRewardETH: string;
|
|
40
|
+
stabilityRewardLQTY: string;
|
|
41
|
+
showStakingBalances: boolean;
|
|
42
|
+
}
|
package/esm/types/liquityV2.d.ts
CHANGED
|
@@ -121,3 +121,27 @@ export interface LiquityV2TroveData {
|
|
|
121
121
|
lastInterestRateAdjTime: string;
|
|
122
122
|
exposure: string;
|
|
123
123
|
}
|
|
124
|
+
/** The stability pool deposit of an address in one market, from getLiquityV2Staking. */
|
|
125
|
+
export interface LiquityV2StakingData {
|
|
126
|
+
totalBOLDDeposited: string;
|
|
127
|
+
stakedBOLDBalance: string;
|
|
128
|
+
stabilityRewardColl: string;
|
|
129
|
+
stabilityRewardYield: string;
|
|
130
|
+
showStakingBalances: boolean;
|
|
131
|
+
debtTokenBalance: string;
|
|
132
|
+
stabilityPoolApy: string;
|
|
133
|
+
}
|
|
134
|
+
/** sBOLD, yBOLD and stYBOLD of an address, from getLiquitySAndYBold. */
|
|
135
|
+
export interface LiquityV2SBoldYBoldData {
|
|
136
|
+
spApy: string;
|
|
137
|
+
yBoldApy: string;
|
|
138
|
+
totalBoldDepositedSBold: string;
|
|
139
|
+
boldRateSBold: string;
|
|
140
|
+
maxWithdrawSBold: string;
|
|
141
|
+
totalBoldDepositedYBold: string;
|
|
142
|
+
boldRateYBold: string;
|
|
143
|
+
maxWithdrawYBold: string;
|
|
144
|
+
sBoldBalance: string;
|
|
145
|
+
yBoldBalance: string;
|
|
146
|
+
stYBoldBalance: string;
|
|
147
|
+
}
|
package/esm/types/portfolio.d.ts
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import { AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions } from './aave';
|
|
1
|
+
import { AaveV2MarketData, AaveV2PositionData, AaveV3MarketData, AaveV3PositionData, AaveVersions, StakeAaveData, UmbrellaStakingData } from './aave';
|
|
2
2
|
import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokesType } from './aaveV4';
|
|
3
|
+
import { AaveRewardsClaimableToken, EthenaAirdropClaimableToken, KingRewardsClaimableToken, MerklRewardsClaimableToken, SparkAirdropClaimableToken, SparkRewardsClaimableToken, UniswapAirdropClaimableToken } from './claiming';
|
|
3
4
|
import { EthAddress } from './common';
|
|
4
5
|
import { CompoundV2MarketsData, CompoundV2PositionData, CompoundV3MarketsData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
5
6
|
import { CrvUSDGlobalMarketData, CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
6
|
-
import { FluidVaultData } from './fluid';
|
|
7
|
-
import { LiquityTroveInfo } from './liquity';
|
|
8
|
-
import { LiquityV2MarketData } from './liquityV2';
|
|
7
|
+
import { FluidEarnPositionData, FluidVaultData } from './fluid';
|
|
8
|
+
import { LiquityStakingData, LiquityTroveInfo } from './liquity';
|
|
9
|
+
import { LiquityV2MarketData, LiquityV2SBoldYBoldData, LiquityV2StakingData, LiquityV2Versions } from './liquityV2';
|
|
9
10
|
import { LlamaLendGlobalMarketData, LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
10
11
|
import { CdpData } from './maker';
|
|
11
|
-
import { MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
|
+
import { MorphoBlueEarnData, MorphoBlueMarketInfo, MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
13
|
import { MorphoMidnightMarketInfo, MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
|
|
13
14
|
import { SparkMarketsData, SparkPositionData, SparkVersions } from './spark';
|
|
14
15
|
export interface PortfolioProtocolData<T> {
|
|
15
16
|
error: string;
|
|
16
17
|
data: T | null;
|
|
17
18
|
}
|
|
19
|
+
/** A failed fetch of a protocol that, when it succeeds, getPortfolioData returns unwrapped rather than as `{ error, data }`. */
|
|
20
|
+
export interface PortfolioProtocolError {
|
|
21
|
+
error: string;
|
|
22
|
+
data: null;
|
|
23
|
+
}
|
|
24
|
+
/** What getPortfolioData reads besides positions and markets. Both default to true. */
|
|
25
|
+
export interface PortfolioDataOptions {
|
|
26
|
+
/** stakingPositions; with false it comes back as {} and no staking source is read. */
|
|
27
|
+
staking?: boolean;
|
|
28
|
+
/** rewardsData; with false it comes back as {} and no rewards source is read. */
|
|
29
|
+
rewards?: boolean;
|
|
30
|
+
}
|
|
18
31
|
export interface PortfolioPositionsDataForAddress {
|
|
19
32
|
aaveV3: {
|
|
20
33
|
[key in AaveVersions]?: PortfolioProtocolData<AaveV3PositionData>;
|
|
@@ -60,6 +73,56 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
60
73
|
export interface PortfolioPositionsData {
|
|
61
74
|
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
|
62
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The staking positions getPortfolioData returns for an address. The shapes are uneven, and the DeFi Saver app
|
|
78
|
+
* parses them as they are: a protocol read once per address comes back unwrapped on success, as
|
|
79
|
+
* `{ error, data: null }` on failure, and as {} (or Fluid's `{ error: '', data: {} }`) on a network it is not read on.
|
|
80
|
+
*/
|
|
81
|
+
export interface PortfolioStakingPositionsDataForAddress {
|
|
82
|
+
/** stkAAVE, stkGHO and sGHO; mainnet only. */
|
|
83
|
+
aaveV3: StakeAaveData | PortfolioProtocolError | {};
|
|
84
|
+
/** Morpho Blue supply without a borrow (Earn), by market; only markets with a deposit or an error. */
|
|
85
|
+
morphoBlue: {
|
|
86
|
+
[key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBlueEarnData>;
|
|
87
|
+
};
|
|
88
|
+
compoundV3: Record<string, never>;
|
|
89
|
+
spark: Record<string, never>;
|
|
90
|
+
aaveV2: Record<string, never>;
|
|
91
|
+
compoundV2: Record<string, never>;
|
|
92
|
+
/** LQTY staking and the LUSD stability pool; mainnet only. */
|
|
93
|
+
liquity: LiquityStakingData | PortfolioProtocolError | {};
|
|
94
|
+
/** Stability pool deposits, by market; mainnet only, legacy markets left out. */
|
|
95
|
+
liquityV2: {
|
|
96
|
+
[key in LiquityV2Versions]?: PortfolioProtocolData<LiquityV2StakingData>;
|
|
97
|
+
};
|
|
98
|
+
/** Fluid lending (fToken) deposits; `{ error: '', data: {} }` on a network without Fluid. */
|
|
99
|
+
fluid: FluidEarnPositionData[] | PortfolioProtocolError | {
|
|
100
|
+
error: string;
|
|
101
|
+
data: Record<string, never>;
|
|
102
|
+
};
|
|
103
|
+
/** Umbrella stakes; absent off mainnet. */
|
|
104
|
+
umbrella?: UmbrellaStakingData | PortfolioProtocolError;
|
|
105
|
+
/** sBOLD, yBOLD and stYBOLD; data is null off mainnet. */
|
|
106
|
+
liquityV2SBoldYBold: PortfolioProtocolData<LiquityV2SBoldYBoldData>;
|
|
107
|
+
}
|
|
108
|
+
export type PortfolioStakingPositionsData = Record<EthAddress, PortfolioStakingPositionsDataForAddress>;
|
|
109
|
+
/** The claimable rewards getPortfolioData returns for an address. Off mainnet only Merkl and Aave V3 are read. */
|
|
110
|
+
export interface PortfolioRewardsDataForAddress {
|
|
111
|
+
merkl: PortfolioProtocolData<MerklRewardsClaimableToken[]>;
|
|
112
|
+
aaveV3: {
|
|
113
|
+
[key in AaveVersions]?: PortfolioProtocolData<AaveRewardsClaimableToken[]>;
|
|
114
|
+
};
|
|
115
|
+
spark: {
|
|
116
|
+
[key in SparkVersions]?: PortfolioProtocolData<SparkRewardsClaimableToken[]>;
|
|
117
|
+
};
|
|
118
|
+
/** The SPK airdrop. */
|
|
119
|
+
spk: PortfolioProtocolData<SparkAirdropClaimableToken[]>;
|
|
120
|
+
king: PortfolioProtocolData<KingRewardsClaimableToken[]>;
|
|
121
|
+
/** {} off mainnet. */
|
|
122
|
+
ethena: PortfolioProtocolData<EthenaAirdropClaimableToken[]> | {};
|
|
123
|
+
uniswap: PortfolioProtocolData<UniswapAirdropClaimableToken[]>;
|
|
124
|
+
}
|
|
125
|
+
export type PortfolioRewardsData = Record<EthAddress, PortfolioRewardsDataForAddress>;
|
|
63
126
|
/** The `markets` getPortfolioData returns: every market it read, by protocol, keyed by market or spoke. */
|
|
64
127
|
export interface PortfolioMarketsData {
|
|
65
128
|
morphoMarketsData: Record<string, MorphoBlueMarketInfo>;
|
package/esm/umbrella/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}>;
|
|
3
|
+
import { UmbrellaStakingData } from '../types/aave';
|
|
4
|
+
export declare const getUmbrellaData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<UmbrellaStakingData>;
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
EModeCategoriesData,
|
|
31
31
|
EModeCategoryData,
|
|
32
32
|
EModeCategoryDataMapping,
|
|
33
|
+
StakeAaveData,
|
|
33
34
|
} from '../types';
|
|
34
35
|
import {
|
|
35
36
|
Blockish,
|
|
@@ -608,7 +609,7 @@ export const fetchYearlyMeritApyForStakingGho = async () => {
|
|
|
608
609
|
}
|
|
609
610
|
};
|
|
610
611
|
|
|
611
|
-
export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
|
|
612
|
+
export const getStakeAaveData = async (provider: Client, network: NetworkNumber, address: EthAddress): Promise<StakeAaveData> => {
|
|
612
613
|
const stkGhoAddress = getAssetInfo('stkGHO').address as HexString;
|
|
613
614
|
const stkAaveAddress = getAssetInfo('stkAAVE').address as HexString;
|
|
614
615
|
|
package/src/aaveV3/sgho.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
3
|
+
import { SghoData } from '../types/aave';
|
|
3
4
|
import { DEFAULT_TIMEOUT } from '../services/utils';
|
|
4
5
|
import { ZERO_ADDRESS } from '../constants';
|
|
5
6
|
|
|
6
|
-
export
|
|
7
|
-
shares: string;
|
|
8
|
-
balance: string;
|
|
9
|
-
maxDeposit: string;
|
|
10
|
-
maxWithdraw: string;
|
|
11
|
-
underlyingBalance: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface SghoData {
|
|
15
|
-
totalAssets: string;
|
|
16
|
-
totalSupply: string;
|
|
17
|
-
supplyCap: string;
|
|
18
|
-
/** Target savings rate as an APY percent (e.g. "4.25" for 4.25%). */
|
|
19
|
-
targetRate: string;
|
|
20
|
-
paused: boolean;
|
|
21
|
-
user: SghoUserData;
|
|
22
|
-
}
|
|
7
|
+
export type { SghoData, SghoUserData } from '../types/aave';
|
|
23
8
|
|
|
24
9
|
const EMPTY_SGHO_DATA: SghoData = {
|
|
25
10
|
totalAssets: '0',
|
package/src/claiming/aaveV3.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import Dec from 'decimal.js';
|
|
3
3
|
import { EthAddress, NetworkNumber } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AaveRewardsClaimableToken, ClaimableToken, ClaimType, MerklRewardsClaimableToken,
|
|
6
|
+
} from '../types/claiming';
|
|
5
7
|
import {
|
|
6
8
|
AaveIncentiveDataProviderV3ContractViem,
|
|
7
9
|
AaveRewardsControllerViem,
|
|
@@ -37,7 +39,7 @@ export async function getUnclaimedRewardsForAllMarkets(
|
|
|
37
39
|
network: NetworkNumber,
|
|
38
40
|
walletAddress: EthAddress,
|
|
39
41
|
marketAddress: EthAddress,
|
|
40
|
-
): Promise<
|
|
42
|
+
): Promise<AaveRewardsClaimableToken[]> {
|
|
41
43
|
const contract = AaveIncentiveDataProviderV3ContractViem(provider, network);
|
|
42
44
|
const tokensData = await contract.read.getUserReservesIncentivesData([marketAddress, walletAddress]);
|
|
43
45
|
const allTokensDataArrays = tokensData.reduce((acc: any[], val) => {
|
package/src/claiming/ethena.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { getAssetInfo } from '@defisaver/tokens';
|
|
|
2
2
|
import Dec from 'decimal.js';
|
|
3
3
|
import { getAddress } from 'viem';
|
|
4
4
|
import { EthAddress } from '../types/common';
|
|
5
|
-
import { ClaimType } from '../types/claiming';
|
|
5
|
+
import { ClaimType, EthenaAirdropClaimableToken } from '../types/claiming';
|
|
6
6
|
import { getEthAmountForDecimals } from '../services/utils';
|
|
7
7
|
|
|
8
8
|
export const fetchEthenaAirdropReward = async (address: EthAddress) => {
|
|
@@ -23,11 +23,11 @@ export const fetchEthenaAirdropReward = async (address: EthAddress) => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]): Promise<Record<string,
|
|
26
|
+
export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]): Promise<Record<string, EthenaAirdropClaimableToken[]>> => {
|
|
27
27
|
const apiDataPromises = walletAddresses.map(address => fetchEthenaAirdropReward(address));
|
|
28
28
|
const apiDataArray = await Promise.all(apiDataPromises);
|
|
29
29
|
|
|
30
|
-
const results: Record<string,
|
|
30
|
+
const results: Record<string, EthenaAirdropClaimableToken[]> = {};
|
|
31
31
|
for (let i = 0; i < walletAddresses.length; i++) {
|
|
32
32
|
const walletAddress = walletAddresses[i];
|
|
33
33
|
const data = apiDataArray[i];
|
|
@@ -36,7 +36,7 @@ export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]):
|
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const processedRewards = [];
|
|
39
|
+
const processedRewards: EthenaAirdropClaimableToken[] = [];
|
|
40
40
|
const assetInfo = getAssetInfo('sENA');
|
|
41
41
|
|
|
42
42
|
const amount = getEthAmountForDecimals(data.events[0].awardAmount, assetInfo.decimals);
|
|
@@ -47,7 +47,7 @@ export const fetchEthenaAirdropRewards = async (walletAddresses: EthAddress[]):
|
|
|
47
47
|
underlyingSymbol: assetInfo.symbol,
|
|
48
48
|
amount,
|
|
49
49
|
claimType: ClaimType.ETHENA_AIRDROP,
|
|
50
|
-
tokenAddress: assetInfo.address,
|
|
50
|
+
tokenAddress: assetInfo.address as EthAddress,
|
|
51
51
|
walletAddress,
|
|
52
52
|
label: 'Ethena Airdrop',
|
|
53
53
|
});
|
package/src/claiming/king.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { assetAmountInEth } from '@defisaver/tokens';
|
|
|
3
3
|
import { Client } from 'viem';
|
|
4
4
|
import { UUPSViem } from '../contracts';
|
|
5
5
|
import { EthAddress, HexString, NetworkNumber } from '../types/common';
|
|
6
|
-
import { ClaimType } from '../types/claiming';
|
|
6
|
+
import { ClaimType, KingRewardsClaimableToken } from '../types/claiming';
|
|
7
7
|
|
|
8
8
|
export const fetchKingRewards = async (walletAddress: EthAddress) => {
|
|
9
9
|
try {
|
|
@@ -19,7 +19,7 @@ export const fetchKingRewards = async (walletAddress: EthAddress) => {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export const getKingRewards = async (provider: Client, network: NetworkNumber, walletAddresses: EthAddress[]) => {
|
|
22
|
+
export const getKingRewards = async (provider: Client, network: NetworkNumber, walletAddresses: EthAddress[]): Promise<Record<string, KingRewardsClaimableToken[]>> => {
|
|
23
23
|
// Fetch all API data in parallel (these are external API calls, can't be batched with multicall)
|
|
24
24
|
const apiDataPromises = walletAddresses.map(address => fetchKingRewards(address));
|
|
25
25
|
const apiDataArray = await Promise.all(apiDataPromises);
|
|
@@ -31,7 +31,7 @@ export const getKingRewards = async (provider: Client, network: NetworkNumber, w
|
|
|
31
31
|
const cumulativeResults = await Promise.all(cumulativePromises);
|
|
32
32
|
|
|
33
33
|
// Process results
|
|
34
|
-
const results: Record<string,
|
|
34
|
+
const results: Record<string, KingRewardsClaimableToken[]> = {};
|
|
35
35
|
|
|
36
36
|
for (let i = 0; i < walletAddresses.length; i++) {
|
|
37
37
|
const walletAddress = walletAddresses[i];
|
package/src/claiming/spark.ts
CHANGED
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
SparkRewardsControllerViem,
|
|
8
8
|
} from '../contracts';
|
|
9
9
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
ClaimType, SparkAirdropClaimableToken, SparkAirdropType, SparkRewardsClaimableToken,
|
|
12
|
+
} from '../types/claiming';
|
|
11
13
|
import { compareAddresses, getEthAmountForDecimals } from '../services/utils';
|
|
12
14
|
|
|
13
15
|
const IGNITION_REWARDS = '0xCBA0C0a2a0B6Bb11233ec4EA85C5bFfea33e724d';
|
|
@@ -50,7 +52,7 @@ export const fetchSparkAirdropRewards = async (
|
|
|
50
52
|
provider: Client,
|
|
51
53
|
network: NetworkNumber,
|
|
52
54
|
walletAddresses: EthAddress[],
|
|
53
|
-
) => {
|
|
55
|
+
): Promise<Record<string, SparkAirdropClaimableToken[]>> => {
|
|
54
56
|
// Fetch all API data in parallel (these are external API calls, can't be batched with multicall)
|
|
55
57
|
const apiDataPromises = walletAddresses.map(address => fetchSpkAirdropRewards(address));
|
|
56
58
|
const apiDataArray = await Promise.all(apiDataPromises);
|
|
@@ -92,7 +94,7 @@ export const fetchSparkAirdropRewards = async (
|
|
|
92
94
|
const cumulativeClaimedAmounts = await getCumulativeClaimedSpkAirdrop(provider, network, contractCallsData);
|
|
93
95
|
|
|
94
96
|
// Process results
|
|
95
|
-
const results: Record<string,
|
|
97
|
+
const results: Record<string, SparkAirdropClaimableToken[]> = {};
|
|
96
98
|
let contractCallIndex = 0;
|
|
97
99
|
|
|
98
100
|
for (const { walletAddress, data } of allClaimData) {
|
|
@@ -101,7 +103,7 @@ export const fetchSparkAirdropRewards = async (
|
|
|
101
103
|
continue;
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
const processedRewards = [];
|
|
106
|
+
const processedRewards: SparkAirdropClaimableToken[] = [];
|
|
105
107
|
for (let i = 0; i < data.length; i++) {
|
|
106
108
|
const rewardInfo = data[i];
|
|
107
109
|
const assetInfo = getAssetInfoByAddress(rewardInfo.token_address);
|
package/src/fluid/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
FluidAggregatedVaultData,
|
|
11
11
|
FluidAssetData,
|
|
12
12
|
FluidAssetsData,
|
|
13
|
+
FluidEarnPositionData,
|
|
13
14
|
FluidFTokenDataStructOutput,
|
|
14
15
|
FluidMarketData,
|
|
15
16
|
FluidMarketInfo,
|
|
@@ -1597,7 +1598,7 @@ export const getFluidTokenData = async (
|
|
|
1597
1598
|
token: string,
|
|
1598
1599
|
) => _getFluidTokenData(getViemProvider(provider, network), network, token);
|
|
1599
1600
|
|
|
1600
|
-
const parseFDepositTokenData = (fTokenData: FluidFTokenDataStructOutput, userPosition: FluidUserEarnPositionStructOutput, apiData: any, fTokenAddress?: string) => {
|
|
1601
|
+
const parseFDepositTokenData = (fTokenData: FluidFTokenDataStructOutput, userPosition: FluidUserEarnPositionStructOutput, apiData: any, fTokenAddress?: string): FluidEarnPositionData => {
|
|
1601
1602
|
const decimals = fTokenData.decimals.toString();
|
|
1602
1603
|
const depositRate = new Dec(getEthAmountForDecimals(fTokenData.convertToShares.toString(), decimals)).toString();
|
|
1603
1604
|
const withdrawRate = new Dec(getEthAmountForDecimals(fTokenData.convertToAssets.toString(), decimals)).toString();
|
|
@@ -1645,7 +1646,7 @@ export const getFluidDepositData = async (
|
|
|
1645
1646
|
address: EthAddress,
|
|
1646
1647
|
) => _getFluidDepositData(getViemProvider(provider, network), network, token, address);
|
|
1647
1648
|
|
|
1648
|
-
export const _getAllUserEarnPositionsWithFTokens = async (provider: Client, network: NetworkNumber, user: EthAddress) => {
|
|
1649
|
+
export const _getAllUserEarnPositionsWithFTokens = async (provider: Client, network: NetworkNumber, user: EthAddress): Promise<FluidEarnPositionData[]> => {
|
|
1649
1650
|
const view = FluidViewContractViem(provider, network);
|
|
1650
1651
|
const [
|
|
1651
1652
|
[userPositions, fTokensData],
|
|
@@ -1664,7 +1665,7 @@ export const _getAllUserEarnPositionsWithFTokens = async (provider: Client, netw
|
|
|
1664
1665
|
rewardsData = await rewardsApiResponse.json();
|
|
1665
1666
|
}
|
|
1666
1667
|
|
|
1667
|
-
const parsedRes = fTokensData.reduce<
|
|
1668
|
+
const parsedRes = fTokensData.reduce<FluidEarnPositionData[]>((acc, fTokenData, i) => {
|
|
1668
1669
|
const userPosition = userPositions[i];
|
|
1669
1670
|
const deposited = userPosition?.underlyingAssets;
|
|
1670
1671
|
|
package/src/liquity/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
LiquityTroveManagerContractViem,
|
|
14
14
|
LiquityViewContractViem,
|
|
15
15
|
} from '../contracts';
|
|
16
|
-
import { LIQUITY_TROVE_STATUS_ENUM, LiquityTroveInfo } from '../types';
|
|
16
|
+
import { LIQUITY_TROVE_STATUS_ENUM, LiquityStakingData, LiquityTroveInfo } from '../types';
|
|
17
17
|
import { ZERO_ADDRESS } from '../constants';
|
|
18
18
|
import { getViemProvider, setViemBlockNumber } from '../services/viem';
|
|
19
19
|
import { getEthAmountForDecimals } from '../services/utils';
|
|
@@ -113,7 +113,7 @@ export const _getLiquityTroveInfo = async (provider: Client, network: NetworkNum
|
|
|
113
113
|
|
|
114
114
|
export const getLiquityTroveInfo = async (provider: EthereumProvider, network: NetworkNumber, address: EthAddress): Promise<LiquityTroveInfo> => _getLiquityTroveInfo(getViemProvider(provider, network, { batch: { multicall: true } }), network, address);
|
|
115
115
|
|
|
116
|
-
export const getLiquityStakingData = async (provider: Client, network: NetworkNumber, address: EthAddress) => {
|
|
116
|
+
export const getLiquityStakingData = async (provider: Client, network: NetworkNumber, address: EthAddress): Promise<LiquityStakingData> => {
|
|
117
117
|
const lqtyStakingView = LiquityLQTYStakingViem(provider, network);
|
|
118
118
|
const stabilityPoolView = LiquityStabilityPoolViem(provider, network);
|
|
119
119
|
const [
|
package/src/liquityV2/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '../types/common';
|
|
13
13
|
import {
|
|
14
14
|
LIQUITY_V2_TROVE_STATUS_ENUM,
|
|
15
|
-
LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2TroveData, LiquityV2UsedAssets,
|
|
15
|
+
LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2SBoldYBoldData, LiquityV2StakingData, LiquityV2TroveData, LiquityV2UsedAssets,
|
|
16
16
|
LiquityV2Versions,
|
|
17
17
|
} from '../types';
|
|
18
18
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
@@ -579,7 +579,7 @@ const calculateSPApy = (
|
|
|
579
579
|
return apy;
|
|
580
580
|
};
|
|
581
581
|
|
|
582
|
-
export const getLiquityV2Staking = async (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => {
|
|
582
|
+
export const getLiquityV2Staking = async (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress): Promise<LiquityV2StakingData> => {
|
|
583
583
|
const stabilityPoolView = createViemContractFromConfigFunc('LiquityV2StabilityPool', stabilityPoolAddrForMarket[market])(provider, network);
|
|
584
584
|
const activePoolView = createViemContractFromConfigFunc('LiquityV2ActivePool', activePoolAddrForMarket[market])(provider, network);
|
|
585
585
|
|
|
@@ -638,7 +638,7 @@ export const getLiquityV2Staking = async (provider: Client, network: NetworkNumb
|
|
|
638
638
|
};
|
|
639
639
|
};
|
|
640
640
|
|
|
641
|
-
export const getLiquitySAndYBold = async (provider: Client, network: NetworkNumber, markets: any, user: EthAddress) => {
|
|
641
|
+
export const getLiquitySAndYBold = async (provider: Client, network: NetworkNumber, markets: any, user: EthAddress): Promise<LiquityV2SBoldYBoldData> => {
|
|
642
642
|
const sBold = LiquityV2sBoldVaultViem(provider, network);
|
|
643
643
|
const yBold = createViemContractFromConfigFunc('Erc4626', '0x9F4330700a36B29952869fac9b33f45EEdd8A3d8')(provider, network);
|
|
644
644
|
const stYBold = createViemContractFromConfigFunc('Erc4626', '0x23346B04a7f55b8760E5860AA5A77383D63491cD')(provider, network);
|