@defisaver/positions-sdk 0.0.98 → 0.0.100
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/README.md +63 -63
- package/cjs/config/contracts.d.ts +361 -15
- package/cjs/config/contracts.js +37 -15
- package/cjs/helpers/morphoBlueHelpers/index.d.ts +9 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -1
- package/cjs/maker/index.js +1 -1
- package/cjs/morphoBlue/index.js +4 -27
- package/cjs/types/contracts/generated/AaveV3View.d.ts +29 -2
- package/cjs/types/contracts/generated/MorphoBlueView.d.ts +61 -0
- package/cjs/types/contracts/generated/SparkView.d.ts +29 -2
- package/esm/config/contracts.d.ts +361 -15
- package/esm/config/contracts.js +37 -15
- package/esm/helpers/morphoBlueHelpers/index.d.ts +9 -2
- package/esm/helpers/morphoBlueHelpers/index.js +62 -0
- package/esm/maker/index.js +1 -1
- package/esm/morphoBlue/index.js +4 -27
- package/esm/types/contracts/generated/AaveV3View.d.ts +29 -2
- package/esm/types/contracts/generated/MorphoBlueView.d.ts +61 -0
- package/esm/types/contracts/generated/SparkView.d.ts +29 -2
- package/package.json +41 -40
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +558 -558
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +219 -219
- package/src/compoundV3/index.ts +266 -266
- package/src/config/contracts.js +871 -848
- package/src/constants/index.ts +5 -5
- package/src/contracts.ts +128 -128
- package/src/curveUsd/index.ts +229 -229
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +134 -134
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +181 -181
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/index.ts +7 -7
- package/src/helpers/llamaLendHelpers/index.ts +45 -45
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +117 -56
- package/src/helpers/sparkHelpers/index.ts +106 -106
- package/src/index.ts +46 -46
- package/src/liquity/index.ts +116 -116
- package/src/llamaLend/index.ts +268 -268
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +80 -80
- package/src/markets/aave/marketAssets.ts +24 -24
- package/src/markets/compound/index.ts +142 -142
- package/src/markets/compound/marketsAssets.ts +50 -50
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/index.ts +5 -5
- package/src/markets/llamaLend/contractAddresses.ts +95 -95
- package/src/markets/llamaLend/index.ts +150 -150
- package/src/markets/morphoBlue/index.ts +611 -611
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +76 -76
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +612 -612
- package/src/morphoBlue/index.ts +171 -199
- package/src/multicall/index.ts +22 -22
- package/src/services/dsrService.ts +15 -15
- package/src/services/priceService.ts +21 -21
- package/src/services/utils.ts +51 -51
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +424 -424
- package/src/staking/staking.ts +187 -187
- package/src/types/aave.ts +256 -256
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +128 -128
- package/src/types/contracts/generated/AaveV3View.ts +43 -3
- package/src/types/contracts/generated/MorphoBlueView.ts +87 -0
- package/src/types/contracts/generated/SparkView.ts +43 -3
- package/src/types/curveUsd.ts +118 -118
- package/src/types/index.ts +8 -8
- package/src/types/liquity.ts +30 -30
- package/src/types/llamaLend.ts +143 -143
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +139 -139
- package/src/types/spark.ts +106 -106
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import Web3 from 'web3';
|
|
2
|
+
import { MMUsedAssets, NetworkNumber } from '../../types/common';
|
|
3
|
+
import { MorphoBlueAggregatedPositionData, MorphoBlueAssetsData, MorphoBlueMarketData, MorphoBlueMarketInfo } from '../../types';
|
|
3
4
|
export declare const getMorphoBlueAggregatedPositionData: ({ usedAssets, assetsData, marketInfo }: {
|
|
4
5
|
usedAssets: MMUsedAssets;
|
|
5
6
|
assetsData: MorphoBlueAssetsData;
|
|
6
7
|
marketInfo: MorphoBlueMarketInfo;
|
|
7
8
|
}) => MorphoBlueAggregatedPositionData;
|
|
9
|
+
export declare const getSupplyRate: (totalSupplyAssets: string, totalBorrowAssets: string, borrowRate: string, fee: string) => string;
|
|
10
|
+
export declare const getBorrowRate: (borrowRate: string, totalBorrowShares: string) => string;
|
|
11
|
+
export declare const getApyAfterValuesEstimation: (selectedMarket: MorphoBlueMarketData, action: string, amount: string, asset: string, web3: Web3, network: NetworkNumber) => Promise<{
|
|
12
|
+
borrowRate: string;
|
|
13
|
+
supplyRate: string;
|
|
14
|
+
}>;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getMorphoBlueAggregatedPositionData = void 0;
|
|
15
|
+
exports.getApyAfterValuesEstimation = exports.getBorrowRate = exports.getSupplyRate = exports.getMorphoBlueAggregatedPositionData = void 0;
|
|
7
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
8
18
|
const moneymarket_1 = require("../../moneymarket");
|
|
9
19
|
const staking_1 = require("../../staking");
|
|
20
|
+
const constants_1 = require("../../constants");
|
|
21
|
+
const contracts_1 = require("../../contracts");
|
|
10
22
|
const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInfo }) => {
|
|
11
23
|
var _a, _b, _c, _d, _e, _f;
|
|
12
24
|
const payload = {};
|
|
@@ -46,3 +58,56 @@ const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInf
|
|
|
46
58
|
return payload;
|
|
47
59
|
};
|
|
48
60
|
exports.getMorphoBlueAggregatedPositionData = getMorphoBlueAggregatedPositionData;
|
|
61
|
+
const compound = (ratePerSeconds) => {
|
|
62
|
+
const compounding = new decimal_js_1.default(ratePerSeconds).mul(constants_1.SECONDS_PER_YEAR).toString();
|
|
63
|
+
const apyNumber = Math.expm1(new decimal_js_1.default(compounding).div(constants_1.WAD).toNumber());
|
|
64
|
+
return new decimal_js_1.default(apyNumber).mul(constants_1.WAD).floor().toString();
|
|
65
|
+
};
|
|
66
|
+
const getSupplyRate = (totalSupplyAssets, totalBorrowAssets, borrowRate, fee) => {
|
|
67
|
+
if (totalBorrowAssets === '0' || totalSupplyAssets === '0') {
|
|
68
|
+
return '0';
|
|
69
|
+
}
|
|
70
|
+
const utillization = new decimal_js_1.default(totalBorrowAssets).mul(constants_1.WAD).div(totalSupplyAssets).ceil()
|
|
71
|
+
.toString();
|
|
72
|
+
const supplyRate = new decimal_js_1.default(utillization).mul(borrowRate).div(constants_1.WAD).ceil()
|
|
73
|
+
.toString();
|
|
74
|
+
const ratePerSecond = new decimal_js_1.default(supplyRate).mul(new decimal_js_1.default(constants_1.WAD).minus(fee)).div(constants_1.WAD).ceil()
|
|
75
|
+
.toString();
|
|
76
|
+
return new decimal_js_1.default(compound(ratePerSecond)).div(1e18).mul(100).toString();
|
|
77
|
+
};
|
|
78
|
+
exports.getSupplyRate = getSupplyRate;
|
|
79
|
+
const getBorrowRate = (borrowRate, totalBorrowShares) => {
|
|
80
|
+
if (totalBorrowShares === '0') {
|
|
81
|
+
return '0';
|
|
82
|
+
}
|
|
83
|
+
return new decimal_js_1.default(compound(borrowRate)).div(1e18).mul(100).toString();
|
|
84
|
+
};
|
|
85
|
+
exports.getBorrowRate = getBorrowRate;
|
|
86
|
+
const borrowOperations = ['borrow', 'payback'];
|
|
87
|
+
const getApyAfterValuesEstimation = (selectedMarket, action, amount, asset, web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const morphoBlueViewContract = (0, contracts_1.MorphoBlueViewContract)(web3, network);
|
|
89
|
+
const lltvInWei = (0, tokens_1.assetAmountInWei)(selectedMarket.lltv, 'ETH');
|
|
90
|
+
const marketData = [selectedMarket.loanToken, selectedMarket.collateralToken, selectedMarket.oracle, selectedMarket.irm, lltvInWei];
|
|
91
|
+
const isBorrowOperation = borrowOperations.includes(action);
|
|
92
|
+
const amountInWei = (0, tokens_1.assetAmountInWei)(amount, asset);
|
|
93
|
+
let liquidityAdded;
|
|
94
|
+
let liquidityRemoved;
|
|
95
|
+
if (isBorrowOperation) {
|
|
96
|
+
liquidityAdded = action === 'payback' ? amountInWei : '0';
|
|
97
|
+
liquidityRemoved = action === 'borrow' ? amountInWei : '0';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
liquidityAdded = action === 'collateral' ? amountInWei : '0';
|
|
101
|
+
liquidityRemoved = action === 'withdraw' ? amountInWei : '0';
|
|
102
|
+
}
|
|
103
|
+
const data = yield morphoBlueViewContract.methods.getApyAfterValuesEstimation([
|
|
104
|
+
marketData,
|
|
105
|
+
isBorrowOperation,
|
|
106
|
+
liquidityAdded,
|
|
107
|
+
liquidityRemoved,
|
|
108
|
+
]).call();
|
|
109
|
+
const borrowRate = (0, exports.getBorrowRate)(data.borrowRate, data.market.totalBorrowShares);
|
|
110
|
+
const supplyRate = (0, exports.getSupplyRate)(data.market.totalSupplyAssets, data.market.totalBorrowAssets, data.borrowRate, data.market.fee);
|
|
111
|
+
return { borrowRate, supplyRate };
|
|
112
|
+
});
|
|
113
|
+
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
package/cjs/maker/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const getMakerAccountBalances = (web3, network, block, addressMapping, cdpId, _m
|
|
|
29
29
|
}
|
|
30
30
|
const viewContract = (0, contracts_1.McdViewContract)(web3, network, block);
|
|
31
31
|
let ilk;
|
|
32
|
-
const needsIlk = new decimal_js_1.default(block).lt(14410792) && new decimal_js_1.default(block).gte(14384301);
|
|
32
|
+
const needsIlk = block !== 'latest' && new decimal_js_1.default(block).lt(14410792) && new decimal_js_1.default(block).gte(14384301);
|
|
33
33
|
if (needsIlk) {
|
|
34
34
|
ilk = (yield viewContract.methods.getUrnAndIlk(managerAddress, cdpId).call({}, block)).ilk;
|
|
35
35
|
}
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -21,29 +21,6 @@ const constants_1 = require("../constants");
|
|
|
21
21
|
const staking_1 = require("../staking");
|
|
22
22
|
const utils_1 = require("../services/utils");
|
|
23
23
|
const morphoBlueHelpers_1 = require("../helpers/morphoBlueHelpers");
|
|
24
|
-
const compound = (ratePerSeconds) => {
|
|
25
|
-
const compounding = new decimal_js_1.default(ratePerSeconds).mul(constants_1.SECONDS_PER_YEAR).toString();
|
|
26
|
-
const apyNumber = Math.expm1(new decimal_js_1.default(compounding).div(constants_1.WAD).toNumber());
|
|
27
|
-
return new decimal_js_1.default(apyNumber).mul(constants_1.WAD).floor().toString();
|
|
28
|
-
};
|
|
29
|
-
const getSupplyRate = (totalSupplyAssets, totalBorrowAssets, borrowRate, fee) => {
|
|
30
|
-
if (totalBorrowAssets === '0' || totalSupplyAssets === '0') {
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
const utillization = new decimal_js_1.default(totalBorrowAssets).mul(constants_1.WAD).div(totalSupplyAssets).ceil()
|
|
34
|
-
.toString();
|
|
35
|
-
const supplyRate = new decimal_js_1.default(utillization).mul(borrowRate).div(constants_1.WAD).ceil()
|
|
36
|
-
.toString();
|
|
37
|
-
const ratePerSecond = new decimal_js_1.default(supplyRate).mul(new decimal_js_1.default(constants_1.WAD).minus(fee)).div(constants_1.WAD).ceil()
|
|
38
|
-
.toString();
|
|
39
|
-
return compound(ratePerSecond);
|
|
40
|
-
};
|
|
41
|
-
const getBorrowRate = (borrowRate, totalBorrowShares) => {
|
|
42
|
-
if (totalBorrowShares === '0') {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
return compound(borrowRate);
|
|
46
|
-
};
|
|
47
24
|
function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
48
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
26
|
const { loanToken, collateralToken, oracle, irm, lltv, oracleType, } = selectedMarket;
|
|
@@ -61,8 +38,8 @@ function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
|
61
38
|
loanTokenInfo.symbol === 'USDA' ? '100000000' : feedRegistryContract.methods.latestAnswer(loanTokenFeedAddress, constants_1.USD_QUOTE).call(),
|
|
62
39
|
morphoBlueViewContract.methods.getMarketInfoNotTuple(loanToken, collateralToken, oracle, irm, lltvInWei).call(),
|
|
63
40
|
]);
|
|
64
|
-
const supplyRate = getSupplyRate(marketInfo.totalSupplyAssets, marketInfo.totalBorrowAssets, marketInfo.borrowRate, marketInfo.fee);
|
|
65
|
-
const compoundedBorrowRate = getBorrowRate(marketInfo.borrowRate, marketInfo.totalBorrowShares);
|
|
41
|
+
const supplyRate = (0, morphoBlueHelpers_1.getSupplyRate)(marketInfo.totalSupplyAssets, marketInfo.totalBorrowAssets, marketInfo.borrowRate, marketInfo.fee);
|
|
42
|
+
const compoundedBorrowRate = (0, morphoBlueHelpers_1.getBorrowRate)(marketInfo.borrowRate, marketInfo.totalBorrowShares);
|
|
66
43
|
const utillization = new decimal_js_1.default(marketInfo.totalBorrowAssets).div(marketInfo.totalSupplyAssets).mul(100).toString();
|
|
67
44
|
const oracleScaleFactor = new decimal_js_1.default(36).add(loanTokenInfo.decimals).sub(collateralTokenInfo.decimals).toString();
|
|
68
45
|
const oracleScale = new decimal_js_1.default(10).pow(oracleScaleFactor).toString();
|
|
@@ -73,8 +50,8 @@ function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
|
73
50
|
symbol: (0, utils_1.wethToEth)(loanTokenInfo.symbol),
|
|
74
51
|
address: loanToken,
|
|
75
52
|
price: new decimal_js_1.default(loanTokenPrice).div(1e8).toString(),
|
|
76
|
-
supplyRate
|
|
77
|
-
borrowRate:
|
|
53
|
+
supplyRate,
|
|
54
|
+
borrowRate: compoundedBorrowRate,
|
|
78
55
|
totalSupply: new decimal_js_1.default(marketInfo.totalSupplyAssets).div(scale).toString(),
|
|
79
56
|
totalBorrow: new decimal_js_1.default(marketInfo.totalBorrowAssets).div(scale).toString(),
|
|
80
57
|
canBeSupplied: true,
|
|
@@ -10,6 +10,30 @@ export interface EventOptions {
|
|
|
10
10
|
topics?: string[];
|
|
11
11
|
}
|
|
12
12
|
export declare namespace AaveV3View {
|
|
13
|
+
type LiquidityChangeParamsStruct = [string, number | string | BN, number | string | BN] | {
|
|
14
|
+
reserveAddress: string;
|
|
15
|
+
liquidityAdded: number | string | BN;
|
|
16
|
+
liquidityTaken: number | string | BN;
|
|
17
|
+
};
|
|
18
|
+
type LiquidityChangeParamsStructOutputArray = [string, string, string];
|
|
19
|
+
type LiquidityChangeParamsStructOutputStruct = {
|
|
20
|
+
reserveAddress: string;
|
|
21
|
+
liquidityAdded: string;
|
|
22
|
+
liquidityTaken: string;
|
|
23
|
+
};
|
|
24
|
+
type LiquidityChangeParamsStructOutput = LiquidityChangeParamsStructOutputArray & LiquidityChangeParamsStructOutputStruct;
|
|
25
|
+
type EstimatedRatesStruct = [string, number | string | BN, number | string | BN] | {
|
|
26
|
+
reserveAddress: string;
|
|
27
|
+
supplyRate: number | string | BN;
|
|
28
|
+
variableBorrowRate: number | string | BN;
|
|
29
|
+
};
|
|
30
|
+
type EstimatedRatesStructOutputArray = [string, string, string];
|
|
31
|
+
type EstimatedRatesStructOutputStruct = {
|
|
32
|
+
reserveAddress: string;
|
|
33
|
+
supplyRate: string;
|
|
34
|
+
variableBorrowRate: string;
|
|
35
|
+
};
|
|
36
|
+
type EstimatedRatesStructOutput = EstimatedRatesStructOutputArray & EstimatedRatesStructOutputStruct;
|
|
13
37
|
type TokenInfoFullStruct = [
|
|
14
38
|
string,
|
|
15
39
|
string,
|
|
@@ -159,6 +183,7 @@ export declare namespace AaveV3View {
|
|
|
159
183
|
number | string | BN,
|
|
160
184
|
number | string | BN,
|
|
161
185
|
string[],
|
|
186
|
+
boolean[],
|
|
162
187
|
string[],
|
|
163
188
|
number | string | BN[],
|
|
164
189
|
number | string | BN[],
|
|
@@ -173,6 +198,7 @@ export declare namespace AaveV3View {
|
|
|
173
198
|
ratio: number | string | BN;
|
|
174
199
|
eMode: number | string | BN;
|
|
175
200
|
collAddr: string[];
|
|
201
|
+
enabledAsColl: boolean[];
|
|
176
202
|
borrowAddr: string[];
|
|
177
203
|
collAmounts: number | string | BN[];
|
|
178
204
|
borrowStableAmounts: number | string | BN[];
|
|
@@ -188,6 +214,7 @@ export declare namespace AaveV3View {
|
|
|
188
214
|
string,
|
|
189
215
|
string,
|
|
190
216
|
string[],
|
|
217
|
+
boolean[],
|
|
191
218
|
string[],
|
|
192
219
|
string[],
|
|
193
220
|
string[],
|
|
@@ -203,6 +230,7 @@ export declare namespace AaveV3View {
|
|
|
203
230
|
ratio: string;
|
|
204
231
|
eMode: string;
|
|
205
232
|
collAddr: string[];
|
|
233
|
+
enabledAsColl: boolean[];
|
|
206
234
|
borrowAddr: string[];
|
|
207
235
|
collAmounts: string[];
|
|
208
236
|
borrowStableAmounts: string[];
|
|
@@ -276,8 +304,7 @@ export interface AaveV3View extends BaseContract {
|
|
|
276
304
|
clone(): AaveV3View;
|
|
277
305
|
methods: {
|
|
278
306
|
AAVE_REFERRAL_CODE(): NonPayableTransactionObject<string>;
|
|
279
|
-
|
|
280
|
-
VARIABLE_ID(): NonPayableTransactionObject<string>;
|
|
307
|
+
getApyAfterValuesEstimation(_market: string, _reserveParams: AaveV3View.LiquidityChangeParamsStruct[]): NonPayableTransactionObject<AaveV3View.EstimatedRatesStructOutput[]>;
|
|
281
308
|
getAssetPrice(_market: string, _tokenAddr: string): NonPayableTransactionObject<string>;
|
|
282
309
|
getCollFactors(_market: string, _tokens: string[]): NonPayableTransactionObject<string[]>;
|
|
283
310
|
getEModeCollateralFactor(emodeCategory: number | string | BN, lendingPool: string): NonPayableTransactionObject<string>;
|
|
@@ -31,7 +31,58 @@ export type MarketParamsStructOutputStruct = {
|
|
|
31
31
|
lltv: string;
|
|
32
32
|
};
|
|
33
33
|
export type MarketParamsStructOutput = MarketParamsStructOutputArray & MarketParamsStructOutputStruct;
|
|
34
|
+
export type MarketStruct = [
|
|
35
|
+
number | string | BN,
|
|
36
|
+
number | string | BN,
|
|
37
|
+
number | string | BN,
|
|
38
|
+
number | string | BN,
|
|
39
|
+
number | string | BN,
|
|
40
|
+
number | string | BN
|
|
41
|
+
] | {
|
|
42
|
+
totalSupplyAssets: number | string | BN;
|
|
43
|
+
totalSupplyShares: number | string | BN;
|
|
44
|
+
totalBorrowAssets: number | string | BN;
|
|
45
|
+
totalBorrowShares: number | string | BN;
|
|
46
|
+
lastUpdate: number | string | BN;
|
|
47
|
+
fee: number | string | BN;
|
|
48
|
+
};
|
|
49
|
+
export type MarketStructOutputArray = [
|
|
50
|
+
string,
|
|
51
|
+
string,
|
|
52
|
+
string,
|
|
53
|
+
string,
|
|
54
|
+
string,
|
|
55
|
+
string
|
|
56
|
+
];
|
|
57
|
+
export type MarketStructOutputStruct = {
|
|
58
|
+
totalSupplyAssets: string;
|
|
59
|
+
totalSupplyShares: string;
|
|
60
|
+
totalBorrowAssets: string;
|
|
61
|
+
totalBorrowShares: string;
|
|
62
|
+
lastUpdate: string;
|
|
63
|
+
fee: string;
|
|
64
|
+
};
|
|
65
|
+
export type MarketStructOutput = MarketStructOutputArray & MarketStructOutputStruct;
|
|
34
66
|
export declare namespace MorphoBlueView {
|
|
67
|
+
type LiquidityChangeParamsStruct = [MarketParamsStruct, boolean, number | string | BN, number | string | BN] | {
|
|
68
|
+
marketParams: MarketParamsStruct;
|
|
69
|
+
isBorrowOperation: boolean;
|
|
70
|
+
liquidityAdded: number | string | BN;
|
|
71
|
+
liquidityRemoved: number | string | BN;
|
|
72
|
+
};
|
|
73
|
+
type LiquidityChangeParamsStructOutputArray = [
|
|
74
|
+
MarketParamsStructOutput,
|
|
75
|
+
boolean,
|
|
76
|
+
string,
|
|
77
|
+
string
|
|
78
|
+
];
|
|
79
|
+
type LiquidityChangeParamsStructOutputStruct = {
|
|
80
|
+
marketParams: MarketParamsStructOutput;
|
|
81
|
+
isBorrowOperation: boolean;
|
|
82
|
+
liquidityAdded: string;
|
|
83
|
+
liquidityRemoved: string;
|
|
84
|
+
};
|
|
85
|
+
type LiquidityChangeParamsStructOutput = LiquidityChangeParamsStructOutputArray & LiquidityChangeParamsStructOutputStruct;
|
|
35
86
|
type MarketInfoStruct = [
|
|
36
87
|
string | number[],
|
|
37
88
|
number | string | BN,
|
|
@@ -110,9 +161,19 @@ export interface MorphoBlueView extends BaseContract {
|
|
|
110
161
|
clone(): MorphoBlueView;
|
|
111
162
|
methods: {
|
|
112
163
|
MORPHO_BLUE_ADDRESS(): NonPayableTransactionObject<string>;
|
|
164
|
+
getApyAfterValuesEstimation(params: MorphoBlueView.LiquidityChangeParamsStruct): NonPayableTransactionObject<[
|
|
165
|
+
string,
|
|
166
|
+
MarketStructOutput
|
|
167
|
+
] & {
|
|
168
|
+
borrowRate: string;
|
|
169
|
+
market: MarketStructOutput;
|
|
170
|
+
}>;
|
|
113
171
|
getMarketId(marketParams: MarketParamsStruct): NonPayableTransactionObject<string>;
|
|
114
172
|
getMarketInfo(marketParams: MarketParamsStruct): NonPayableTransactionObject<MorphoBlueView.MarketInfoStructOutput>;
|
|
115
173
|
getMarketInfoNotTuple(loanToken: string, collToken: string, oracle: string, irm: string, lltv: number | string | BN): NonPayableTransactionObject<MorphoBlueView.MarketInfoStructOutput>;
|
|
174
|
+
getRatio(marketId: string | number[], marketParams: MarketParamsStruct, owner: string): NonPayableTransactionObject<string>;
|
|
175
|
+
getRatioUsingId(marketId: string | number[], owner: string): NonPayableTransactionObject<string>;
|
|
176
|
+
getRatioUsingParams(marketParams: MarketParamsStruct, owner: string): NonPayableTransactionObject<string>;
|
|
116
177
|
getUserInfo(marketParams: MarketParamsStruct, owner: string): NonPayableTransactionObject<MorphoBlueView.PositionInfoStructOutput>;
|
|
117
178
|
morphoBlue(): NonPayableTransactionObject<string>;
|
|
118
179
|
};
|
|
@@ -10,6 +10,30 @@ export interface EventOptions {
|
|
|
10
10
|
topics?: string[];
|
|
11
11
|
}
|
|
12
12
|
export declare namespace SparkView {
|
|
13
|
+
type LiquidityChangeParamsStruct = [string, number | string | BN, number | string | BN] | {
|
|
14
|
+
reserveAddress: string;
|
|
15
|
+
liquidityAdded: number | string | BN;
|
|
16
|
+
liquidityTaken: number | string | BN;
|
|
17
|
+
};
|
|
18
|
+
type LiquidityChangeParamsStructOutputArray = [string, string, string];
|
|
19
|
+
type LiquidityChangeParamsStructOutputStruct = {
|
|
20
|
+
reserveAddress: string;
|
|
21
|
+
liquidityAdded: string;
|
|
22
|
+
liquidityTaken: string;
|
|
23
|
+
};
|
|
24
|
+
type LiquidityChangeParamsStructOutput = LiquidityChangeParamsStructOutputArray & LiquidityChangeParamsStructOutputStruct;
|
|
25
|
+
type EstimatedRatesStruct = [string, number | string | BN, number | string | BN] | {
|
|
26
|
+
reserveAddress: string;
|
|
27
|
+
supplyRate: number | string | BN;
|
|
28
|
+
variableBorrowRate: number | string | BN;
|
|
29
|
+
};
|
|
30
|
+
type EstimatedRatesStructOutputArray = [string, string, string];
|
|
31
|
+
type EstimatedRatesStructOutputStruct = {
|
|
32
|
+
reserveAddress: string;
|
|
33
|
+
supplyRate: string;
|
|
34
|
+
variableBorrowRate: string;
|
|
35
|
+
};
|
|
36
|
+
type EstimatedRatesStructOutput = EstimatedRatesStructOutputArray & EstimatedRatesStructOutputStruct;
|
|
13
37
|
type TokenInfoFullStruct = [
|
|
14
38
|
string,
|
|
15
39
|
string,
|
|
@@ -159,6 +183,7 @@ export declare namespace SparkView {
|
|
|
159
183
|
number | string | BN,
|
|
160
184
|
number | string | BN,
|
|
161
185
|
string[],
|
|
186
|
+
boolean[],
|
|
162
187
|
string[],
|
|
163
188
|
number | string | BN[],
|
|
164
189
|
number | string | BN[],
|
|
@@ -173,6 +198,7 @@ export declare namespace SparkView {
|
|
|
173
198
|
ratio: number | string | BN;
|
|
174
199
|
eMode: number | string | BN;
|
|
175
200
|
collAddr: string[];
|
|
201
|
+
enabledAsColl: boolean[];
|
|
176
202
|
borrowAddr: string[];
|
|
177
203
|
collAmounts: number | string | BN[];
|
|
178
204
|
borrowStableAmounts: number | string | BN[];
|
|
@@ -188,6 +214,7 @@ export declare namespace SparkView {
|
|
|
188
214
|
string,
|
|
189
215
|
string,
|
|
190
216
|
string[],
|
|
217
|
+
boolean[],
|
|
191
218
|
string[],
|
|
192
219
|
string[],
|
|
193
220
|
string[],
|
|
@@ -203,6 +230,7 @@ export declare namespace SparkView {
|
|
|
203
230
|
ratio: string;
|
|
204
231
|
eMode: string;
|
|
205
232
|
collAddr: string[];
|
|
233
|
+
enabledAsColl: boolean[];
|
|
206
234
|
borrowAddr: string[];
|
|
207
235
|
collAmounts: string[];
|
|
208
236
|
borrowStableAmounts: string[];
|
|
@@ -276,8 +304,7 @@ export interface SparkView extends BaseContract {
|
|
|
276
304
|
clone(): SparkView;
|
|
277
305
|
methods: {
|
|
278
306
|
SPARK_REFERRAL_CODE(): NonPayableTransactionObject<string>;
|
|
279
|
-
|
|
280
|
-
VARIABLE_ID(): NonPayableTransactionObject<string>;
|
|
307
|
+
getApyAfterValuesEstimation(_market: string, _reserveParams: SparkView.LiquidityChangeParamsStruct[]): NonPayableTransactionObject<SparkView.EstimatedRatesStructOutput[]>;
|
|
281
308
|
getAssetPrice(_market: string, _tokenAddr: string): NonPayableTransactionObject<string>;
|
|
282
309
|
getCollFactors(_market: string, _tokens: string[]): NonPayableTransactionObject<string[]>;
|
|
283
310
|
getEModeCollateralFactor(emodeCategory: number | string | BN, lendingPool: string): NonPayableTransactionObject<string>;
|