@defisaver/positions-sdk 2.1.161-portfolio-api-1-dev → 2.1.161-portfolio-api-3-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/aaveV2/index.js +2 -0
- package/cjs/aaveV3/index.d.ts +41 -12
- package/cjs/aaveV3/index.js +237 -2
- package/cjs/aaveV3/sgho.d.ts +2 -16
- package/cjs/aaveV4/lend.d.ts +2 -43
- package/cjs/claiming/aaveV3.d.ts +2 -2
- package/cjs/claiming/ethena.d.ts +2 -1
- package/cjs/claiming/king.d.ts +2 -1
- package/cjs/claiming/spark.d.ts +2 -2
- package/cjs/curveUsd/index.d.ts +5 -2
- package/cjs/curveUsd/index.js +30 -15
- package/cjs/fluid/index.d.ts +10 -49
- package/cjs/fluid/index.js +36 -1
- package/cjs/helpers/aaveHelpers/index.d.ts +9 -1
- package/cjs/helpers/aaveHelpers/index.js +26 -6
- package/cjs/helpers/aaveV4Helpers/index.js +1 -0
- package/cjs/helpers/compoundHelpers/index.js +2 -0
- package/cjs/helpers/curveUsdHelpers/index.d.ts +3 -1
- package/cjs/helpers/curveUsdHelpers/index.js +15 -2
- package/cjs/helpers/fluidHelpers/index.js +1 -0
- package/cjs/helpers/liquityV2Helpers/index.js +1 -0
- package/cjs/helpers/llamaLendHelpers/index.js +1 -0
- package/cjs/helpers/makerHelpers/index.d.ts +1 -1
- package/cjs/helpers/makerHelpers/index.js +2 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +2 -0
- package/cjs/helpers/morphoMidnightHelpers/index.js +2 -0
- package/cjs/helpers/sparkHelpers/index.js +1 -0
- package/cjs/liquity/index.d.ts +2 -12
- package/cjs/liquity/index.js +15 -2
- package/cjs/liquityV2/index.d.ts +8 -23
- package/cjs/liquityV2/index.js +37 -19
- package/cjs/maker/index.d.ts +7 -2
- package/cjs/maker/index.js +44 -12
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/markets/maker/index.d.ts +1 -0
- package/cjs/markets/maker/index.js +13 -0
- package/cjs/moneymarket/moneymarketCommonService.d.ts +9 -0
- package/cjs/moneymarket/moneymarketCommonService.js +13 -1
- package/cjs/portfolio/index.d.ts +17 -5
- package/cjs/portfolio/index.js +583 -381
- package/cjs/portfolio/lendingProtocols.d.ts +184 -0
- package/cjs/portfolio/lendingProtocols.js +196 -0
- package/cjs/savings/index.d.ts +8 -2
- package/cjs/savings/index.js +37 -5
- package/cjs/savings/morphoVaults/index.d.ts +1 -1
- package/cjs/savings/morphoVaults/index.js +56 -18
- package/cjs/savings/morphoVaults/options.d.ts +2 -0
- package/cjs/savings/morphoVaults/options.js +61 -1
- package/cjs/spark/index.js +1 -0
- package/cjs/staking/staking.d.ts +20 -0
- package/cjs/staking/staking.js +19 -1
- package/cjs/types/aave.d.ts +86 -0
- package/cjs/types/aaveV4.d.ts +45 -0
- package/cjs/types/compound.d.ts +2 -0
- package/cjs/types/curveUsd.d.ts +6 -0
- package/cjs/types/fluid.d.ts +14 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquity.d.ts +16 -0
- package/cjs/types/liquityV2.d.ts +26 -0
- package/cjs/types/maker.d.ts +4 -0
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/morphoMidnight.d.ts +1 -0
- package/cjs/types/portfolio.d.ts +127 -6
- package/cjs/types/savings/index.d.ts +9 -1
- package/cjs/types/savings/morphoVaults.d.ts +10 -2
- package/cjs/types/savings/morphoVaults.js +9 -1
- package/cjs/types/spark.d.ts +2 -0
- package/cjs/umbrella/index.d.ts +2 -3
- package/esm/aaveV2/index.js +2 -0
- package/esm/aaveV3/index.d.ts +41 -12
- package/esm/aaveV3/index.js +231 -2
- package/esm/aaveV3/sgho.d.ts +2 -16
- package/esm/aaveV4/lend.d.ts +2 -43
- package/esm/claiming/aaveV3.d.ts +2 -2
- package/esm/claiming/aaveV3.js +1 -1
- package/esm/claiming/ethena.d.ts +2 -1
- package/esm/claiming/king.d.ts +2 -1
- package/esm/claiming/spark.d.ts +2 -2
- package/esm/claiming/spark.js +1 -1
- package/esm/curveUsd/index.d.ts +5 -2
- package/esm/curveUsd/index.js +30 -15
- package/esm/fluid/index.d.ts +10 -49
- package/esm/fluid/index.js +33 -0
- package/esm/helpers/aaveHelpers/index.d.ts +9 -1
- package/esm/helpers/aaveHelpers/index.js +23 -5
- package/esm/helpers/aaveV4Helpers/index.js +1 -0
- package/esm/helpers/compoundHelpers/index.js +2 -0
- package/esm/helpers/curveUsdHelpers/index.d.ts +3 -1
- package/esm/helpers/curveUsdHelpers/index.js +16 -3
- package/esm/helpers/fluidHelpers/index.js +1 -0
- package/esm/helpers/liquityV2Helpers/index.js +1 -0
- package/esm/helpers/llamaLendHelpers/index.js +2 -1
- package/esm/helpers/makerHelpers/index.d.ts +1 -1
- package/esm/helpers/makerHelpers/index.js +2 -2
- package/esm/helpers/morphoBlueHelpers/index.js +2 -0
- package/esm/helpers/morphoMidnightHelpers/index.js +2 -0
- package/esm/helpers/sparkHelpers/index.js +1 -0
- package/esm/liquity/index.d.ts +2 -12
- package/esm/liquity/index.js +16 -3
- package/esm/liquityV2/index.d.ts +8 -23
- package/esm/liquityV2/index.js +35 -18
- package/esm/maker/index.d.ts +7 -2
- package/esm/maker/index.js +44 -14
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/markets/maker/index.d.ts +1 -0
- package/esm/markets/maker/index.js +10 -0
- package/esm/moneymarket/moneymarketCommonService.d.ts +9 -0
- package/esm/moneymarket/moneymarketCommonService.js +11 -0
- package/esm/portfolio/index.d.ts +17 -5
- package/esm/portfolio/index.js +584 -385
- package/esm/portfolio/lendingProtocols.d.ts +184 -0
- package/esm/portfolio/lendingProtocols.js +189 -0
- package/esm/savings/index.d.ts +8 -2
- package/esm/savings/index.js +35 -4
- package/esm/savings/morphoVaults/index.d.ts +1 -1
- package/esm/savings/morphoVaults/index.js +57 -19
- package/esm/savings/morphoVaults/options.d.ts +2 -0
- package/esm/savings/morphoVaults/options.js +61 -1
- package/esm/spark/index.js +1 -0
- package/esm/staking/staking.d.ts +20 -0
- package/esm/staking/staking.js +17 -0
- package/esm/types/aave.d.ts +86 -0
- package/esm/types/aaveV4.d.ts +45 -0
- package/esm/types/compound.d.ts +2 -0
- package/esm/types/curveUsd.d.ts +6 -0
- package/esm/types/fluid.d.ts +14 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquity.d.ts +16 -0
- package/esm/types/liquityV2.d.ts +26 -0
- package/esm/types/maker.d.ts +4 -0
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/morphoMidnight.d.ts +1 -0
- package/esm/types/portfolio.d.ts +127 -6
- package/esm/types/savings/index.d.ts +9 -1
- package/esm/types/savings/morphoVaults.d.ts +10 -2
- package/esm/types/savings/morphoVaults.js +8 -0
- package/esm/types/spark.d.ts +2 -0
- package/esm/umbrella/index.d.ts +2 -3
- package/package.json +3 -2
- package/src/aaveV2/index.ts +2 -0
- package/src/aaveV3/index.ts +293 -2
- package/src/aaveV3/sgho.ts +2 -17
- package/src/aaveV4/lend.ts +2 -48
- package/src/claiming/aaveV3.ts +4 -2
- package/src/claiming/ethena.ts +5 -5
- package/src/claiming/king.ts +3 -3
- package/src/claiming/spark.ts +6 -4
- package/src/curveUsd/index.ts +33 -16
- package/src/fluid/index.ts +44 -3
- package/src/helpers/aaveHelpers/index.ts +27 -7
- package/src/helpers/aaveV4Helpers/index.ts +1 -0
- package/src/helpers/compoundHelpers/index.ts +2 -0
- package/src/helpers/curveUsdHelpers/index.ts +23 -3
- package/src/helpers/fluidHelpers/index.ts +1 -0
- package/src/helpers/liquityV2Helpers/index.ts +1 -0
- package/src/helpers/llamaLendHelpers/index.ts +2 -1
- package/src/helpers/makerHelpers/index.ts +2 -1
- package/src/helpers/morphoBlueHelpers/index.ts +2 -0
- package/src/helpers/morphoMidnightHelpers/index.ts +2 -0
- package/src/helpers/sparkHelpers/index.ts +1 -0
- package/src/liquity/index.ts +19 -5
- package/src/liquityV2/index.ts +48 -22
- package/src/maker/index.ts +77 -30
- package/src/markets/index.ts +2 -1
- package/src/markets/maker/index.ts +10 -0
- package/src/moneymarket/moneymarketCommonService.ts +15 -0
- package/src/portfolio/index.ts +477 -248
- package/src/portfolio/lendingProtocols.ts +281 -0
- package/src/savings/index.ts +45 -5
- package/src/savings/morphoVaults/index.ts +73 -21
- package/src/savings/morphoVaults/options.ts +67 -1
- package/src/spark/index.ts +1 -0
- package/src/staking/staking.ts +28 -0
- package/src/types/aave.ts +90 -0
- package/src/types/aaveV4.ts +50 -0
- package/src/types/compound.ts +2 -0
- package/src/types/curveUsd.ts +7 -0
- package/src/types/fluid.ts +15 -0
- package/src/types/index.ts +2 -1
- package/src/types/liquity.ts +19 -1
- package/src/types/liquityV2.ts +28 -1
- package/src/types/maker.ts +6 -0
- package/src/types/morphoBlue.ts +2 -0
- package/src/types/morphoMidnight.ts +1 -0
- package/src/types/portfolio.ts +153 -7
- package/src/types/savings/index.ts +12 -1
- package/src/types/savings/morphoVaults.ts +11 -1
- package/src/types/spark.ts +2 -0
- package/src/umbrella/index.ts +2 -1
package/cjs/maker/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Client, PublicClient } from 'viem';
|
|
2
2
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
-
import { CdpData, CdpInfo } from '../types';
|
|
3
|
+
import { CdpData, CdpInfo, IlkInfo } from '../types';
|
|
4
4
|
export declare const _getMakerAccountBalances: (provider: PublicClient, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
|
|
5
5
|
export declare const getMakerAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress) => Promise<PositionBalances>;
|
|
6
6
|
export declare const _getUserCdps: (provider: Client, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
|
|
7
7
|
export declare const getUserCdps: (provider: EthereumProvider, network: NetworkNumber, userAddress: EthAddress) => Promise<CdpInfo[]>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const _getMakerIlksData: (provider: Client, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
|
|
9
|
+
export declare const getMakerIlksData: (provider: EthereumProvider, network: NetworkNumber, ilkLabels: string[]) => Promise<Record<string, IlkInfo>>;
|
|
10
|
+
/**
|
|
11
|
+
* @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
|
|
12
|
+
*/
|
|
13
|
+
export declare const _getMakerCdpData: (provider: Client, network: NetworkNumber, cdp: CdpInfo, ilkInfo?: IlkInfo) => Promise<CdpData>;
|
|
9
14
|
export declare const getMakerCdpData: (provider: EthereumProvider, network: NetworkNumber, cdp: CdpInfo) => Promise<CdpData>;
|
package/cjs/maker/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.getMakerCdpData = exports._getMakerCdpData = exports.getUserCdps = exports._getUserCdps = exports.getMakerAccountBalances = exports._getMakerAccountBalances = void 0;
|
|
15
|
+
exports.getMakerCdpData = exports._getMakerCdpData = exports.getMakerIlksData = exports._getMakerIlksData = exports.getUserCdps = exports._getUserCdps = exports.getMakerAccountBalances = exports._getMakerAccountBalances = 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");
|
|
@@ -21,6 +21,7 @@ const utils_1 = require("../services/utils");
|
|
|
21
21
|
const makerHelpers_1 = require("../helpers/makerHelpers");
|
|
22
22
|
const viem_1 = require("../services/viem");
|
|
23
23
|
const moneymarket_1 = require("../moneymarket");
|
|
24
|
+
const staking_1 = require("../staking");
|
|
24
25
|
const _getMakerAccountBalances = (provider, network, block, addressMapping, cdpId, _managerAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
26
|
let balances = {
|
|
26
27
|
collateral: {},
|
|
@@ -44,7 +45,7 @@ const _getMakerAccountBalances = (provider, network, block, addressMapping, cdpI
|
|
|
44
45
|
// [urn, owner, userAddr, ilk, collateral, debt]
|
|
45
46
|
const cdpInfo = yield viewContract.read.getCdpInfo((needsIlk ? [managerAddress, cdpId, ilk] : [cdpId]), (0, viem_1.setViemBlockNumber)(block));
|
|
46
47
|
cdpInfo.ilk = cdpInfo[3];
|
|
47
|
-
const [par, [_, mat], [artGlobal, rate, spot, line], [duty], futureRate, chop,] = yield Promise.all([
|
|
48
|
+
const [par, [_, mat], [artGlobal, rate, spot, line, dust], [duty], futureRate, chop,] = yield Promise.all([
|
|
48
49
|
spotterContract.read.par((0, viem_1.setViemBlockNumber)(block)),
|
|
49
50
|
spotterContract.read.ilks(needsIlk ? [ilk] : [cdpInfo.ilk], (0, viem_1.setViemBlockNumber)(block)),
|
|
50
51
|
vatContract.read.ilks(needsIlk ? [ilk] : [cdpInfo.ilk], (0, viem_1.setViemBlockNumber)(block)),
|
|
@@ -52,7 +53,7 @@ const _getMakerAccountBalances = (provider, network, block, addressMapping, cdpI
|
|
|
52
53
|
jugContract.read.drip(needsIlk ? [ilk] : [cdpInfo.ilk], (0, viem_1.setViemBlockNumber)(block)),
|
|
53
54
|
dogContract.read.chop(needsIlk ? [ilk] : [cdpInfo.ilk], (0, viem_1.setViemBlockNumber)(block)),
|
|
54
55
|
]);
|
|
55
|
-
const ilkInfo = (0, makerHelpers_1.parseCollateralInfo)(needsIlk ? ilk : cdpInfo.ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), duty.toString(), futureRate.toString(), chop.toString());
|
|
56
|
+
const ilkInfo = (0, makerHelpers_1.parseCollateralInfo)(needsIlk ? ilk : cdpInfo.ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), dust.toString(), duty.toString(), futureRate.toString(), chop.toString());
|
|
56
57
|
const collateral = cdpInfo[4];
|
|
57
58
|
const debt = cdpInfo[5];
|
|
58
59
|
const asset = (0, utils_1.wethToEth)((0, tokens_1.ilkToAsset)(needsIlk ? ilk : cdpInfo.ilk));
|
|
@@ -90,22 +91,40 @@ const _getUserCdps = (provider, network, userAddress) => __awaiter(void 0, void
|
|
|
90
91
|
exports._getUserCdps = _getUserCdps;
|
|
91
92
|
const getUserCdps = (provider, network, userAddress) => __awaiter(void 0, void 0, void 0, function* () { return (0, exports._getUserCdps)((0, viem_1.getViemProvider)(provider, network), network, userAddress); });
|
|
92
93
|
exports.getUserCdps = getUserCdps;
|
|
93
|
-
const
|
|
94
|
+
const _getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
95
|
const vatContract = (0, contracts_1.McdVatContractViem)(provider, network);
|
|
95
96
|
const spotterContract = (0, contracts_1.McdSpotterContractViem)(provider, network);
|
|
96
97
|
const dogContract = (0, contracts_1.McdDogContractViem)(provider, network);
|
|
97
98
|
const jugContract = (0, contracts_1.McdJugContractViem)(provider, network);
|
|
98
|
-
const
|
|
99
|
+
const par = yield spotterContract.read.par();
|
|
100
|
+
const ilksInfo = yield Promise.all(ilkLabels.map((ilkLabel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
const ilk = (0, tokens_1.stringToBytes)(ilkLabel);
|
|
102
|
+
const [[_, mat], [artGlobal, rate, spot, line, dust], [duty], futureRate, chop,] = yield Promise.all([
|
|
103
|
+
spotterContract.read.ilks([ilk]),
|
|
104
|
+
vatContract.read.ilks([ilk]),
|
|
105
|
+
jugContract.read.ilks([ilk]),
|
|
106
|
+
jugContract.read.drip([ilk]),
|
|
107
|
+
dogContract.read.chop([ilk]),
|
|
108
|
+
]);
|
|
109
|
+
return (0, makerHelpers_1.parseCollateralInfo)(ilk, par.toString(), mat.toString(), artGlobal.toString(), rate.toString(), spot.toString(), line.toString(), dust.toString(), duty.toString(), futureRate.toString(), chop.toString());
|
|
110
|
+
})));
|
|
111
|
+
return Object.fromEntries(ilksInfo.map((ilkInfo) => [ilkInfo.ilkLabel, ilkInfo]));
|
|
112
|
+
});
|
|
113
|
+
exports._getMakerIlksData = _getMakerIlksData;
|
|
114
|
+
const getMakerIlksData = (provider, network, ilkLabels) => __awaiter(void 0, void 0, void 0, function* () { return (0, exports._getMakerIlksData)((0, viem_1.getViemProvider)(provider, network, { batch: { multicall: true } }), network, ilkLabels); });
|
|
115
|
+
exports.getMakerIlksData = getMakerIlksData;
|
|
116
|
+
/**
|
|
117
|
+
* @param ilkInfo optional precomputed ilk data (from `_getMakerIlksData`); when provided the per-ilk reads are skipped
|
|
118
|
+
*/
|
|
119
|
+
const _getMakerCdpData = (provider, network, cdp, ilkInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
const vatContract = (0, contracts_1.McdVatContractViem)(provider, network);
|
|
121
|
+
const [[ink, art], coll, fetchedIlkInfo, collStakingApy,] = yield Promise.all([
|
|
99
122
|
vatContract.read.urns([cdp.ilk, cdp.urn]),
|
|
100
123
|
vatContract.read.gem([cdp.ilk, cdp.urn]),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
vatContract.read.ilks([cdp.ilk]),
|
|
104
|
-
jugContract.read.ilks([cdp.ilk]),
|
|
105
|
-
jugContract.read.drip([cdp.ilk]),
|
|
106
|
-
dogContract.read.chop([cdp.ilk]),
|
|
124
|
+
ilkInfo || (0, exports._getMakerIlksData)(provider, network, [cdp.ilkLabel]).then((ilks) => ilks[cdp.ilkLabel]),
|
|
125
|
+
staking_1.STAKING_ASSETS.includes(cdp.asset) ? (0, staking_1.getStakingApy)(cdp.asset) : Promise.resolve('0'),
|
|
107
126
|
]);
|
|
108
|
-
const collInfo =
|
|
127
|
+
const collInfo = fetchedIlkInfo;
|
|
109
128
|
const collateral = (0, tokens_1.assetAmountInEth)(ink.toString(), `MCD-${cdp.asset}`);
|
|
110
129
|
const collateralUsd = new decimal_js_1.default(collateral).mul(collInfo.assetPrice).toString();
|
|
111
130
|
const debt = new decimal_js_1.default(art).times(collInfo.currentRate).div(1e27).floor()
|
|
@@ -117,7 +136,16 @@ const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, void 0, v
|
|
|
117
136
|
.toString();
|
|
118
137
|
if (new decimal_js_1.default(debt).eq(0))
|
|
119
138
|
ratio = '0';
|
|
139
|
+
const safetyRatio = (0, moneymarket_1.getSafetyRatioFromCollateralRatio)(ratio, collInfo.liqPercent);
|
|
120
140
|
const debtTooLow = new decimal_js_1.default(debt).gt(0) && new decimal_js_1.default((0, tokens_1.assetAmountInEth)(debt, 'DAI')).lt(collInfo.minDebt);
|
|
141
|
+
// DAI debt accrues the ilk's stability fee. Collateral earns nothing inside the vault, except for the
|
|
142
|
+
// native yield of staked collateral (e.g. wstETH), which is tracked as an incentive.
|
|
143
|
+
const { netApy, totalInterestUsd, incentiveUsd } = (0, staking_1.calculateNetApyFromRates)({
|
|
144
|
+
suppliedUsd: collateralUsd,
|
|
145
|
+
borrowedUsd: (0, tokens_1.assetAmountInEth)(debt, 'DAI'),
|
|
146
|
+
borrowRate: collInfo.stabilityFee.toString(),
|
|
147
|
+
incentives: [{ apy: collStakingApy, amountUsd: collateralUsd }],
|
|
148
|
+
});
|
|
121
149
|
return {
|
|
122
150
|
owner: cdp.owner,
|
|
123
151
|
id: cdp.id.toString(),
|
|
@@ -136,6 +164,7 @@ const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, void 0, v
|
|
|
136
164
|
debtAssetMarketPrice: '1',
|
|
137
165
|
liquidationPrice,
|
|
138
166
|
ratio,
|
|
167
|
+
safetyRatio,
|
|
139
168
|
liqRatio: collInfo.liqRatio.toString(),
|
|
140
169
|
liqPercent: parseFloat(collInfo.liqPercent.toString()),
|
|
141
170
|
assetPrice: collInfo.assetPrice,
|
|
@@ -151,6 +180,9 @@ const _getMakerCdpData = (provider, network, cdp) => __awaiter(void 0, void 0, v
|
|
|
151
180
|
liquidationFee: collInfo.liquidationFee,
|
|
152
181
|
lastUpdated: Date.now(),
|
|
153
182
|
exposure: (0, moneymarket_1.getExposure)((0, tokens_1.assetAmountInEth)(debt, 'DAI'), collateralUsd),
|
|
183
|
+
netApy,
|
|
184
|
+
totalInterestUsd,
|
|
185
|
+
incentiveUsd,
|
|
154
186
|
};
|
|
155
187
|
});
|
|
156
188
|
exports._getMakerCdpData = _getMakerCdpData;
|
package/cjs/markets/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { LlamaLendMarkets } from './llamaLend';
|
|
|
8
8
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
10
|
export { AaveV4Spokes, findAaveV4SpokeByAddress } from './aaveV4';
|
|
11
|
+
export { MakerActiveIlks } from './maker';
|
package/cjs/markets/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.morphoMidnightVisibleCollaterals = exports.morphoMidnightMarketCollateralParams = exports.isTenorMidnightMarket = exports.findMorphoMidnightMarket = exports.MorphoMidnightMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
3
|
+
exports.MakerActiveIlks = exports.findAaveV4SpokeByAddress = exports.AaveV4Spokes = exports.getFluidMarketInfoByAddress = exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.morphoMidnightVisibleCollaterals = exports.morphoMidnightMarketCollateralParams = exports.isTenorMidnightMarket = exports.findMorphoMidnightMarket = exports.MorphoMidnightMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
4
4
|
var aave_1 = require("./aave");
|
|
5
5
|
Object.defineProperty(exports, "AaveMarkets", { enumerable: true, get: function () { return aave_1.AaveMarkets; } });
|
|
6
6
|
Object.defineProperty(exports, "aaveV1AssetsDefaultMarket", { enumerable: true, get: function () { return aave_1.aaveV1AssetsDefaultMarket; } });
|
|
@@ -42,3 +42,5 @@ Object.defineProperty(exports, "getFluidMarketInfoByAddress", { enumerable: true
|
|
|
42
42
|
var aaveV4_1 = require("./aaveV4");
|
|
43
43
|
Object.defineProperty(exports, "AaveV4Spokes", { enumerable: true, get: function () { return aaveV4_1.AaveV4Spokes; } });
|
|
44
44
|
Object.defineProperty(exports, "findAaveV4SpokeByAddress", { enumerable: true, get: function () { return aaveV4_1.findAaveV4SpokeByAddress; } });
|
|
45
|
+
var maker_1 = require("./maker");
|
|
46
|
+
Object.defineProperty(exports, "MakerActiveIlks", { enumerable: true, get: function () { return maker_1.MakerActiveIlks; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MakerActiveIlks: string[];
|
|
@@ -11,3 +11,12 @@ export declare const isLeveragedPos: (usedAssets: MMUsedAssets, dustLimit?: numb
|
|
|
11
11
|
};
|
|
12
12
|
export declare const aprToApy: (interest: string | number, frequency?: number) => string;
|
|
13
13
|
export declare const getExposure: (borrowedUsd: string, suppliedUsd: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* A collateral ratio rebased so that 100 means "sitting exactly on the liquidation ratio": the scale the
|
|
16
|
+
* shared `safetyRatio` field assumes. Protocols that liquidate on a raw collateral ratio (Maker at the ilk's
|
|
17
|
+
* liquidation ratio, Liquity at 110%, crvUSD/LlamaLend at the band-derived minimum) pass through here.
|
|
18
|
+
*
|
|
19
|
+
* Yields '0' when the liquidation ratio isn't available (or is 0), the "no signal" value consumers already recognise.
|
|
20
|
+
* Mirrors `getSafetyRatioFromCollateralRatio` on the client.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getSafetyRatioFromCollateralRatio: (collateralRatio: string | number | undefined, liquidationRatio: string | number | undefined) => string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getExposure = exports.aprToApy = exports.isLeveragedPos = exports.STABLE_ASSETS = exports.calculateBorrowingAssetLimit = exports.calcLeverageLiqPrice = exports.calcShortLiqPrice = exports.calcLongLiqPrice = exports.getAssetsTotal = void 0;
|
|
6
|
+
exports.getSafetyRatioFromCollateralRatio = exports.getExposure = exports.aprToApy = exports.isLeveragedPos = exports.STABLE_ASSETS = exports.calculateBorrowingAssetLimit = exports.calcLeverageLiqPrice = exports.calcShortLiqPrice = exports.calcLongLiqPrice = exports.getAssetsTotal = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -102,3 +102,15 @@ const getExposure = (borrowedUsd, suppliedUsd) => {
|
|
|
102
102
|
return new decimal_js_1.default(suppliedUsd).div(balanceUsd).toDecimalPlaces(2).toString();
|
|
103
103
|
};
|
|
104
104
|
exports.getExposure = getExposure;
|
|
105
|
+
/**
|
|
106
|
+
* A collateral ratio rebased so that 100 means "sitting exactly on the liquidation ratio": the scale the
|
|
107
|
+
* shared `safetyRatio` field assumes. Protocols that liquidate on a raw collateral ratio (Maker at the ilk's
|
|
108
|
+
* liquidation ratio, Liquity at 110%, crvUSD/LlamaLend at the band-derived minimum) pass through here.
|
|
109
|
+
*
|
|
110
|
+
* Yields '0' when the liquidation ratio isn't available (or is 0), the "no signal" value consumers already recognise.
|
|
111
|
+
* Mirrors `getSafetyRatioFromCollateralRatio` on the client.
|
|
112
|
+
*/
|
|
113
|
+
const getSafetyRatioFromCollateralRatio = (collateralRatio, liquidationRatio) => (+(liquidationRatio !== null && liquidationRatio !== void 0 ? liquidationRatio : 0) > 0
|
|
114
|
+
? new decimal_js_1.default(collateralRatio || 0).div(liquidationRatio).mul(100).toString()
|
|
115
|
+
: '0');
|
|
116
|
+
exports.getSafetyRatioFromCollateralRatio = getSafetyRatioFromCollateralRatio;
|
package/cjs/portfolio/index.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
2
|
-
import { PortfolioMarketsData, PortfolioPositionsData } from '../types';
|
|
3
|
-
|
|
2
|
+
import { PortfolioData, PortfolioDataOptions, PortfolioMarketsData, PortfolioMarketsResult, PortfolioPositionsData, PortfolioUserData, ShifterPortfolioMarketsData } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Every market the portfolio reads on a network — the markets half of getPortfolioData, for a caller that keeps
|
|
5
|
+
* markets apart from what it reads per address (a cache shared by many addresses). A market that fails is left out
|
|
6
|
+
* of `markets` and named in `errors`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPortfolioMarketsData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, isSim?: boolean): Promise<PortfolioMarketsResult>;
|
|
9
|
+
/**
|
|
10
|
+
* What the portfolio reads per address — the other half of getPortfolioData — against `markets` from
|
|
11
|
+
* getPortfolioMarketsData. `markets` can be a promise: reads that do not need a market (Maker, Fluid, Liquity, staking,
|
|
12
|
+
* rewards) start at once, and each read on a market waits for it. A position on a market missing from `markets` is an
|
|
13
|
+
* entry with an error.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getPortfolioUserData(provider: EthereumProvider, network: NetworkNumber, addresses: EthAddress[], markets: PortfolioMarketsData | Promise<PortfolioMarketsData>, isSim?: boolean, options?: PortfolioDataOptions): Promise<PortfolioUserData>;
|
|
16
|
+
export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean, options?: PortfolioDataOptions): Promise<PortfolioData>;
|
|
17
|
+
export declare function getShifterPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim?: boolean): Promise<{
|
|
4
18
|
positions: PortfolioPositionsData;
|
|
5
|
-
|
|
6
|
-
rewardsData: any;
|
|
7
|
-
markets: PortfolioMarketsData;
|
|
19
|
+
markets: ShifterPortfolioMarketsData;
|
|
8
20
|
}>;
|
|
9
21
|
export * from './discovery';
|