@defisaver/positions-sdk 2.1.167 → 2.1.168
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/aaveV2/index.js +8 -29
- package/cjs/aaveV3/index.js +2 -31
- package/cjs/aaveV4/index.d.ts +25 -0
- package/cjs/aaveV4/index.js +4 -1
- package/cjs/compoundV2/index.d.ts +1 -1
- package/cjs/compoundV2/index.js +2 -2
- package/cjs/curveUsd/index.d.ts +1 -1
- package/cjs/curveUsd/index.js +6 -1
- package/cjs/fluid/index.js +13 -12
- package/cjs/helpers/aaveBalances.d.ts +5 -0
- package/cjs/helpers/aaveBalances.js +51 -0
- package/cjs/helpers/fluidBalances.d.ts +6 -0
- package/cjs/helpers/fluidBalances.js +36 -0
- package/cjs/liquityV2/index.d.ts +8 -0
- package/cjs/liquityV2/index.js +3 -3
- package/cjs/llamaLend/index.d.ts +1 -1
- package/cjs/llamaLend/index.js +6 -1
- package/cjs/morphoMidnight/index.d.ts +1 -1
- package/cjs/morphoMidnight/index.js +6 -1
- package/cjs/portfolio/index.d.ts +1 -0
- package/cjs/portfolio/index.js +3 -0
- package/cjs/portfolio/lendingSummaries.d.ts +7 -0
- package/cjs/portfolio/lendingSummaries.js +262 -0
- package/cjs/portfolio/lendingSummaryTransport.d.ts +8 -0
- package/cjs/portfolio/lendingSummaryTransport.js +109 -0
- package/cjs/spark/index.js +2 -31
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/lendingSummary.d.ts +34 -0
- package/cjs/types/lendingSummary.js +2 -0
- package/esm/aaveV2/index.js +11 -32
- package/esm/aaveV3/index.js +3 -32
- package/esm/aaveV4/index.d.ts +25 -0
- package/esm/aaveV4/index.js +3 -1
- package/esm/compoundV2/index.d.ts +1 -1
- package/esm/compoundV2/index.js +2 -2
- package/esm/curveUsd/index.d.ts +1 -1
- package/esm/curveUsd/index.js +6 -1
- package/esm/fluid/index.js +13 -12
- package/esm/helpers/aaveBalances.d.ts +5 -0
- package/esm/helpers/aaveBalances.js +45 -0
- package/esm/helpers/fluidBalances.d.ts +6 -0
- package/esm/helpers/fluidBalances.js +28 -0
- package/esm/liquityV2/index.d.ts +8 -0
- package/esm/liquityV2/index.js +1 -1
- package/esm/llamaLend/index.d.ts +1 -1
- package/esm/llamaLend/index.js +6 -1
- package/esm/morphoMidnight/index.d.ts +1 -1
- package/esm/morphoMidnight/index.js +6 -1
- package/esm/portfolio/index.d.ts +1 -0
- package/esm/portfolio/index.js +1 -0
- package/esm/portfolio/lendingSummaries.d.ts +7 -0
- package/esm/portfolio/lendingSummaries.js +256 -0
- package/esm/portfolio/lendingSummaryTransport.d.ts +8 -0
- package/esm/portfolio/lendingSummaryTransport.js +104 -0
- package/esm/spark/index.js +4 -33
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/lendingSummary.d.ts +34 -0
- package/esm/types/lendingSummary.js +1 -0
- package/package.json +1 -1
- package/src/aaveV2/index.ts +8 -48
- package/src/aaveV3/index.ts +2 -48
- package/src/aaveV4/index.ts +6 -1
- package/src/compoundV2/index.ts +2 -2
- package/src/curveUsd/index.ts +6 -1
- package/src/fluid/index.ts +13 -12
- package/src/helpers/aaveBalances.ts +41 -0
- package/src/helpers/fluidBalances.ts +34 -0
- package/src/liquityV2/index.ts +1 -1
- package/src/llamaLend/index.ts +6 -1
- package/src/morphoMidnight/index.ts +6 -1
- package/src/portfolio/index.ts +2 -0
- package/src/portfolio/lendingSummaries.ts +216 -0
- package/src/portfolio/lendingSummaryTransport.ts +84 -0
- package/src/spark/index.ts +3 -49
- package/src/types/index.ts +2 -1
- package/src/types/lendingSummary.ts +41 -0
package/cjs/aaveV2/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getAaveV2FullPositionData = exports.getAaveV2AccountData = exports._getAaveV2AccountData = exports.getAaveV2AccountBalances = exports._getAaveV2AccountBalances = exports.getAaveV2MarketsData = exports._getAaveV2MarketsData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
+
const aaveBalances_1 = require("../helpers/aaveBalances");
|
|
18
19
|
const common_1 = require("../types/common");
|
|
19
20
|
const staking_1 = require("../staking");
|
|
20
21
|
const utils_1 = require("../services/utils");
|
|
@@ -93,36 +94,14 @@ exports._getAaveV2MarketsData = _getAaveV2MarketsData;
|
|
|
93
94
|
const getAaveV2MarketsData = (provider, network, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () { return (0, exports._getAaveV2MarketsData)((0, viem_1.getViemProvider)(provider, network), network, selectedMarket); });
|
|
94
95
|
exports.getAaveV2MarketsData = getAaveV2MarketsData;
|
|
95
96
|
const _getAaveV2AccountBalances = (provider, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
100
|
-
if (!address) {
|
|
97
|
+
var _a;
|
|
98
|
+
const balances = yield (0, aaveBalances_1.getAaveLikeBalances)(provider, network, block, addressMapping, address, aave_1.AAVE_V2, 'AaveLoanInfoV2');
|
|
99
|
+
if (!address)
|
|
101
100
|
return balances;
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
const protocolDataProviderContract = (0, contracts_1.createViemContractFromConfigFunc)(market.protocolData, market.protocolDataAddress)(provider, network);
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
const reserveTokens = yield protocolDataProviderContract.read.getAllReservesTokens((0, viem_1.setViemBlockNumber)(block));
|
|
110
|
-
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
111
|
-
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
112
|
-
const loanInfo = yield loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses], (0, viem_1.setViemBlockNumber)(block));
|
|
113
|
-
loanInfo.forEach((_tokenInfo, i) => {
|
|
114
|
-
const asset = (0, utils_1.wethToEth)(symbols[i]);
|
|
115
|
-
const assetAddr = (0, utils_1.wethToEthByAddress)(_addresses[i], network).toLowerCase();
|
|
116
|
-
const tokenInfo = Object.assign({}, _tokenInfo);
|
|
117
|
-
// known bug: stETH leaves 1 wei on every transfer
|
|
118
|
-
if (asset === 'stETH' && tokenInfo.balance.toString() === '1') {
|
|
119
|
-
tokenInfo.balance = '0';
|
|
120
|
-
}
|
|
121
|
-
balances = {
|
|
122
|
-
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ? assetAddr : asset]: tokenInfo.balance.toString() }),
|
|
123
|
-
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ? assetAddr : asset]: new decimal_js_1.default(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString() }),
|
|
124
|
-
};
|
|
125
|
-
});
|
|
101
|
+
// Preserve the legacy getter's stETH transfer-dust convention.
|
|
102
|
+
const key = addressMapping ? (0, tokens_1.getAssetInfo)('stETH', network).address.toLowerCase() : 'stETH';
|
|
103
|
+
if (((_a = balances.collateral) === null || _a === void 0 ? void 0 : _a[key]) === '1')
|
|
104
|
+
balances.collateral[key] = '0';
|
|
126
105
|
return balances;
|
|
127
106
|
});
|
|
128
107
|
exports._getAaveV2AccountBalances = _getAaveV2AccountBalances;
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -17,6 +17,7 @@ exports._getAaveV3MarketData = _getAaveV3MarketData;
|
|
|
17
17
|
exports.getAaveV3MarketData = getAaveV3MarketData;
|
|
18
18
|
const tokens_1 = require("@defisaver/tokens");
|
|
19
19
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
20
|
+
const aaveBalances_1 = require("../helpers/aaveBalances");
|
|
20
21
|
const contracts_1 = require("../contracts");
|
|
21
22
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
22
23
|
const aave_1 = require("../markets/aave");
|
|
@@ -345,37 +346,7 @@ exports.EMPTY_AAVE_DATA = {
|
|
|
345
346
|
exposure: 'N/A',
|
|
346
347
|
};
|
|
347
348
|
const _getAaveV3AccountBalances = (provider, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
348
|
-
|
|
349
|
-
collateral: {},
|
|
350
|
-
debt: {},
|
|
351
|
-
};
|
|
352
|
-
if (!address) {
|
|
353
|
-
return balances;
|
|
354
|
-
}
|
|
355
|
-
const loanInfoContract = (0, contracts_1.AaveV3ViewContractViem)(provider, network, block);
|
|
356
|
-
const market = (0, aave_1.AAVE_V3)(network);
|
|
357
|
-
const marketAddress = market.providerAddress;
|
|
358
|
-
// @ts-ignore
|
|
359
|
-
const protocolDataProviderContract = (0, contracts_1.createViemContractFromConfigFunc)(market.protocolData, market.protocolDataAddress)(provider, network);
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
const reserveTokens = yield protocolDataProviderContract.read.getAllReservesTokens((0, viem_1.setViemBlockNumber)(block));
|
|
362
|
-
const symbols = reserveTokens.map(({ symbol }) => symbol);
|
|
363
|
-
const _addresses = reserveTokens.map(({ tokenAddress }) => tokenAddress);
|
|
364
|
-
// split addresses in half to avoid gas limit by multicall
|
|
365
|
-
const middleAddressIndex = Math.floor(_addresses.length / 2);
|
|
366
|
-
const [tokenBalances1, tokenBalances2] = yield Promise.all([
|
|
367
|
-
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(0, middleAddressIndex)], (0, viem_1.setViemBlockNumber)(block)),
|
|
368
|
-
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length)], (0, viem_1.setViemBlockNumber)(block)),
|
|
369
|
-
]);
|
|
370
|
-
const loanInfo = [...tokenBalances1, ...tokenBalances2];
|
|
371
|
-
loanInfo.forEach((tokenInfo, i) => {
|
|
372
|
-
const asset = (0, utils_1.wethToEth)(symbols[i]);
|
|
373
|
-
const assetAddr = (0, utils_1.wethToEthByAddress)(_addresses[i], network).toLowerCase();
|
|
374
|
-
balances = {
|
|
375
|
-
collateral: Object.assign(Object.assign({}, balances.collateral), { [addressMapping ? assetAddr : asset]: tokenInfo.balance.toString() }),
|
|
376
|
-
debt: Object.assign(Object.assign({}, balances.debt), { [addressMapping ? assetAddr : asset]: new decimal_js_1.default(tokenInfo.borrowsStable.toString()).add(tokenInfo.borrowsVariable.toString()).toString() }),
|
|
377
|
-
};
|
|
378
|
-
});
|
|
349
|
+
const balances = yield (0, aaveBalances_1.getAaveLikeBalances)(provider, network, block, addressMapping, address, (0, aave_1.AAVE_V3)(network), 'AaveV3View');
|
|
379
350
|
return balances;
|
|
380
351
|
});
|
|
381
352
|
exports._getAaveV3AccountBalances = _getAaveV3AccountBalances;
|
package/cjs/aaveV4/index.d.ts
CHANGED
|
@@ -5,6 +5,31 @@ export { getAaveV4MerkleCampaigns } from './merkl';
|
|
|
5
5
|
export declare function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
6
6
|
export declare function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
7
7
|
export declare function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<AaveV4AccountData>;
|
|
8
|
+
/** Shared raw read; no spoke metadata or market enrichment. */
|
|
9
|
+
export declare const _getAaveV4LoanBalances: (provider: Client, network: NetworkNumber, block: Blockish, address: EthAddress, spoke: EthAddress) => Promise<{
|
|
10
|
+
user: `0x${string}`;
|
|
11
|
+
riskPremium: bigint;
|
|
12
|
+
avgCollateralFactor: bigint;
|
|
13
|
+
healthFactor: bigint;
|
|
14
|
+
totalCollateralInUsd: bigint;
|
|
15
|
+
totalDebtInUsdRay: bigint;
|
|
16
|
+
activeCollateralCount: bigint;
|
|
17
|
+
borrowCount: bigint;
|
|
18
|
+
reserves: readonly {
|
|
19
|
+
reserveId: bigint;
|
|
20
|
+
assetId: number;
|
|
21
|
+
underlying: `0x${string}`;
|
|
22
|
+
supplied: bigint;
|
|
23
|
+
drawn: bigint;
|
|
24
|
+
premium: bigint;
|
|
25
|
+
totalDebt: bigint;
|
|
26
|
+
collateralFactor: number;
|
|
27
|
+
maxLiquidationBonus: number;
|
|
28
|
+
liquidationFee: number;
|
|
29
|
+
isUsingAsCollateral: boolean;
|
|
30
|
+
isBorrowing: boolean;
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
8
33
|
/**
|
|
9
34
|
* Lightweight existence check for Loan Shifter / UI discovery.
|
|
10
35
|
* Reads only `getLoanData(spoke, user)` and returns whether any reserve has
|
package/cjs/aaveV4/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.getAaveV4AccountBalances = exports._getAaveV4AccountBalances = exports._getAaveV4AccountHasAnyBalance = exports.getAaveV4MerkleCampaigns = exports.lend = void 0;
|
|
48
|
+
exports.getAaveV4AccountBalances = exports._getAaveV4AccountBalances = exports._getAaveV4AccountHasAnyBalance = exports._getAaveV4LoanBalances = exports.getAaveV4MerkleCampaigns = exports.lend = void 0;
|
|
49
49
|
exports._getAaveV4SpokeData = _getAaveV4SpokeData;
|
|
50
50
|
exports.getAaveV4SpokeData = getAaveV4SpokeData;
|
|
51
51
|
exports._getAaveV4AccountData = _getAaveV4AccountData;
|
|
@@ -296,6 +296,9 @@ function _getAaveV4AccountData(provider_1, network_1, spokeData_1, address_1) {
|
|
|
296
296
|
riskPremiumBps });
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
+
/** Shared raw read; no spoke metadata or market enrichment. */
|
|
300
|
+
const _getAaveV4LoanBalances = (provider, network, block, address, spoke) => ((0, contracts_1.AaveV4ViewContractViem)(provider, network, block).read.getLoanData([spoke, address], (0, viem_1.setViemBlockNumber)(block)));
|
|
301
|
+
exports._getAaveV4LoanBalances = _getAaveV4LoanBalances;
|
|
299
302
|
/**
|
|
300
303
|
* Lightweight existence check for Loan Shifter / UI discovery.
|
|
301
304
|
* Reads only `getLoanData(spoke, user)` and returns whether any reserve has
|
|
@@ -17,7 +17,7 @@ export declare const EMPTY_COMPOUND_DATA: {
|
|
|
17
17
|
borrowStableSupplyUnstable: boolean;
|
|
18
18
|
exposure: string;
|
|
19
19
|
};
|
|
20
|
-
export declare const _getCompoundV2AccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
20
|
+
export declare const _getCompoundV2AccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, tokens?: EthAddress[]) => Promise<PositionBalances>;
|
|
21
21
|
export declare const getCompoundV2AccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
22
22
|
export declare const _getCompoundV2AccountData: (provider: Client, network: NetworkNumber, address: EthAddress, assetsData: CompoundV2AssetsData) => Promise<CompoundV2PositionData>;
|
|
23
23
|
export declare const getCompoundV2AccountData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, assetsData: CompoundV2AssetsData) => Promise<CompoundV2PositionData>;
|
package/cjs/compoundV2/index.js
CHANGED
|
@@ -109,7 +109,7 @@ const getAllMarketAddresses = (provider, network, block) => __awaiter(void 0, vo
|
|
|
109
109
|
const contract = (0, contracts_1.ComptrollerContractViem)(provider, network);
|
|
110
110
|
return contract.read.getAllMarkets((0, viem_1.setViemBlockNumber)(block));
|
|
111
111
|
});
|
|
112
|
-
const _getCompoundV2AccountBalances = (provider, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
const _getCompoundV2AccountBalances = (provider, network, block, addressMapping, address, tokens) => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
113
|
let balances = {
|
|
114
114
|
collateral: {},
|
|
115
115
|
debt: {},
|
|
@@ -117,7 +117,7 @@ const _getCompoundV2AccountBalances = (provider, network, block, addressMapping,
|
|
|
117
117
|
if (!address) {
|
|
118
118
|
return balances;
|
|
119
119
|
}
|
|
120
|
-
const assets = yield getAllMarketAddresses(provider, network, block);
|
|
120
|
+
const assets = tokens || (yield getAllMarketAddresses(provider, network, block));
|
|
121
121
|
const assetInfo = assets.map(a => (0, tokens_1.getAssetInfoByAddress)(a, network));
|
|
122
122
|
const loanInfoContract = (0, contracts_1.CompoundLoanInfoContractViem)(provider, network, block);
|
|
123
123
|
const loanInfo = yield loanInfoContract.read.getTokenBalances([address, assets], (0, viem_1.setViemBlockNumber)(block));
|
package/cjs/curveUsd/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CrvUSDGlobalMarketData, CrvUSDMarketData, CrvUSDUserData } from '../typ
|
|
|
3
3
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
4
4
|
export declare const _getCurveUsdGlobalData: (provider: Client, network: NetworkNumber, selectedMarket: CrvUSDMarketData) => Promise<CrvUSDGlobalMarketData>;
|
|
5
5
|
export declare const getCurveUsdGlobalData: (provider: EthereumProvider, network: NetworkNumber, selectedMarket: CrvUSDMarketData) => Promise<CrvUSDGlobalMarketData>;
|
|
6
|
-
export declare const _getCrvUsdAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress) => Promise<PositionBalances>;
|
|
6
|
+
export declare const _getCrvUsdAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress, includeDeposited?: boolean) => Promise<PositionBalances>;
|
|
7
7
|
export declare const getCrvUsdAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress) => Promise<PositionBalances>;
|
|
8
8
|
/**
|
|
9
9
|
* @param borrowRate market borrow APY in % (`CrvUSDGlobalMarketData.borrowRate`); when omitted it is read from the view contract
|
package/cjs/curveUsd/index.js
CHANGED
|
@@ -107,7 +107,7 @@ const getStatusForUser = (bandRange, activeBand, crvUSDSupplied, collSupplied, h
|
|
|
107
107
|
return types_1.CrvUSDStatus.SoftLiquidated; // or is fully soft liquidated
|
|
108
108
|
return types_1.CrvUSDStatus.Nonexistant;
|
|
109
109
|
};
|
|
110
|
-
const _getCrvUsdAccountBalances = (
|
|
110
|
+
const _getCrvUsdAccountBalances = (provider_1, network_1, block_1, addressMapping_1, address_1, controllerAddress_1, ...args_1) => __awaiter(void 0, [provider_1, network_1, block_1, addressMapping_1, address_1, controllerAddress_1, ...args_1], void 0, function* (provider, network, block, addressMapping, address, controllerAddress, includeDeposited = false) {
|
|
111
111
|
let balances = {
|
|
112
112
|
collateral: {},
|
|
113
113
|
debt: {},
|
|
@@ -126,6 +126,11 @@ const _getCrvUsdAccountBalances = (provider, network, block, addressMapping, add
|
|
|
126
126
|
[addressMapping ? (0, tokens_1.getAssetInfo)((0, utils_1.wethToEth)(selectedMarket.baseAsset), network).address.toLowerCase() : (0, utils_1.wethToEth)(selectedMarket.baseAsset)]: data.debtAmount.toString(),
|
|
127
127
|
},
|
|
128
128
|
};
|
|
129
|
+
if (includeDeposited) {
|
|
130
|
+
balances.deposited = {
|
|
131
|
+
[addressMapping ? (0, tokens_1.getAssetInfo)((0, utils_1.wethToEth)(selectedMarket.baseAsset), network).address.toLowerCase() : (0, utils_1.wethToEth)(selectedMarket.baseAsset)]: data.curveUsdCollateralAmount.toString(),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
129
134
|
return balances;
|
|
130
135
|
});
|
|
131
136
|
exports._getCrvUsdAccountBalances = _getCrvUsdAccountBalances;
|
package/cjs/fluid/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getAllFluidMarketDataPortfolio = exports._getAllFluidMarketDataPortfolio = exports._getUserPositionsPortfolio = exports.getUserPositions = exports._getUserPositions = exports.getAllUserEarnPositionsWithFTokens = exports._getAllUserEarnPositionsWithFTokens = exports.getFluidDepositData = exports._getFluidDepositData = exports.getFluidTokenData = exports._getFluidTokenData = exports.getAllFluidMarketDataChunked = exports._getAllFluidMarketDataChunked = exports.getFluidPositionWithMarket = exports._getFluidPositionWithMarket = exports.getFluidPosition = exports._getFluidPosition = exports.getFluidVaultIdsForUser = exports._getFluidVaultIdsForUser = exports.getFluidMarketData = exports._getFluidMarketData = exports.EMPTY_FLUID_DATA = exports.EMPTY_USED_ASSET = exports.attachFluidMerklIncentives = exports.getFluidMerklCampaigns = exports.buildFluidMerklRewardMap = exports.FluidMerklOpportunityType = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
+
const fluidBalances_1 = require("../helpers/fluidBalances");
|
|
18
19
|
const common_1 = require("../types/common");
|
|
19
20
|
const types_1 = require("../types");
|
|
20
21
|
const contracts_1 = require("../contracts");
|
|
@@ -935,8 +936,8 @@ const parseT1UserData = (userPositionData, vaultData) => {
|
|
|
935
936
|
const collAsset = (0, tokens_1.getAssetInfo)(marketData.collAsset0);
|
|
936
937
|
const debtAsset = (0, tokens_1.getAssetInfo)(marketData.debtAsset0);
|
|
937
938
|
// for T2 and T4 - this is the number of shares
|
|
938
|
-
const supplied = (0,
|
|
939
|
-
const borrowed = (0,
|
|
939
|
+
const supplied = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset.decimals);
|
|
940
|
+
const borrowed = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset.decimals);
|
|
940
941
|
const collUsedAsset = Object.assign(Object.assign({}, exports.EMPTY_USED_ASSET), { symbol: collAsset.symbol, collateral: true, supplied, suppliedUsd: new decimal_js_1.default(supplied).mul(assetsData[collAsset.symbol].price).toString(), isSupplied: new decimal_js_1.default(supplied).gt(0) });
|
|
941
942
|
const debtUsedAsset = Object.assign(Object.assign({}, exports.EMPTY_USED_ASSET), { symbol: debtAsset.symbol, collateral: false, borrowed, borrowedUsd: new decimal_js_1.default(borrowed).mul(assetsData[debtAsset.symbol].price).toString(), isBorrowed: new decimal_js_1.default(borrowed).gt(0) });
|
|
942
943
|
const usedAssets = {
|
|
@@ -956,9 +957,9 @@ const parseT2UserData = (userPositionData, vaultData) => {
|
|
|
956
957
|
const collAsset1 = (0, tokens_1.getAssetInfo)(marketData.collAsset1);
|
|
957
958
|
const debtAsset = (0, tokens_1.getAssetInfo)(marketData.debtAsset0);
|
|
958
959
|
const supplyShares = (0, utils_1.getEthAmountForDecimals)(userPositionData.supply.toString(), 18); // this is supplied in coll shares
|
|
959
|
-
const borrowed = (0,
|
|
960
|
-
const supplied0 =
|
|
961
|
-
const supplied1 =
|
|
960
|
+
const borrowed = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset.decimals); // this is actual token borrow
|
|
961
|
+
const supplied0 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset0.decimals, assetsData[collAsset0.symbol].tokenPerSupplyShare);
|
|
962
|
+
const supplied1 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset1.decimals, assetsData[collAsset1.symbol].tokenPerSupplyShare);
|
|
962
963
|
const collUsedAsset0 = {
|
|
963
964
|
symbol: collAsset0.symbol,
|
|
964
965
|
collateral: true,
|
|
@@ -1001,10 +1002,10 @@ const parseT3UserData = (userPositionData, vaultData) => {
|
|
|
1001
1002
|
const collAsset = (0, tokens_1.getAssetInfo)(marketData.collAsset0);
|
|
1002
1003
|
const debtAsset0 = (0, tokens_1.getAssetInfo)(marketData.debtAsset0);
|
|
1003
1004
|
const debtAsset1 = (0, tokens_1.getAssetInfo)(marketData.debtAsset1);
|
|
1004
|
-
const supplied = (0,
|
|
1005
|
+
const supplied = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset.decimals); // this is actual token supply
|
|
1005
1006
|
const borrowShares = (0, utils_1.getEthAmountForDecimals)(userPositionData.borrow.toString(), 18); // this is actual token borrow
|
|
1006
|
-
const borrowed0 =
|
|
1007
|
-
const borrowed1 =
|
|
1007
|
+
const borrowed0 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset0.decimals, assetsData[debtAsset0.symbol].tokenPerBorrowShare);
|
|
1008
|
+
const borrowed1 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset1.decimals, assetsData[debtAsset1.symbol].tokenPerBorrowShare);
|
|
1008
1009
|
const collUsedAsset = {
|
|
1009
1010
|
symbol: collAsset.symbol,
|
|
1010
1011
|
collateral: true,
|
|
@@ -1049,10 +1050,10 @@ const parseT4UserData = (userPositionData, vaultData) => {
|
|
|
1049
1050
|
const debtAsset1 = (0, tokens_1.getAssetInfo)(marketData.debtAsset1);
|
|
1050
1051
|
const supplyShares = (0, utils_1.getEthAmountForDecimals)(userPositionData.supply.toString(), 18); // this is actual token supply
|
|
1051
1052
|
const borrowShares = (0, utils_1.getEthAmountForDecimals)(userPositionData.borrow.toString(), 18); // this is actual token borrow
|
|
1052
|
-
const supplied0 =
|
|
1053
|
-
const supplied1 =
|
|
1054
|
-
const borrowed0 =
|
|
1055
|
-
const borrowed1 =
|
|
1053
|
+
const supplied0 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset0.decimals, assetsData[collAsset0.symbol].tokenPerSupplyShare);
|
|
1054
|
+
const supplied1 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.supply, collAsset1.decimals, assetsData[collAsset1.symbol].tokenPerSupplyShare);
|
|
1055
|
+
const borrowed0 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset0.decimals, assetsData[debtAsset0.symbol].tokenPerBorrowShare);
|
|
1056
|
+
const borrowed1 = (0, fluidBalances_1.fluidTokenAmount)(userPositionData.borrow, debtAsset1.decimals, assetsData[debtAsset1.symbol].tokenPerBorrowShare);
|
|
1056
1057
|
const collUsedAsset0 = {
|
|
1057
1058
|
symbol: collAsset0.symbol,
|
|
1058
1059
|
collateral: true,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import { AaveMarketInfo, SparkMarketData } from '../types';
|
|
3
|
+
import { Blockish, EthAddress, NetworkNumber, PositionBalances } from '../types/common';
|
|
4
|
+
/** Raw token balances shared by Aave/Spark getters and lending previews. */
|
|
5
|
+
export declare function getAaveLikeBalances(client: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, market: Pick<AaveMarketInfo | SparkMarketData, 'providerAddress' | 'protocolData' | 'protocolDataAddress'>, view: 'AaveLoanInfoV2' | 'AaveV3View' | 'SparkView', tokens?: EthAddress[]): Promise<PositionBalances>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getAaveLikeBalances = getAaveLikeBalances;
|
|
16
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
+
const contracts_1 = require("../contracts");
|
|
19
|
+
const viem_1 = require("../services/viem");
|
|
20
|
+
const utils_1 = require("../services/utils");
|
|
21
|
+
/** Raw token balances shared by Aave/Spark getters and lending previews. */
|
|
22
|
+
function getAaveLikeBalances(client, network, block, addressMapping, address, market, view, tokens) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const balances = { collateral: {}, debt: {} };
|
|
25
|
+
if (!address)
|
|
26
|
+
return balances;
|
|
27
|
+
let reserves;
|
|
28
|
+
if (tokens)
|
|
29
|
+
reserves = tokens.map(tokenAddress => ({ tokenAddress, symbol: (0, tokens_1.getAssetInfoByAddress)(tokenAddress, network).symbol }));
|
|
30
|
+
else {
|
|
31
|
+
if (!market.protocolData)
|
|
32
|
+
throw new Error('Missing protocol data provider');
|
|
33
|
+
reserves = [...yield (0, contracts_1.createViemContractFromConfigFunc)(market.protocolData, market.protocolDataAddress)(client, network)
|
|
34
|
+
.read.getAllReservesTokens((0, viem_1.setViemBlockNumber)(block))];
|
|
35
|
+
}
|
|
36
|
+
const addresses = reserves.map(token => token.tokenAddress);
|
|
37
|
+
const contract = (0, contracts_1.createViemContractFromConfigFunc)(view)(client, network, block);
|
|
38
|
+
const middle = tokens ? Math.ceil(addresses.length / 2) : Math.floor(addresses.length / 2);
|
|
39
|
+
// Preserve legacy V2 single-call and V3/Spark two-call behavior.
|
|
40
|
+
const parts = !tokens && view === 'AaveLoanInfoV2' ? [addresses] : [addresses.slice(0, middle), addresses.slice(middle)];
|
|
41
|
+
const data = (yield Promise.all((tokens ? parts.filter(part => part.length) : parts)
|
|
42
|
+
.map(part => contract.read.getTokenBalances([market.providerAddress, address, part], (0, viem_1.setViemBlockNumber)(block))))).flat();
|
|
43
|
+
data.forEach((token, i) => {
|
|
44
|
+
// The views leave token.token unset; input order identifies the reserve.
|
|
45
|
+
const key = addressMapping ? (0, utils_1.wethToEthByAddress)(reserves[i].tokenAddress, network).toLowerCase() : (0, utils_1.wethToEth)(reserves[i].symbol);
|
|
46
|
+
balances.collateral[key] = token.balance.toString();
|
|
47
|
+
balances.debt[key] = new decimal_js_1.default(token.borrowsStable.toString()).add(token.borrowsVariable.toString()).toString();
|
|
48
|
+
});
|
|
49
|
+
return balances;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FluidUserPositionStructOutputStruct, FluidVaultDataStructOutputStruct } from '../types';
|
|
2
|
+
import { NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
+
/** Convert raw tokens, or raw 18-decimal shares with a human-readable token/share ratio. */
|
|
4
|
+
export declare const fluidTokenAmount: (amount: bigint, decimals: number, perShare?: string) => string;
|
|
5
|
+
/** The same token/share conversion used by the full Fluid user parsers, without prices or yield. */
|
|
6
|
+
export declare function parseFluidBalances(position: FluidUserPositionStructOutputStruct, vault: FluidVaultDataStructOutputStruct, network: NetworkNumber): PositionBalances;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fluidTokenAmount = void 0;
|
|
7
|
+
exports.parseFluidBalances = parseFluidBalances;
|
|
8
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
10
|
+
/** Convert raw tokens, or raw 18-decimal shares with a human-readable token/share ratio. */
|
|
11
|
+
const fluidTokenAmount = (amount, decimals, perShare) => (new decimal_js_1.default(amount.toString()).div(new decimal_js_1.default(10).pow(perShare === undefined ? decimals : 18)).mul(perShare !== null && perShare !== void 0 ? perShare : 1).toString());
|
|
12
|
+
exports.fluidTokenAmount = fluidTokenAmount;
|
|
13
|
+
/** The same token/share conversion used by the full Fluid user parsers, without prices or yield. */
|
|
14
|
+
function parseFluidBalances(position, vault, network) {
|
|
15
|
+
const type = Number(vault.vaultType);
|
|
16
|
+
if (![10000, 20000, 30000, 40000].includes(type))
|
|
17
|
+
throw new Error('Unsupported Fluid vault');
|
|
18
|
+
const side = (amount, tokens, ratios) => {
|
|
19
|
+
const balances = {};
|
|
20
|
+
tokens.forEach((address, i) => {
|
|
21
|
+
const token = (0, tokens_1.getAssetInfoByAddress)(address, network);
|
|
22
|
+
if (!Number.isFinite(token.decimals) || !token.symbol)
|
|
23
|
+
throw new Error('Fluid token metadata unavailable');
|
|
24
|
+
const perShare = ratios ? (0, exports.fluidTokenAmount)(ratios[i], token.decimals) : undefined;
|
|
25
|
+
const value = (0, exports.fluidTokenAmount)(amount, token.decimals, perShare);
|
|
26
|
+
balances[token.symbol] = new decimal_js_1.default(balances[token.symbol] || 0).add(value).toString();
|
|
27
|
+
});
|
|
28
|
+
return balances;
|
|
29
|
+
};
|
|
30
|
+
const smartSupply = type === 20000 || type === 40000;
|
|
31
|
+
const smartDebt = type === 30000 || type === 40000;
|
|
32
|
+
return {
|
|
33
|
+
collateral: side(position.supply, smartSupply ? [vault.supplyToken0, vault.supplyToken1] : [vault.supplyToken0], smartSupply ? [vault.dexSupplyData.token0PerSupplyShare, vault.dexSupplyData.token1PerSupplyShare] : undefined),
|
|
34
|
+
debt: side(position.borrow, smartDebt ? [vault.borrowToken0, vault.borrowToken1] : [vault.borrowToken0], smartDebt ? [vault.dexBorrowData.token0PerBorrowShare, vault.dexBorrowData.token1PerBorrowShare] : undefined),
|
|
35
|
+
};
|
|
36
|
+
}
|
package/cjs/liquityV2/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export type SPYieldGainParameters = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare const _getLiquityV2MarketData: (provider: Client, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo) => Promise<LiquityV2MarketData>;
|
|
13
13
|
export declare const getLiquityV2MarketData: (provider: EthereumProvider, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo) => Promise<LiquityV2MarketData>;
|
|
14
|
+
export declare const nftContractCreationBlockMapping: {
|
|
15
|
+
liquityv2eth: number;
|
|
16
|
+
liquityv2wsteth: number;
|
|
17
|
+
liquityv2reth: number;
|
|
18
|
+
liquityv2ethlegacy: number;
|
|
19
|
+
liquityv2wstethlegacy: number;
|
|
20
|
+
liquityv2rethlegacy: number;
|
|
21
|
+
};
|
|
14
22
|
export declare const _getLiquityV2UserTroveIds: (provider: PublicClient, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo, troveNFTAddress: EthAddress, limitBlocksForEventFetching: boolean, account: EthAddress) => Promise<{
|
|
15
23
|
troves: {
|
|
16
24
|
troveId: string;
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getLiquitySAndYBold = exports.getLiquityV2Staking = exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getDebtInFrontForInterestRateIncludingNewDebtLiquityV2 = exports.calculateDebtInFrontLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
15
|
+
exports.getLiquitySAndYBold = exports.getLiquityV2Staking = exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getDebtInFrontForInterestRateIncludingNewDebtLiquityV2 = exports.calculateDebtInFrontLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.nftContractCreationBlockMapping = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
@@ -120,7 +120,7 @@ const getUserTroves = (provider_1, network_1, isLegacy_1, account_1, marketAddre
|
|
|
120
120
|
return { troves: existingTroves.filter((trove) => trove.ownedByUser), nextFreeTroveIndex };
|
|
121
121
|
return getUserTroves(provider, network, isLegacy, account, marketAddress, newStartIndex, newStartIndex + 100, existingTroves);
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
exports.nftContractCreationBlockMapping = {
|
|
124
124
|
[types_1.LiquityV2Versions.LiquityV2Eth]: 22516079,
|
|
125
125
|
[types_1.LiquityV2Versions.LiquityV2WstEth]: 22516099,
|
|
126
126
|
[types_1.LiquityV2Versions.LiquityV2REth]: 22516118,
|
|
@@ -131,7 +131,7 @@ const nftContractCreationBlockMapping = {
|
|
|
131
131
|
};
|
|
132
132
|
const getTransferredTroves = (provider, network, troveNFTAddress, limitBlocksForEventFetching, market, account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
133
|
const nftContract = (0, contracts_1.createViemContractFromConfigFunc)('LiquityV2TroveNFT', troveNFTAddress)(provider, network);
|
|
134
|
-
const nftContractCreationBlock = nftContractCreationBlockMapping[market];
|
|
134
|
+
const nftContractCreationBlock = exports.nftContractCreationBlockMapping[market];
|
|
135
135
|
const currentBlock = +(yield provider.getBlockNumber()).toString();
|
|
136
136
|
const _events = yield nftContract.getEvents.Transfer({}, { fromBlock: limitBlocksForEventFetching ? BigInt(currentBlock - 1000) : BigInt(nftContractCreationBlock) });
|
|
137
137
|
const events = _events.map((event) => ({
|
package/cjs/llamaLend/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { LlamaLendGlobalMarketData, LlamaLendMarketData, LlamaLendUserData } fro
|
|
|
3
3
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
4
4
|
export declare const _getLlamaLendGlobalData: (provider: Client, network: NetworkNumber, selectedMarket: LlamaLendMarketData) => Promise<LlamaLendGlobalMarketData>;
|
|
5
5
|
export declare const getLlamaLendGlobalData: (provider: EthereumProvider, network: NetworkNumber, selectedMarket: LlamaLendMarketData) => Promise<LlamaLendGlobalMarketData>;
|
|
6
|
-
export declare const _getLlamaLendAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress) => Promise<PositionBalances>;
|
|
6
|
+
export declare const _getLlamaLendAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress, includeDeposited?: boolean) => Promise<PositionBalances>;
|
|
7
7
|
export declare const getLlamaLendAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, controllerAddress: EthAddress) => Promise<PositionBalances>;
|
|
8
8
|
export declare const _getLlamaLendUserData: (provider: Client, network: NetworkNumber, address: EthAddress, selectedMarket: LlamaLendMarketData, marketData: LlamaLendGlobalMarketData) => Promise<LlamaLendUserData>;
|
|
9
9
|
export declare const getLlamaLendUserData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, selectedMarket: LlamaLendMarketData, marketData: LlamaLendGlobalMarketData) => Promise<LlamaLendUserData>;
|
package/cjs/llamaLend/index.js
CHANGED
|
@@ -161,7 +161,7 @@ const getStatusForUser = (bandRange, activeBand, debtSupplied, collSupplied, hea
|
|
|
161
161
|
return types_1.LlamaLendStatus.SoftLiquidated; // or is fully soft liquidated
|
|
162
162
|
return types_1.LlamaLendStatus.Nonexistant;
|
|
163
163
|
};
|
|
164
|
-
const _getLlamaLendAccountBalances = (
|
|
164
|
+
const _getLlamaLendAccountBalances = (provider_1, network_1, block_1, addressMapping_1, address_1, controllerAddress_1, ...args_1) => __awaiter(void 0, [provider_1, network_1, block_1, addressMapping_1, address_1, controllerAddress_1, ...args_1], void 0, function* (provider, network, block, addressMapping, address, controllerAddress, includeDeposited = false) {
|
|
165
165
|
let balances = {
|
|
166
166
|
collateral: {},
|
|
167
167
|
debt: {},
|
|
@@ -180,6 +180,11 @@ const _getLlamaLendAccountBalances = (provider, network, block, addressMapping,
|
|
|
180
180
|
[addressMapping ? (0, tokens_1.getAssetInfo)((0, utils_1.wethToEth)(selectedMarket.baseAsset), network).address.toLowerCase() : (0, utils_1.wethToEth)(selectedMarket.baseAsset)]: data.debtAmount.toString(),
|
|
181
181
|
},
|
|
182
182
|
};
|
|
183
|
+
if (includeDeposited) {
|
|
184
|
+
balances.deposited = {
|
|
185
|
+
[addressMapping ? (0, tokens_1.getAssetInfo)((0, utils_1.wethToEth)(selectedMarket.baseAsset), network).address.toLowerCase() : (0, utils_1.wethToEth)(selectedMarket.baseAsset)]: data.debtTokenCollateralAmount.toString(),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
183
188
|
return balances;
|
|
184
189
|
});
|
|
185
190
|
exports._getLlamaLendAccountBalances = _getLlamaLendAccountBalances;
|
|
@@ -5,7 +5,7 @@ export declare function _getMorphoMidnightMarketData(provider: Client, network:
|
|
|
5
5
|
export declare function getMorphoMidnightMarketData(provider: EthereumProvider, network: NetworkNumber, selectedMarket: MorphoMidnightMarketData): Promise<MorphoMidnightMarketInfo>;
|
|
6
6
|
export declare function _getMorphoMidnightAccountData(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoMidnightMarketData, marketInfo: MorphoMidnightMarketInfo): Promise<MorphoMidnightPositionData>;
|
|
7
7
|
export declare function getMorphoMidnightAccountData(provider: EthereumProvider, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoMidnightMarketData, marketInfo: MorphoMidnightMarketInfo): Promise<MorphoMidnightPositionData>;
|
|
8
|
-
export declare const _getMorphoMidnightAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoMidnightMarketData) => Promise<PositionBalances>;
|
|
8
|
+
export declare const _getMorphoMidnightAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoMidnightMarketData, includeCredit?: boolean) => Promise<PositionBalances>;
|
|
9
9
|
export declare const getMorphoMidnightAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoMidnightMarketData) => Promise<PositionBalances>;
|
|
10
10
|
export declare function getMorphoMidnightEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoMidnightMarketData, marketInfo: MorphoMidnightMarketInfo): Promise<{
|
|
11
11
|
apy: string;
|
|
@@ -221,7 +221,7 @@ function getMorphoMidnightAccountData(provider, network, account, selectedMarket
|
|
|
221
221
|
return _getMorphoMidnightAccountData((0, viem_1.getViemProvider)(provider, network), network, account, selectedMarket, marketInfo);
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
const _getMorphoMidnightAccountBalances = (
|
|
224
|
+
const _getMorphoMidnightAccountBalances = (provider_1, network_1, block_1, addressMapping_1, address_1, selectedMarket_1, ...args_1) => __awaiter(void 0, [provider_1, network_1, block_1, addressMapping_1, address_1, selectedMarket_1, ...args_1], void 0, function* (provider, network, block, addressMapping, address, selectedMarket, includeCredit = false) {
|
|
225
225
|
const balances = { collateral: {}, debt: {} };
|
|
226
226
|
if (!address)
|
|
227
227
|
return balances;
|
|
@@ -241,6 +241,11 @@ const _getMorphoMidnightAccountBalances = (provider, network, block, addressMapp
|
|
|
241
241
|
collateral[addressMapping ? collInfo.address.toLowerCase() : (0, utils_1.wethToEth)(collInfo.symbol)] = (0, tokens_1.assetAmountInEth)(rawAmount, (0, utils_1.wethToEth)(collInfo.symbol));
|
|
242
242
|
});
|
|
243
243
|
balances.collateral = collateral;
|
|
244
|
+
if (includeCredit) {
|
|
245
|
+
balances.deposited = {
|
|
246
|
+
[addressMapping ? loanTokenInfo.address.toLowerCase() : (0, utils_1.wethToEth)(loanTokenInfo.symbol)]: (0, tokens_1.assetAmountInEth)(positionInfo.credit.toString(), (0, utils_1.wethToEth)(loanTokenInfo.symbol)),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
244
249
|
return balances;
|
|
245
250
|
});
|
|
246
251
|
exports._getMorphoMidnightAccountBalances = _getMorphoMidnightAccountBalances;
|
package/cjs/portfolio/index.d.ts
CHANGED
package/cjs/portfolio/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getWalletLendingSummaries = void 0;
|
|
29
30
|
exports.getPortfolioData = getPortfolioData;
|
|
30
31
|
exports.getShifterPortfolioData = getShifterPortfolioData;
|
|
31
32
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
@@ -886,3 +887,5 @@ function getShifterPortfolioData(provider_1, network_1, defaultProvider_1, addre
|
|
|
886
887
|
});
|
|
887
888
|
}
|
|
888
889
|
__exportStar(require("./discovery"), exports);
|
|
890
|
+
var lendingSummaries_1 = require("./lendingSummaries");
|
|
891
|
+
Object.defineProperty(exports, "getWalletLendingSummaries", { enumerable: true, get: function () { return lendingSummaries_1.getWalletLendingSummaries; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
2
|
+
import { LendingSummaryOptions, WalletLendingSummaries } from '../types/lendingSummary';
|
|
3
|
+
/** Lending-only balances at one snapshot, valued with caller-supplied market prices.
|
|
4
|
+
* One shared client/limiter covers every wallet. Failed reads remain partial; cancellation
|
|
5
|
+
* discards results. Morpho Blue earn deposits, rewards and savings are excluded.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getWalletLendingSummaries(provider: EthereumProvider, network: NetworkNumber, walletAddresses: EthAddress[], options: LendingSummaryOptions): Promise<WalletLendingSummaries>;
|