@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,6 +1,18 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import Dec from 'decimal.js';
|
|
11
|
+
import { assetAmountInWei } from '@defisaver/tokens';
|
|
2
12
|
import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
|
|
3
13
|
import { calculateNetApy } from '../../staking';
|
|
14
|
+
import { SECONDS_PER_YEAR, WAD } from '../../constants';
|
|
15
|
+
import { MorphoBlueViewContract } from '../../contracts';
|
|
4
16
|
export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInfo }) => {
|
|
5
17
|
var _a, _b, _c, _d, _e, _f;
|
|
6
18
|
const payload = {};
|
|
@@ -39,3 +51,53 @@ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, ma
|
|
|
39
51
|
}
|
|
40
52
|
return payload;
|
|
41
53
|
};
|
|
54
|
+
const compound = (ratePerSeconds) => {
|
|
55
|
+
const compounding = new Dec(ratePerSeconds).mul(SECONDS_PER_YEAR).toString();
|
|
56
|
+
const apyNumber = Math.expm1(new Dec(compounding).div(WAD).toNumber());
|
|
57
|
+
return new Dec(apyNumber).mul(WAD).floor().toString();
|
|
58
|
+
};
|
|
59
|
+
export const getSupplyRate = (totalSupplyAssets, totalBorrowAssets, borrowRate, fee) => {
|
|
60
|
+
if (totalBorrowAssets === '0' || totalSupplyAssets === '0') {
|
|
61
|
+
return '0';
|
|
62
|
+
}
|
|
63
|
+
const utillization = new Dec(totalBorrowAssets).mul(WAD).div(totalSupplyAssets).ceil()
|
|
64
|
+
.toString();
|
|
65
|
+
const supplyRate = new Dec(utillization).mul(borrowRate).div(WAD).ceil()
|
|
66
|
+
.toString();
|
|
67
|
+
const ratePerSecond = new Dec(supplyRate).mul(new Dec(WAD).minus(fee)).div(WAD).ceil()
|
|
68
|
+
.toString();
|
|
69
|
+
return new Dec(compound(ratePerSecond)).div(1e18).mul(100).toString();
|
|
70
|
+
};
|
|
71
|
+
export const getBorrowRate = (borrowRate, totalBorrowShares) => {
|
|
72
|
+
if (totalBorrowShares === '0') {
|
|
73
|
+
return '0';
|
|
74
|
+
}
|
|
75
|
+
return new Dec(compound(borrowRate)).div(1e18).mul(100).toString();
|
|
76
|
+
};
|
|
77
|
+
const borrowOperations = ['borrow', 'payback'];
|
|
78
|
+
export const getApyAfterValuesEstimation = (selectedMarket, action, amount, asset, web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const morphoBlueViewContract = MorphoBlueViewContract(web3, network);
|
|
80
|
+
const lltvInWei = assetAmountInWei(selectedMarket.lltv, 'ETH');
|
|
81
|
+
const marketData = [selectedMarket.loanToken, selectedMarket.collateralToken, selectedMarket.oracle, selectedMarket.irm, lltvInWei];
|
|
82
|
+
const isBorrowOperation = borrowOperations.includes(action);
|
|
83
|
+
const amountInWei = assetAmountInWei(amount, asset);
|
|
84
|
+
let liquidityAdded;
|
|
85
|
+
let liquidityRemoved;
|
|
86
|
+
if (isBorrowOperation) {
|
|
87
|
+
liquidityAdded = action === 'payback' ? amountInWei : '0';
|
|
88
|
+
liquidityRemoved = action === 'borrow' ? amountInWei : '0';
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
liquidityAdded = action === 'collateral' ? amountInWei : '0';
|
|
92
|
+
liquidityRemoved = action === 'withdraw' ? amountInWei : '0';
|
|
93
|
+
}
|
|
94
|
+
const data = yield morphoBlueViewContract.methods.getApyAfterValuesEstimation([
|
|
95
|
+
marketData,
|
|
96
|
+
isBorrowOperation,
|
|
97
|
+
liquidityAdded,
|
|
98
|
+
liquidityRemoved,
|
|
99
|
+
]).call();
|
|
100
|
+
const borrowRate = getBorrowRate(data.borrowRate, data.market.totalBorrowShares);
|
|
101
|
+
const supplyRate = getSupplyRate(data.market.totalSupplyAssets, data.market.totalBorrowAssets, data.borrowRate, data.market.fee);
|
|
102
|
+
return { borrowRate, supplyRate };
|
|
103
|
+
});
|
package/esm/maker/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export const getMakerAccountBalances = (web3, network, block, addressMapping, cd
|
|
|
23
23
|
}
|
|
24
24
|
const viewContract = McdViewContract(web3, network, block);
|
|
25
25
|
let ilk;
|
|
26
|
-
const needsIlk = new Dec(block).lt(14410792) && new Dec(block).gte(14384301);
|
|
26
|
+
const needsIlk = block !== 'latest' && new Dec(block).lt(14410792) && new Dec(block).gte(14384301);
|
|
27
27
|
if (needsIlk) {
|
|
28
28
|
ilk = (yield viewContract.methods.getUrnAndIlk(managerAddress, cdpId).call({}, block)).ilk;
|
|
29
29
|
}
|
package/esm/morphoBlue/index.js
CHANGED
|
@@ -11,33 +11,10 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
12
|
import { NetworkNumber, } from '../types/common';
|
|
13
13
|
import { FeedRegistryContract, MorphoBlueViewContract, } from '../contracts';
|
|
14
|
-
import { WAD,
|
|
14
|
+
import { WAD, USD_QUOTE } from '../constants';
|
|
15
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
16
|
import { wethToEth } from '../services/utils';
|
|
17
|
-
import { getMorphoBlueAggregatedPositionData } from '../helpers/morphoBlueHelpers';
|
|
18
|
-
const compound = (ratePerSeconds) => {
|
|
19
|
-
const compounding = new Dec(ratePerSeconds).mul(SECONDS_PER_YEAR).toString();
|
|
20
|
-
const apyNumber = Math.expm1(new Dec(compounding).div(WAD).toNumber());
|
|
21
|
-
return new Dec(apyNumber).mul(WAD).floor().toString();
|
|
22
|
-
};
|
|
23
|
-
const getSupplyRate = (totalSupplyAssets, totalBorrowAssets, borrowRate, fee) => {
|
|
24
|
-
if (totalBorrowAssets === '0' || totalSupplyAssets === '0') {
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
const utillization = new Dec(totalBorrowAssets).mul(WAD).div(totalSupplyAssets).ceil()
|
|
28
|
-
.toString();
|
|
29
|
-
const supplyRate = new Dec(utillization).mul(borrowRate).div(WAD).ceil()
|
|
30
|
-
.toString();
|
|
31
|
-
const ratePerSecond = new Dec(supplyRate).mul(new Dec(WAD).minus(fee)).div(WAD).ceil()
|
|
32
|
-
.toString();
|
|
33
|
-
return compound(ratePerSecond);
|
|
34
|
-
};
|
|
35
|
-
const getBorrowRate = (borrowRate, totalBorrowShares) => {
|
|
36
|
-
if (totalBorrowShares === '0') {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
return compound(borrowRate);
|
|
40
|
-
};
|
|
17
|
+
import { getBorrowRate, getMorphoBlueAggregatedPositionData, getSupplyRate } from '../helpers/morphoBlueHelpers';
|
|
41
18
|
export function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
42
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
20
|
const { loanToken, collateralToken, oracle, irm, lltv, oracleType, } = selectedMarket;
|
|
@@ -67,8 +44,8 @@ export function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWe
|
|
|
67
44
|
symbol: wethToEth(loanTokenInfo.symbol),
|
|
68
45
|
address: loanToken,
|
|
69
46
|
price: new Dec(loanTokenPrice).div(1e8).toString(),
|
|
70
|
-
supplyRate
|
|
71
|
-
borrowRate:
|
|
47
|
+
supplyRate,
|
|
48
|
+
borrowRate: compoundedBorrowRate,
|
|
72
49
|
totalSupply: new Dec(marketInfo.totalSupplyAssets).div(scale).toString(),
|
|
73
50
|
totalBorrow: new Dec(marketInfo.totalBorrowAssets).div(scale).toString(),
|
|
74
51
|
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>;
|
package/package.json
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./cjs/index.js",
|
|
6
|
-
"module": "./esm/index.js",
|
|
7
|
-
"types": "./esm/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build:esm": "rm -rf esm && tsc -p tsconfig.json",
|
|
10
|
-
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
-
"build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
|
|
12
|
-
"dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
|
|
13
|
-
"lint": "eslint src/ --fix",
|
|
14
|
-
"generate-contracts": "node scripts/generateContracts.js",
|
|
15
|
-
"test": "mocha tests/*",
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"typechain
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@defisaver/positions-sdk",
|
|
3
|
+
"version": "0.0.100",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./cjs/index.js",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"types": "./esm/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build:esm": "rm -rf esm && tsc -p tsconfig.json",
|
|
10
|
+
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
+
"build": "npm run generate-contracts && npm run build:cjs && npm run build:esm",
|
|
12
|
+
"dev": "npm run generate-contracts && tsc -p tsconfig.cjs.json --watch",
|
|
13
|
+
"lint": "eslint src/ --fix",
|
|
14
|
+
"generate-contracts": "node scripts/generateContracts.js",
|
|
15
|
+
"test": "mocha tests/*",
|
|
16
|
+
"test:debugger": "mocha --inspect-brk tests/*",
|
|
17
|
+
"build-test": "npm run build && mocha tests/*"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@defisaver/tokens": "^1.5.27",
|
|
24
|
+
"@ethersproject/bignumber": "^5.7.0",
|
|
25
|
+
"@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
|
|
26
|
+
"decimal.js": "^10.4.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@defisaver/eslint-config": "^1.0.1",
|
|
30
|
+
"chai": "^4.3.8",
|
|
31
|
+
"dotenv": "^16.3.1",
|
|
32
|
+
"eslint": "^8.49.0",
|
|
33
|
+
"mocha": "^10.2.0",
|
|
34
|
+
"typechain": "^8.3.1",
|
|
35
|
+
"typechain-target-web3-v1-3mihai3": "^6.0.2",
|
|
36
|
+
"typescript": "^5.2.2"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"web3": "^1.10.2"
|
|
40
|
+
}
|
|
41
|
+
}
|