@defisaver/positions-sdk 0.0.144 → 0.0.146
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/aaveV3/index.js +6 -97
- package/cjs/config/contracts.js +4 -4
- package/cjs/markets/aave/index.js +2 -0
- package/cjs/morphoAaveV3/index.js +4 -3
- package/cjs/types/aave.d.ts +4 -1
- package/esm/aaveV3/index.js +4 -95
- package/esm/config/contracts.js +4 -4
- package/esm/markets/aave/index.js +2 -0
- package/esm/morphoAaveV3/index.js +4 -3
- package/esm/types/aave.d.ts +4 -1
- package/package.json +41 -41
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +584 -676
- 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 +1034 -1034
- package/src/constants/index.ts +6 -6
- 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 +195 -195
- 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/index.ts +7 -7
- 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 +46 -46
- 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 -150
- package/src/markets/aave/marketAssets.ts +48 -48
- 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/index.ts +21 -21
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +691 -691
- 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 +616 -615
- 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 +51 -51
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +424 -424
- package/src/staking/staking.ts +189 -189
- package/src/types/aave.ts +263 -263
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +129 -129
- 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 +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +144 -144
- package/src/types/spark.ts +127 -127
package/README.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
-
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
-
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
-
|
|
16
|
-
## Setup
|
|
17
|
-
Supported Node version is v10.
|
|
18
|
-
|
|
19
|
-
- run `npm install` (first time)
|
|
20
|
-
- run `npm run build`
|
|
21
|
-
|
|
22
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
-
|
|
24
|
-
## How to use
|
|
25
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
-
|
|
27
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
-
```js
|
|
29
|
-
import Web3 from 'web3';
|
|
30
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// every protocol has market data and user data getters
|
|
34
|
-
const {
|
|
35
|
-
getCompoundV3MarketsData,
|
|
36
|
-
getCompoundV3AccountData,
|
|
37
|
-
} = compoundV3;
|
|
38
|
-
|
|
39
|
-
const provider = 'Your RPC provider';
|
|
40
|
-
const web3 = new Web3(provider);
|
|
41
|
-
|
|
42
|
-
const user = '0x123...';
|
|
43
|
-
|
|
44
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
-
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
-
1, // network
|
|
47
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
-
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const userData = await getCompoundV3AccountData(
|
|
52
|
-
web3,
|
|
53
|
-
1, // network
|
|
54
|
-
userAddress, // EOA or DSProxy
|
|
55
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
-
{
|
|
57
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
-
assetsData,
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Morpho Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV2)
|
|
10
|
+
- [Morpho Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/morphoAaveV3)
|
|
11
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
12
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
13
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
14
|
+
- [Chicken Bonds](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/chickenBonds)
|
|
15
|
+
|
|
16
|
+
## Setup
|
|
17
|
+
Supported Node version is v10.
|
|
18
|
+
|
|
19
|
+
- run `npm install` (first time)
|
|
20
|
+
- run `npm run build`
|
|
21
|
+
|
|
22
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
23
|
+
|
|
24
|
+
## How to use
|
|
25
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
26
|
+
|
|
27
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
28
|
+
```js
|
|
29
|
+
import Web3 from 'web3';
|
|
30
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// every protocol has market data and user data getters
|
|
34
|
+
const {
|
|
35
|
+
getCompoundV3MarketsData,
|
|
36
|
+
getCompoundV3AccountData,
|
|
37
|
+
} = compoundV3;
|
|
38
|
+
|
|
39
|
+
const provider = 'Your RPC provider';
|
|
40
|
+
const web3 = new Web3(provider);
|
|
41
|
+
|
|
42
|
+
const user = '0x123...';
|
|
43
|
+
|
|
44
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
45
|
+
web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
46
|
+
1, // network
|
|
47
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
48
|
+
web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const userData = await getCompoundV3AccountData(
|
|
52
|
+
web3,
|
|
53
|
+
1, // network
|
|
54
|
+
userAddress, // EOA or DSProxy
|
|
55
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
56
|
+
{
|
|
57
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
58
|
+
assetsData,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -17,14 +17,13 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
19
19
|
const utils_1 = require("../services/utils");
|
|
20
|
-
const aave_1 = require("../types/aave");
|
|
21
20
|
const common_1 = require("../types/common");
|
|
22
21
|
const staking_1 = require("../staking");
|
|
23
22
|
const multicall_1 = require("../multicall");
|
|
24
23
|
const assets_1 = require("../assets");
|
|
25
24
|
const moneymarket_1 = require("../moneymarket");
|
|
26
25
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
27
|
-
const
|
|
26
|
+
const aave_1 = require("../markets/aave");
|
|
28
27
|
const test = (web3, network) => {
|
|
29
28
|
const contract = (0, contracts_1.AaveV3ViewContract)(web3, 1);
|
|
30
29
|
return contract.methods.AAVE_REFERRAL_CODE().call();
|
|
@@ -74,94 +73,7 @@ const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
|
74
73
|
};
|
|
75
74
|
exports.aaveV3EmodeCategoriesMapping = aaveV3EmodeCategoriesMapping;
|
|
76
75
|
// eslint-disable-next-line no-bitwise
|
|
77
|
-
const isEnabledOnBitmap = (bitmap, assetId) => ((
|
|
78
|
-
// @DEV: hardcode emodes till they add new emodes structs to all chains
|
|
79
|
-
const getAllEmodesHardcoded = (network, selectedMarket) => {
|
|
80
|
-
switch (network) {
|
|
81
|
-
case common_1.NetworkNumber.Eth:
|
|
82
|
-
{
|
|
83
|
-
switch (selectedMarket) {
|
|
84
|
-
case aave_1.AaveVersions.AaveV3:
|
|
85
|
-
return [
|
|
86
|
-
{
|
|
87
|
-
ltv: 9300,
|
|
88
|
-
liquidationThreshold: 9500,
|
|
89
|
-
liquidationBonus: 10100,
|
|
90
|
-
collateralBitmap: '2952790659',
|
|
91
|
-
label: 'ETH correlated',
|
|
92
|
-
borrowableBitmap: '2952790659',
|
|
93
|
-
},
|
|
94
|
-
];
|
|
95
|
-
case aave_1.AaveVersions.AaveV3Lido:
|
|
96
|
-
return [
|
|
97
|
-
{
|
|
98
|
-
ltv: 9350,
|
|
99
|
-
liquidationThreshold: 9550,
|
|
100
|
-
liquidationBonus: 10100,
|
|
101
|
-
collateralBitmap: '3',
|
|
102
|
-
label: 'ETH correlated',
|
|
103
|
-
borrowableBitmap: '3',
|
|
104
|
-
},
|
|
105
|
-
];
|
|
106
|
-
case aave_1.AaveVersions.AaveV3Etherfi:
|
|
107
|
-
return [];
|
|
108
|
-
default:
|
|
109
|
-
throw new Error('Emode not implemented for this market');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
case common_1.NetworkNumber.Arb:
|
|
113
|
-
return [
|
|
114
|
-
{
|
|
115
|
-
ltv: 9300,
|
|
116
|
-
liquidationThreshold: 9500,
|
|
117
|
-
liquidationBonus: 10100,
|
|
118
|
-
collateralBitmap: '4261',
|
|
119
|
-
label: 'Stablecoins',
|
|
120
|
-
borrowableBitmap: '4261',
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
ltv: 9300,
|
|
124
|
-
liquidationThreshold: 9500,
|
|
125
|
-
liquidationBonus: 10100,
|
|
126
|
-
collateralBitmap: '33040',
|
|
127
|
-
label: 'ETH correlated',
|
|
128
|
-
borrowableBitmap: '33040',
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
case common_1.NetworkNumber.Opt:
|
|
132
|
-
return [
|
|
133
|
-
{
|
|
134
|
-
ltv: 9000,
|
|
135
|
-
liquidationThreshold: 9300,
|
|
136
|
-
liquidationBonus: 10100,
|
|
137
|
-
collateralBitmap: '8357',
|
|
138
|
-
label: 'Stablecoins',
|
|
139
|
-
borrowableBitmap: '8357',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
ltv: 9300,
|
|
143
|
-
liquidationThreshold: 9500,
|
|
144
|
-
liquidationBonus: 10100,
|
|
145
|
-
collateralBitmap: '4624',
|
|
146
|
-
label: 'ETH correlated',
|
|
147
|
-
borrowableBitmap: '4624',
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
case common_1.NetworkNumber.Base:
|
|
151
|
-
return [
|
|
152
|
-
{
|
|
153
|
-
ltv: 9000,
|
|
154
|
-
liquidationThreshold: 9300,
|
|
155
|
-
liquidationBonus: 10200,
|
|
156
|
-
collateralBitmap: '43',
|
|
157
|
-
label: 'ETH correlated',
|
|
158
|
-
borrowableBitmap: '43',
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
default:
|
|
162
|
-
throw new Error('Emode not implemented for this network');
|
|
163
|
-
}
|
|
164
|
-
};
|
|
76
|
+
const isEnabledOnBitmap = (bitmap, assetId) => (BigInt(bitmap) >> BigInt(assetId)) & BigInt(1);
|
|
165
77
|
function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
166
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
79
|
const _addresses = market.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a), network).address);
|
|
@@ -203,8 +115,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
203
115
|
// eslint-disable-next-line prefer-const
|
|
204
116
|
let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
|
|
205
117
|
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
206
|
-
|
|
207
|
-
getAllEmodesHardcoded(network, market.value),
|
|
118
|
+
loanInfoContract.methods.getAllEmodes(marketAddress).call(),
|
|
208
119
|
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
|
|
209
120
|
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : (0, multicall_1.multicall)(multicallCallsObject, web3, network),
|
|
210
121
|
]);
|
|
@@ -227,9 +138,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
227
138
|
}
|
|
228
139
|
const [{ 0: ghoDiscountedPerDiscountToken }, { 0: discountRate }, { 0: minDiscountTokenBalance }, { 0: minGhoBalanceForDiscount }, { 0: facilitatorsList },] = multiRes;
|
|
229
140
|
let rewardInfo = null;
|
|
230
|
-
|
|
231
|
-
// const networksWithIncentives = [NetworkNumber.Arb, NetworkNumber.Opt];
|
|
232
|
-
const networksWithIncentives = [];
|
|
141
|
+
const networksWithIncentives = [common_1.NetworkNumber.Arb, common_1.NetworkNumber.Opt];
|
|
233
142
|
if (networksWithIncentives.includes(network)) {
|
|
234
143
|
rewardInfo = yield aaveIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
|
|
235
144
|
rewardInfo = rewardInfo.reduce((all, _market) => {
|
|
@@ -374,7 +283,7 @@ const getAaveV3AccountBalances = (web3, network, block, addressMapping, address)
|
|
|
374
283
|
return balances;
|
|
375
284
|
}
|
|
376
285
|
const loanInfoContract = (0, contracts_1.AaveV3ViewContract)(web3, network, block);
|
|
377
|
-
const market = (0,
|
|
286
|
+
const market = (0, aave_1.AAVE_V3)(network);
|
|
378
287
|
const marketAddress = market.providerAddress;
|
|
379
288
|
// @ts-ignore
|
|
380
289
|
const protocolDataProviderContract = (0, contracts_1.createContractWrapper)(web3, network, market.protocolData, market.protocolDataAddress);
|
|
@@ -510,7 +419,7 @@ const getAaveV3AccountData = (web3, network, address, extractedState) => __await
|
|
|
510
419
|
exports.getAaveV3AccountData = getAaveV3AccountData;
|
|
511
420
|
const getAaveV3FullPositionData = (web3, network, address, market, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
512
421
|
const marketData = yield getAaveV3MarketData(web3, network, market, mainnetWeb3);
|
|
513
|
-
const positionData = yield (0, exports.getAaveV3AccountData)(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
422
|
+
const positionData = yield (0, exports.getAaveV3AccountData)(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market, eModeCategoriesData: marketData.eModeCategoriesData });
|
|
514
423
|
return positionData;
|
|
515
424
|
});
|
|
516
425
|
exports.getAaveV3FullPositionData = getAaveV3FullPositionData;
|
package/cjs/config/contracts.js
CHANGED
|
@@ -266,16 +266,16 @@ module.exports = {
|
|
|
266
266
|
"abi": [{ "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }], "name": "getReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "aIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "vIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "sIncentiveData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "getUserReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "aTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "vTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "sTokenIncentivesUserData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }],
|
|
267
267
|
"networks": {
|
|
268
268
|
"1": {
|
|
269
|
-
"address": "
|
|
269
|
+
"address": "0x5a40cDe2b76Da2beD545efB3ae15708eE56aAF9c"
|
|
270
270
|
},
|
|
271
271
|
"10": {
|
|
272
|
-
"address": "
|
|
272
|
+
"address": "0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3"
|
|
273
273
|
},
|
|
274
274
|
"8453": {
|
|
275
|
-
"address": "
|
|
275
|
+
"address": "0x5c5228aC8BC1528482514aF3e27E692495148717"
|
|
276
276
|
},
|
|
277
277
|
"42161": {
|
|
278
|
-
"address": "
|
|
278
|
+
"address": "0xE92cd6164CE7DC68e740765BC1f2a091B6CBc3e4"
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
},
|
|
@@ -119,6 +119,8 @@ const MORPHO_AAVE_V3_ETH = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
|
119
119
|
providerAddress: (0, contracts_1.getConfigContractAddress)('AaveV3PoolAddressesProvider', networkId),
|
|
120
120
|
protocolData: 'AaveV3ProtocolDataProvider',
|
|
121
121
|
protocolDataAddress: (0, contracts_1.getConfigContractAddress)('AaveV3ProtocolDataProvider', networkId),
|
|
122
|
+
aaveLendingPool: 'AaveV3LendingPool',
|
|
123
|
+
aaveLendingPoolAddress: (0, contracts_1.getConfigContractAddress)('AaveV3LendingPool', networkId),
|
|
122
124
|
lendingPool: 'MorphoAaveV3ProxyEthMarket',
|
|
123
125
|
lendingPoolAddress: (0, contracts_1.getConfigContractAddress)('MorphoAaveV3ProxyEthMarket', 1),
|
|
124
126
|
// icon: SvgAdapter(protocolIcons.morpho),
|
|
@@ -80,6 +80,7 @@ const computeMorphoMarketData = (loanInfo, morphoMarketData, aaveIndexes) => {
|
|
|
80
80
|
const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
81
|
// @ts-ignore
|
|
82
82
|
const lendingPoolContract = (0, contracts_1.createContractWrapper)(web3, network, selectedMarket.lendingPool, selectedMarket.lendingPoolAddress);
|
|
83
|
+
const aaveLendingPoolContract = (0, contracts_1.createContractWrapper)(web3, network, selectedMarket.aaveLendingPool, selectedMarket.aaveLendingPoolAddress);
|
|
83
84
|
const _addresses = selectedMarket.assets.map((a) => (0, tokens_1.getAssetInfo)((0, utils_1.ethToWeth)(a)).address);
|
|
84
85
|
const splitStart = Math.floor(_addresses.length / 2);
|
|
85
86
|
const loanInfoCallsToSkip = 2; // skipping getFullTokensInfo calls at the start of multicallArray
|
|
@@ -102,9 +103,9 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
|
|
|
102
103
|
params: [underlyingAddress],
|
|
103
104
|
},
|
|
104
105
|
{
|
|
105
|
-
target:
|
|
106
|
+
target: aaveLendingPoolContract.options.address,
|
|
106
107
|
// @ts-ignore
|
|
107
|
-
abiItem: (0, utils_1.getAbiItem)((0, contracts_1.getConfigContractAbi)(selectedMarket.
|
|
108
|
+
abiItem: (0, utils_1.getAbiItem)((0, contracts_1.getConfigContractAbi)(selectedMarket.aaveLendingPool), 'getReserveData'),
|
|
108
109
|
params: [underlyingAddress],
|
|
109
110
|
}]))).flat(),
|
|
110
111
|
];
|
|
@@ -140,7 +141,7 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
|
|
|
140
141
|
const assetsData = yield Promise.all(loanInfo.map((info, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
142
|
var _a, _b, _c, _d, _e, _f;
|
|
142
143
|
const morphoMarketData = Object.assign(Object.assign({}, multicallResponse[(2 * i) + loanInfoCallsToSkip][0]), { scaledMorphoBorrowOnPool: scaledBalanceResponse.value[2 * i][0], scaledMorphoSupplyOnPool: scaledBalanceResponse.value[(2 * i) + 1][0] });
|
|
143
|
-
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)]);
|
|
144
|
+
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)][0]);
|
|
144
145
|
const { symbol, address } = (0, tokens_1.getAssetInfoByAddress)((0, utils_1.wethToEthByAddress)(marketData.underlyingTokenAddress));
|
|
145
146
|
const data = {
|
|
146
147
|
symbol,
|
package/cjs/types/aave.d.ts
CHANGED
|
@@ -234,5 +234,8 @@ export interface AaveHelperCommon {
|
|
|
234
234
|
network?: NetworkNumber;
|
|
235
235
|
}
|
|
236
236
|
export type MorphoAaveV2MarketInfo = Omit<AaveMarketInfo, 'provider' | 'lendingPool' | 'protocolData' | 'protocolDataAddress'>;
|
|
237
|
-
export type MorphoAaveV3MarketInfo = Omit<AaveMarketInfo, 'provider'
|
|
237
|
+
export type MorphoAaveV3MarketInfo = Omit<AaveMarketInfo, 'provider'> & {
|
|
238
|
+
aaveLendingPool: 'AaveV3LendingPool';
|
|
239
|
+
aaveLendingPoolAddress: string;
|
|
240
|
+
};
|
|
238
241
|
export type MorphoAaveMarketInfo = MorphoAaveV2MarketInfo | MorphoAaveV3MarketInfo;
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
12
12
|
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, createContractWrapper, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
13
13
|
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
14
|
-
import { AaveVersions, } from '../types/aave';
|
|
15
14
|
import { NetworkNumber, } from '../types/common';
|
|
16
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
17
16
|
import { multicall } from '../multicall';
|
|
@@ -65,94 +64,7 @@ export const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
|
65
64
|
return categoriesMapping;
|
|
66
65
|
};
|
|
67
66
|
// eslint-disable-next-line no-bitwise
|
|
68
|
-
const isEnabledOnBitmap = (bitmap, assetId) => ((
|
|
69
|
-
// @DEV: hardcode emodes till they add new emodes structs to all chains
|
|
70
|
-
const getAllEmodesHardcoded = (network, selectedMarket) => {
|
|
71
|
-
switch (network) {
|
|
72
|
-
case NetworkNumber.Eth:
|
|
73
|
-
{
|
|
74
|
-
switch (selectedMarket) {
|
|
75
|
-
case AaveVersions.AaveV3:
|
|
76
|
-
return [
|
|
77
|
-
{
|
|
78
|
-
ltv: 9300,
|
|
79
|
-
liquidationThreshold: 9500,
|
|
80
|
-
liquidationBonus: 10100,
|
|
81
|
-
collateralBitmap: '2952790659',
|
|
82
|
-
label: 'ETH correlated',
|
|
83
|
-
borrowableBitmap: '2952790659',
|
|
84
|
-
},
|
|
85
|
-
];
|
|
86
|
-
case AaveVersions.AaveV3Lido:
|
|
87
|
-
return [
|
|
88
|
-
{
|
|
89
|
-
ltv: 9350,
|
|
90
|
-
liquidationThreshold: 9550,
|
|
91
|
-
liquidationBonus: 10100,
|
|
92
|
-
collateralBitmap: '3',
|
|
93
|
-
label: 'ETH correlated',
|
|
94
|
-
borrowableBitmap: '3',
|
|
95
|
-
},
|
|
96
|
-
];
|
|
97
|
-
case AaveVersions.AaveV3Etherfi:
|
|
98
|
-
return [];
|
|
99
|
-
default:
|
|
100
|
-
throw new Error('Emode not implemented for this market');
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
case NetworkNumber.Arb:
|
|
104
|
-
return [
|
|
105
|
-
{
|
|
106
|
-
ltv: 9300,
|
|
107
|
-
liquidationThreshold: 9500,
|
|
108
|
-
liquidationBonus: 10100,
|
|
109
|
-
collateralBitmap: '4261',
|
|
110
|
-
label: 'Stablecoins',
|
|
111
|
-
borrowableBitmap: '4261',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
ltv: 9300,
|
|
115
|
-
liquidationThreshold: 9500,
|
|
116
|
-
liquidationBonus: 10100,
|
|
117
|
-
collateralBitmap: '33040',
|
|
118
|
-
label: 'ETH correlated',
|
|
119
|
-
borrowableBitmap: '33040',
|
|
120
|
-
},
|
|
121
|
-
];
|
|
122
|
-
case NetworkNumber.Opt:
|
|
123
|
-
return [
|
|
124
|
-
{
|
|
125
|
-
ltv: 9000,
|
|
126
|
-
liquidationThreshold: 9300,
|
|
127
|
-
liquidationBonus: 10100,
|
|
128
|
-
collateralBitmap: '8357',
|
|
129
|
-
label: 'Stablecoins',
|
|
130
|
-
borrowableBitmap: '8357',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
ltv: 9300,
|
|
134
|
-
liquidationThreshold: 9500,
|
|
135
|
-
liquidationBonus: 10100,
|
|
136
|
-
collateralBitmap: '4624',
|
|
137
|
-
label: 'ETH correlated',
|
|
138
|
-
borrowableBitmap: '4624',
|
|
139
|
-
},
|
|
140
|
-
];
|
|
141
|
-
case NetworkNumber.Base:
|
|
142
|
-
return [
|
|
143
|
-
{
|
|
144
|
-
ltv: 9000,
|
|
145
|
-
liquidationThreshold: 9300,
|
|
146
|
-
liquidationBonus: 10200,
|
|
147
|
-
collateralBitmap: '43',
|
|
148
|
-
label: 'ETH correlated',
|
|
149
|
-
borrowableBitmap: '43',
|
|
150
|
-
},
|
|
151
|
-
];
|
|
152
|
-
default:
|
|
153
|
-
throw new Error('Emode not implemented for this network');
|
|
154
|
-
}
|
|
155
|
-
};
|
|
67
|
+
const isEnabledOnBitmap = (bitmap, assetId) => (BigInt(bitmap) >> BigInt(assetId)) & BigInt(1);
|
|
156
68
|
export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
157
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
70
|
const _addresses = market.assets.map(a => getAssetInfo(ethToWeth(a), network).address);
|
|
@@ -194,8 +106,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
194
106
|
// eslint-disable-next-line prefer-const
|
|
195
107
|
let [loanInfo, eModesInfo, isBorrowAllowed, multiRes] = yield Promise.all([
|
|
196
108
|
loanInfoContract.methods.getFullTokensInfo(marketAddress, _addresses).call(),
|
|
197
|
-
|
|
198
|
-
getAllEmodesHardcoded(network, market.value),
|
|
109
|
+
loanInfoContract.methods.getAllEmodes(marketAddress).call(),
|
|
199
110
|
loanInfoContract.methods.isBorrowAllowed(marketAddress).call(),
|
|
200
111
|
isL2 ? [{ 0: null }, { 0: null }, { 0: null }, { 0: null }, { 0: null }] : multicall(multicallCallsObject, web3, network),
|
|
201
112
|
]);
|
|
@@ -218,9 +129,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
218
129
|
}
|
|
219
130
|
const [{ 0: ghoDiscountedPerDiscountToken }, { 0: discountRate }, { 0: minDiscountTokenBalance }, { 0: minGhoBalanceForDiscount }, { 0: facilitatorsList },] = multiRes;
|
|
220
131
|
let rewardInfo = null;
|
|
221
|
-
|
|
222
|
-
// const networksWithIncentives = [NetworkNumber.Arb, NetworkNumber.Opt];
|
|
223
|
-
const networksWithIncentives = [];
|
|
132
|
+
const networksWithIncentives = [NetworkNumber.Arb, NetworkNumber.Opt];
|
|
224
133
|
if (networksWithIncentives.includes(network)) {
|
|
225
134
|
rewardInfo = yield aaveIncentivesContract.methods.getReservesIncentivesData(marketAddress).call();
|
|
226
135
|
rewardInfo = rewardInfo.reduce((all, _market) => {
|
|
@@ -498,6 +407,6 @@ export const getAaveV3AccountData = (web3, network, address, extractedState) =>
|
|
|
498
407
|
});
|
|
499
408
|
export const getAaveV3FullPositionData = (web3, network, address, market, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
500
409
|
const marketData = yield getAaveV3MarketData(web3, network, market, mainnetWeb3);
|
|
501
|
-
const positionData = yield getAaveV3AccountData(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
410
|
+
const positionData = yield getAaveV3AccountData(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market, eModeCategoriesData: marketData.eModeCategoriesData });
|
|
502
411
|
return positionData;
|
|
503
412
|
});
|
package/esm/config/contracts.js
CHANGED
|
@@ -265,16 +265,16 @@ module.exports = {
|
|
|
265
265
|
"abi": [{ "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }], "name": "getReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "aIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "vIncentiveData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "uint256", "name": "emissionPerSecond", "type": "uint256" }, { "internalType": "uint256", "name": "incentivesLastUpdateTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesIndex", "type": "uint256" }, { "internalType": "uint256", "name": "emissionEndTimestamp", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "precision", "type": "uint8" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.RewardInfo[]", "name": "rewardsTokenInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.IncentiveData", "name": "sIncentiveData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.AggregatedReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract IPoolAddressesProvider", "name": "provider", "type": "address" }, { "internalType": "address", "name": "user", "type": "address" }], "name": "getUserReservesIncentivesData", "outputs": [{ "components": [{ "internalType": "address", "name": "underlyingAsset", "type": "address" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "aTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "vTokenIncentivesUserData", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }, { "internalType": "address", "name": "incentiveControllerAddress", "type": "address" }, { "components": [{ "internalType": "string", "name": "rewardTokenSymbol", "type": "string" }, { "internalType": "address", "name": "rewardOracleAddress", "type": "address" }, { "internalType": "address", "name": "rewardTokenAddress", "type": "address" }, { "internalType": "uint256", "name": "userUnclaimedRewards", "type": "uint256" }, { "internalType": "uint256", "name": "tokenIncentivesUserIndex", "type": "uint256" }, { "internalType": "int256", "name": "rewardPriceFeed", "type": "int256" }, { "internalType": "uint8", "name": "priceFeedDecimals", "type": "uint8" }, { "internalType": "uint8", "name": "rewardTokenDecimals", "type": "uint8" }], "internalType": "struct IUiIncentiveDataProviderV3.UserRewardInfo[]", "name": "userRewardsInformation", "type": "tuple[]" }], "internalType": "struct IUiIncentiveDataProviderV3.UserIncentiveData", "name": "sTokenIncentivesUserData", "type": "tuple" }], "internalType": "struct IUiIncentiveDataProviderV3.UserReserveIncentiveData[]", "name": "", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }],
|
|
266
266
|
"networks": {
|
|
267
267
|
"1": {
|
|
268
|
-
"address": "
|
|
268
|
+
"address": "0x5a40cDe2b76Da2beD545efB3ae15708eE56aAF9c"
|
|
269
269
|
},
|
|
270
270
|
"10": {
|
|
271
|
-
"address": "
|
|
271
|
+
"address": "0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3"
|
|
272
272
|
},
|
|
273
273
|
"8453": {
|
|
274
|
-
"address": "
|
|
274
|
+
"address": "0x5c5228aC8BC1528482514aF3e27E692495148717"
|
|
275
275
|
},
|
|
276
276
|
"42161": {
|
|
277
|
-
"address": "
|
|
277
|
+
"address": "0xE92cd6164CE7DC68e740765BC1f2a091B6CBc3e4"
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
},
|
|
@@ -108,6 +108,8 @@ export const MORPHO_AAVE_V3_ETH = (networkId = NetworkNumber.Eth) => ({
|
|
|
108
108
|
providerAddress: getConfigContractAddress('AaveV3PoolAddressesProvider', networkId),
|
|
109
109
|
protocolData: 'AaveV3ProtocolDataProvider',
|
|
110
110
|
protocolDataAddress: getConfigContractAddress('AaveV3ProtocolDataProvider', networkId),
|
|
111
|
+
aaveLendingPool: 'AaveV3LendingPool',
|
|
112
|
+
aaveLendingPoolAddress: getConfigContractAddress('AaveV3LendingPool', networkId),
|
|
111
113
|
lendingPool: 'MorphoAaveV3ProxyEthMarket',
|
|
112
114
|
lendingPoolAddress: getConfigContractAddress('MorphoAaveV3ProxyEthMarket', 1),
|
|
113
115
|
// icon: SvgAdapter(protocolIcons.morpho),
|
|
@@ -74,6 +74,7 @@ const computeMorphoMarketData = (loanInfo, morphoMarketData, aaveIndexes) => {
|
|
|
74
74
|
export const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
const lendingPoolContract = createContractWrapper(web3, network, selectedMarket.lendingPool, selectedMarket.lendingPoolAddress);
|
|
77
|
+
const aaveLendingPoolContract = createContractWrapper(web3, network, selectedMarket.aaveLendingPool, selectedMarket.aaveLendingPoolAddress);
|
|
77
78
|
const _addresses = selectedMarket.assets.map((a) => getAssetInfo(ethToWeth(a)).address);
|
|
78
79
|
const splitStart = Math.floor(_addresses.length / 2);
|
|
79
80
|
const loanInfoCallsToSkip = 2; // skipping getFullTokensInfo calls at the start of multicallArray
|
|
@@ -96,9 +97,9 @@ export const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainne
|
|
|
96
97
|
params: [underlyingAddress],
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
|
-
target:
|
|
100
|
+
target: aaveLendingPoolContract.options.address,
|
|
100
101
|
// @ts-ignore
|
|
101
|
-
abiItem: getAbiItem(getConfigContractAbi(selectedMarket.
|
|
102
|
+
abiItem: getAbiItem(getConfigContractAbi(selectedMarket.aaveLendingPool), 'getReserveData'),
|
|
102
103
|
params: [underlyingAddress],
|
|
103
104
|
}]))).flat(),
|
|
104
105
|
];
|
|
@@ -134,7 +135,7 @@ export const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainne
|
|
|
134
135
|
const assetsData = yield Promise.all(loanInfo.map((info, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
136
|
var _a, _b, _c, _d, _e, _f;
|
|
136
137
|
const morphoMarketData = Object.assign(Object.assign({}, multicallResponse[(2 * i) + loanInfoCallsToSkip][0]), { scaledMorphoBorrowOnPool: scaledBalanceResponse.value[2 * i][0], scaledMorphoSupplyOnPool: scaledBalanceResponse.value[(2 * i) + 1][0] });
|
|
137
|
-
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)]);
|
|
138
|
+
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)][0]);
|
|
138
139
|
const { symbol, address } = getAssetInfoByAddress(wethToEthByAddress(marketData.underlyingTokenAddress));
|
|
139
140
|
const data = {
|
|
140
141
|
symbol,
|
package/esm/types/aave.d.ts
CHANGED
|
@@ -234,5 +234,8 @@ export interface AaveHelperCommon {
|
|
|
234
234
|
network?: NetworkNumber;
|
|
235
235
|
}
|
|
236
236
|
export type MorphoAaveV2MarketInfo = Omit<AaveMarketInfo, 'provider' | 'lendingPool' | 'protocolData' | 'protocolDataAddress'>;
|
|
237
|
-
export type MorphoAaveV3MarketInfo = Omit<AaveMarketInfo, 'provider'
|
|
237
|
+
export type MorphoAaveV3MarketInfo = Omit<AaveMarketInfo, 'provider'> & {
|
|
238
|
+
aaveLendingPool: 'AaveV3LendingPool';
|
|
239
|
+
aaveLendingPoolAddress: string;
|
|
240
|
+
};
|
|
238
241
|
export type MorphoAaveMarketInfo = MorphoAaveV2MarketInfo | MorphoAaveV3MarketInfo;
|