@defisaver/positions-sdk 2.1.127-midnight-dev → 2.1.127-uniswap-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/claiming/index.d.ts +2 -1
- package/cjs/claiming/index.js +3 -1
- package/cjs/claiming/uniswap.d.ts +4 -0
- package/cjs/claiming/uniswap.js +70 -0
- package/cjs/config/contracts.d.ts +22 -249
- package/cjs/config/contracts.js +10 -11
- package/cjs/contracts.d.ts +35 -1510
- package/cjs/contracts.js +3 -3
- package/cjs/helpers/index.d.ts +0 -1
- package/cjs/helpers/index.js +1 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +1 -0
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +1 -3
- package/cjs/markets/index.d.ts +0 -1
- package/cjs/markets/index.js +1 -4
- package/cjs/morphoBlue/index.d.ts +8 -6
- package/cjs/morphoBlue/index.js +69 -40
- package/cjs/portfolio/discovery.js +0 -4
- package/cjs/portfolio/index.js +30 -45
- package/cjs/services/viem.d.ts +11 -11
- package/cjs/types/claiming.d.ts +2 -0
- package/cjs/types/claiming.js +2 -0
- package/cjs/types/index.d.ts +0 -1
- package/cjs/types/index.js +0 -1
- package/cjs/types/morphoBlue.d.ts +9 -0
- package/cjs/types/portfolio.d.ts +0 -4
- package/esm/claiming/index.d.ts +2 -1
- package/esm/claiming/index.js +2 -1
- package/esm/claiming/uniswap.d.ts +4 -0
- package/esm/claiming/uniswap.js +62 -0
- package/esm/config/contracts.d.ts +22 -249
- package/esm/config/contracts.js +8 -9
- package/esm/contracts.d.ts +35 -1510
- package/esm/contracts.js +1 -1
- package/esm/helpers/index.d.ts +0 -1
- package/esm/helpers/index.js +0 -1
- package/esm/helpers/morphoBlueHelpers/index.js +1 -0
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/markets/index.d.ts +0 -1
- package/esm/markets/index.js +0 -1
- package/esm/morphoBlue/index.d.ts +8 -6
- package/esm/morphoBlue/index.js +62 -39
- package/esm/portfolio/discovery.js +1 -5
- package/esm/portfolio/index.js +32 -47
- package/esm/services/viem.d.ts +11 -11
- package/esm/types/claiming.d.ts +2 -0
- package/esm/types/claiming.js +2 -0
- package/esm/types/index.d.ts +0 -1
- package/esm/types/index.js +0 -1
- package/esm/types/morphoBlue.d.ts +9 -0
- package/esm/types/portfolio.d.ts +0 -4
- package/package.json +1 -1
- package/src/claiming/index.ts +2 -0
- package/src/claiming/uniswap.ts +65 -0
- package/src/config/contracts.ts +9 -9
- package/src/contracts.ts +2 -1
- package/src/helpers/index.ts +0 -1
- package/src/helpers/morphoBlueHelpers/index.ts +1 -0
- package/src/index.ts +0 -2
- package/src/markets/index.ts +0 -1
- package/src/morphoBlue/index.ts +101 -44
- package/src/portfolio/discovery.ts +0 -6
- package/src/portfolio/index.ts +30 -46
- package/src/types/claiming.ts +2 -0
- package/src/types/index.ts +0 -1
- package/src/types/morphoBlue.ts +11 -0
- package/src/types/portfolio.ts +0 -4
- package/cjs/helpers/morphoMidnightHelpers/index.d.ts +0 -16
- package/cjs/helpers/morphoMidnightHelpers/index.js +0 -68
- package/cjs/markets/morphoMidnight/index.d.ts +0 -16
- package/cjs/markets/morphoMidnight/index.js +0 -159
- package/cjs/morphoMidnight/index.d.ts +0 -14
- package/cjs/morphoMidnight/index.js +0 -220
- package/cjs/types/morphoMidnight.d.ts +0 -91
- package/cjs/types/morphoMidnight.js +0 -15
- package/esm/helpers/morphoMidnightHelpers/index.d.ts +0 -16
- package/esm/helpers/morphoMidnightHelpers/index.js +0 -61
- package/esm/markets/morphoMidnight/index.d.ts +0 -16
- package/esm/markets/morphoMidnight/index.js +0 -148
- package/esm/morphoMidnight/index.d.ts +0 -14
- package/esm/morphoMidnight/index.js +0 -207
- package/esm/types/morphoMidnight.d.ts +0 -91
- package/esm/types/morphoMidnight.js +0 -12
- package/src/helpers/morphoMidnightHelpers/index.ts +0 -86
- package/src/markets/morphoMidnight/index.ts +0 -161
- package/src/morphoMidnight/index.ts +0 -234
- package/src/types/morphoMidnight.ts +0 -104
|
@@ -212,6 +212,15 @@ export interface MorphoBluePositionData {
|
|
|
212
212
|
borrowShares: string;
|
|
213
213
|
exposure: string;
|
|
214
214
|
}
|
|
215
|
+
export interface MorphoBlueEarnData {
|
|
216
|
+
apy: string;
|
|
217
|
+
amount: string;
|
|
218
|
+
amountUsd: string;
|
|
219
|
+
}
|
|
220
|
+
export interface MorphoBlueMarketRewards {
|
|
221
|
+
supplyApy: string;
|
|
222
|
+
borrowApy: string;
|
|
223
|
+
}
|
|
215
224
|
export interface MorphoBlueVault {
|
|
216
225
|
address: string;
|
|
217
226
|
}
|
package/esm/types/portfolio.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { LiquityTroveInfo } from './liquity';
|
|
|
9
9
|
import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
|
|
10
10
|
import { CdpData } from './maker';
|
|
11
11
|
import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
|
|
12
|
-
import { MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
|
|
13
12
|
import { SparkPositionData, SparkVersions } from './spark';
|
|
14
13
|
export interface PortfolioProtocolData<T> {
|
|
15
14
|
error: string;
|
|
@@ -22,9 +21,6 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
22
21
|
morphoBlue: {
|
|
23
22
|
[key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
|
|
24
23
|
};
|
|
25
|
-
morphoMidnight: {
|
|
26
|
-
[key in MorphoMidnightVersions]?: PortfolioProtocolData<MorphoMidnightPositionData>;
|
|
27
|
-
};
|
|
28
24
|
compoundV3: {
|
|
29
25
|
[key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
|
|
30
26
|
};
|
package/package.json
CHANGED
package/src/claiming/index.ts
CHANGED
|
@@ -2,10 +2,12 @@ import * as aaveV3Claim from './aaveV3';
|
|
|
2
2
|
import * as compV3Claim from './compV3';
|
|
3
3
|
import * as kingV3Claim from './king';
|
|
4
4
|
import * as sparkClaim from './spark';
|
|
5
|
+
import * as uniswapClaim from './uniswap';
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
aaveV3Claim,
|
|
8
9
|
compV3Claim,
|
|
9
10
|
kingV3Claim,
|
|
10
11
|
sparkClaim,
|
|
12
|
+
uniswapClaim,
|
|
11
13
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Dec from 'decimal.js';
|
|
2
|
+
import { Client } from 'viem';
|
|
3
|
+
import { assetAmountInEth } from '@defisaver/tokens';
|
|
4
|
+
import { EthAddress, NetworkNumber } from '../types';
|
|
5
|
+
import { UniswapTokenDistributorViem } from '../contracts';
|
|
6
|
+
import { ClaimType } from '../types/claiming';
|
|
7
|
+
|
|
8
|
+
const EMPTY_DATA = (walletAddress: EthAddress) => ({
|
|
9
|
+
address: walletAddress, index: 0, amount: '0x0', proof: [],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const fetchUniswapRewardsData = async (walletAddress: EthAddress) => {
|
|
13
|
+
try {
|
|
14
|
+
const res = await fetch(`https://uniswap-merkl-drop.defisaver.com/claims/${walletAddress}`,
|
|
15
|
+
{ signal: AbortSignal.timeout(5000) });
|
|
16
|
+
|
|
17
|
+
if (!res.ok) throw new Error(await res.text());
|
|
18
|
+
|
|
19
|
+
const data = await res.json();
|
|
20
|
+
if (data.error) return EMPTY_DATA(walletAddress);
|
|
21
|
+
|
|
22
|
+
return data;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error('External API Error: Error fetching Uniswap rewards:', err);
|
|
25
|
+
return EMPTY_DATA(walletAddress);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const getUniswapRewards = async (provider: Client, network: NetworkNumber, walletAddresses: EthAddress[]) => {
|
|
30
|
+
// Fetch all API data in parallel (these are external API calls, can't be batched with multicall)
|
|
31
|
+
const apiDataPromises = walletAddresses.map(address => fetchUniswapRewardsData(address));
|
|
32
|
+
const apiDataArray = await Promise.all(apiDataPromises);
|
|
33
|
+
|
|
34
|
+
// Batch all contract calls using multicall
|
|
35
|
+
const contract = UniswapTokenDistributorViem(provider, network);
|
|
36
|
+
const cumulativePromises = apiDataArray.map(data => (data.index ? contract.read.isClaimed([data.index]) : Promise.resolve(false)),
|
|
37
|
+
);
|
|
38
|
+
const cumulativeResults = await Promise.all(cumulativePromises);
|
|
39
|
+
|
|
40
|
+
// Process results
|
|
41
|
+
const results: Record<string, any[]> = {};
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < walletAddresses.length; i++) {
|
|
44
|
+
const walletAddress = walletAddresses[i];
|
|
45
|
+
const data = apiDataArray[i];
|
|
46
|
+
const cumulative = cumulativeResults[i];
|
|
47
|
+
|
|
48
|
+
const amountToClaim = new Dec(data.amount);
|
|
49
|
+
|
|
50
|
+
if (amountToClaim.lessThanOrEqualTo('0')) {
|
|
51
|
+
results[walletAddress.toLowerCase() as EthAddress] = [];
|
|
52
|
+
} else {
|
|
53
|
+
results[walletAddress.toLowerCase() as EthAddress] = [{
|
|
54
|
+
amount: assetAmountInEth(amountToClaim.toString(), 'UNI'),
|
|
55
|
+
walletAddress,
|
|
56
|
+
claimType: ClaimType.UNI_REWARDS,
|
|
57
|
+
index: data.index,
|
|
58
|
+
proof: data.proof,
|
|
59
|
+
isClaimed: cumulative,
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return results;
|
|
65
|
+
};
|
package/src/config/contracts.ts
CHANGED
|
@@ -1113,15 +1113,6 @@ export const MorphoBlueView = {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
},
|
|
1115
1115
|
} as const;
|
|
1116
|
-
export const MidnightView = {
|
|
1117
|
-
"abi": [{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getMarketInfo","outputs":[{"components":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"uint128","name":"totalUnits","type":"uint128"},{"internalType":"uint128","name":"lossFactor","type":"uint128"},{"internalType":"uint128","name":"withdrawable","type":"uint128"},{"internalType":"uint128","name":"continuousFeeCredit","type":"uint128"},{"internalType":"uint16[7]","name":"settlementFees","type":"uint16[7]"},{"internalType":"uint32","name":"continuousFee","type":"uint32"},{"internalType":"uint8","name":"tickSpacing","type":"uint8"},{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"internalType":"struct MidnightView.MarketInfo","name":"info","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getPositionInfo","outputs":[{"components":[{"internalType":"uint128","name":"credit","type":"uint128"},{"internalType":"uint128","name":"pendingFee","type":"uint128"},{"internalType":"uint128","name":"debt","type":"uint128"},{"internalType":"uint128","name":"collateralBitmap","type":"uint128"},{"internalType":"uint128[]","name":"collateral","type":"uint128[]"},{"internalType":"uint256","name":"ratio","type":"uint256"}],"internalType":"struct MidnightView.PositionInfo","name":"pos","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"}],"name":"getRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"_market","type":"tuple"}],"name":"toId","outputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"toMarket","outputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"midnight","type":"address"},{"internalType":"address","name":"loanToken","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"},{"internalType":"uint256","name":"liquidationCursor","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct CollateralParams[]","name":"collateralParams","type":"tuple[]"},{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"rcfThreshold","type":"uint256"},{"internalType":"address","name":"enterGate","type":"address"},{"internalType":"address","name":"liquidatorGate","type":"address"}],"internalType":"struct Market","name":"market","type":"tuple"}],"stateMutability":"view","type":"function"}],
|
|
1118
|
-
"networks": {
|
|
1119
|
-
"8453": {
|
|
1120
|
-
"address": "0x3aa272f329E8B562A3bA56Bb6979a44D23A28839",
|
|
1121
|
-
"createdBlock": 48932293,
|
|
1122
|
-
}
|
|
1123
|
-
},
|
|
1124
|
-
} as const;
|
|
1125
1116
|
export const FeedRegistry = {
|
|
1126
1117
|
"abi": [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"address","name":"aggregator","type":"address"}],"name":"confirmFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAccessController","outputs":[{"internalType":"contract AccessControllerInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"getAnswer","outputs":[{"internalType":"int256","name":"answer","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"getCurrentPhaseId","outputs":[{"internalType":"uint16","name":"currentPhaseId","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"getFeed","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"aggregator","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint80","name":"roundId","type":"uint80"}],"name":"getNextRoundId","outputs":[{"internalType":"uint80","name":"nextRoundId","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint16","name":"phaseId","type":"uint16"}],"name":"getPhase","outputs":[{"components":[{"internalType":"uint16","name":"phaseId","type":"uint16"},{"internalType":"uint80","name":"startingAggregatorRoundId","type":"uint80"},{"internalType":"uint80","name":"endingAggregatorRoundId","type":"uint80"}],"internalType":"struct FeedRegistryInterface.Phase","name":"phase","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint16","name":"phaseId","type":"uint16"}],"name":"getPhaseFeed","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"aggregator","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint16","name":"phaseId","type":"uint16"}],"name":"getPhaseRange","outputs":[{"internalType":"uint80","name":"startingRoundId","type":"uint80"},{"internalType":"uint80","name":"endingRoundId","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint80","name":"roundId","type":"uint80"}],"name":"getPreviousRoundId","outputs":[{"internalType":"uint80","name":"previousRoundId","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"getProposedFeed","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"proposedAggregator","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint80","name":"roundId","type":"uint80"}],"name":"getRoundFeed","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"aggregator","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"getTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"aggregator","type":"address"}],"name":"isFeedEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"answer","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"latestRound","outputs":[{"internalType":"uint256","name":"roundId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"latestTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"address","name":"aggregator","type":"address"}],"name":"proposeFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"},{"internalType":"uint80","name":"roundId","type":"uint80"}],"name":"proposedGetRoundData","outputs":[{"internalType":"uint80","name":"id","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"proposedLatestRoundData","outputs":[{"internalType":"uint80","name":"id","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract AccessControllerInterface","name":"_accessController","type":"address"}],"name":"setAccessController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"typeAndVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"base","type":"address"},{"internalType":"address","name":"quote","type":"address"}],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],
|
|
1127
1118
|
"networks": {
|
|
@@ -1360,3 +1351,12 @@ export const AaveV4View = {
|
|
|
1360
1351
|
}
|
|
1361
1352
|
}
|
|
1362
1353
|
} as const;
|
|
1354
|
+
|
|
1355
|
+
export const UniswapTokenDistributor = {
|
|
1356
|
+
"abi": [{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],
|
|
1357
|
+
"networks": {
|
|
1358
|
+
"1": {
|
|
1359
|
+
"address": "0x090D4613473dEE047c3f2706764f49E0821D256e",
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
} as const;
|
package/src/contracts.ts
CHANGED
|
@@ -122,7 +122,6 @@ export const getYearnV3VaultContractViem = (client: Client, address: HexString)
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
export const MorphoBlueViewContractViem = createViemContractFromConfigFunc('MorphoBlueView');
|
|
125
|
-
export const MorphoMidnightViewContractViem = createViemContractFromConfigFunc('MidnightView');
|
|
126
125
|
export const AaveLoanInfoV2ContractViem = createViemContractFromConfigFunc('AaveLoanInfoV2');
|
|
127
126
|
export const AaveV3ViewContractViem = createViemContractFromConfigFunc('AaveV3View');
|
|
128
127
|
export const AaveIncentiveDataProviderV3ContractViem = createViemContractFromConfigFunc('AaveUiIncentiveDataProviderV3');
|
|
@@ -182,3 +181,5 @@ export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr')
|
|
|
182
181
|
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
183
182
|
|
|
184
183
|
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|
|
184
|
+
|
|
185
|
+
export const UniswapTokenDistributorViem = createViemContractFromConfigFunc('UniswapTokenDistributor');
|
package/src/helpers/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ export * as sparkHelpers from './sparkHelpers';
|
|
|
4
4
|
export * as curveUsdHelpers from './curveUsdHelpers';
|
|
5
5
|
export * as makerHelpers from './makerHelpers';
|
|
6
6
|
export * as morphoBlueHelpers from './morphoBlueHelpers';
|
|
7
|
-
export * as morphoMidnightHelpers from './morphoMidnightHelpers';
|
|
8
7
|
export * as llamaLendHelpers from './llamaLendHelpers';
|
|
9
8
|
export * as liquityV2Helpers from './liquityV2Helpers';
|
|
10
9
|
export * as eulerV2Helpers from './eulerHelpers';
|
|
@@ -389,6 +389,7 @@ export const getRewardsForMarket = async (marketId: string, network: NetworkNumb
|
|
|
389
389
|
query: REWARDS_QUERY,
|
|
390
390
|
variables: { marketId, chainId: network },
|
|
391
391
|
}),
|
|
392
|
+
signal: AbortSignal.timeout(LONGER_TIMEOUT),
|
|
392
393
|
});
|
|
393
394
|
|
|
394
395
|
const data = await response.json();
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ import * as markets from './markets';
|
|
|
17
17
|
import * as helpers from './helpers';
|
|
18
18
|
import * as exchange from './exchange';
|
|
19
19
|
import * as morphoBlue from './morphoBlue';
|
|
20
|
-
import * as morphoMidnight from './morphoMidnight';
|
|
21
20
|
import * as llamaLend from './llamaLend';
|
|
22
21
|
import * as eulerV2 from './eulerV2';
|
|
23
22
|
import * as portfolio from './portfolio';
|
|
@@ -43,7 +42,6 @@ export {
|
|
|
43
42
|
markets,
|
|
44
43
|
helpers,
|
|
45
44
|
morphoBlue,
|
|
46
|
-
morphoMidnight,
|
|
47
45
|
llamaLend,
|
|
48
46
|
eulerV2,
|
|
49
47
|
fluid,
|
package/src/markets/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ export {
|
|
|
17
17
|
export { SparkMarkets } from './spark';
|
|
18
18
|
export { CrvUsdMarkets } from './curveUsd';
|
|
19
19
|
export { MorphoBlueMarkets, findMorphoBlueMarket } from './morphoBlue';
|
|
20
|
-
export { MorphoMidnightMarkets, findMorphoMidnightMarket } from './morphoMidnight';
|
|
21
20
|
export { LlamaLendMarkets } from './llamaLend';
|
|
22
21
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
23
22
|
export { EulerV2Markets } from './euler';
|
package/src/morphoBlue/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
DFSFeedRegistryContractViem, FeedRegistryContractViem, MorphoBlueViewContractViem,
|
|
9
9
|
} from '../contracts';
|
|
10
10
|
import {
|
|
11
|
-
MorphoBlueAssetsData, MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBluePositionData,
|
|
11
|
+
MorphoBlueAssetsData, MorphoBlueEarnData, MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBlueMarketRewards, MorphoBluePositionData,
|
|
12
12
|
} from '../types';
|
|
13
13
|
import { USD_QUOTE, WAD } from '../constants';
|
|
14
14
|
import { calculateNetApy, getStakingApy, STAKING_ASSETS } from '../staking';
|
|
@@ -21,7 +21,39 @@ import { getViemProvider, setViemBlockNumber } from '../services/viem';
|
|
|
21
21
|
|
|
22
22
|
const HARDCODED_USD_STABLE_PRICE = '100000000'; // $1 with 8 decimals
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const getMorphoRewardIncentives = (apy: string) => [{
|
|
25
|
+
token: 'MORPHO',
|
|
26
|
+
apy,
|
|
27
|
+
incentiveKind: IncentiveKind.Reward,
|
|
28
|
+
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
29
|
+
}];
|
|
30
|
+
|
|
31
|
+
export const addMorphoBlueRewardsToMarketInfo = (
|
|
32
|
+
marketInfo: MorphoBlueMarketInfo,
|
|
33
|
+
rewards: MorphoBlueMarketRewards,
|
|
34
|
+
): MorphoBlueMarketInfo => ({
|
|
35
|
+
...marketInfo,
|
|
36
|
+
assetsData: {
|
|
37
|
+
...marketInfo.assetsData,
|
|
38
|
+
[marketInfo.loanToken]: {
|
|
39
|
+
...marketInfo.assetsData[marketInfo.loanToken],
|
|
40
|
+
supplyIncentives: [
|
|
41
|
+
...marketInfo.assetsData[marketInfo.loanToken].supplyIncentives.filter(({ token }) => token !== 'MORPHO'),
|
|
42
|
+
...getMorphoRewardIncentives(rewards.supplyApy),
|
|
43
|
+
],
|
|
44
|
+
borrowIncentives: [
|
|
45
|
+
...marketInfo.assetsData[marketInfo.loanToken].borrowIncentives.filter(({ token }) => token !== 'MORPHO'),
|
|
46
|
+
...getMorphoRewardIncentives(rewards.borrowApy),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
async function getMorphoBlueMarketDataInternal(
|
|
53
|
+
provider: Client,
|
|
54
|
+
network: NetworkNumber,
|
|
55
|
+
selectedMarket: MorphoBlueMarketData,
|
|
56
|
+
): Promise<MorphoBlueMarketInfo> {
|
|
25
57
|
const {
|
|
26
58
|
loanToken, collateralToken, oracle, irm, lltv, oracleType,
|
|
27
59
|
} = selectedMarket;
|
|
@@ -59,16 +91,6 @@ export async function _getMorphoBlueMarketData(provider: Client, network: Networ
|
|
|
59
91
|
loanTokenPrice = loanTokenPriceRound[1].toString();
|
|
60
92
|
}
|
|
61
93
|
|
|
62
|
-
let morphoSupplyApy = '0';
|
|
63
|
-
let morphoBorrowApy = '0';
|
|
64
|
-
try {
|
|
65
|
-
const { supplyApy: _morphoSupplyApy, borrowApy: _morphoBorrowApy } = await getRewardsForMarket(selectedMarket.marketId, network);
|
|
66
|
-
morphoSupplyApy = _morphoSupplyApy;
|
|
67
|
-
morphoBorrowApy = _morphoBorrowApy;
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.error(e);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
94
|
const supplyRate = getSupplyRate(marketInfo.totalSupplyAssets.toString(), marketInfo.totalBorrowAssets.toString(), marketInfo.borrowRate.toString(), marketInfo.fee.toString());
|
|
73
95
|
const compoundedBorrowRate = getBorrowRate(marketInfo.borrowRate.toString(), marketInfo.totalBorrowShares.toString());
|
|
74
96
|
const utillization = new Dec(marketInfo.totalBorrowAssets.toString()).div(marketInfo.totalSupplyAssets.toString()).mul(100).toString();
|
|
@@ -90,18 +112,8 @@ export async function _getMorphoBlueMarketData(provider: Client, network: Networ
|
|
|
90
112
|
totalBorrow: new Dec(marketInfo.totalBorrowAssets.toString()).div(scale).toString(),
|
|
91
113
|
canBeSupplied: true,
|
|
92
114
|
canBeBorrowed: true,
|
|
93
|
-
supplyIncentives: [
|
|
94
|
-
|
|
95
|
-
apy: morphoSupplyApy,
|
|
96
|
-
incentiveKind: IncentiveKind.Reward,
|
|
97
|
-
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
98
|
-
}],
|
|
99
|
-
borrowIncentives: [{
|
|
100
|
-
token: 'MORPHO',
|
|
101
|
-
apy: morphoBorrowApy,
|
|
102
|
-
incentiveKind: IncentiveKind.Reward,
|
|
103
|
-
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
104
|
-
}],
|
|
115
|
+
supplyIncentives: [],
|
|
116
|
+
borrowIncentives: [],
|
|
105
117
|
};
|
|
106
118
|
|
|
107
119
|
assetsData[wethToEth(collateralTokenInfo.symbol)] = {
|
|
@@ -138,10 +150,70 @@ export async function _getMorphoBlueMarketData(provider: Client, network: Networ
|
|
|
138
150
|
};
|
|
139
151
|
}
|
|
140
152
|
|
|
153
|
+
export async function _getMorphoBlueMarketData(provider: Client, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo> {
|
|
154
|
+
const marketInfo = await getMorphoBlueMarketDataInternal(provider, network, selectedMarket);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
const rewards = await getRewardsForMarket(selectedMarket.marketId, network);
|
|
158
|
+
return addMorphoBlueRewardsToMarketInfo(marketInfo, rewards);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.error(error);
|
|
161
|
+
return addMorphoBlueRewardsToMarketInfo(marketInfo, { supplyApy: '0', borrowApy: '0' });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function _getMorphoBluePortfolioMarketData(provider: Client, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo> {
|
|
166
|
+
return getMorphoBlueMarketDataInternal(provider, network, selectedMarket);
|
|
167
|
+
}
|
|
168
|
+
|
|
141
169
|
export async function getMorphoBlueMarketData(provider: EthereumProvider, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo> {
|
|
142
170
|
return _getMorphoBlueMarketData(getViemProvider(provider, network), network, selectedMarket);
|
|
143
171
|
}
|
|
144
172
|
|
|
173
|
+
export function getMorphoBluePortfolioMarketData(provider: EthereumProvider, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo> {
|
|
174
|
+
return _getMorphoBluePortfolioMarketData(getViemProvider(provider, network), network, selectedMarket);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export const getMorphoBluePositionDataWithMarketInfo = (
|
|
178
|
+
data: MorphoBluePositionData,
|
|
179
|
+
marketInfo: MorphoBlueMarketInfo,
|
|
180
|
+
): MorphoBluePositionData => ({
|
|
181
|
+
...data,
|
|
182
|
+
...getMorphoBlueAggregatedPositionData({
|
|
183
|
+
usedAssets: data.usedAssets,
|
|
184
|
+
assetsData: marketInfo.assetsData,
|
|
185
|
+
marketInfo,
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
export const getMorphoEarnDataWithMarketInfo = (data: MorphoBlueEarnData, marketInfo: MorphoBlueMarketInfo): MorphoBlueEarnData => {
|
|
190
|
+
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
191
|
+
const usedAssets: MMUsedAssets = {
|
|
192
|
+
[marketInfo.loanToken]: {
|
|
193
|
+
symbol: loanTokenInfo.symbol,
|
|
194
|
+
supplied: data.amount,
|
|
195
|
+
borrowed: '0',
|
|
196
|
+
isSupplied: new Dec(data.amount).gt(0),
|
|
197
|
+
isBorrowed: false,
|
|
198
|
+
collateral: false,
|
|
199
|
+
suppliedUsd: data.amountUsd,
|
|
200
|
+
borrowedUsd: '0',
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
...data,
|
|
206
|
+
apy: calculateNetApy({ usedAssets, assetsData: marketInfo.assetsData as unknown as MMAssetsData }).netApy,
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export function getMorphoBlueMarketRewards(
|
|
211
|
+
network: NetworkNumber,
|
|
212
|
+
selectedMarket: MorphoBlueMarketData,
|
|
213
|
+
): Promise<MorphoBlueMarketRewards> {
|
|
214
|
+
return getRewardsForMarket(selectedMarket.marketId, network);
|
|
215
|
+
}
|
|
216
|
+
|
|
145
217
|
export const _getMorphoBlueAccountBalances = async (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoBlueMarketData): Promise<PositionBalances> => {
|
|
146
218
|
let balances: PositionBalances = {
|
|
147
219
|
collateral: {},
|
|
@@ -238,7 +310,7 @@ export async function getMorphoBlueAccountData(provider: EthereumProvider, netwo
|
|
|
238
310
|
return _getMorphoBlueAccountData(getViemProvider(provider, network), network, account, selectedMarket, marketInfo);
|
|
239
311
|
}
|
|
240
312
|
|
|
241
|
-
export async function getMorphoEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<
|
|
313
|
+
export async function getMorphoEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBlueEarnData> {
|
|
242
314
|
const {
|
|
243
315
|
loanToken, collateralToken, oracle, irm, lltv,
|
|
244
316
|
} = selectedMarket;
|
|
@@ -254,24 +326,9 @@ export async function getMorphoEarn(provider: Client, network: NetworkNumber, ac
|
|
|
254
326
|
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
255
327
|
const loanTokenSupplied = assetAmountInEth(loanInfo.suppliedInAssets.toString(), marketInfo.loanToken);
|
|
256
328
|
const loanTokenSuppliedUsd = new Dec(loanTokenSupplied).mul(loanTokenInfo.price).toString();
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
symbol: loanTokenInfo.symbol,
|
|
260
|
-
supplied: loanTokenSupplied,
|
|
261
|
-
borrowed: '0',
|
|
262
|
-
isSupplied: new Dec(loanInfo.suppliedInAssets.toString()).gt(0),
|
|
263
|
-
isBorrowed: false,
|
|
264
|
-
collateral: false,
|
|
265
|
-
suppliedUsd: loanTokenSuppliedUsd,
|
|
266
|
-
borrowedUsd: '0',
|
|
267
|
-
},
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const { netApy } = calculateNetApy({ usedAssets, assetsData: marketInfo.assetsData as unknown as MMAssetsData });
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
apy: netApy,
|
|
329
|
+
return getMorphoEarnDataWithMarketInfo({
|
|
330
|
+
apy: '0',
|
|
274
331
|
amount: loanTokenSupplied,
|
|
275
332
|
amountUsd: loanTokenSuppliedUsd,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
333
|
+
}, marketInfo);
|
|
334
|
+
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
CrvUsdMarkets,
|
|
11
11
|
LlamaLendMarkets,
|
|
12
12
|
MorphoBlueMarkets,
|
|
13
|
-
MorphoMidnightMarkets,
|
|
14
13
|
SparkMarkets,
|
|
15
14
|
} from '../markets';
|
|
16
15
|
import { AaveVersions, CompoundVersions } from '../types';
|
|
@@ -20,7 +19,6 @@ import { _getCompoundV3AccountBalances } from '../compoundV3';
|
|
|
20
19
|
import { _getCrvUsdAccountBalances } from '../curveUsd';
|
|
21
20
|
import { _getLlamaLendAccountBalances } from '../llamaLend';
|
|
22
21
|
import { _getMorphoBlueAccountBalances } from '../morphoBlue';
|
|
23
|
-
import { _getMorphoMidnightAccountBalances } from '../morphoMidnight';
|
|
24
22
|
import { createViemContractFromConfigFunc } from '../contracts';
|
|
25
23
|
|
|
26
24
|
const hasAnyBalance = (balances: PositionBalances): boolean => (
|
|
@@ -111,10 +109,6 @@ export async function getUserPositionsExistence(
|
|
|
111
109
|
tasks.push(balanceTask(market.value, () => _getMorphoBlueAccountBalances(client, network, block, false, address, market)));
|
|
112
110
|
});
|
|
113
111
|
|
|
114
|
-
Object.values(MorphoMidnightMarkets(network)).filter((market) => market.chainIds.includes(network)).forEach((market) => {
|
|
115
|
-
tasks.push(balanceTask(market.value, () => _getMorphoMidnightAccountBalances(client, network, block, false, address, market)));
|
|
116
|
-
});
|
|
117
|
-
|
|
118
112
|
await Promise.all(tasks);
|
|
119
113
|
return existence;
|
|
120
114
|
}
|
package/src/portfolio/index.ts
CHANGED
|
@@ -9,11 +9,9 @@ import {
|
|
|
9
9
|
LiquityV2Markets,
|
|
10
10
|
LlamaLendMarkets,
|
|
11
11
|
MorphoBlueMarkets,
|
|
12
|
-
MorphoMidnightMarkets,
|
|
13
12
|
SparkMarkets,
|
|
14
13
|
} from '../markets';
|
|
15
|
-
import { _getMorphoBlueAccountData,
|
|
16
|
-
import { _getMorphoMidnightAccountData, _getMorphoMidnightMarketData, getMorphoMidnightEarn } from '../morphoMidnight';
|
|
14
|
+
import { _getMorphoBlueAccountData, _getMorphoBluePortfolioMarketData, getMorphoEarn } from '../morphoBlue';
|
|
17
15
|
import {
|
|
18
16
|
AaveV2MarketData,
|
|
19
17
|
AaveV3MarketData,
|
|
@@ -28,7 +26,6 @@ import {
|
|
|
28
26
|
LiquityV2MarketData,
|
|
29
27
|
LlamaLendGlobalMarketData,
|
|
30
28
|
MorphoBlueMarketInfo,
|
|
31
|
-
MorphoMidnightMarketInfo,
|
|
32
29
|
PortfolioPositionsData,
|
|
33
30
|
SparkMarketsData,
|
|
34
31
|
} from '../types';
|
|
@@ -54,6 +51,7 @@ import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
|
54
51
|
import { getKingRewards } from '../claiming/king';
|
|
55
52
|
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
56
53
|
import { _getAaveV4AccountData, _getAaveV4SpokeData } from '../aaveV4';
|
|
54
|
+
import { getUniswapRewards } from '../claiming/uniswap';
|
|
57
55
|
|
|
58
56
|
export async function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim = false): Promise<{
|
|
59
57
|
positions: PortfolioPositionsData;
|
|
@@ -65,7 +63,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
65
63
|
const isFluidSupported = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Plasma].includes(network);
|
|
66
64
|
|
|
67
65
|
const morphoMarkets = Object.values(MorphoBlueMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
68
|
-
const morphoMidnightMarkets = Object.values(MorphoMidnightMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
69
66
|
const compoundV3Markets = Object.values(CompoundMarkets(network)).filter((market) => market.chainIds.includes(network) && market.value !== CompoundVersions.CompoundV2);
|
|
70
67
|
const sparkMarkets = Object.values(SparkMarkets(network)).filter((market) => market.chainIds.includes(network));
|
|
71
68
|
const eulerV2Markets = Object.values(EulerV2Markets(network)).filter((market) => market.chainIds.includes(network));
|
|
@@ -83,7 +80,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
83
80
|
const defaultClient = getViemProvider(defaultProvider, ...args);
|
|
84
81
|
|
|
85
82
|
const morphoMarketsData: Record<string, MorphoBlueMarketInfo> = {};
|
|
86
|
-
const morphoMidnightMarketsData: Record<string, MorphoMidnightMarketInfo> = {};
|
|
87
83
|
const compoundV3MarketsData: Record<string, CompoundV3MarketsData> = {};
|
|
88
84
|
const sparkMarketsData: Record<string, SparkMarketsData> = {};
|
|
89
85
|
const eulerV2MarketsData: Record<string, EulerV2FullMarketData> = {};
|
|
@@ -98,7 +94,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
98
94
|
|
|
99
95
|
const markets = {
|
|
100
96
|
morphoMarketsData,
|
|
101
|
-
morphoMidnightMarketsData,
|
|
102
97
|
compoundV3MarketsData,
|
|
103
98
|
sparkMarketsData,
|
|
104
99
|
eulerV2MarketsData,
|
|
@@ -121,7 +116,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
121
116
|
aaveV3: {},
|
|
122
117
|
aaveV4: {},
|
|
123
118
|
morphoBlue: {},
|
|
124
|
-
morphoMidnight: {},
|
|
125
119
|
compoundV3: {},
|
|
126
120
|
spark: {},
|
|
127
121
|
eulerV2: {},
|
|
@@ -143,7 +137,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
143
137
|
stakingPositions[address.toLowerCase() as EthAddress] = {
|
|
144
138
|
aaveV3: {},
|
|
145
139
|
morphoBlue: {},
|
|
146
|
-
morphoMidnight: {},
|
|
147
140
|
compoundV3: {},
|
|
148
141
|
spark: {},
|
|
149
142
|
aaveV2: {},
|
|
@@ -170,13 +163,9 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
170
163
|
await Promise.allSettled([
|
|
171
164
|
// === MARKET DATA (needs to be fetched first) ===
|
|
172
165
|
...morphoMarkets.map(async (market) => {
|
|
173
|
-
const marketData = await
|
|
166
|
+
const marketData = await _getMorphoBluePortfolioMarketData(client, network, market);
|
|
174
167
|
morphoMarketsData[market.value] = marketData;
|
|
175
168
|
}),
|
|
176
|
-
...morphoMidnightMarkets.map(async (market) => {
|
|
177
|
-
const marketData = await _getMorphoMidnightMarketData(client, network, market);
|
|
178
|
-
morphoMidnightMarketsData[market.value] = marketData;
|
|
179
|
-
}),
|
|
180
169
|
...compoundV3Markets.map(async (market) => {
|
|
181
170
|
const marketData = await _getCompoundV3MarketsData(client, network, market, defaultClient);
|
|
182
171
|
compoundV3MarketsData[market.value] = marketData;
|
|
@@ -322,6 +311,33 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
322
311
|
}
|
|
323
312
|
}
|
|
324
313
|
})(),
|
|
314
|
+
// Batch UNI rewards
|
|
315
|
+
(async () => {
|
|
316
|
+
try {
|
|
317
|
+
if (!isMainnet) {
|
|
318
|
+
for (const address of addresses) {
|
|
319
|
+
rewardsData[address.toLowerCase()].uniswap = { error: '', data: [] };
|
|
320
|
+
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const uniswapRewards = await getUniswapRewards(client, network, addresses);
|
|
324
|
+
for (const address of addresses) {
|
|
325
|
+
const lowerAddress = address.toLowerCase() as EthAddress;
|
|
326
|
+
rewardsData[lowerAddress].uniswap = {
|
|
327
|
+
error: '',
|
|
328
|
+
data: uniswapRewards[lowerAddress] || [],
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error('Error fetching Uniswap rewards data in batch:', error);
|
|
333
|
+
for (const address of addresses) {
|
|
334
|
+
rewardsData[address.toLowerCase() as EthAddress].uniswap = {
|
|
335
|
+
error: 'Error fetching Uniswap rewards data in batch',
|
|
336
|
+
data: null,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
})(),
|
|
325
341
|
...sparkMarkets.map((market) => addresses.map(async address => {
|
|
326
342
|
try {
|
|
327
343
|
if (!isMainnet) {
|
|
@@ -468,38 +484,6 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
468
484
|
positions[address.toLowerCase() as EthAddress].morphoBlue[market.value] = { error: `Error fetching MorphoBlue account data for address ${address} on market ${market.value}`, data: null };
|
|
469
485
|
}
|
|
470
486
|
})).flat(),
|
|
471
|
-
...morphoMidnightMarkets.map((market) => addresses.map(async (address) => {
|
|
472
|
-
try {
|
|
473
|
-
const [accDataPromise, earnDataPromise] = await Promise.allSettled([
|
|
474
|
-
_getMorphoMidnightAccountData(client, network, address, market, morphoMidnightMarketsData[market.value]),
|
|
475
|
-
getMorphoMidnightEarn(client, network, address, market, morphoMidnightMarketsData[market.value]),
|
|
476
|
-
]);
|
|
477
|
-
if (accDataPromise.status === 'rejected') {
|
|
478
|
-
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, accDataPromise.reason);
|
|
479
|
-
positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
480
|
-
}
|
|
481
|
-
if (earnDataPromise.status === 'rejected') {
|
|
482
|
-
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, earnDataPromise.reason);
|
|
483
|
-
positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
484
|
-
}
|
|
485
|
-
if (accDataPromise.status !== 'rejected') {
|
|
486
|
-
const accData = accDataPromise.value;
|
|
487
|
-
if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: '', data: accData };
|
|
488
|
-
}
|
|
489
|
-
if (earnDataPromise.status !== 'rejected') {
|
|
490
|
-
const earnData = earnDataPromise.value;
|
|
491
|
-
if (earnData && new Dec(earnData.amount).gt(0)) {
|
|
492
|
-
stakingPositions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = {
|
|
493
|
-
error: '',
|
|
494
|
-
data: earnData,
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
} catch (error) {
|
|
499
|
-
console.error(`Error fetching MorphoMidnight account data for address ${address} on market ${market.value}:`, error);
|
|
500
|
-
positions[address.toLowerCase() as EthAddress].morphoMidnight[market.value] = { error: `Error fetching MorphoMidnight account data for address ${address} on market ${market.value}`, data: null };
|
|
501
|
-
}
|
|
502
|
-
})).flat(),
|
|
503
487
|
...compoundV3Markets.map((market) => addresses.map(async (address) => {
|
|
504
488
|
try {
|
|
505
489
|
const accData = await _getCompoundV3AccountData(client, network, address, ZERO_ADDRESS, { selectedMarket: market, assetsData: compoundV3MarketsData[market.value].assetsData });
|
package/src/types/claiming.ts
CHANGED
|
@@ -15,6 +15,8 @@ export enum ClaimType {
|
|
|
15
15
|
SPARK_AIRDROP = 'SPARK_AIRDROP',
|
|
16
16
|
/** Spark Airdrop */
|
|
17
17
|
SPARK_WST_ETH_REWARDS = 'SPARK_WST_ETH_REWARDS', // TODO: This will be removed once we fully refactor spark rewards
|
|
18
|
+
/** UNI Airdrop */
|
|
19
|
+
UNI_REWARDS = 'UNI_REWARDS',
|
|
18
20
|
|
|
19
21
|
ETHENA_AIRDROP = 'ETHENA_AIRDROP',
|
|
20
22
|
}
|