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