@defisaver/positions-sdk 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/aaveV3/index.d.ts +2 -2
- package/cjs/aaveV3/index.js +7 -7
- package/cjs/liquityV2/index.d.ts +10 -1
- package/cjs/liquityV2/index.js +12 -2
- package/esm/aaveV3/index.d.ts +2 -2
- package/esm/aaveV3/index.js +7 -7
- package/esm/liquityV2/index.d.ts +10 -1
- package/esm/liquityV2/index.js +12 -2
- package/package.json +1 -1
- package/src/aaveV3/index.ts +7 -7
- package/src/liquityV2/index.ts +12 -2
package/cjs/aaveV3/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const aaveV3CalculateDiscountRate: (debtBalance: string, discount
|
|
|
6
6
|
export declare const aaveV3EmodeCategoriesMapping: (extractedState: any, usedAssets: AaveV3UsedAssets) => {
|
|
7
7
|
[key: number]: EModeCategoryDataMapping;
|
|
8
8
|
};
|
|
9
|
-
export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3
|
|
9
|
+
export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3): Promise<AaveV3MarketData>;
|
|
10
10
|
export declare const EMPTY_AAVE_DATA: {
|
|
11
11
|
usedAssets: {};
|
|
12
12
|
suppliedUsd: string;
|
|
@@ -29,5 +29,5 @@ export declare const EMPTY_AAVE_DATA: {
|
|
|
29
29
|
suppliedCollateralUsd: string;
|
|
30
30
|
};
|
|
31
31
|
export declare const getAaveV3AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
32
|
-
export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any
|
|
32
|
+
export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any) => Promise<AaveV3PositionData>;
|
|
33
33
|
export declare const getAaveV3FullPositionData: (web3: Web3, network: NetworkNumber, address: string, market: AaveMarketInfo, mainnetWeb3: Web3) => Promise<AaveV3PositionData>;
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -72,7 +72,7 @@ const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
|
72
72
|
return categoriesMapping;
|
|
73
73
|
};
|
|
74
74
|
exports.aaveV3EmodeCategoriesMapping = aaveV3EmodeCategoriesMapping;
|
|
75
|
-
function getAaveV3MarketData(web3, network, market, defaultWeb3
|
|
75
|
+
function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
77
|
const _addresses = market.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a), network).address);
|
|
78
78
|
const isL2 = (0, utils_1.isLayer2Network)(network);
|
|
@@ -112,10 +112,10 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3, blockNumber = '
|
|
|
112
112
|
const ghoContract = (0, contracts_1.GhoTokenContract)(web3, network);
|
|
113
113
|
// eslint-disable-next-line prefer-const
|
|
114
114
|
let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
|
|
115
|
-
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(
|
|
116
|
-
loanInfoContract.methods.getAllEmodes(marketAddress).call(
|
|
117
|
-
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(
|
|
118
|
-
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : (0, multicall_1.multicall)(multicallCallsObject, web3, network
|
|
115
|
+
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
116
|
+
loanInfoContract.methods.getAllEmodes(marketAddress).call(),
|
|
117
|
+
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
|
|
118
|
+
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : (0, multicall_1.multicall)(multicallCallsObject, web3, network),
|
|
119
119
|
]);
|
|
120
120
|
isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
|
|
121
121
|
const eModeCategoriesData = {};
|
|
@@ -361,7 +361,7 @@ const getAaveV3AccountBalances = (web3, network, block, addressMapping, address)
|
|
|
361
361
|
return balances;
|
|
362
362
|
});
|
|
363
363
|
exports.getAaveV3AccountBalances = getAaveV3AccountBalances;
|
|
364
|
-
const getAaveV3AccountData = (web3, network, address, extractedState
|
|
364
|
+
const getAaveV3AccountData = (web3, network, address, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
365
365
|
const { selectedMarket: market, assetsData, eModeCategoriesData, } = extractedState;
|
|
366
366
|
let payload = Object.assign(Object.assign({}, exports.EMPTY_AAVE_DATA), { lastUpdated: Date.now() });
|
|
367
367
|
if (!address) {
|
|
@@ -395,7 +395,7 @@ const getAaveV3AccountData = (web3, network, address, extractedState, blockNumbe
|
|
|
395
395
|
},
|
|
396
396
|
];
|
|
397
397
|
const [multicallRes, { 0: stkAaveBalance }] = yield Promise.all([
|
|
398
|
-
(0, multicall_1.multicall)(multicallData, web3, network
|
|
398
|
+
(0, multicall_1.multicall)(multicallData, web3, network),
|
|
399
399
|
isL2 ? { 0: '0' } : (0, assets_1.getAssetsBalances)(['stkAAVE'], address, network, web3),
|
|
400
400
|
{ 0: '0' },
|
|
401
401
|
]);
|
package/cjs/liquityV2/index.d.ts
CHANGED
|
@@ -13,7 +13,16 @@ export declare const getDebtInFrontForInterestRateSingleMarketLiquityV2: (viewCo
|
|
|
13
13
|
export declare const getAllMarketsUnbackedDebts: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, web3: Web3, network: NetworkNumber) => Promise<Record<LiquityV2Versions, string>>;
|
|
14
14
|
export declare const calculateDebtInFrontLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, allMarketsUnbackedDebts: Record<LiquityV2Versions, string>, interestRateDebtInFront: string) => string;
|
|
15
15
|
export declare const getDebtInFrontLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, web3: Web3, network: NetworkNumber, viewContract: any, troveId: string) => Promise<string>;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @param markets
|
|
18
|
+
* @param selectedMarket
|
|
19
|
+
* @param web3
|
|
20
|
+
* @param network
|
|
21
|
+
* @param viewContract
|
|
22
|
+
* @param interestRate
|
|
23
|
+
* @param debtInFrontBeingMoved - amound of debt being repositioned if interest rate is being increased (prevents including it as debt in front)
|
|
24
|
+
*/
|
|
25
|
+
export declare const getDebtInFrontForInterestRateLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, web3: Web3, network: NetworkNumber, viewContract: any, interestRate: string, debtInFrontBeingMoved?: string) => Promise<string>;
|
|
17
26
|
export declare const getLiquityV2TroveData: (web3: Web3, network: NetworkNumber, { selectedMarket, assetsData, troveId, allMarketsData, }: {
|
|
18
27
|
selectedMarket: LiquityV2MarketInfo;
|
|
19
28
|
assetsData: LiquityV2AssetsData;
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -207,9 +207,19 @@ const getDebtInFrontLiquityV2 = (markets, selectedMarket, web3, network, viewCon
|
|
|
207
207
|
return (0, exports.calculateDebtInFrontLiquityV2)(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
208
208
|
});
|
|
209
209
|
exports.getDebtInFrontLiquityV2 = getDebtInFrontLiquityV2;
|
|
210
|
-
|
|
210
|
+
/**
|
|
211
|
+
* @param markets
|
|
212
|
+
* @param selectedMarket
|
|
213
|
+
* @param web3
|
|
214
|
+
* @param network
|
|
215
|
+
* @param viewContract
|
|
216
|
+
* @param interestRate
|
|
217
|
+
* @param debtInFrontBeingMoved - amound of debt being repositioned if interest rate is being increased (prevents including it as debt in front)
|
|
218
|
+
*/
|
|
219
|
+
const getDebtInFrontForInterestRateLiquityV2 = (markets, selectedMarket, web3, network, viewContract, interestRate, debtInFrontBeingMoved = '0') => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
220
|
const allMarketsUnbackedDebts = yield (0, exports.getAllMarketsUnbackedDebts)(markets, web3, network);
|
|
212
|
-
const interestRateDebtInFront = new decimal_js_1.default(yield (0, exports.getDebtInFrontForInterestRateSingleMarketLiquityV2)(viewContract, (0, markets_1.LiquityV2Markets)(network)[selectedMarket].marketAddress, interestRate))
|
|
221
|
+
const interestRateDebtInFront = new decimal_js_1.default(yield (0, exports.getDebtInFrontForInterestRateSingleMarketLiquityV2)(viewContract, (0, markets_1.LiquityV2Markets)(network)[selectedMarket].marketAddress, interestRate))
|
|
222
|
+
.sub(debtInFrontBeingMoved);
|
|
213
223
|
return (0, exports.calculateDebtInFrontLiquityV2)(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
214
224
|
});
|
|
215
225
|
exports.getDebtInFrontForInterestRateLiquityV2 = getDebtInFrontForInterestRateLiquityV2;
|
package/esm/aaveV3/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const aaveV3CalculateDiscountRate: (debtBalance: string, discount
|
|
|
6
6
|
export declare const aaveV3EmodeCategoriesMapping: (extractedState: any, usedAssets: AaveV3UsedAssets) => {
|
|
7
7
|
[key: number]: EModeCategoryDataMapping;
|
|
8
8
|
};
|
|
9
|
-
export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3
|
|
9
|
+
export declare function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3): Promise<AaveV3MarketData>;
|
|
10
10
|
export declare const EMPTY_AAVE_DATA: {
|
|
11
11
|
usedAssets: {};
|
|
12
12
|
suppliedUsd: string;
|
|
@@ -29,5 +29,5 @@ export declare const EMPTY_AAVE_DATA: {
|
|
|
29
29
|
suppliedCollateralUsd: string;
|
|
30
30
|
};
|
|
31
31
|
export declare const getAaveV3AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
32
|
-
export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any
|
|
32
|
+
export declare const getAaveV3AccountData: (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any) => Promise<AaveV3PositionData>;
|
|
33
33
|
export declare const getAaveV3FullPositionData: (web3: Web3, network: NetworkNumber, address: string, market: AaveMarketInfo, mainnetWeb3: Web3) => Promise<AaveV3PositionData>;
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -63,7 +63,7 @@ export const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
|
63
63
|
});
|
|
64
64
|
return categoriesMapping;
|
|
65
65
|
};
|
|
66
|
-
export function getAaveV3MarketData(web3, network, market, defaultWeb3
|
|
66
|
+
export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
67
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
68
|
const _addresses = market.assets.map(a => getAssetInfo(ethToWeth(a), network).address);
|
|
69
69
|
const isL2 = isLayer2Network(network);
|
|
@@ -103,10 +103,10 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3, blockNum
|
|
|
103
103
|
const ghoContract = GhoTokenContract(web3, network);
|
|
104
104
|
// eslint-disable-next-line prefer-const
|
|
105
105
|
let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
|
|
106
|
-
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(
|
|
107
|
-
loanInfoContract.methods.getAllEmodes(marketAddress).call(
|
|
108
|
-
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(
|
|
109
|
-
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network
|
|
106
|
+
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
107
|
+
loanInfoContract.methods.getAllEmodes(marketAddress).call(),
|
|
108
|
+
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
|
|
109
|
+
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network),
|
|
110
110
|
]);
|
|
111
111
|
isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
|
|
112
112
|
const eModeCategoriesData = {};
|
|
@@ -350,7 +350,7 @@ export const getAaveV3AccountBalances = (web3, network, block, addressMapping, a
|
|
|
350
350
|
});
|
|
351
351
|
return balances;
|
|
352
352
|
});
|
|
353
|
-
export const getAaveV3AccountData = (web3, network, address, extractedState
|
|
353
|
+
export const getAaveV3AccountData = (web3, network, address, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
|
|
354
354
|
const { selectedMarket: market, assetsData, eModeCategoriesData, } = extractedState;
|
|
355
355
|
let payload = Object.assign(Object.assign({}, EMPTY_AAVE_DATA), { lastUpdated: Date.now() });
|
|
356
356
|
if (!address) {
|
|
@@ -384,7 +384,7 @@ export const getAaveV3AccountData = (web3, network, address, extractedState, blo
|
|
|
384
384
|
},
|
|
385
385
|
];
|
|
386
386
|
const [multicallRes, { 0: stkAaveBalance }] = yield Promise.all([
|
|
387
|
-
multicall(multicallData, web3, network
|
|
387
|
+
multicall(multicallData, web3, network),
|
|
388
388
|
isL2 ? { 0: '0' } : getAssetsBalances(['stkAAVE'], address, network, web3),
|
|
389
389
|
{ 0: '0' },
|
|
390
390
|
]);
|
package/esm/liquityV2/index.d.ts
CHANGED
|
@@ -13,7 +13,16 @@ export declare const getDebtInFrontForInterestRateSingleMarketLiquityV2: (viewCo
|
|
|
13
13
|
export declare const getAllMarketsUnbackedDebts: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, web3: Web3, network: NetworkNumber) => Promise<Record<LiquityV2Versions, string>>;
|
|
14
14
|
export declare const calculateDebtInFrontLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, allMarketsUnbackedDebts: Record<LiquityV2Versions, string>, interestRateDebtInFront: string) => string;
|
|
15
15
|
export declare const getDebtInFrontLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, web3: Web3, network: NetworkNumber, viewContract: any, troveId: string) => Promise<string>;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @param markets
|
|
18
|
+
* @param selectedMarket
|
|
19
|
+
* @param web3
|
|
20
|
+
* @param network
|
|
21
|
+
* @param viewContract
|
|
22
|
+
* @param interestRate
|
|
23
|
+
* @param debtInFrontBeingMoved - amound of debt being repositioned if interest rate is being increased (prevents including it as debt in front)
|
|
24
|
+
*/
|
|
25
|
+
export declare const getDebtInFrontForInterestRateLiquityV2: (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, web3: Web3, network: NetworkNumber, viewContract: any, interestRate: string, debtInFrontBeingMoved?: string) => Promise<string>;
|
|
17
26
|
export declare const getLiquityV2TroveData: (web3: Web3, network: NetworkNumber, { selectedMarket, assetsData, troveId, allMarketsData, }: {
|
|
18
27
|
selectedMarket: LiquityV2MarketInfo;
|
|
19
28
|
assetsData: LiquityV2AssetsData;
|
package/esm/liquityV2/index.js
CHANGED
|
@@ -194,9 +194,19 @@ export const getDebtInFrontLiquityV2 = (markets, selectedMarket, web3, network,
|
|
|
194
194
|
const interestRateDebtInFront = yield getDebtInFrontForSingleMarketLiquityV2(viewContract, LiquityV2Markets(network)[selectedMarket].marketAddress, troveId);
|
|
195
195
|
return calculateDebtInFrontLiquityV2(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
196
196
|
});
|
|
197
|
-
|
|
197
|
+
/**
|
|
198
|
+
* @param markets
|
|
199
|
+
* @param selectedMarket
|
|
200
|
+
* @param web3
|
|
201
|
+
* @param network
|
|
202
|
+
* @param viewContract
|
|
203
|
+
* @param interestRate
|
|
204
|
+
* @param debtInFrontBeingMoved - amound of debt being repositioned if interest rate is being increased (prevents including it as debt in front)
|
|
205
|
+
*/
|
|
206
|
+
export const getDebtInFrontForInterestRateLiquityV2 = (markets, selectedMarket, web3, network, viewContract, interestRate, debtInFrontBeingMoved = '0') => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
207
|
const allMarketsUnbackedDebts = yield getAllMarketsUnbackedDebts(markets, web3, network);
|
|
199
|
-
const interestRateDebtInFront = new Dec(yield getDebtInFrontForInterestRateSingleMarketLiquityV2(viewContract, LiquityV2Markets(network)[selectedMarket].marketAddress, interestRate))
|
|
208
|
+
const interestRateDebtInFront = new Dec(yield getDebtInFrontForInterestRateSingleMarketLiquityV2(viewContract, LiquityV2Markets(network)[selectedMarket].marketAddress, interestRate))
|
|
209
|
+
.sub(debtInFrontBeingMoved);
|
|
200
210
|
return calculateDebtInFrontLiquityV2(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
201
211
|
});
|
|
202
212
|
export const getLiquityV2TroveData = (web3, network, { selectedMarket, assetsData, troveId, allMarketsData, }) => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -97,7 +97,7 @@ export const aaveV3EmodeCategoriesMapping = (extractedState: any, usedAssets: Aa
|
|
|
97
97
|
return categoriesMapping;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3
|
|
100
|
+
export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, market: AaveMarketInfo, defaultWeb3: Web3): Promise<AaveV3MarketData> {
|
|
101
101
|
const _addresses = market.assets.map(a => getAssetInfo(ethToWeth(a), network).address);
|
|
102
102
|
|
|
103
103
|
const isL2 = isLayer2Network(network);
|
|
@@ -142,10 +142,10 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
142
142
|
|
|
143
143
|
// eslint-disable-next-line prefer-const
|
|
144
144
|
let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = await Promise.all([
|
|
145
|
-
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(
|
|
146
|
-
loanInfoContract.methods.getAllEmodes(marketAddress).call(
|
|
147
|
-
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(
|
|
148
|
-
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network
|
|
145
|
+
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
146
|
+
loanInfoContract.methods.getAllEmodes(marketAddress).call(),
|
|
147
|
+
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(), // Used on L2s check for PriceOracleSentinel (mainnet will always return true)
|
|
148
|
+
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network),
|
|
149
149
|
]);
|
|
150
150
|
isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
|
|
151
151
|
|
|
@@ -469,7 +469,7 @@ export const getAaveV3AccountBalances = async (web3: Web3, network: NetworkNumbe
|
|
|
469
469
|
return balances;
|
|
470
470
|
};
|
|
471
471
|
|
|
472
|
-
export const getAaveV3AccountData = async (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any
|
|
472
|
+
export const getAaveV3AccountData = async (web3: Web3, network: NetworkNumber, address: EthAddress, extractedState: any): Promise<AaveV3PositionData> => {
|
|
473
473
|
const {
|
|
474
474
|
selectedMarket: market, assetsData, eModeCategoriesData,
|
|
475
475
|
} = extractedState;
|
|
@@ -515,7 +515,7 @@ export const getAaveV3AccountData = async (web3: Web3, network: NetworkNumber, a
|
|
|
515
515
|
];
|
|
516
516
|
|
|
517
517
|
const [multicallRes, { 0: stkAaveBalance }] = await Promise.all([
|
|
518
|
-
multicall(multicallData, web3, network
|
|
518
|
+
multicall(multicallData, web3, network),
|
|
519
519
|
isL2 ? { 0: '0' } : getAssetsBalances(['stkAAVE'], address, network, web3),
|
|
520
520
|
{ 0: '0' },
|
|
521
521
|
]);
|
package/src/liquityV2/index.ts
CHANGED
|
@@ -223,9 +223,19 @@ export const getDebtInFrontLiquityV2 = async (markets: Record<LiquityV2Versions,
|
|
|
223
223
|
return calculateDebtInFrontLiquityV2(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
|
|
226
|
+
/**
|
|
227
|
+
* @param markets
|
|
228
|
+
* @param selectedMarket
|
|
229
|
+
* @param web3
|
|
230
|
+
* @param network
|
|
231
|
+
* @param viewContract
|
|
232
|
+
* @param interestRate
|
|
233
|
+
* @param debtInFrontBeingMoved - amound of debt being repositioned if interest rate is being increased (prevents including it as debt in front)
|
|
234
|
+
*/
|
|
235
|
+
export const getDebtInFrontForInterestRateLiquityV2 = async (markets: Record<LiquityV2Versions, LiquityV2MarketData>, selectedMarket: LiquityV2Versions, web3: Web3, network: NetworkNumber, viewContract: any, interestRate: string, debtInFrontBeingMoved: string = '0') => {
|
|
227
236
|
const allMarketsUnbackedDebts = await getAllMarketsUnbackedDebts(markets, web3, network);
|
|
228
|
-
const interestRateDebtInFront = new Dec(await getDebtInFrontForInterestRateSingleMarketLiquityV2(viewContract, LiquityV2Markets(network)[selectedMarket].marketAddress, interestRate))
|
|
237
|
+
const interestRateDebtInFront = new Dec(await getDebtInFrontForInterestRateSingleMarketLiquityV2(viewContract, LiquityV2Markets(network)[selectedMarket].marketAddress, interestRate))
|
|
238
|
+
.sub(debtInFrontBeingMoved);
|
|
229
239
|
|
|
230
240
|
return calculateDebtInFrontLiquityV2(markets, selectedMarket, allMarketsUnbackedDebts, interestRateDebtInFront.toString());
|
|
231
241
|
};
|