@defisaver/positions-sdk 2.0.14 → 2.0.15-dev-2
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 +63 -46
- package/cjs/aaveV3/merit.d.ts +17 -0
- package/cjs/aaveV3/merit.js +95 -0
- package/cjs/aaveV3/merkl.d.ts +19 -0
- package/cjs/aaveV3/merkl.js +98 -0
- 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 +3 -8
- 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 +64 -47
- package/esm/aaveV3/merit.d.ts +17 -0
- package/esm/aaveV3/merit.js +90 -0
- package/esm/aaveV3/merkl.d.ts +19 -0
- package/esm/aaveV3/merkl.js +92 -0
- 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 +3 -8
- 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 -488
- package/src/aaveV3/merit.ts +98 -0
- package/src/aaveV3/merkl.ts +141 -0
- 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 -194
- 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,6 +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 merit_1 = require("./merit");
|
|
29
|
+
const merkl_1 = require("./merkl");
|
|
28
30
|
const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
29
31
|
const { eModeCategoriesData } = extractedState;
|
|
30
32
|
const usedAssetsValues = Object.values(usedAssets);
|
|
@@ -60,11 +62,13 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
60
62
|
const marketAddress = market.providerAddress;
|
|
61
63
|
const networksWithIncentives = [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Opt, common_1.NetworkNumber.Linea];
|
|
62
64
|
// eslint-disable-next-line prefer-const
|
|
63
|
-
let [loanInfo, eModesInfo, isBorrowAllowed, rewardInfo] = yield Promise.all([
|
|
65
|
+
let [loanInfo, eModesInfo, isBorrowAllowed, rewardInfo, merkleRewardsMap, meritRewardsMap] = yield Promise.all([
|
|
64
66
|
loanInfoContract.read.getFullTokensInfo([marketAddress, _addresses], (0, viem_1.setViemBlockNumber)(blockNumber)),
|
|
65
67
|
loanInfoContract.read.getAllEmodes([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)),
|
|
66
68
|
loanInfoContract.read.isBorrowAllowed([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)), // Used on L2s check for PriceOracleSentinel (mainnet will always return true)
|
|
67
69
|
networksWithIncentives.includes(network) ? aaveIncentivesContract.read.getReservesIncentivesData([marketAddress], (0, viem_1.setViemBlockNumber)(blockNumber)) : null,
|
|
70
|
+
(0, merkl_1.getMerkleCampaigns)(network),
|
|
71
|
+
(0, merit_1.getMeritCampaigns)(network, market.value),
|
|
68
72
|
]);
|
|
69
73
|
isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
|
|
70
74
|
const eModeCategoriesData = {};
|
|
@@ -146,47 +150,74 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
146
150
|
isolationModeBorrowingEnabled: tokenMarket.isolationModeBorrowingEnabled,
|
|
147
151
|
isFlashLoanEnabled: tokenMarket.isFlashLoanEnabled,
|
|
148
152
|
aTokenAddress: tokenMarket.aTokenAddress,
|
|
153
|
+
vTokenAddress: tokenMarket.debtTokenAddress,
|
|
154
|
+
supplyIncentives: [],
|
|
155
|
+
borrowIncentives: [],
|
|
149
156
|
});
|
|
150
157
|
})));
|
|
151
158
|
// Get incentives data
|
|
152
|
-
yield Promise.all(assetsData.map((_market) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
yield Promise.all(assetsData.map((_market, index) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
var _a, _b;
|
|
153
161
|
/* eslint-disable no-param-reassign */
|
|
154
162
|
// @ts-ignore
|
|
155
163
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
156
164
|
const isStakingAsset = staking_1.STAKING_ASSETS.includes(_market.symbol);
|
|
157
165
|
if (isStakingAsset) {
|
|
158
|
-
|
|
159
|
-
_market.incentiveSupplyToken = _market.symbol;
|
|
160
|
-
if (!_market.supplyIncentives) {
|
|
161
|
-
_market.supplyIncentives = [];
|
|
162
|
-
}
|
|
166
|
+
const yieldApy = yield (0, staking_1.getStakingApy)(_market.symbol);
|
|
163
167
|
_market.supplyIncentives.push({
|
|
164
|
-
apy:
|
|
168
|
+
apy: yieldApy,
|
|
165
169
|
token: _market.symbol,
|
|
166
|
-
incentiveKind:
|
|
170
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
171
|
+
description: `Native ${_market.symbol} yield.`,
|
|
167
172
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
if (_market.canBeBorrowed) {
|
|
174
|
+
// when borrowing assets whose value increases over time
|
|
175
|
+
_market.borrowIncentives.push({
|
|
176
|
+
apy: new decimal_js_1.default(yieldApy).mul(-1).toString(),
|
|
177
|
+
token: _market.symbol,
|
|
178
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
179
|
+
description: `Due to the native yield of ${_market.symbol}, the value of the debt would increase over time.`,
|
|
180
|
+
});
|
|
174
181
|
}
|
|
182
|
+
}
|
|
183
|
+
const aTokenAddress = _market.aTokenAddress.toLowerCase(); // DEV: Should aTokenAddress be in AaveV3AssetData type?
|
|
184
|
+
if ((_a = merkleRewardsMap[aTokenAddress]) === null || _a === void 0 ? void 0 : _a.supply) {
|
|
185
|
+
const { apy, rewardTokenSymbol, description, identifier, } = merkleRewardsMap[aTokenAddress].supply;
|
|
186
|
+
_market.supplyIncentives.push({
|
|
187
|
+
apy,
|
|
188
|
+
token: rewardTokenSymbol,
|
|
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;
|
|
175
197
|
_market.borrowIncentives.push({
|
|
176
|
-
apy
|
|
177
|
-
token:
|
|
178
|
-
incentiveKind:
|
|
198
|
+
apy,
|
|
199
|
+
token: rewardTokenSymbol,
|
|
200
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
201
|
+
description,
|
|
202
|
+
eligibilityId: identifier,
|
|
179
203
|
});
|
|
180
204
|
}
|
|
181
|
-
if (_market.symbol
|
|
182
|
-
const
|
|
183
|
-
if (!_market.supplyIncentives) {
|
|
184
|
-
_market.supplyIncentives = [];
|
|
185
|
-
}
|
|
205
|
+
if (meritRewardsMap.supply[_market.symbol]) {
|
|
206
|
+
const { apy, rewardTokenSymbol, description } = meritRewardsMap.supply[_market.symbol];
|
|
186
207
|
_market.supplyIncentives.push({
|
|
187
|
-
apy
|
|
188
|
-
token:
|
|
189
|
-
incentiveKind:
|
|
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,
|
|
220
|
+
description,
|
|
190
221
|
});
|
|
191
222
|
}
|
|
192
223
|
if (!rewardForMarket)
|
|
@@ -196,10 +227,7 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
196
227
|
if (supplyRewardData) {
|
|
197
228
|
if (+(supplyRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
198
229
|
return;
|
|
199
|
-
_market.incentiveSupplyToken = supplyRewardData.rewardTokenSymbol;
|
|
200
230
|
// reward token is aave asset
|
|
201
|
-
if (supplyRewardData.rewardTokenSymbol.startsWith('a') && supplyRewardData.rewardTokenSymbol.includes(_market.symbol))
|
|
202
|
-
_market.incentiveSupplyToken = _market.symbol;
|
|
203
231
|
const supplyEmissionPerSecond = supplyRewardData.emissionPerSecond;
|
|
204
232
|
const supplyRewardPrice = new decimal_js_1.default(supplyRewardData.rewardPriceFeed).div(Math.pow(10, +supplyRewardData.priceFeedDecimals))
|
|
205
233
|
.toString();
|
|
@@ -209,15 +237,11 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
209
237
|
.div(_market.price)
|
|
210
238
|
.div(_market.totalSupply)
|
|
211
239
|
.toString();
|
|
212
|
-
_market.incentiveSupplyApy = new decimal_js_1.default(_market.incentiveSupplyApy || '0').add(rewardApy)
|
|
213
|
-
.toString();
|
|
214
|
-
if (!_market.supplyIncentives) {
|
|
215
|
-
_market.supplyIncentives = [];
|
|
216
|
-
}
|
|
217
240
|
_market.supplyIncentives.push({
|
|
218
|
-
token: supplyRewardData.rewardTokenSymbol,
|
|
241
|
+
token: (0, merkl_1.getAaveUnderlyingSymbol)(supplyRewardData.rewardTokenSymbol),
|
|
219
242
|
apy: rewardApy,
|
|
220
|
-
incentiveKind:
|
|
243
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
244
|
+
description: 'Eligible for protocol-level incentives.',
|
|
221
245
|
});
|
|
222
246
|
}
|
|
223
247
|
});
|
|
@@ -226,9 +250,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
226
250
|
if (borrowRewardData) {
|
|
227
251
|
if (+(borrowRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
228
252
|
return;
|
|
229
|
-
_market.incentiveBorrowToken = borrowRewardData.rewardTokenSymbol;
|
|
230
|
-
if (borrowRewardData.rewardTokenSymbol.startsWith('a') && borrowRewardData.rewardTokenSymbol.includes(_market.symbol))
|
|
231
|
-
_market.incentiveBorrowToken = _market.symbol;
|
|
232
253
|
const supplyEmissionPerSecond = borrowRewardData.emissionPerSecond;
|
|
233
254
|
const supplyRewardPrice = new decimal_js_1.default(borrowRewardData.rewardPriceFeed).div(Math.pow(10, +borrowRewardData.priceFeedDecimals))
|
|
234
255
|
.toString();
|
|
@@ -238,15 +259,11 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
238
259
|
.div(_market.price)
|
|
239
260
|
.div(_market.totalBorrowVar)
|
|
240
261
|
.toString();
|
|
241
|
-
_market.incentiveBorrowApy = new decimal_js_1.default(_market.incentiveBorrowApy || '0').add(rewardApy)
|
|
242
|
-
.toString();
|
|
243
|
-
if (!_market.borrowIncentives) {
|
|
244
|
-
_market.borrowIncentives = [];
|
|
245
|
-
}
|
|
246
262
|
_market.borrowIncentives.push({
|
|
247
|
-
token: borrowRewardData.rewardTokenSymbol,
|
|
263
|
+
token: (0, merkl_1.getAaveUnderlyingSymbol)(borrowRewardData.rewardTokenSymbol),
|
|
248
264
|
apy: rewardApy,
|
|
249
|
-
incentiveKind:
|
|
265
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
266
|
+
description: 'Eligible for protocol-level incentives.',
|
|
250
267
|
});
|
|
251
268
|
}
|
|
252
269
|
});
|
|
@@ -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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EthAddress, NetworkNumber } from '../types/common';
|
|
2
|
+
type RewardInfo = {
|
|
3
|
+
apy: string;
|
|
4
|
+
rewardTokenSymbol: string;
|
|
5
|
+
description: string;
|
|
6
|
+
identifier: string;
|
|
7
|
+
};
|
|
8
|
+
type MerkleRewardMap = Record<EthAddress, {
|
|
9
|
+
supply?: RewardInfo;
|
|
10
|
+
borrow?: RewardInfo;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const getAaveUnderlyingSymbol: (_symbol?: string) => any;
|
|
13
|
+
/**
|
|
14
|
+
* aEthLidoUSDC -> aUSDC
|
|
15
|
+
* USDC -> USDC
|
|
16
|
+
*/
|
|
17
|
+
export declare const formatAaveAsset: (_symbol: string) => string;
|
|
18
|
+
export declare const getMerkleCampaigns: (chainId: NetworkNumber) => Promise<MerkleRewardMap>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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.getMerkleCampaigns = exports.formatAaveAsset = exports.getAaveUnderlyingSymbol = void 0;
|
|
13
|
+
const moneymarket_1 = require("../moneymarket");
|
|
14
|
+
const utils_1 = require("../services/utils");
|
|
15
|
+
var OpportunityAction;
|
|
16
|
+
(function (OpportunityAction) {
|
|
17
|
+
OpportunityAction["LEND"] = "LEND";
|
|
18
|
+
OpportunityAction["BORROW"] = "BORROW";
|
|
19
|
+
})(OpportunityAction || (OpportunityAction = {}));
|
|
20
|
+
var OpportunityStatus;
|
|
21
|
+
(function (OpportunityStatus) {
|
|
22
|
+
OpportunityStatus["LIVE"] = "LIVE";
|
|
23
|
+
OpportunityStatus["PAST"] = "PAST";
|
|
24
|
+
OpportunityStatus["UPCOMING"] = "UPCOMING";
|
|
25
|
+
})(OpportunityStatus || (OpportunityStatus = {}));
|
|
26
|
+
const getAaveUnderlyingSymbol = (_symbol = '') => {
|
|
27
|
+
let symbol = _symbol
|
|
28
|
+
.replace(/^aEthLido/, '')
|
|
29
|
+
.replace(/^aEthEtherFi/, '')
|
|
30
|
+
.replace(/^aEth/, '')
|
|
31
|
+
.replace(/^aArb/, '')
|
|
32
|
+
.replace(/^aOpt/, '')
|
|
33
|
+
.replace(/^aBas/, '')
|
|
34
|
+
.replace(/^aLin/, '');
|
|
35
|
+
if (symbol.startsWith('a'))
|
|
36
|
+
symbol = symbol.slice(1);
|
|
37
|
+
return (0, utils_1.wethToEth)(symbol);
|
|
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;
|
|
51
|
+
const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
const res = yield fetch('https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave', {
|
|
54
|
+
signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
|
|
55
|
+
});
|
|
56
|
+
if (!res.ok)
|
|
57
|
+
throw new Error('Failed to fetch Merkle campaigns');
|
|
58
|
+
const opportunities = yield res.json();
|
|
59
|
+
const relevantOpportunities = opportunities
|
|
60
|
+
.filter((o) => o.chainId === chainId)
|
|
61
|
+
.filter((o) => o.status === OpportunityStatus.LIVE);
|
|
62
|
+
return relevantOpportunities.reduce((acc, opportunity) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const rewardToken = opportunity.rewardsRecord.breakdowns[0].token;
|
|
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();
|
|
68
|
+
if (!acc[supplyAToken])
|
|
69
|
+
acc[supplyAToken] = {};
|
|
70
|
+
acc[supplyAToken].supply = {
|
|
71
|
+
apy: (0, moneymarket_1.aprToApy)(opportunity.apr),
|
|
72
|
+
// rewardToken: rewardToken.address,
|
|
73
|
+
rewardTokenSymbol: rewardToken.symbol,
|
|
74
|
+
description,
|
|
75
|
+
identifier: opportunity.identifier,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (opportunity.action === OpportunityAction.BORROW && opportunity.explorerAddress) {
|
|
79
|
+
const borrowAToken = (_b = opportunity.explorerAddress) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
80
|
+
if (!acc[borrowAToken])
|
|
81
|
+
acc[borrowAToken] = {};
|
|
82
|
+
acc[borrowAToken].borrow = {
|
|
83
|
+
apy: (0, moneymarket_1.aprToApy)(opportunity.apr),
|
|
84
|
+
// rewardToken: rewardToken.address,
|
|
85
|
+
rewardTokenSymbol: rewardToken.symbol,
|
|
86
|
+
description,
|
|
87
|
+
identifier: opportunity.identifier,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return acc;
|
|
91
|
+
}, {});
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
console.error('Failed to fetch Merkle campaigns', e);
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
exports.getMerkleCampaigns = getMerkleCampaigns;
|
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(),
|