@defisaver/positions-sdk 0.0.166-dev2-liquity-v2 → 0.0.166-dev3
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/config/contracts.d.ts +32 -3
- package/cjs/config/contracts.js +3 -3
- package/cjs/contracts.d.ts +1 -1
- package/cjs/contracts.js +2 -2
- package/cjs/eulerV2/index.d.ts +41 -0
- package/cjs/eulerV2/index.js +214 -0
- package/cjs/helpers/eulerHelpers/index.d.ts +27 -0
- package/cjs/helpers/eulerHelpers/index.js +232 -0
- package/cjs/helpers/index.d.ts +1 -1
- package/cjs/helpers/index.js +2 -2
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +3 -3
- package/cjs/markets/euler/index.d.ts +8 -0
- package/cjs/markets/euler/index.js +30 -0
- package/cjs/markets/index.d.ts +1 -1
- package/cjs/markets/index.js +3 -3
- package/cjs/services/utils.d.ts +2 -0
- package/cjs/services/utils.js +4 -1
- package/cjs/types/contracts/generated/EulerV2View.d.ts +345 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -1
- package/cjs/types/euler.d.ts +147 -0
- package/cjs/types/euler.js +14 -0
- package/cjs/types/index.d.ts +1 -1
- package/cjs/types/index.js +1 -1
- package/esm/config/contracts.d.ts +32 -3
- package/esm/config/contracts.js +3 -3
- package/esm/contracts.d.ts +1 -1
- package/esm/contracts.js +1 -1
- package/esm/eulerV2/index.d.ts +41 -0
- package/esm/eulerV2/index.js +206 -0
- package/esm/helpers/eulerHelpers/index.d.ts +27 -0
- package/esm/helpers/eulerHelpers/index.js +219 -0
- package/esm/helpers/index.d.ts +1 -1
- package/esm/helpers/index.js +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -2
- package/esm/markets/euler/index.d.ts +8 -0
- package/esm/markets/euler/index.js +24 -0
- package/esm/markets/index.d.ts +1 -1
- package/esm/markets/index.js +1 -1
- package/esm/services/utils.d.ts +2 -0
- package/esm/services/utils.js +2 -0
- package/esm/types/contracts/generated/EulerV2View.d.ts +345 -0
- package/esm/types/contracts/generated/index.d.ts +1 -1
- package/esm/types/euler.d.ts +147 -0
- package/esm/types/euler.js +11 -0
- package/esm/types/index.d.ts +1 -1
- package/esm/types/index.js +1 -1
- package/package.json +49 -49
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +590 -590
- 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 +281 -281
- package/src/config/contracts.js +1040 -1040
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +130 -130
- package/src/curveUsd/index.ts +229 -229
- package/src/eulerV2/index.ts +297 -0
- package/src/exchange/index.ts +17 -17
- package/src/helpers/aaveHelpers/index.ts +194 -194
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +246 -246
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +231 -0
- package/src/helpers/index.ts +9 -9
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +115 -115
- package/src/helpers/sparkHelpers/index.ts +150 -150
- package/src/index.ts +48 -48
- package/src/liquity/index.ts +116 -116
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +46 -46
- package/src/markets/compound/index.ts +173 -173
- package/src/markets/compound/marketsAssets.ts +64 -64
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +27 -0
- package/src/markets/index.ts +24 -23
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +728 -728
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +630 -630
- package/src/morphoBlue/index.ts +171 -171
- 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 +57 -54
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +424 -424
- package/src/staking/staking.ts +218 -218
- package/src/types/aave.ts +262 -262
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +129 -129
- package/src/types/contracts/generated/EulerV2View.ts +446 -0
- package/src/types/contracts/generated/index.ts +1 -1
- package/src/types/curveUsd.ts +118 -118
- package/src/types/euler.ts +170 -0
- package/src/types/index.ts +10 -10
- package/src/types/liquity.ts +30 -30
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +146 -146
- package/src/types/spark.ts +127 -127
- package/cjs/helpers/liquityV2Helpers/index.d.ts +0 -12
- package/cjs/helpers/liquityV2Helpers/index.js +0 -61
- package/cjs/liquityV2/index.d.ts +0 -10
- package/cjs/liquityV2/index.js +0 -98
- package/cjs/markets/liquityV2/index.d.ts +0 -8
- package/cjs/markets/liquityV2/index.js +0 -34
- package/cjs/types/contracts/generated/LiquityV2View.d.ts +0 -222
- package/cjs/types/liquityV2.d.ts +0 -81
- package/cjs/types/liquityV2.js +0 -8
- package/esm/helpers/liquityV2Helpers/index.d.ts +0 -12
- package/esm/helpers/liquityV2Helpers/index.js +0 -53
- package/esm/liquityV2/index.d.ts +0 -10
- package/esm/liquityV2/index.js +0 -90
- package/esm/markets/liquityV2/index.d.ts +0 -8
- package/esm/markets/liquityV2/index.js +0 -28
- package/esm/types/contracts/generated/LiquityV2View.d.ts +0 -222
- package/esm/types/liquityV2.d.ts +0 -81
- package/esm/types/liquityV2.js +0 -5
- package/src/helpers/liquityV2Helpers/index.ts +0 -78
- package/src/liquityV2/index.ts +0 -115
- package/src/markets/liquityV2/index.ts +0 -31
- package/src/types/contracts/generated/LiquityV2View.ts +0 -280
- package/src/types/liquityV2.ts +0 -87
- /package/cjs/types/contracts/generated/{LiquityV2View.js → EulerV2View.js} +0 -0
- /package/esm/types/contracts/generated/{LiquityV2View.js → EulerV2View.js} +0 -0
package/src/types/morphoBlue.ts
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import { MMUsedAssets, NetworkNumber } from './common';
|
|
2
|
-
|
|
3
|
-
export enum MorphoBlueVersions {
|
|
4
|
-
// MAINNET
|
|
5
|
-
MorphoBlueWstEthUSDC = 'morphobluewstethusdc', // wstETH/USDC
|
|
6
|
-
MorphoBlueSDAIUSDC = 'morphobluesdaiusdc', // sDAI/USDC
|
|
7
|
-
MorphoBlueWBTCUSDC = 'morphobluewbtcusdc', // WBTC/USDC
|
|
8
|
-
MorphoBlueEthUSDC = 'morphoblueethusdc', // ETH/USDC
|
|
9
|
-
MorphoBlueWBTCUSDT = 'morphobluewbtcusdt', // WBTC/USDT
|
|
10
|
-
MorphoBlueWstEthUSDT = 'morphobluewstethusdt', // wstETH/USDT
|
|
11
|
-
MorphoBlueWstEthUSDA_Exchange_Rate = 'morphobluewstethusda_exchange_rate', // wstETH/USDA
|
|
12
|
-
MorphoBlueWstEthPYUSD = 'morphobluwstethpyusd', // wstETH/PYUSD
|
|
13
|
-
MorphoBlueWeEthEth = 'morphoblueweetheth', // weETH/ETH
|
|
14
|
-
MorphoBlueREthEth_945 = 'morphoblueretheth_945', // rETH/ETH
|
|
15
|
-
MorphoBlueWBTCPYUSD = 'morphobluewbtcpyusd', // WBTC/PYUSD
|
|
16
|
-
MorphoBlueWBTCEth = 'morphobluewbtceth', // WBTC/ETH
|
|
17
|
-
MorphoBlueUSDeUSDT = 'morphoblueusdeusdt', // USDe/USDT
|
|
18
|
-
MorphoBlueSUSDeUSDT = 'morphobluesusdeusdt', // sUSDe/USDT
|
|
19
|
-
MorphoBlueSDAIEth = 'morphobluesdaieth', // sDAI/ETH
|
|
20
|
-
MorphoBlueEzEthEth = 'morphoblueezetheth', // ezETH/ETH
|
|
21
|
-
MorphoBlueMKRUSDC = 'morphobluemkrusdc', // MKR/USDC
|
|
22
|
-
MorphoBlueTBTCUSDC = 'morphobluetbtcusdc', // tBTC/USDC
|
|
23
|
-
MorphoBlueCbBTCEth_915 = 'morphobluecbbtceth', // cbBTC/Eth
|
|
24
|
-
MorphoBlueCbBTCUSDC_860 = 'morphobluecbbtcusdc', // cbBTC/USDC
|
|
25
|
-
// wstETH/WETH
|
|
26
|
-
MorphoBlueWstEthEth_945 = 'morphobluewstetheth_945',
|
|
27
|
-
MorphoBlueWstEthEth_945_Exchange_Rate = 'morphobluewstetheth_945_exchange_rate',
|
|
28
|
-
MorphoBlueWstEthEth_965_Exchange_Rate = 'morphobluewstetheth_965_exchange_rate',
|
|
29
|
-
// sUSDe/DAI
|
|
30
|
-
MorphoBlueSUSDeDAI_770 = 'morphobluesusdedai_770',
|
|
31
|
-
MorphoBlueSUSDeDAI_860 = 'morphobluesusdedai_860',
|
|
32
|
-
MorphoBlueSUSDeDAI_915 = 'morphobluesusdedai_915',
|
|
33
|
-
MorphoBlueSUSDeDAI_945 = 'morphobluesusdedai_945',
|
|
34
|
-
// USDe/DAI
|
|
35
|
-
MorphoBlueUSDeDAI_770 = 'morphoblueusdedai_770',
|
|
36
|
-
MorphoBlueUSDeDAI_860 = 'morphoblueusdedai_860',
|
|
37
|
-
MorphoBlueUSDeDAI_915 = 'morphoblueusdedai_915',
|
|
38
|
-
MorphoBlueUSDeDAI_945 = 'morphoblueusdedai_945',
|
|
39
|
-
|
|
40
|
-
// BASE
|
|
41
|
-
MorphoBlueCbEthUSDC_860_Base = 'morphobluecbethusdc_860_base',
|
|
42
|
-
MorphoBlueWstEthUSDC_860_Base = 'morphobluewstethusdc_860_base',
|
|
43
|
-
MorphoBlueEthUSDC_860_Base = 'morphoblueethusdc_860_base',
|
|
44
|
-
MorphoBlueCbEthEth_945_Base = 'morphobluecbetheth_945_base',
|
|
45
|
-
MorphoBlueCbEthEth_965_Base = 'morphobluecbetheth_965_base',
|
|
46
|
-
MorphoBlueWstEthEth_945_Base = 'morphobluewstetheth_945_base',
|
|
47
|
-
MorphoBlueWstEthEth_965_Base = 'morphobluewstetheth_965_base',
|
|
48
|
-
MorphoBlueREthUSDC_860_Base = 'morphobluerethusdc_860_base',
|
|
49
|
-
MorphoBlueREthEth_945_Base = 'morphoblueretheth_945_base',
|
|
50
|
-
MorphoBlueCbBTCEth_915_Base = 'morphobluecbbtceth_915_base',
|
|
51
|
-
MorphoBlueCbBTCUSDC_860_Base = 'morphobluecbbtcusdc_860_base',
|
|
52
|
-
MorphoBlueWsuperOETHbWETH_915_Base = 'morphobluewsuperoethbweth_915_base',
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export enum MorphoBlueOracleType {
|
|
56
|
-
MARKET_RATE = 'Market rate',
|
|
57
|
-
LIDO_RATE = 'Lido rate',
|
|
58
|
-
ETHENA_RATE = 'Ethena rate',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface MorphoBlueMarketData {
|
|
62
|
-
chainIds: NetworkNumber[],
|
|
63
|
-
label: string,
|
|
64
|
-
shortLabel: string,
|
|
65
|
-
url: string,
|
|
66
|
-
value: MorphoBlueVersions,
|
|
67
|
-
loanToken: string,
|
|
68
|
-
collateralToken: string,
|
|
69
|
-
oracle: string,
|
|
70
|
-
oracleType: MorphoBlueOracleType,
|
|
71
|
-
irm: string,
|
|
72
|
-
lltv: number | string,
|
|
73
|
-
marketId: string,
|
|
74
|
-
// icon: Function,
|
|
75
|
-
protocolName: string,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface MorphoBlueAssetData {
|
|
79
|
-
symbol: string,
|
|
80
|
-
address: string,
|
|
81
|
-
price: string,
|
|
82
|
-
supplyRate: string,
|
|
83
|
-
borrowRate: string,
|
|
84
|
-
incentiveSupplyApy?: string,
|
|
85
|
-
incentiveSupplyToken?: string,
|
|
86
|
-
totalSupply?: string,
|
|
87
|
-
totalBorrow?: string,
|
|
88
|
-
canBeSupplied?: boolean,
|
|
89
|
-
canBeBorrowed?: boolean,
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export type MorphoBlueAssetsData = { [key: string]: MorphoBlueAssetData };
|
|
93
|
-
|
|
94
|
-
export interface MorphoBlueMarketInfo {
|
|
95
|
-
id: string,
|
|
96
|
-
fee: string,
|
|
97
|
-
loanToken: string,
|
|
98
|
-
collateralToken: string,
|
|
99
|
-
utillization: string,
|
|
100
|
-
oracle: string,
|
|
101
|
-
oracleType: MorphoBlueOracleType,
|
|
102
|
-
lltv: string,
|
|
103
|
-
minRatio: string,
|
|
104
|
-
assetsData: MorphoBlueAssetsData,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface MorphoBlueAggregatedPositionData {
|
|
108
|
-
suppliedUsd: string,
|
|
109
|
-
suppliedCollateralUsd: string,
|
|
110
|
-
borrowedUsd: string,
|
|
111
|
-
borrowLimitUsd: string,
|
|
112
|
-
liquidationLimitUsd: string,
|
|
113
|
-
leftToBorrowUsd: string,
|
|
114
|
-
leftToBorrow: string,
|
|
115
|
-
netApy: string,
|
|
116
|
-
incentiveUsd: string,
|
|
117
|
-
totalInterestUsd: string,
|
|
118
|
-
ltv: string,
|
|
119
|
-
ratio: string,
|
|
120
|
-
leveragedType: string,
|
|
121
|
-
leveragedAsset?: string,
|
|
122
|
-
leveragedLsdAssetRatio?: string,
|
|
123
|
-
liquidationPrice?: string,
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface MorphoBluePositionData {
|
|
127
|
-
usedAssets: MMUsedAssets,
|
|
128
|
-
suppliedUsd: string,
|
|
129
|
-
suppliedCollateralUsd: string,
|
|
130
|
-
borrowedUsd: string,
|
|
131
|
-
borrowLimitUsd: string,
|
|
132
|
-
liquidationLimitUsd: string,
|
|
133
|
-
leftToBorrowUsd: string,
|
|
134
|
-
leftToBorrow: string,
|
|
135
|
-
netApy: string,
|
|
136
|
-
incentiveUsd: string,
|
|
137
|
-
totalInterestUsd: string,
|
|
138
|
-
ltv: string,
|
|
139
|
-
ratio: string,
|
|
140
|
-
leveragedType: string,
|
|
141
|
-
leveragedAsset?: string,
|
|
142
|
-
leveragedLsdAssetRatio?: string,
|
|
143
|
-
liquidationPrice?: string,
|
|
144
|
-
supplyShares: string,
|
|
145
|
-
borrowShares: string,
|
|
146
|
-
}
|
|
1
|
+
import { MMUsedAssets, NetworkNumber } from './common';
|
|
2
|
+
|
|
3
|
+
export enum MorphoBlueVersions {
|
|
4
|
+
// MAINNET
|
|
5
|
+
MorphoBlueWstEthUSDC = 'morphobluewstethusdc', // wstETH/USDC
|
|
6
|
+
MorphoBlueSDAIUSDC = 'morphobluesdaiusdc', // sDAI/USDC
|
|
7
|
+
MorphoBlueWBTCUSDC = 'morphobluewbtcusdc', // WBTC/USDC
|
|
8
|
+
MorphoBlueEthUSDC = 'morphoblueethusdc', // ETH/USDC
|
|
9
|
+
MorphoBlueWBTCUSDT = 'morphobluewbtcusdt', // WBTC/USDT
|
|
10
|
+
MorphoBlueWstEthUSDT = 'morphobluewstethusdt', // wstETH/USDT
|
|
11
|
+
MorphoBlueWstEthUSDA_Exchange_Rate = 'morphobluewstethusda_exchange_rate', // wstETH/USDA
|
|
12
|
+
MorphoBlueWstEthPYUSD = 'morphobluwstethpyusd', // wstETH/PYUSD
|
|
13
|
+
MorphoBlueWeEthEth = 'morphoblueweetheth', // weETH/ETH
|
|
14
|
+
MorphoBlueREthEth_945 = 'morphoblueretheth_945', // rETH/ETH
|
|
15
|
+
MorphoBlueWBTCPYUSD = 'morphobluewbtcpyusd', // WBTC/PYUSD
|
|
16
|
+
MorphoBlueWBTCEth = 'morphobluewbtceth', // WBTC/ETH
|
|
17
|
+
MorphoBlueUSDeUSDT = 'morphoblueusdeusdt', // USDe/USDT
|
|
18
|
+
MorphoBlueSUSDeUSDT = 'morphobluesusdeusdt', // sUSDe/USDT
|
|
19
|
+
MorphoBlueSDAIEth = 'morphobluesdaieth', // sDAI/ETH
|
|
20
|
+
MorphoBlueEzEthEth = 'morphoblueezetheth', // ezETH/ETH
|
|
21
|
+
MorphoBlueMKRUSDC = 'morphobluemkrusdc', // MKR/USDC
|
|
22
|
+
MorphoBlueTBTCUSDC = 'morphobluetbtcusdc', // tBTC/USDC
|
|
23
|
+
MorphoBlueCbBTCEth_915 = 'morphobluecbbtceth', // cbBTC/Eth
|
|
24
|
+
MorphoBlueCbBTCUSDC_860 = 'morphobluecbbtcusdc', // cbBTC/USDC
|
|
25
|
+
// wstETH/WETH
|
|
26
|
+
MorphoBlueWstEthEth_945 = 'morphobluewstetheth_945',
|
|
27
|
+
MorphoBlueWstEthEth_945_Exchange_Rate = 'morphobluewstetheth_945_exchange_rate',
|
|
28
|
+
MorphoBlueWstEthEth_965_Exchange_Rate = 'morphobluewstetheth_965_exchange_rate',
|
|
29
|
+
// sUSDe/DAI
|
|
30
|
+
MorphoBlueSUSDeDAI_770 = 'morphobluesusdedai_770',
|
|
31
|
+
MorphoBlueSUSDeDAI_860 = 'morphobluesusdedai_860',
|
|
32
|
+
MorphoBlueSUSDeDAI_915 = 'morphobluesusdedai_915',
|
|
33
|
+
MorphoBlueSUSDeDAI_945 = 'morphobluesusdedai_945',
|
|
34
|
+
// USDe/DAI
|
|
35
|
+
MorphoBlueUSDeDAI_770 = 'morphoblueusdedai_770',
|
|
36
|
+
MorphoBlueUSDeDAI_860 = 'morphoblueusdedai_860',
|
|
37
|
+
MorphoBlueUSDeDAI_915 = 'morphoblueusdedai_915',
|
|
38
|
+
MorphoBlueUSDeDAI_945 = 'morphoblueusdedai_945',
|
|
39
|
+
|
|
40
|
+
// BASE
|
|
41
|
+
MorphoBlueCbEthUSDC_860_Base = 'morphobluecbethusdc_860_base',
|
|
42
|
+
MorphoBlueWstEthUSDC_860_Base = 'morphobluewstethusdc_860_base',
|
|
43
|
+
MorphoBlueEthUSDC_860_Base = 'morphoblueethusdc_860_base',
|
|
44
|
+
MorphoBlueCbEthEth_945_Base = 'morphobluecbetheth_945_base',
|
|
45
|
+
MorphoBlueCbEthEth_965_Base = 'morphobluecbetheth_965_base',
|
|
46
|
+
MorphoBlueWstEthEth_945_Base = 'morphobluewstetheth_945_base',
|
|
47
|
+
MorphoBlueWstEthEth_965_Base = 'morphobluewstetheth_965_base',
|
|
48
|
+
MorphoBlueREthUSDC_860_Base = 'morphobluerethusdc_860_base',
|
|
49
|
+
MorphoBlueREthEth_945_Base = 'morphoblueretheth_945_base',
|
|
50
|
+
MorphoBlueCbBTCEth_915_Base = 'morphobluecbbtceth_915_base',
|
|
51
|
+
MorphoBlueCbBTCUSDC_860_Base = 'morphobluecbbtcusdc_860_base',
|
|
52
|
+
MorphoBlueWsuperOETHbWETH_915_Base = 'morphobluewsuperoethbweth_915_base',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export enum MorphoBlueOracleType {
|
|
56
|
+
MARKET_RATE = 'Market rate',
|
|
57
|
+
LIDO_RATE = 'Lido rate',
|
|
58
|
+
ETHENA_RATE = 'Ethena rate',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface MorphoBlueMarketData {
|
|
62
|
+
chainIds: NetworkNumber[],
|
|
63
|
+
label: string,
|
|
64
|
+
shortLabel: string,
|
|
65
|
+
url: string,
|
|
66
|
+
value: MorphoBlueVersions,
|
|
67
|
+
loanToken: string,
|
|
68
|
+
collateralToken: string,
|
|
69
|
+
oracle: string,
|
|
70
|
+
oracleType: MorphoBlueOracleType,
|
|
71
|
+
irm: string,
|
|
72
|
+
lltv: number | string,
|
|
73
|
+
marketId: string,
|
|
74
|
+
// icon: Function,
|
|
75
|
+
protocolName: string,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface MorphoBlueAssetData {
|
|
79
|
+
symbol: string,
|
|
80
|
+
address: string,
|
|
81
|
+
price: string,
|
|
82
|
+
supplyRate: string,
|
|
83
|
+
borrowRate: string,
|
|
84
|
+
incentiveSupplyApy?: string,
|
|
85
|
+
incentiveSupplyToken?: string,
|
|
86
|
+
totalSupply?: string,
|
|
87
|
+
totalBorrow?: string,
|
|
88
|
+
canBeSupplied?: boolean,
|
|
89
|
+
canBeBorrowed?: boolean,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type MorphoBlueAssetsData = { [key: string]: MorphoBlueAssetData };
|
|
93
|
+
|
|
94
|
+
export interface MorphoBlueMarketInfo {
|
|
95
|
+
id: string,
|
|
96
|
+
fee: string,
|
|
97
|
+
loanToken: string,
|
|
98
|
+
collateralToken: string,
|
|
99
|
+
utillization: string,
|
|
100
|
+
oracle: string,
|
|
101
|
+
oracleType: MorphoBlueOracleType,
|
|
102
|
+
lltv: string,
|
|
103
|
+
minRatio: string,
|
|
104
|
+
assetsData: MorphoBlueAssetsData,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface MorphoBlueAggregatedPositionData {
|
|
108
|
+
suppliedUsd: string,
|
|
109
|
+
suppliedCollateralUsd: string,
|
|
110
|
+
borrowedUsd: string,
|
|
111
|
+
borrowLimitUsd: string,
|
|
112
|
+
liquidationLimitUsd: string,
|
|
113
|
+
leftToBorrowUsd: string,
|
|
114
|
+
leftToBorrow: string,
|
|
115
|
+
netApy: string,
|
|
116
|
+
incentiveUsd: string,
|
|
117
|
+
totalInterestUsd: string,
|
|
118
|
+
ltv: string,
|
|
119
|
+
ratio: string,
|
|
120
|
+
leveragedType: string,
|
|
121
|
+
leveragedAsset?: string,
|
|
122
|
+
leveragedLsdAssetRatio?: string,
|
|
123
|
+
liquidationPrice?: string,
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface MorphoBluePositionData {
|
|
127
|
+
usedAssets: MMUsedAssets,
|
|
128
|
+
suppliedUsd: string,
|
|
129
|
+
suppliedCollateralUsd: string,
|
|
130
|
+
borrowedUsd: string,
|
|
131
|
+
borrowLimitUsd: string,
|
|
132
|
+
liquidationLimitUsd: string,
|
|
133
|
+
leftToBorrowUsd: string,
|
|
134
|
+
leftToBorrow: string,
|
|
135
|
+
netApy: string,
|
|
136
|
+
incentiveUsd: string,
|
|
137
|
+
totalInterestUsd: string,
|
|
138
|
+
ltv: string,
|
|
139
|
+
ratio: string,
|
|
140
|
+
leveragedType: string,
|
|
141
|
+
leveragedAsset?: string,
|
|
142
|
+
leveragedLsdAssetRatio?: string,
|
|
143
|
+
liquidationPrice?: string,
|
|
144
|
+
supplyShares: string,
|
|
145
|
+
borrowShares: string,
|
|
146
|
+
}
|
package/src/types/spark.ts
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
3
|
-
} from './common';
|
|
4
|
-
|
|
5
|
-
export enum SparkVersions {
|
|
6
|
-
SparkV1 = 'v1default',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface SparkEModeCategoryData {
|
|
10
|
-
label: string,
|
|
11
|
-
liquidationBonus: string,
|
|
12
|
-
liquidationRatio: string,
|
|
13
|
-
collateralFactor: string,
|
|
14
|
-
priceSource: string,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SparkEModeCategoryDataMapping {
|
|
18
|
-
enteringTerms: boolean[],
|
|
19
|
-
canEnterCategory: boolean,
|
|
20
|
-
id: number,
|
|
21
|
-
data: SparkEModeCategoryData,
|
|
22
|
-
assets: string[],
|
|
23
|
-
enabledData: {
|
|
24
|
-
ratio: string,
|
|
25
|
-
liqRatio: string,
|
|
26
|
-
liqPercent: string,
|
|
27
|
-
collRatio: string,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface SparkMarketData {
|
|
32
|
-
chainIds: NetworkNumber[],
|
|
33
|
-
label: string,
|
|
34
|
-
shortLabel: string,
|
|
35
|
-
url: string,
|
|
36
|
-
value: SparkVersions,
|
|
37
|
-
assets: readonly string[],
|
|
38
|
-
provider: '' | 'SparkPoolAddressesProvider',
|
|
39
|
-
providerAddress: string,
|
|
40
|
-
lendingPool: 'SparkLendingPool',
|
|
41
|
-
lendingPoolAddress: string,
|
|
42
|
-
protocolData: '' | 'SparkProtocolDataProvider',
|
|
43
|
-
protocolDataAddress: string
|
|
44
|
-
subVersionLabel?: string
|
|
45
|
-
// icon: Function,
|
|
46
|
-
protocolName: string,
|
|
47
|
-
disabled?: boolean,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SparkAssetData extends MMAssetData {
|
|
51
|
-
totalBorrowVar: string,
|
|
52
|
-
sortIndex?: number,
|
|
53
|
-
usageAsCollateralEnabled: boolean,
|
|
54
|
-
isIsolated: boolean,
|
|
55
|
-
eModeCategory: number,
|
|
56
|
-
eModeCategoryData: SparkEModeCategoryData,
|
|
57
|
-
liquidationRatio: string,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface SparkAssetsData {
|
|
61
|
-
[token: string]: SparkAssetData,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type SparkMarketsData = { assetsData: SparkAssetsData };
|
|
65
|
-
|
|
66
|
-
export interface SparkUsedAsset extends MMUsedAsset {
|
|
67
|
-
stableBorrowRate: string,
|
|
68
|
-
borrowedStable: string,
|
|
69
|
-
borrowedVariable: string,
|
|
70
|
-
borrowedUsdStable: string,
|
|
71
|
-
borrowedUsdVariable: string,
|
|
72
|
-
stableLimit: string,
|
|
73
|
-
variableLimit: string,
|
|
74
|
-
limit: string,
|
|
75
|
-
eModeCategory: number,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface SparkUsedAssets {
|
|
79
|
-
[token: string]: SparkUsedAsset,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface SparkHelperCommon {
|
|
83
|
-
usedAssets: SparkUsedAssets,
|
|
84
|
-
eModeCategory: number,
|
|
85
|
-
eModeCategories?: object,
|
|
86
|
-
assetsData: SparkAssetsData,
|
|
87
|
-
selectedMarket?: SparkMarketData,
|
|
88
|
-
network?: NetworkNumber,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface SparkAggregatedPositionData {
|
|
92
|
-
suppliedUsd: string,
|
|
93
|
-
suppliedCollateralUsd: string,
|
|
94
|
-
borrowedUsd: string,
|
|
95
|
-
borrowLimitUsd: string,
|
|
96
|
-
liquidationLimitUsd: string,
|
|
97
|
-
leftToBorrowUsd: string,
|
|
98
|
-
ratio: string,
|
|
99
|
-
collRatio: string,
|
|
100
|
-
netApy: string,
|
|
101
|
-
incentiveUsd: string,
|
|
102
|
-
totalInterestUsd: string,
|
|
103
|
-
liqRatio: string,
|
|
104
|
-
liqPercent: string,
|
|
105
|
-
leveragedType: string,
|
|
106
|
-
leveragedAsset?: string,
|
|
107
|
-
leveragedLsdAssetRatio?: string,
|
|
108
|
-
liquidationPrice?: string,
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface SparkPositionData extends MMPositionData {
|
|
112
|
-
ratio: string,
|
|
113
|
-
minRatio: string,
|
|
114
|
-
collRatio: string,
|
|
115
|
-
borrowedUsd: string,
|
|
116
|
-
borrowLimitUsd: string,
|
|
117
|
-
suppliedCollateralUsd: string,
|
|
118
|
-
incentiveUsd: string,
|
|
119
|
-
totalInterestUsd: string,
|
|
120
|
-
isSubscribedToAutomation?: boolean,
|
|
121
|
-
automationResubscribeRequired?: boolean,
|
|
122
|
-
totalSupplied: string,
|
|
123
|
-
usedAssets: SparkUsedAssets,
|
|
124
|
-
eModeCategory: number,
|
|
125
|
-
isInIsolationMode: boolean,
|
|
126
|
-
isInSiloedMode: boolean,
|
|
127
|
-
eModeCategories: { [key: number]: SparkEModeCategoryDataMapping },
|
|
1
|
+
import {
|
|
2
|
+
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
3
|
+
} from './common';
|
|
4
|
+
|
|
5
|
+
export enum SparkVersions {
|
|
6
|
+
SparkV1 = 'v1default',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SparkEModeCategoryData {
|
|
10
|
+
label: string,
|
|
11
|
+
liquidationBonus: string,
|
|
12
|
+
liquidationRatio: string,
|
|
13
|
+
collateralFactor: string,
|
|
14
|
+
priceSource: string,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SparkEModeCategoryDataMapping {
|
|
18
|
+
enteringTerms: boolean[],
|
|
19
|
+
canEnterCategory: boolean,
|
|
20
|
+
id: number,
|
|
21
|
+
data: SparkEModeCategoryData,
|
|
22
|
+
assets: string[],
|
|
23
|
+
enabledData: {
|
|
24
|
+
ratio: string,
|
|
25
|
+
liqRatio: string,
|
|
26
|
+
liqPercent: string,
|
|
27
|
+
collRatio: string,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SparkMarketData {
|
|
32
|
+
chainIds: NetworkNumber[],
|
|
33
|
+
label: string,
|
|
34
|
+
shortLabel: string,
|
|
35
|
+
url: string,
|
|
36
|
+
value: SparkVersions,
|
|
37
|
+
assets: readonly string[],
|
|
38
|
+
provider: '' | 'SparkPoolAddressesProvider',
|
|
39
|
+
providerAddress: string,
|
|
40
|
+
lendingPool: 'SparkLendingPool',
|
|
41
|
+
lendingPoolAddress: string,
|
|
42
|
+
protocolData: '' | 'SparkProtocolDataProvider',
|
|
43
|
+
protocolDataAddress: string
|
|
44
|
+
subVersionLabel?: string
|
|
45
|
+
// icon: Function,
|
|
46
|
+
protocolName: string,
|
|
47
|
+
disabled?: boolean,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface SparkAssetData extends MMAssetData {
|
|
51
|
+
totalBorrowVar: string,
|
|
52
|
+
sortIndex?: number,
|
|
53
|
+
usageAsCollateralEnabled: boolean,
|
|
54
|
+
isIsolated: boolean,
|
|
55
|
+
eModeCategory: number,
|
|
56
|
+
eModeCategoryData: SparkEModeCategoryData,
|
|
57
|
+
liquidationRatio: string,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SparkAssetsData {
|
|
61
|
+
[token: string]: SparkAssetData,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type SparkMarketsData = { assetsData: SparkAssetsData };
|
|
65
|
+
|
|
66
|
+
export interface SparkUsedAsset extends MMUsedAsset {
|
|
67
|
+
stableBorrowRate: string,
|
|
68
|
+
borrowedStable: string,
|
|
69
|
+
borrowedVariable: string,
|
|
70
|
+
borrowedUsdStable: string,
|
|
71
|
+
borrowedUsdVariable: string,
|
|
72
|
+
stableLimit: string,
|
|
73
|
+
variableLimit: string,
|
|
74
|
+
limit: string,
|
|
75
|
+
eModeCategory: number,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SparkUsedAssets {
|
|
79
|
+
[token: string]: SparkUsedAsset,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface SparkHelperCommon {
|
|
83
|
+
usedAssets: SparkUsedAssets,
|
|
84
|
+
eModeCategory: number,
|
|
85
|
+
eModeCategories?: object,
|
|
86
|
+
assetsData: SparkAssetsData,
|
|
87
|
+
selectedMarket?: SparkMarketData,
|
|
88
|
+
network?: NetworkNumber,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SparkAggregatedPositionData {
|
|
92
|
+
suppliedUsd: string,
|
|
93
|
+
suppliedCollateralUsd: string,
|
|
94
|
+
borrowedUsd: string,
|
|
95
|
+
borrowLimitUsd: string,
|
|
96
|
+
liquidationLimitUsd: string,
|
|
97
|
+
leftToBorrowUsd: string,
|
|
98
|
+
ratio: string,
|
|
99
|
+
collRatio: string,
|
|
100
|
+
netApy: string,
|
|
101
|
+
incentiveUsd: string,
|
|
102
|
+
totalInterestUsd: string,
|
|
103
|
+
liqRatio: string,
|
|
104
|
+
liqPercent: string,
|
|
105
|
+
leveragedType: string,
|
|
106
|
+
leveragedAsset?: string,
|
|
107
|
+
leveragedLsdAssetRatio?: string,
|
|
108
|
+
liquidationPrice?: string,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface SparkPositionData extends MMPositionData {
|
|
112
|
+
ratio: string,
|
|
113
|
+
minRatio: string,
|
|
114
|
+
collRatio: string,
|
|
115
|
+
borrowedUsd: string,
|
|
116
|
+
borrowLimitUsd: string,
|
|
117
|
+
suppliedCollateralUsd: string,
|
|
118
|
+
incentiveUsd: string,
|
|
119
|
+
totalInterestUsd: string,
|
|
120
|
+
isSubscribedToAutomation?: boolean,
|
|
121
|
+
automationResubscribeRequired?: boolean,
|
|
122
|
+
totalSupplied: string,
|
|
123
|
+
usedAssets: SparkUsedAssets,
|
|
124
|
+
eModeCategory: number,
|
|
125
|
+
isInIsolationMode: boolean,
|
|
126
|
+
isInSiloedMode: boolean,
|
|
127
|
+
eModeCategories: { [key: number]: SparkEModeCategoryDataMapping },
|
|
128
128
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { LiquityV2AggregatedTroveData, LiquityV2AssetsData, LiquityV2UsedAssets } from '../../types';
|
|
2
|
-
export declare const calculateNetApyLiquityV2: (usedAssets: LiquityV2UsedAssets, assetsData: LiquityV2AssetsData, interestRate: string) => {
|
|
3
|
-
netApy: string;
|
|
4
|
-
totalInterestUsd: string;
|
|
5
|
-
incentiveUsd: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const getLiquityV2AggregatedPositionData: ({ usedAssets, assetsData, minRatio, interestRate, }: {
|
|
8
|
-
usedAssets: LiquityV2UsedAssets;
|
|
9
|
-
assetsData: LiquityV2AssetsData;
|
|
10
|
-
minRatio: string;
|
|
11
|
-
interestRate: string;
|
|
12
|
-
}) => LiquityV2AggregatedTroveData;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getLiquityV2AggregatedPositionData = exports.calculateNetApyLiquityV2 = void 0;
|
|
7
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
-
const moneymarket_1 = require("../../moneymarket");
|
|
9
|
-
const staking_1 = require("../../staking");
|
|
10
|
-
const calculateNetApyLiquityV2 = (usedAssets, assetsData, interestRate) => {
|
|
11
|
-
const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
|
|
12
|
-
const acc = Object.assign({}, _acc);
|
|
13
|
-
const assetData = assetsData[usedAsset.symbol];
|
|
14
|
-
if (usedAsset.suppliedUsd) {
|
|
15
|
-
const amount = usedAsset.suppliedUsd;
|
|
16
|
-
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
|
17
|
-
if (assetData.incentiveSupplyApy) {
|
|
18
|
-
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, assetData.incentiveSupplyApy, 'year', true);
|
|
19
|
-
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (usedAsset.borrowedUsd) {
|
|
23
|
-
const amount = usedAsset.borrowedUsd;
|
|
24
|
-
acc.borrowedUsd = new decimal_js_1.default(acc.borrowedUsd).add(amount).toString();
|
|
25
|
-
const rate = interestRate;
|
|
26
|
-
const borrowInterest = (0, staking_1.calculateInterestEarned)(amount, rate, 'year', true);
|
|
27
|
-
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
28
|
-
}
|
|
29
|
-
return acc;
|
|
30
|
-
}, {
|
|
31
|
-
borrowInterest: '0', supplyInterest: '0', incentiveUsd: '0', borrowedUsd: '0', suppliedUsd: '0',
|
|
32
|
-
});
|
|
33
|
-
const { borrowedUsd, suppliedUsd, borrowInterest, supplyInterest, incentiveUsd, } = sumValues;
|
|
34
|
-
const totalInterestUsd = new decimal_js_1.default(borrowInterest).add(supplyInterest).add(incentiveUsd).toString();
|
|
35
|
-
const balance = new decimal_js_1.default(suppliedUsd).sub(borrowedUsd);
|
|
36
|
-
const netApy = new decimal_js_1.default(totalInterestUsd).div(balance).times(100).toString();
|
|
37
|
-
return { netApy, totalInterestUsd, incentiveUsd };
|
|
38
|
-
};
|
|
39
|
-
exports.calculateNetApyLiquityV2 = calculateNetApyLiquityV2;
|
|
40
|
-
const getLiquityV2AggregatedPositionData = ({ usedAssets, assetsData, minRatio, interestRate, }) => {
|
|
41
|
-
const payload = {};
|
|
42
|
-
payload.suppliedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, (usedAsset) => usedAsset, ({ suppliedUsd }) => suppliedUsd);
|
|
43
|
-
payload.borrowedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, (usedAsset) => usedAsset, ({ borrowedUsd }) => borrowedUsd);
|
|
44
|
-
payload.borrowLimitUsd = new decimal_js_1.default(payload.suppliedUsd).div(minRatio).mul(100).toString();
|
|
45
|
-
const leftToBorrowUsd = new decimal_js_1.default(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
46
|
-
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
47
|
-
const { netApy, incentiveUsd, totalInterestUsd } = (0, exports.calculateNetApyLiquityV2)(usedAssets, assetsData, interestRate);
|
|
48
|
-
payload.netApy = netApy;
|
|
49
|
-
payload.incentiveUsd = incentiveUsd;
|
|
50
|
-
payload.totalInterestUsd = totalInterestUsd;
|
|
51
|
-
const { leveragedType, leveragedAsset } = (0, moneymarket_1.isLeveragedPos)(usedAssets);
|
|
52
|
-
payload.leveragedType = leveragedType;
|
|
53
|
-
payload.leveragedAsset = leveragedAsset;
|
|
54
|
-
payload.liquidationPrice = '';
|
|
55
|
-
if (leveragedType !== '') {
|
|
56
|
-
const assetPrice = assetsData[leveragedAsset].price;
|
|
57
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.borrowLimitUsd);
|
|
58
|
-
}
|
|
59
|
-
return payload;
|
|
60
|
-
};
|
|
61
|
-
exports.getLiquityV2AggregatedPositionData = getLiquityV2AggregatedPositionData;
|
package/cjs/liquityV2/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Web3 from 'web3';
|
|
2
|
-
import { NetworkNumber } from '../types/common';
|
|
3
|
-
import { InnerLiquityV2MarketData, LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2TroveData } from '../types';
|
|
4
|
-
export declare const getLiquityV2MarketData: (web3: Web3, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo, mainnetWeb3: Web3) => Promise<LiquityV2MarketData>;
|
|
5
|
-
export declare const getLiquityV2TroveData: (web3: Web3, network: NetworkNumber, { selectedMarket, assetsData, marketData, troveId, }: {
|
|
6
|
-
selectedMarket: LiquityV2MarketInfo;
|
|
7
|
-
assetsData: LiquityV2AssetsData;
|
|
8
|
-
marketData: InnerLiquityV2MarketData;
|
|
9
|
-
troveId: string;
|
|
10
|
-
}) => Promise<LiquityV2TroveData>;
|