@defisaver/positions-sdk 2.0.15-dev → 2.0.15-dev-3
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 +64 -64
- package/cjs/aaveV2/index.js +9 -5
- package/cjs/aaveV3/index.js +50 -40
- package/cjs/aaveV3/merit.d.ts +17 -0
- package/cjs/aaveV3/merit.js +95 -0
- package/cjs/aaveV3/{rewards.d.ts → merkl.d.ts} +7 -2
- package/cjs/aaveV3/{rewards.js → merkl.js} +30 -14
- package/cjs/compoundV2/index.js +13 -7
- package/cjs/compoundV3/index.js +7 -2
- package/cjs/config/contracts.d.ts +6510 -1851
- package/cjs/config/contracts.js +33 -12
- package/cjs/contracts.d.ts +178 -0
- package/cjs/eulerV2/index.js +11 -2
- package/cjs/fluid/index.js +105 -34
- package/cjs/helpers/aaveHelpers/index.js +0 -1
- package/cjs/helpers/compoundHelpers/index.d.ts +3 -5
- package/cjs/helpers/compoundHelpers/index.js +15 -11
- package/cjs/helpers/eulerHelpers/index.d.ts +0 -5
- package/cjs/helpers/eulerHelpers/index.js +2 -31
- package/cjs/helpers/fluidHelpers/index.js +2 -0
- package/cjs/helpers/liquityV2Helpers/index.js +3 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/liquityV2/index.js +10 -2
- package/cjs/llamaLend/index.js +10 -2
- package/cjs/morphoBlue/index.js +20 -6
- package/cjs/spark/index.js +20 -30
- package/cjs/staking/eligibility.d.ts +11 -0
- package/cjs/staking/eligibility.js +43 -0
- package/cjs/staking/index.d.ts +1 -0
- package/cjs/staking/index.js +1 -0
- package/cjs/staking/staking.d.ts +1 -7
- package/cjs/staking/staking.js +29 -55
- package/cjs/types/aave.d.ts +1 -7
- package/cjs/types/common.d.ts +16 -4
- package/cjs/types/common.js +10 -1
- package/cjs/types/euler.d.ts +3 -3
- package/cjs/types/fluid.d.ts +3 -5
- package/cjs/types/liquityV2.d.ts +3 -3
- package/cjs/types/llamaLend.d.ts +3 -1
- package/cjs/types/morphoBlue.d.ts +3 -5
- package/cjs/types/spark.d.ts +0 -3
- package/esm/aaveV2/index.js +9 -5
- package/esm/aaveV3/index.js +48 -38
- package/esm/aaveV3/merit.d.ts +17 -0
- package/esm/aaveV3/merit.js +90 -0
- package/esm/aaveV3/{rewards.d.ts → merkl.d.ts} +7 -2
- package/esm/aaveV3/{rewards.js → merkl.js} +28 -13
- package/esm/compoundV2/index.js +13 -7
- package/esm/compoundV3/index.js +7 -2
- package/esm/config/contracts.d.ts +6510 -1851
- package/esm/config/contracts.js +33 -12
- package/esm/contracts.d.ts +178 -0
- package/esm/eulerV2/index.js +11 -2
- package/esm/fluid/index.js +106 -35
- package/esm/helpers/aaveHelpers/index.js +0 -1
- package/esm/helpers/compoundHelpers/index.d.ts +3 -5
- package/esm/helpers/compoundHelpers/index.js +16 -12
- package/esm/helpers/eulerHelpers/index.d.ts +0 -5
- package/esm/helpers/eulerHelpers/index.js +2 -30
- package/esm/helpers/fluidHelpers/index.js +2 -0
- package/esm/helpers/liquityV2Helpers/index.js +3 -2
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/liquityV2/index.js +11 -3
- package/esm/llamaLend/index.js +11 -3
- package/esm/morphoBlue/index.js +21 -7
- package/esm/spark/index.js +21 -31
- package/esm/staking/eligibility.d.ts +11 -0
- package/esm/staking/eligibility.js +36 -0
- package/esm/staking/index.d.ts +1 -0
- package/esm/staking/index.js +1 -0
- package/esm/staking/staking.d.ts +1 -7
- package/esm/staking/staking.js +28 -53
- package/esm/types/aave.d.ts +1 -7
- package/esm/types/common.d.ts +16 -4
- package/esm/types/common.js +9 -0
- package/esm/types/euler.d.ts +3 -3
- package/esm/types/fluid.d.ts +3 -5
- package/esm/types/liquityV2.d.ts +3 -3
- package/esm/types/llamaLend.d.ts +3 -1
- package/esm/types/morphoBlue.d.ts +3 -5
- package/esm/types/spark.d.ts +0 -3
- package/package.json +47 -47
- package/src/aaveV2/index.ts +239 -236
- package/src/aaveV3/index.ts +511 -493
- package/src/aaveV3/merit.ts +98 -0
- package/src/aaveV3/{rewards.ts → merkl.ts} +141 -125
- package/src/compoundV2/index.ts +244 -240
- package/src/compoundV3/index.ts +274 -270
- package/src/config/contracts.ts +1129 -1108
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +107 -107
- package/src/curveUsd/index.ts +250 -250
- package/src/eulerV2/index.ts +324 -314
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1636 -1568
- package/src/helpers/aaveHelpers/index.ts +169 -170
- package/src/helpers/compoundHelpers/index.ts +267 -261
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -259
- package/src/helpers/fluidHelpers/index.ts +326 -324
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +390 -390
- package/src/helpers/sparkHelpers/index.ts +155 -155
- package/src/index.ts +45 -45
- package/src/liquity/index.ts +104 -104
- package/src/liquityV2/index.ts +418 -408
- package/src/llamaLend/index.ts +305 -296
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +49 -49
- package/src/markets/compound/index.ts +227 -227
- package/src/markets/compound/marketsAssets.ts +90 -90
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2456 -2456
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +11 -11
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoBlue/index.ts +236 -222
- package/src/portfolio/index.ts +285 -285
- package/src/services/priceService.ts +159 -159
- package/src/services/utils.ts +63 -63
- package/src/services/viem.ts +32 -32
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +444 -456
- package/src/staking/eligibility.ts +37 -0
- package/src/staking/index.ts +2 -1
- package/src/staking/staking.ts +169 -194
- package/src/types/aave.ts +189 -195
- package/src/types/common.ts +103 -88
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +121 -121
- package/src/types/euler.ts +175 -174
- package/src/types/fluid.ts +448 -450
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -157
- package/src/types/maker.ts +63 -63
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/portfolio.ts +60 -60
- package/src/types/spark.ts +135 -137
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
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
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
-
|
|
13
|
-
## Setup
|
|
14
|
-
Supported Node version is v10.
|
|
15
|
-
|
|
16
|
-
- run `npm install` (first time)
|
|
17
|
-
- run `npm run build`
|
|
18
|
-
|
|
19
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
-
|
|
21
|
-
## How to use
|
|
22
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
-
|
|
24
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
-
```js
|
|
26
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// every protocol has market data and user data getters
|
|
30
|
-
const {
|
|
31
|
-
getCompoundV3MarketsData,
|
|
32
|
-
getCompoundV3AccountData,
|
|
33
|
-
} = compoundV3;
|
|
34
|
-
|
|
35
|
-
const provider = 'Your RPC provider';
|
|
36
|
-
|
|
37
|
-
const user = '0x123...';
|
|
38
|
-
|
|
39
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
-
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
-
1, // network
|
|
42
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
-
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const userData = await getCompoundV3AccountData(
|
|
47
|
-
provider,
|
|
48
|
-
1, // network
|
|
49
|
-
userAddress, // EOA or DSProxy
|
|
50
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
-
{
|
|
52
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
-
assetsData,
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
-
|
|
60
|
-
## Testing
|
|
61
|
-
|
|
62
|
-
`npm run test` - Run all tests
|
|
63
|
-
|
|
64
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
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
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
Supported Node version is v10.
|
|
15
|
+
|
|
16
|
+
- run `npm install` (first time)
|
|
17
|
+
- run `npm run build`
|
|
18
|
+
|
|
19
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
+
|
|
21
|
+
## How to use
|
|
22
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
+
|
|
24
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
+
```js
|
|
26
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// every protocol has market data and user data getters
|
|
30
|
+
const {
|
|
31
|
+
getCompoundV3MarketsData,
|
|
32
|
+
getCompoundV3AccountData,
|
|
33
|
+
} = compoundV3;
|
|
34
|
+
|
|
35
|
+
const provider = 'Your RPC provider';
|
|
36
|
+
|
|
37
|
+
const user = '0x123...';
|
|
38
|
+
|
|
39
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
+
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
+
1, // network
|
|
42
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
+
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const userData = await getCompoundV3AccountData(
|
|
47
|
+
provider,
|
|
48
|
+
1, // network
|
|
49
|
+
userAddress, // EOA or DSProxy
|
|
50
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
+
{
|
|
52
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
+
assetsData,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
+
|
|
60
|
+
## Testing
|
|
61
|
+
|
|
62
|
+
`npm run test` - Run all tests
|
|
63
|
+
|
|
64
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
package/cjs/aaveV2/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getAaveV2FullPositionData = exports.getAaveV2AccountData = exports._getAaveV2AccountData = exports.getAaveV2AccountBalances = exports._getAaveV2AccountBalances = exports.getAaveV2MarketsData = exports._getAaveV2MarketsData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
+
const common_1 = require("../types/common");
|
|
18
19
|
const staking_1 = require("../staking");
|
|
19
20
|
const utils_1 = require("../services/utils");
|
|
20
21
|
const contracts_1 = require("../contracts");
|
|
@@ -62,15 +63,18 @@ const _getAaveV2MarketsData = (provider, network, selectedMarket) => __awaiter(v
|
|
|
62
63
|
totalBorrow: (0, tokens_1.assetAmountInEth)(market.totalBorrow.toString(), selectedMarket.assets[i]),
|
|
63
64
|
totalBorrowVar: (0, tokens_1.assetAmountInEth)(market.totalBorrowVar.toString(), selectedMarket.assets[i]),
|
|
64
65
|
priceInEth: new decimal_js_1.default(market.price.toString()).div(1e18).toString(),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
incentiveSupplyApy: '0',
|
|
66
|
+
supplyIncentives: [],
|
|
67
|
+
borrowIncentives: [],
|
|
68
68
|
price: new decimal_js_1.default(market.price.toString()).div(1e18).mul(ethPrice).toString(),
|
|
69
69
|
}));
|
|
70
70
|
const stEthMarket = markets.find(({ symbol }) => symbol === 'stETH');
|
|
71
71
|
if (stEthMarket) {
|
|
72
|
-
stEthMarket.
|
|
73
|
-
|
|
72
|
+
stEthMarket.supplyIncentives.push({
|
|
73
|
+
apy: yield (0, staking_1.getStakingApy)('stETH'),
|
|
74
|
+
token: 'stETH',
|
|
75
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
76
|
+
description: 'Native stETH yield.',
|
|
77
|
+
});
|
|
74
78
|
}
|
|
75
79
|
const payload = {};
|
|
76
80
|
// Sort by market size
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -25,7 +25,8 @@ const utils_1 = require("../services/utils");
|
|
|
25
25
|
const staking_1 = require("../staking");
|
|
26
26
|
const common_1 = require("../types/common");
|
|
27
27
|
const viem_1 = require("../services/viem");
|
|
28
|
-
const
|
|
28
|
+
const merit_1 = require("./merit");
|
|
29
|
+
const merkl_1 = require("./merkl");
|
|
29
30
|
const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
30
31
|
const { eModeCategoriesData } = extractedState;
|
|
31
32
|
const usedAssetsValues = Object.values(usedAssets);
|
|
@@ -61,12 +62,13 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
61
62
|
const marketAddress = market.providerAddress;
|
|
62
63
|
const networksWithIncentives = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Opt, common_1.NetworkNumber.Linea];
|
|
63
64
|
// eslint-disable-next-line prefer-const
|
|
64
|
-
let [loanInfo, eModesInfo, isBorrowAllowed, rewardInfo, merkleRewardsMap] = yield Promise.all([
|
|
65
|
+
let [loanInfo, eModesInfo, isBorrowAllowed, rewardInfo, merkleRewardsMap, meritRewardsMap] = yield Promise.all([
|
|
65
66
|
loanInfoContract.read.getFullTokensInfo([marketAddress, _addresses], (0, viem_1.setViemBlockNumber)(blockNumber)),
|
|
66
67
|
loanInfoContract.read.getAllEmodes([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)),
|
|
67
68
|
loanInfoContract.read.isBorrowAllowed([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)), // Used on L2s check for PriceOracleSentinel (mainnet will always return true)
|
|
68
69
|
networksWithIncentives.includes(network) ? aaveIncentivesContract.read.getReservesIncentivesData([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)) : null,
|
|
69
|
-
(0,
|
|
70
|
+
(0, merkl_1.getMerkleCampaigns)(network),
|
|
71
|
+
(0, merit_1.getMeritCampaigns)(network, market.value),
|
|
70
72
|
]);
|
|
71
73
|
isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
|
|
72
74
|
const eModeCategoriesData = {};
|
|
@@ -148,58 +150,76 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
148
150
|
isolationModeBorrowingEnabled: tokenMarket.isolationModeBorrowingEnabled,
|
|
149
151
|
isFlashLoanEnabled: tokenMarket.isFlashLoanEnabled,
|
|
150
152
|
aTokenAddress: tokenMarket.aTokenAddress,
|
|
153
|
+
vTokenAddress: tokenMarket.debtTokenAddress,
|
|
151
154
|
supplyIncentives: [],
|
|
152
155
|
borrowIncentives: [],
|
|
153
156
|
});
|
|
154
157
|
})));
|
|
155
158
|
// Get incentives data
|
|
156
159
|
yield Promise.all(assetsData.map((_market, index) => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
var _a;
|
|
160
|
+
var _a, _b;
|
|
158
161
|
/* eslint-disable no-param-reassign */
|
|
159
162
|
// @ts-ignore
|
|
160
163
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
161
164
|
const isStakingAsset = staking_1.STAKING_ASSETS.includes(_market.symbol);
|
|
162
165
|
if (isStakingAsset) {
|
|
163
|
-
|
|
164
|
-
_market.incentiveSupplyToken = _market.symbol;
|
|
166
|
+
const yieldApy = yield (0, staking_1.getStakingApy)(_market.symbol);
|
|
165
167
|
_market.supplyIncentives.push({
|
|
166
|
-
apy:
|
|
168
|
+
apy: yieldApy,
|
|
167
169
|
token: _market.symbol,
|
|
168
|
-
incentiveKind:
|
|
170
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
169
171
|
description: `Native ${_market.symbol} yield.`,
|
|
170
172
|
});
|
|
171
173
|
if (_market.canBeBorrowed) {
|
|
172
174
|
// when borrowing assets whose value increases over time
|
|
173
|
-
_market.incentiveBorrowApy = new decimal_js_1.default(_market.incentiveSupplyApy).mul(-1).toString();
|
|
174
|
-
_market.incentiveBorrowToken = _market.symbol;
|
|
175
175
|
_market.borrowIncentives.push({
|
|
176
|
-
apy:
|
|
177
|
-
token: _market.
|
|
178
|
-
incentiveKind:
|
|
176
|
+
apy: new decimal_js_1.default(yieldApy).mul(-1).toString(),
|
|
177
|
+
token: _market.symbol,
|
|
178
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
179
179
|
description: `Due to the native yield of ${_market.symbol}, the value of the debt would increase over time.`,
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
const aTokenAddress = _market.aTokenAddress.toLowerCase(); // DEV: Should aTokenAddress be in AaveV3AssetData type?
|
|
184
184
|
if ((_a = merkleRewardsMap[aTokenAddress]) === null || _a === void 0 ? void 0 : _a.supply) {
|
|
185
|
-
const {
|
|
185
|
+
const { apy, rewardTokenSymbol, description, identifier, } = merkleRewardsMap[aTokenAddress].supply;
|
|
186
186
|
_market.supplyIncentives.push({
|
|
187
|
-
apy
|
|
187
|
+
apy,
|
|
188
188
|
token: rewardTokenSymbol,
|
|
189
|
-
incentiveKind:
|
|
189
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
190
|
+
description,
|
|
191
|
+
eligibilityId: identifier,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const vTokenAddress = _market.vTokenAddress.toLowerCase(); // DEV: Should vTokenAddress be in AaveV3AssetData type?
|
|
195
|
+
if ((_b = merkleRewardsMap[vTokenAddress]) === null || _b === void 0 ? void 0 : _b.borrow) {
|
|
196
|
+
const { apy, rewardTokenSymbol, description, identifier, } = merkleRewardsMap[vTokenAddress].borrow;
|
|
197
|
+
_market.borrowIncentives.push({
|
|
198
|
+
apy,
|
|
199
|
+
token: rewardTokenSymbol,
|
|
200
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
201
|
+
description,
|
|
202
|
+
eligibilityId: identifier,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (meritRewardsMap.supply[_market.symbol]) {
|
|
206
|
+
const { apy, rewardTokenSymbol, description } = meritRewardsMap.supply[_market.symbol];
|
|
207
|
+
_market.supplyIncentives.push({
|
|
208
|
+
apy,
|
|
209
|
+
token: rewardTokenSymbol,
|
|
210
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
211
|
+
description,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (meritRewardsMap.borrow[_market.symbol]) {
|
|
215
|
+
const { apy, rewardTokenSymbol, description } = meritRewardsMap.borrow[_market.symbol];
|
|
216
|
+
_market.borrowIncentives.push({
|
|
217
|
+
apy,
|
|
218
|
+
token: rewardTokenSymbol,
|
|
219
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
190
220
|
description,
|
|
191
221
|
});
|
|
192
222
|
}
|
|
193
|
-
// const aTokenDebtAddress = '0xTODO';
|
|
194
|
-
// if (merkleRewardsMap[aTokenDebtAddress]?.supply) {
|
|
195
|
-
// const { apr, rewardTokenSymbol, description } = merkleRewardsMap[aTokenDebtAddress].supply;
|
|
196
|
-
// _market.borrowIncentives.push({
|
|
197
|
-
// apy: aprToApy(apr),
|
|
198
|
-
// token: rewardTokenSymbol,
|
|
199
|
-
// incentiveKind: 'reward',
|
|
200
|
-
// description,
|
|
201
|
-
// });
|
|
202
|
-
// }
|
|
203
223
|
if (!rewardForMarket)
|
|
204
224
|
return;
|
|
205
225
|
// @ts-ignore
|
|
@@ -207,10 +227,7 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
207
227
|
if (supplyRewardData) {
|
|
208
228
|
if (+(supplyRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
209
229
|
return;
|
|
210
|
-
_market.incentiveSupplyToken = supplyRewardData.rewardTokenSymbol;
|
|
211
230
|
// reward token is aave asset
|
|
212
|
-
if (supplyRewardData.rewardTokenSymbol.startsWith('a') && supplyRewardData.rewardTokenSymbol.includes(_market.symbol))
|
|
213
|
-
_market.incentiveSupplyToken = _market.symbol;
|
|
214
231
|
const supplyEmissionPerSecond = supplyRewardData.emissionPerSecond;
|
|
215
232
|
const supplyRewardPrice = new decimal_js_1.default(supplyRewardData.rewardPriceFeed).div(Math.pow(10, +supplyRewardData.priceFeedDecimals))
|
|
216
233
|
.toString();
|
|
@@ -220,12 +237,10 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
220
237
|
.div(_market.price)
|
|
221
238
|
.div(_market.totalSupply)
|
|
222
239
|
.toString();
|
|
223
|
-
_market.incentiveSupplyApy = new decimal_js_1.default(_market.incentiveSupplyApy || '0').add(rewardApy)
|
|
224
|
-
.toString();
|
|
225
240
|
_market.supplyIncentives.push({
|
|
226
|
-
token: (0,
|
|
241
|
+
token: (0, merkl_1.getAaveUnderlyingSymbol)(supplyRewardData.rewardTokenSymbol),
|
|
227
242
|
apy: rewardApy,
|
|
228
|
-
incentiveKind:
|
|
243
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
229
244
|
description: 'Eligible for protocol-level incentives.',
|
|
230
245
|
});
|
|
231
246
|
}
|
|
@@ -235,9 +250,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
235
250
|
if (borrowRewardData) {
|
|
236
251
|
if (+(borrowRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
237
252
|
return;
|
|
238
|
-
_market.incentiveBorrowToken = borrowRewardData.rewardTokenSymbol;
|
|
239
|
-
if (borrowRewardData.rewardTokenSymbol.startsWith('a') && borrowRewardData.rewardTokenSymbol.includes(_market.symbol))
|
|
240
|
-
_market.incentiveBorrowToken = _market.symbol;
|
|
241
253
|
const supplyEmissionPerSecond = borrowRewardData.emissionPerSecond;
|
|
242
254
|
const supplyRewardPrice = new decimal_js_1.default(borrowRewardData.rewardPriceFeed).div(Math.pow(10, +borrowRewardData.priceFeedDecimals))
|
|
243
255
|
.toString();
|
|
@@ -247,12 +259,10 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
247
259
|
.div(_market.price)
|
|
248
260
|
.div(_market.totalBorrowVar)
|
|
249
261
|
.toString();
|
|
250
|
-
_market.incentiveBorrowApy = new decimal_js_1.default(_market.incentiveBorrowApy || '0').add(rewardApy)
|
|
251
|
-
.toString();
|
|
252
262
|
_market.borrowIncentives.push({
|
|
253
|
-
token: (0,
|
|
263
|
+
token: (0, merkl_1.getAaveUnderlyingSymbol)(borrowRewardData.rewardTokenSymbol),
|
|
254
264
|
apy: rewardApy,
|
|
255
|
-
incentiveKind:
|
|
265
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
256
266
|
description: 'Eligible for protocol-level incentives.',
|
|
257
267
|
});
|
|
258
268
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NetworkNumber } from '../types/common';
|
|
2
|
+
import { AaveVersions } from '../types';
|
|
3
|
+
type RewardInfo = {
|
|
4
|
+
apy: string;
|
|
5
|
+
rewardTokenSymbol: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
type MeritTokenRewardMap = {
|
|
9
|
+
supply: Record<string, RewardInfo>;
|
|
10
|
+
borrow: Record<string, RewardInfo>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Fetches merit rewards data from Aave API
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchMeritRewardsData: () => Promise<Record<string, number | null>>;
|
|
16
|
+
export declare const getMeritCampaigns: (chainId: NetworkNumber, market: AaveVersions) => Promise<MeritTokenRewardMap>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getMeritCampaigns = exports.fetchMeritRewardsData = void 0;
|
|
13
|
+
const utils_1 = require("../services/utils");
|
|
14
|
+
const common_1 = require("../types/common");
|
|
15
|
+
const moneymarket_1 = require("../moneymarket");
|
|
16
|
+
const types_1 = require("../types");
|
|
17
|
+
/**
|
|
18
|
+
* Maps API keys to reward data & actions - hardcoded and needs to be maintained actively.
|
|
19
|
+
* Mapping based on Aave interface implementation: https://github.com/aave/interface/blob/main/src/hooks/useMeritIncentives.ts
|
|
20
|
+
* Active campaigns found here: https://apps.aavechan.com/merit
|
|
21
|
+
*/
|
|
22
|
+
const MERIT_DATA_MAP = {
|
|
23
|
+
[common_1.NetworkNumber.Eth]: {
|
|
24
|
+
[types_1.AaveVersions.AaveV3]: {
|
|
25
|
+
'ethereum-supply-ethx': { rewardTokenSymbol: 'SD', action: 'supply', supplyTokens: ['ETHx'] },
|
|
26
|
+
'ethereum-supply-rlusd': { rewardTokenSymbol: 'aEthRLUSD', action: 'supply', supplyTokens: ['RLUSD'] },
|
|
27
|
+
// Campaign disabled here as it's present on Merkl API:
|
|
28
|
+
// 'ethereum-borrow-eurc': { rewardTokenSymbol: 'aEthEURC', action: 'borrow', borrowTokens: ['EURC'] },
|
|
29
|
+
},
|
|
30
|
+
[types_1.AaveVersions.AaveV3Lido]: {},
|
|
31
|
+
[types_1.AaveVersions.AaveV3Etherfi]: {},
|
|
32
|
+
},
|
|
33
|
+
[common_1.NetworkNumber.Arb]: {
|
|
34
|
+
[types_1.AaveVersions.AaveV3]: {},
|
|
35
|
+
},
|
|
36
|
+
[common_1.NetworkNumber.Opt]: {
|
|
37
|
+
[types_1.AaveVersions.AaveV3]: {},
|
|
38
|
+
},
|
|
39
|
+
[common_1.NetworkNumber.Base]: {
|
|
40
|
+
[types_1.AaveVersions.AaveV3]: {
|
|
41
|
+
'base-borrow-usdc': { rewardTokenSymbol: 'USDC', action: 'borrow', borrowTokens: ['USDC'] },
|
|
42
|
+
'base-borrow-gho': { rewardTokenSymbol: 'GHO', action: 'borrow', borrowTokens: ['GHO'] },
|
|
43
|
+
'base-borrow-eurc': { rewardTokenSymbol: 'EURC', action: 'borrow', borrowTokens: ['EURC'] },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
[common_1.NetworkNumber.Linea]: {
|
|
47
|
+
[types_1.AaveVersions.AaveV3]: {},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Fetches merit rewards data from Aave API
|
|
52
|
+
*/
|
|
53
|
+
const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
try {
|
|
55
|
+
const response = yield fetch('https://apps.aavechan.com/api/merit/aprs', {
|
|
56
|
+
signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
|
|
57
|
+
});
|
|
58
|
+
const data = yield response.json();
|
|
59
|
+
return data.currentAPR.actionsAPR;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Failed to fetch merit rewards data:', error);
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
exports.fetchMeritRewardsData = fetchMeritRewardsData;
|
|
67
|
+
const getMeritCampaigns = (chainId, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
var _a;
|
|
69
|
+
const meritData = yield (0, exports.fetchMeritRewardsData)();
|
|
70
|
+
const relevantCampaigns = {
|
|
71
|
+
supply: {},
|
|
72
|
+
borrow: {},
|
|
73
|
+
};
|
|
74
|
+
Object.entries(((_a = MERIT_DATA_MAP[chainId]) === null || _a === void 0 ? void 0 : _a[market]) || {})
|
|
75
|
+
.filter(([key, rewardData]) => !!meritData[key])
|
|
76
|
+
.forEach(([key, rewardData]) => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const apr = meritData[key];
|
|
79
|
+
if (!apr)
|
|
80
|
+
return;
|
|
81
|
+
const reward = {
|
|
82
|
+
rewardTokenSymbol: rewardData.rewardTokenSymbol,
|
|
83
|
+
apy: (0, moneymarket_1.aprToApy)(apr).toString(),
|
|
84
|
+
description: `Eligible for Merit rewards in ${rewardData.rewardTokenSymbol}. ${rewardData.message ? `\n${rewardData.message}` : ''}`,
|
|
85
|
+
};
|
|
86
|
+
(_a = rewardData.supplyTokens) === null || _a === void 0 ? void 0 : _a.forEach(token => {
|
|
87
|
+
relevantCampaigns.supply[token] = reward;
|
|
88
|
+
});
|
|
89
|
+
(_b = rewardData.borrowTokens) === null || _b === void 0 ? void 0 : _b.forEach(token => {
|
|
90
|
+
relevantCampaigns.borrow[token] = reward;
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
return relevantCampaigns;
|
|
94
|
+
});
|
|
95
|
+
exports.getMeritCampaigns = getMeritCampaigns;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { EthAddress, NetworkNumber } from '../types/common';
|
|
2
2
|
type RewardInfo = {
|
|
3
|
-
|
|
4
|
-
rewardToken: EthAddress;
|
|
3
|
+
apy: string;
|
|
5
4
|
rewardTokenSymbol: string;
|
|
6
5
|
description: string;
|
|
6
|
+
identifier: string;
|
|
7
7
|
};
|
|
8
8
|
type MerkleRewardMap = Record<EthAddress, {
|
|
9
9
|
supply?: RewardInfo;
|
|
10
10
|
borrow?: RewardInfo;
|
|
11
11
|
}>;
|
|
12
12
|
export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
|
|
13
|
+
/**
|
|
14
|
+
* aEthLidoUSDC -> aUSDC
|
|
15
|
+
* USDC -> USDC
|
|
16
|
+
*/
|
|
17
|
+
export declare const formatAaveAsset: (_symbol: string) => string;
|
|
13
18
|
export declare const getMerkleCampaigns: (chainId: NetworkNumber) => Promise<MerkleRewardMap>;
|
|
14
19
|
export {};
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getMerkleCampaigns = exports.getAaveUnderlyingSymbol = void 0;
|
|
12
|
+
exports.getMerkleCampaigns = exports.formatAaveAsset = exports.getAaveUnderlyingSymbol = void 0;
|
|
13
|
+
const moneymarket_1 = require("../moneymarket");
|
|
13
14
|
const utils_1 = require("../services/utils");
|
|
14
15
|
var OpportunityAction;
|
|
15
16
|
(function (OpportunityAction) {
|
|
@@ -36,6 +37,17 @@ const getAaveUnderlyingSymbol = (_symbol = '') => {
|
|
|
36
37
|
return (0, utils_1.wethToEth)(symbol);
|
|
37
38
|
};
|
|
38
39
|
exports.getAaveUnderlyingSymbol = getAaveUnderlyingSymbol;
|
|
40
|
+
/**
|
|
41
|
+
* aEthLidoUSDC -> aUSDC
|
|
42
|
+
* USDC -> USDC
|
|
43
|
+
*/
|
|
44
|
+
const formatAaveAsset = (_symbol) => {
|
|
45
|
+
if (_symbol.startsWith('a')) {
|
|
46
|
+
return `a${(0, exports.getAaveUnderlyingSymbol)(_symbol)}`;
|
|
47
|
+
}
|
|
48
|
+
return _symbol;
|
|
49
|
+
};
|
|
50
|
+
exports.formatAaveAsset = formatAaveAsset;
|
|
39
51
|
const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
52
|
try {
|
|
41
53
|
const res = yield fetch('https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave', {
|
|
@@ -46,29 +58,33 @@ const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
46
58
|
const opportunities = yield res.json();
|
|
47
59
|
const relevantOpportunities = opportunities
|
|
48
60
|
.filter((o) => o.chainId === chainId)
|
|
49
|
-
.filter((o) => o.
|
|
61
|
+
.filter((o) => o.status === OpportunityStatus.LIVE);
|
|
50
62
|
return relevantOpportunities.reduce((acc, opportunity) => {
|
|
63
|
+
var _a, _b;
|
|
51
64
|
const rewardToken = opportunity.rewardsRecord.breakdowns[0].token;
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
const description = `Eligible for ${(0, exports.formatAaveAsset)(rewardToken.symbol)} rewards through Merkl. ${opportunity.description ? `\n${opportunity.description}` : ''}`;
|
|
66
|
+
if (opportunity.action === OpportunityAction.LEND && opportunity.explorerAddress) {
|
|
67
|
+
const supplyAToken = (_a = opportunity.explorerAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
54
68
|
if (!acc[supplyAToken])
|
|
55
69
|
acc[supplyAToken] = {};
|
|
56
70
|
acc[supplyAToken].supply = {
|
|
57
|
-
|
|
58
|
-
rewardToken: rewardToken.address,
|
|
59
|
-
rewardTokenSymbol:
|
|
60
|
-
description
|
|
71
|
+
apy: (0, moneymarket_1.aprToApy)(opportunity.apr),
|
|
72
|
+
// rewardToken: rewardToken.address,
|
|
73
|
+
rewardTokenSymbol: rewardToken.symbol,
|
|
74
|
+
description,
|
|
75
|
+
identifier: opportunity.identifier,
|
|
61
76
|
};
|
|
62
77
|
}
|
|
63
|
-
if (opportunity.action === OpportunityAction.BORROW) {
|
|
64
|
-
const borrowAToken = opportunity.explorerAddress.toLowerCase();
|
|
78
|
+
if (opportunity.action === OpportunityAction.BORROW && opportunity.explorerAddress) {
|
|
79
|
+
const borrowAToken = (_b = opportunity.explorerAddress) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
65
80
|
if (!acc[borrowAToken])
|
|
66
81
|
acc[borrowAToken] = {};
|
|
67
82
|
acc[borrowAToken].borrow = {
|
|
68
|
-
|
|
69
|
-
rewardToken: rewardToken.address,
|
|
70
|
-
rewardTokenSymbol:
|
|
71
|
-
description
|
|
83
|
+
apy: (0, moneymarket_1.aprToApy)(opportunity.apr),
|
|
84
|
+
// rewardToken: rewardToken.address,
|
|
85
|
+
rewardTokenSymbol: rewardToken.symbol,
|
|
86
|
+
description,
|
|
87
|
+
identifier: opportunity.identifier,
|
|
72
88
|
};
|
|
73
89
|
}
|
|
74
90
|
return acc;
|
package/cjs/compoundV2/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
19
|
const moneymarket_1 = require("../moneymarket");
|
|
20
20
|
const utils_1 = require("../services/utils");
|
|
21
|
+
const common_1 = require("../types/common");
|
|
21
22
|
const contracts_1 = require("../contracts");
|
|
22
23
|
const markets_1 = require("../markets");
|
|
23
24
|
const compoundHelpers_1 = require("../helpers/compoundHelpers");
|
|
@@ -39,9 +40,6 @@ const _getCompoundV2MarketsData = (provider, network) => __awaiter(void 0, void
|
|
|
39
40
|
const compBorrowSpeeds = market.compBorrowSpeeds.toString();
|
|
40
41
|
const assetPrice = market.price.toString();
|
|
41
42
|
const pricePrecisionDiff = 18 - (0, tokens_1.getAssetInfo)((0, tokens_1.getAssetInfoByAddress)(cAddresses[i]).underlyingAsset).decimals;
|
|
42
|
-
// compSupplySpeeds/compBorrowSpeeds is per block per market (borrow & supply are separate markets)
|
|
43
|
-
const incentiveSupplyApy = (0, moneymarket_1.aprToApy)((100 * constants_1.BLOCKS_IN_A_YEAR * +compSupplySpeeds * +compPrice) / +assetPrice / +totalSupply).toString();
|
|
44
|
-
const incentiveBorrowApy = (0, moneymarket_1.aprToApy)((100 * constants_1.BLOCKS_IN_A_YEAR * +compBorrowSpeeds * +compPrice) / +assetPrice / +totalBorrow).toString();
|
|
45
43
|
if (cAddresses[i].toLowerCase() === '0xc11b1268c1a384e55c48c2391d8d480264a3a7f4'.toLowerCase()) {
|
|
46
44
|
symbol = 'WBTC Legacy';
|
|
47
45
|
isWbtcLegacy = true;
|
|
@@ -51,10 +49,18 @@ const _getCompoundV2MarketsData = (provider, network) => __awaiter(void 0, void
|
|
|
51
49
|
underlyingTokenAddress: market.underlyingTokenAddress,
|
|
52
50
|
supplyRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(constants_1.BLOCKS_IN_A_YEAR).times(market.supplyRate.toString()).div(1e16).toString()).toString(),
|
|
53
51
|
borrowRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(constants_1.BLOCKS_IN_A_YEAR).times(market.borrowRate.toString()).div(1e16).toString()).toString(),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
supplyIncentives: [{
|
|
53
|
+
token: 'COMP',
|
|
54
|
+
apy: (0, moneymarket_1.aprToApy)((100 * constants_1.BLOCKS_IN_A_YEAR * +compSupplySpeeds * +compPrice) / +assetPrice / +totalSupply).toString(),
|
|
55
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
56
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
57
|
+
}],
|
|
58
|
+
borrowIncentives: [{
|
|
59
|
+
token: 'COMP',
|
|
60
|
+
apy: (0, moneymarket_1.aprToApy)((100 * constants_1.BLOCKS_IN_A_YEAR * +compBorrowSpeeds * +compPrice) / +assetPrice / +totalBorrow).toString(),
|
|
61
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
62
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
63
|
+
}],
|
|
58
64
|
collateralFactor: new decimal_js_1.default(market.collateralFactor.toString()).div(1e18).toString(),
|
|
59
65
|
marketLiquidity: (0, tokens_1.assetAmountInEth)(market.marketLiquidity.toString(), (0, utils_1.handleWbtcLegacy)(symbol)),
|
|
60
66
|
utilization: new decimal_js_1.default(market.totalBorrow.toString()).div(totalSupply).times(100).toString(),
|
package/cjs/compoundV3/index.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.getCompoundV3FullPositionData = exports.getCompoundV3AccountData = expor
|
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
19
|
+
const common_1 = require("../types/common");
|
|
19
20
|
const staking_1 = require("../staking");
|
|
20
21
|
const utils_1 = require("../services/utils");
|
|
21
22
|
const constants_1 = require("../constants");
|
|
@@ -49,8 +50,12 @@ const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultPro
|
|
|
49
50
|
.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice));
|
|
50
51
|
for (const coll of colls) {
|
|
51
52
|
if (staking_1.STAKING_ASSETS.includes(coll.symbol)) {
|
|
52
|
-
coll.
|
|
53
|
-
|
|
53
|
+
coll.supplyIncentives.push({
|
|
54
|
+
apy: yield (0, staking_1.getStakingApy)(coll.symbol),
|
|
55
|
+
token: coll.symbol,
|
|
56
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
57
|
+
description: `Native ${coll.symbol} yield.`,
|
|
58
|
+
});
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
const base = (0, compoundHelpers_1.formatBaseData)(baseTokenInfo, network, baseAssetPrice);
|