@defisaver/positions-sdk 1.0.3 → 1.0.5

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.
Files changed (108) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +69 -69
  4. package/cjs/aaveV3/index.js +7 -7
  5. package/cjs/curveUsd/index.js +8 -1
  6. package/cjs/fluid/index.d.ts +2 -0
  7. package/cjs/helpers/aaveHelpers/index.js +6 -0
  8. package/cjs/helpers/compoundHelpers/index.js +2 -0
  9. package/cjs/helpers/eulerHelpers/index.js +2 -0
  10. package/cjs/helpers/fluidHelpers/index.js +2 -0
  11. package/cjs/helpers/morphoBlueHelpers/index.js +68 -66
  12. package/cjs/helpers/sparkHelpers/index.js +6 -0
  13. package/cjs/staking/staking.d.ts +2 -1
  14. package/cjs/staking/staking.js +3 -7
  15. package/cjs/types/aave.d.ts +4 -0
  16. package/cjs/types/compound.d.ts +2 -0
  17. package/cjs/types/curveUsd.d.ts +1 -0
  18. package/cjs/types/euler.d.ts +2 -0
  19. package/cjs/types/fluid.d.ts +2 -0
  20. package/cjs/types/morphoBlue.d.ts +2 -0
  21. package/cjs/types/spark.d.ts +4 -0
  22. package/esm/aaveV3/index.js +7 -7
  23. package/esm/curveUsd/index.js +10 -3
  24. package/esm/fluid/index.d.ts +2 -0
  25. package/esm/helpers/aaveHelpers/index.js +6 -0
  26. package/esm/helpers/compoundHelpers/index.js +2 -0
  27. package/esm/helpers/eulerHelpers/index.js +2 -0
  28. package/esm/helpers/fluidHelpers/index.js +2 -0
  29. package/esm/helpers/morphoBlueHelpers/index.js +68 -66
  30. package/esm/helpers/sparkHelpers/index.js +6 -0
  31. package/esm/staking/staking.d.ts +2 -1
  32. package/esm/staking/staking.js +3 -6
  33. package/esm/types/aave.d.ts +4 -0
  34. package/esm/types/compound.d.ts +2 -0
  35. package/esm/types/curveUsd.d.ts +1 -0
  36. package/esm/types/euler.d.ts +2 -0
  37. package/esm/types/fluid.d.ts +2 -0
  38. package/esm/types/morphoBlue.d.ts +2 -0
  39. package/esm/types/spark.d.ts +4 -0
  40. package/package.json +54 -52
  41. package/src/aaveV2/index.ts +227 -227
  42. package/src/aaveV3/index.ts +624 -625
  43. package/src/assets/index.ts +60 -60
  44. package/src/chickenBonds/index.ts +123 -123
  45. package/src/compoundV2/index.ts +220 -220
  46. package/src/compoundV3/index.ts +291 -291
  47. package/src/config/contracts.js +1147 -1147
  48. package/src/constants/index.ts +6 -6
  49. package/src/contracts.ts +134 -134
  50. package/src/curveUsd/index.ts +239 -230
  51. package/src/eulerV2/index.ts +303 -303
  52. package/src/exchange/index.ts +17 -17
  53. package/src/fluid/index.ts +354 -354
  54. package/src/helpers/aaveHelpers/index.ts +204 -198
  55. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  56. package/src/helpers/compoundHelpers/index.ts +248 -246
  57. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  58. package/src/helpers/eulerHelpers/index.ts +234 -232
  59. package/src/helpers/fluidHelpers/index.ts +56 -53
  60. package/src/helpers/index.ts +11 -11
  61. package/src/helpers/liquityV2Helpers/index.ts +80 -80
  62. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  63. package/src/helpers/makerHelpers/index.ts +94 -94
  64. package/src/helpers/morphoBlueHelpers/index.ts +367 -365
  65. package/src/helpers/sparkHelpers/index.ts +155 -150
  66. package/src/index.ts +52 -52
  67. package/src/liquity/index.ts +116 -116
  68. package/src/liquityV2/index.ts +295 -295
  69. package/src/llamaLend/index.ts +275 -275
  70. package/src/maker/index.ts +117 -117
  71. package/src/markets/aave/index.ts +152 -152
  72. package/src/markets/aave/marketAssets.ts +44 -44
  73. package/src/markets/compound/index.ts +213 -213
  74. package/src/markets/compound/marketsAssets.ts +82 -82
  75. package/src/markets/curveUsd/index.ts +69 -69
  76. package/src/markets/euler/index.ts +26 -26
  77. package/src/markets/fluid/index.ts +2012 -2012
  78. package/src/markets/index.ts +27 -27
  79. package/src/markets/liquityV2/index.ts +54 -54
  80. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  81. package/src/markets/llamaLend/index.ts +235 -235
  82. package/src/markets/morphoBlue/index.ts +895 -895
  83. package/src/markets/spark/index.ts +29 -29
  84. package/src/markets/spark/marketAssets.ts +10 -10
  85. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  86. package/src/morphoAaveV2/index.ts +256 -256
  87. package/src/morphoAaveV3/index.ts +630 -630
  88. package/src/morphoBlue/index.ts +202 -202
  89. package/src/multicall/index.ts +33 -33
  90. package/src/services/priceService.ts +91 -91
  91. package/src/services/utils.ts +59 -59
  92. package/src/setup.ts +8 -8
  93. package/src/spark/index.ts +460 -460
  94. package/src/staking/staking.ts +217 -220
  95. package/src/types/aave.ts +275 -271
  96. package/src/types/chickenBonds.ts +45 -45
  97. package/src/types/common.ts +84 -84
  98. package/src/types/compound.ts +133 -131
  99. package/src/types/curveUsd.ts +119 -118
  100. package/src/types/euler.ts +173 -171
  101. package/src/types/fluid.ts +268 -266
  102. package/src/types/index.ts +11 -11
  103. package/src/types/liquity.ts +30 -30
  104. package/src/types/liquityV2.ts +119 -119
  105. package/src/types/llamaLend.ts +155 -155
  106. package/src/types/maker.ts +50 -50
  107. package/src/types/morphoBlue.ts +194 -192
  108. package/src/types/spark.ts +135 -131
@@ -1,118 +1,118 @@
1
- import Web3 from 'web3';
2
- import Dec from 'decimal.js';
3
- import { assetAmountInEth, getAssetInfo, ilkToAsset } from '@defisaver/tokens';
4
- import {
5
- Blockish, EthAddress, NetworkNumber, PositionBalances,
6
- } from '../types/common';
7
- import { McdViewContract } from '../contracts';
8
- import { makerHelpers } from '../helpers';
9
- import { CdpData } from '../types';
10
- import { wethToEth } from '../services/utils';
11
-
12
- export const getMakerAccountBalances = async (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress): Promise<PositionBalances> => {
13
- let balances: PositionBalances = {
14
- collateral: {},
15
- debt: {},
16
- };
17
- const managerAddress = _managerAddress || '0x5ef30b9986345249bc32d8928B7ee64DE9435E39'; // Default CDP Manager (This is used only to differentiate BProtocol CDPs)
18
-
19
- if (!cdpId) {
20
- return balances;
21
- }
22
-
23
- const viewContract = McdViewContract(web3, network, block);
24
-
25
- let ilk;
26
-
27
- const needsIlk = block !== 'latest' && new Dec(block).lt(14410792) && new Dec(block).gte(14384301);
28
-
29
- if (needsIlk) {
30
- ilk = (await viewContract.methods.getUrnAndIlk(managerAddress, cdpId).call({}, block)).ilk;
31
- }
32
-
33
- // @ts-ignore
34
- const cdpInfo = await viewContract.methods.getCdpInfo(...(needsIlk ? [managerAddress, cdpId, ilk] : [cdpId])).call({}, block);
35
- const ilkInfo = await makerHelpers.getCollateralInfo(needsIlk ? ilk : cdpInfo.ilk, web3, network, block);
36
-
37
-
38
- const collateral = needsIlk ? cdpInfo[1] : cdpInfo.collateral;
39
- const debt = needsIlk ? cdpInfo[0] : cdpInfo.debt;
40
-
41
- const asset = wethToEth(ilkToAsset(needsIlk ? ilk : cdpInfo.ilk));
42
-
43
- balances = {
44
- collateral: {
45
- [addressMapping ? getAssetInfo(asset, network).address.toLowerCase() : asset]: asset === 'WBTC' ? new Dec(collateral).div(1e10).floor().toString() : collateral,
46
- },
47
- debt: {
48
- [addressMapping ? getAssetInfo('DAI', network).address.toLowerCase() : 'DAI']: new Dec(debt).times(ilkInfo.currentRate).div(1e27).floor()
49
- .toString(),
50
- },
51
- };
52
-
53
- return balances;
54
- };
55
-
56
- export const getMakerCdpData = async (web3: Web3, network: NetworkNumber, cdpId: string): Promise<CdpData> => {
57
- const viewContract = McdViewContract(web3, network);
58
-
59
- // @ts-ignore
60
- const cdpInfo = await viewContract.methods.getCdpInfo(cdpId).call();
61
-
62
- const [ilkInfo, coll] = await Promise.all([
63
- makerHelpers.getCollateralInfo(cdpInfo.ilk, web3, network),
64
- makerHelpers.getUnclaimedCollateral(web3, network, cdpInfo.urn, cdpInfo.ilk),
65
- ]);
66
-
67
- const asset = ilkToAsset(cdpInfo.ilk);
68
-
69
- const collateralUsd = new Dec(cdpInfo.collateral).mul(ilkInfo.assetPrice).floor().toString();
70
- const debt = new Dec(cdpInfo.debt).times(ilkInfo.currentRate).div(1e27).floor()
71
- .toString();
72
- const futureDebt = new Dec(cdpInfo.debt).times(ilkInfo.futureRate).div(1e27).floor()
73
- .toString(); // after drip
74
- const debtDripDelta = assetAmountInEth(new Dec(futureDebt).sub(debt).toString(), 'DAI');
75
- const liquidationPrice = new Dec(debt).times(ilkInfo.liqRatio).div(cdpInfo.collateral).toString();
76
-
77
- let ratio = new Dec(cdpInfo.collateral).times(ilkInfo.assetPrice).div(debt).times(100)
78
- .toString();
79
- if (new Dec(debt).eq(0)) ratio = '0';
80
-
81
- const debtTooLow = new Dec(debt).gt(0) && new Dec(assetAmountInEth(debt, 'DAI')).lt(ilkInfo.minDebt);
82
-
83
- const par = '1';
84
- return {
85
- owner: cdpInfo.owner,
86
- userAddress: cdpInfo.userAddr,
87
- id: cdpId,
88
- urn: cdpInfo.urn,
89
- type: 'mcd',
90
- ilk: cdpInfo.ilk,
91
- ilkLabel: ilkInfo.ilkLabel,
92
- asset,
93
- collateral: assetAmountInEth(cdpInfo.collateral, `MCD-${asset}`),
94
- collateralUsd: assetAmountInEth(collateralUsd, `MCD-${asset}`),
95
- futureDebt: assetAmountInEth(futureDebt, 'DAI'),
96
- debtDai: assetAmountInEth(debt, 'DAI'),
97
- debtUsd: assetAmountInEth(debt, 'DAI'),
98
- debtInAsset: assetAmountInEth(debt, 'DAI'),
99
- debtAssetPrice: par,
100
- debtAssetMarketPrice: par,
101
- liquidationPrice,
102
- ratio,
103
- liqRatio: ilkInfo.liqRatio.toString(),
104
- liqPercent: parseFloat(ilkInfo.liqPercent.toString()),
105
- assetPrice: ilkInfo.assetPrice,
106
- daiLabel: 'DAI',
107
- debtAsset: 'DAI',
108
- unclaimedCollateral: assetAmountInEth(coll, asset),
109
- debtTooLow,
110
- minDebt: ilkInfo.minDebt,
111
- stabilityFee: ilkInfo.stabilityFee,
112
- creatableDebt: ilkInfo.creatableDebt,
113
- globalDebtCeiling: ilkInfo.globalDebtCeiling,
114
- globalDebtCurrent: ilkInfo.globalDebtCurrent,
115
- liquidationFee: ilkInfo.liquidationFee,
116
- lastUpdated: Date.now(),
117
- };
1
+ import Web3 from 'web3';
2
+ import Dec from 'decimal.js';
3
+ import { assetAmountInEth, getAssetInfo, ilkToAsset } from '@defisaver/tokens';
4
+ import {
5
+ Blockish, EthAddress, NetworkNumber, PositionBalances,
6
+ } from '../types/common';
7
+ import { McdViewContract } from '../contracts';
8
+ import { makerHelpers } from '../helpers';
9
+ import { CdpData } from '../types';
10
+ import { wethToEth } from '../services/utils';
11
+
12
+ export const getMakerAccountBalances = async (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, cdpId: string, _managerAddress?: EthAddress): Promise<PositionBalances> => {
13
+ let balances: PositionBalances = {
14
+ collateral: {},
15
+ debt: {},
16
+ };
17
+ const managerAddress = _managerAddress || '0x5ef30b9986345249bc32d8928B7ee64DE9435E39'; // Default CDP Manager (This is used only to differentiate BProtocol CDPs)
18
+
19
+ if (!cdpId) {
20
+ return balances;
21
+ }
22
+
23
+ const viewContract = McdViewContract(web3, network, block);
24
+
25
+ let ilk;
26
+
27
+ const needsIlk = block !== 'latest' && new Dec(block).lt(14410792) && new Dec(block).gte(14384301);
28
+
29
+ if (needsIlk) {
30
+ ilk = (await viewContract.methods.getUrnAndIlk(managerAddress, cdpId).call({}, block)).ilk;
31
+ }
32
+
33
+ // @ts-ignore
34
+ const cdpInfo = await viewContract.methods.getCdpInfo(...(needsIlk ? [managerAddress, cdpId, ilk] : [cdpId])).call({}, block);
35
+ const ilkInfo = await makerHelpers.getCollateralInfo(needsIlk ? ilk : cdpInfo.ilk, web3, network, block);
36
+
37
+
38
+ const collateral = needsIlk ? cdpInfo[1] : cdpInfo.collateral;
39
+ const debt = needsIlk ? cdpInfo[0] : cdpInfo.debt;
40
+
41
+ const asset = wethToEth(ilkToAsset(needsIlk ? ilk : cdpInfo.ilk));
42
+
43
+ balances = {
44
+ collateral: {
45
+ [addressMapping ? getAssetInfo(asset, network).address.toLowerCase() : asset]: asset === 'WBTC' ? new Dec(collateral).div(1e10).floor().toString() : collateral,
46
+ },
47
+ debt: {
48
+ [addressMapping ? getAssetInfo('DAI', network).address.toLowerCase() : 'DAI']: new Dec(debt).times(ilkInfo.currentRate).div(1e27).floor()
49
+ .toString(),
50
+ },
51
+ };
52
+
53
+ return balances;
54
+ };
55
+
56
+ export const getMakerCdpData = async (web3: Web3, network: NetworkNumber, cdpId: string): Promise<CdpData> => {
57
+ const viewContract = McdViewContract(web3, network);
58
+
59
+ // @ts-ignore
60
+ const cdpInfo = await viewContract.methods.getCdpInfo(cdpId).call();
61
+
62
+ const [ilkInfo, coll] = await Promise.all([
63
+ makerHelpers.getCollateralInfo(cdpInfo.ilk, web3, network),
64
+ makerHelpers.getUnclaimedCollateral(web3, network, cdpInfo.urn, cdpInfo.ilk),
65
+ ]);
66
+
67
+ const asset = ilkToAsset(cdpInfo.ilk);
68
+
69
+ const collateralUsd = new Dec(cdpInfo.collateral).mul(ilkInfo.assetPrice).floor().toString();
70
+ const debt = new Dec(cdpInfo.debt).times(ilkInfo.currentRate).div(1e27).floor()
71
+ .toString();
72
+ const futureDebt = new Dec(cdpInfo.debt).times(ilkInfo.futureRate).div(1e27).floor()
73
+ .toString(); // after drip
74
+ const debtDripDelta = assetAmountInEth(new Dec(futureDebt).sub(debt).toString(), 'DAI');
75
+ const liquidationPrice = new Dec(debt).times(ilkInfo.liqRatio).div(cdpInfo.collateral).toString();
76
+
77
+ let ratio = new Dec(cdpInfo.collateral).times(ilkInfo.assetPrice).div(debt).times(100)
78
+ .toString();
79
+ if (new Dec(debt).eq(0)) ratio = '0';
80
+
81
+ const debtTooLow = new Dec(debt).gt(0) && new Dec(assetAmountInEth(debt, 'DAI')).lt(ilkInfo.minDebt);
82
+
83
+ const par = '1';
84
+ return {
85
+ owner: cdpInfo.owner,
86
+ userAddress: cdpInfo.userAddr,
87
+ id: cdpId,
88
+ urn: cdpInfo.urn,
89
+ type: 'mcd',
90
+ ilk: cdpInfo.ilk,
91
+ ilkLabel: ilkInfo.ilkLabel,
92
+ asset,
93
+ collateral: assetAmountInEth(cdpInfo.collateral, `MCD-${asset}`),
94
+ collateralUsd: assetAmountInEth(collateralUsd, `MCD-${asset}`),
95
+ futureDebt: assetAmountInEth(futureDebt, 'DAI'),
96
+ debtDai: assetAmountInEth(debt, 'DAI'),
97
+ debtUsd: assetAmountInEth(debt, 'DAI'),
98
+ debtInAsset: assetAmountInEth(debt, 'DAI'),
99
+ debtAssetPrice: par,
100
+ debtAssetMarketPrice: par,
101
+ liquidationPrice,
102
+ ratio,
103
+ liqRatio: ilkInfo.liqRatio.toString(),
104
+ liqPercent: parseFloat(ilkInfo.liqPercent.toString()),
105
+ assetPrice: ilkInfo.assetPrice,
106
+ daiLabel: 'DAI',
107
+ debtAsset: 'DAI',
108
+ unclaimedCollateral: assetAmountInEth(coll, asset),
109
+ debtTooLow,
110
+ minDebt: ilkInfo.minDebt,
111
+ stabilityFee: ilkInfo.stabilityFee,
112
+ creatableDebt: ilkInfo.creatableDebt,
113
+ globalDebtCeiling: ilkInfo.globalDebtCeiling,
114
+ globalDebtCurrent: ilkInfo.globalDebtCurrent,
115
+ liquidationFee: ilkInfo.liquidationFee,
116
+ lastUpdated: Date.now(),
117
+ };
118
118
  };
@@ -1,152 +1,152 @@
1
- import { getConfigContractAddress } from '../../contracts';
2
- import { compareAddresses } from '../../services/utils';
3
- import {
4
- AaveMarketInfo, AaveVersions, MorphoAaveV2MarketInfo, MorphoAaveV3MarketInfo,
5
- } from '../../types';
6
- import { NetworkNumber } from '../../types/common';
7
- import {
8
- aaveV1AssetsDefaultMarket, aaveV2AssetsDefaultMarket, aaveV3AssetsDefaultMarket, aaveV3AssetsEtherfiMarket, aaveV3AssetsLidoMarket, morphoAaveV2AssetDefaultMarket, morphoAaveV3AssetEthMarket,
9
- } from './marketAssets';
10
-
11
- export {
12
- aaveV1AssetsDefaultMarket,
13
- aaveV2AssetsDefaultMarket,
14
- aaveV3AssetsDefaultMarket,
15
- morphoAaveV2AssetDefaultMarket,
16
- morphoAaveV3AssetEthMarket,
17
- aaveV3AssetsLidoMarket,
18
- };
19
-
20
- export const AAVE_V1: AaveMarketInfo = {
21
- chainIds: [NetworkNumber.Eth],
22
- label: 'Aave v1',
23
- shortLabel: 'v1',
24
- url: '',
25
- value: AaveVersions.AaveV1,
26
- assets: aaveV1AssetsDefaultMarket.map((a) => a.underlyingAsset),
27
- provider: '',
28
- providerAddress: '',
29
- lendingPool: '',
30
- lendingPoolAddress: '',
31
- protocolData: '',
32
- protocolDataAddress: '',
33
- // icon: SvgAdapter(protocolIcons.aave),
34
- disabled: true,
35
- protocolName: 'aave',
36
- };
37
-
38
- export const AAVE_V2: AaveMarketInfo = {
39
- chainIds: [NetworkNumber.Eth],
40
- label: 'Aave v2',
41
- shortLabel: 'v2',
42
- value: AaveVersions.AaveV2,
43
- url: 'default',
44
- assets: aaveV2AssetsDefaultMarket,
45
- provider: 'LendingPoolAddressesProvider',
46
- providerAddress: getConfigContractAddress('LendingPoolAddressesProvider', 1), // rename
47
- lendingPool: 'AaveLendingPoolV2',
48
- lendingPoolAddress: getConfigContractAddress('AaveLendingPoolV2', 1),
49
- protocolData: 'AaveProtocolDataProvider',
50
- protocolDataAddress: getConfigContractAddress('AaveProtocolDataProvider', 1),
51
- // icon: SvgAdapter(protocolIcons.aave),
52
- protocolName: 'aave',
53
- };
54
-
55
- export const AAVE_V3 = (networkId: NetworkNumber): AaveMarketInfo => ({
56
- chainIds: [NetworkNumber.Eth, NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base],
57
- label: networkId === 1 ? 'Aave v3 Core' : 'Aave v3',
58
- shortLabel: 'v3',
59
- value: AaveVersions.AaveV3,
60
- url: 'default',
61
- assets: networkId ? aaveV3AssetsDefaultMarket[networkId] : [],
62
- provider: 'AaveV3PoolAddressesProvider',
63
- providerAddress: getConfigContractAddress('AaveV3PoolAddressesProvider', networkId),
64
- lendingPool: 'AaveV3LendingPool',
65
- lendingPoolAddress: getConfigContractAddress('AaveV3LendingPool', networkId),
66
- protocolData: 'AaveV3ProtocolDataProvider',
67
- protocolDataAddress: getConfigContractAddress('AaveV3ProtocolDataProvider', networkId),
68
- // icon: SvgAdapter(protocolIcons.aave),
69
- protocolName: 'aave',
70
- });
71
-
72
- export const AAVE_V3_LIDO = (networkId: NetworkNumber): AaveMarketInfo => ({
73
- chainIds: [NetworkNumber.Eth],
74
- label: 'Aave v3 Prime',
75
- shortLabel: 'v3',
76
- value: AaveVersions.AaveV3Lido,
77
- url: 'lido',
78
- assets: networkId ? aaveV3AssetsLidoMarket[networkId] : [],
79
- provider: 'AaveV3LidoPoolAddressesProvider',
80
- providerAddress: getConfigContractAddress('AaveV3LidoPoolAddressesProvider', networkId),
81
- lendingPool: 'AaveV3LidoLendingPool',
82
- lendingPoolAddress: getConfigContractAddress('AaveV3LidoLendingPool', networkId),
83
- protocolData: 'AaveV3LidoProtocolDataProvider',
84
- protocolDataAddress: getConfigContractAddress('AaveV3LidoProtocolDataProvider', networkId),
85
- // icon: SvgAdapter(protocolIcons.aave),
86
- protocolName: 'aave',
87
- });
88
-
89
- export const AAVE_V3_ETHERFI = (networkId: NetworkNumber): AaveMarketInfo => ({
90
- chainIds: [NetworkNumber.Eth],
91
- label: 'Aave v3 EtherFi',
92
- shortLabel: 'v3',
93
- value: AaveVersions.AaveV3Etherfi,
94
- url: 'etherfi',
95
- assets: networkId ? aaveV3AssetsEtherfiMarket[networkId] : [],
96
- provider: 'AaveV3EtherfiPoolAddressesProvider',
97
- providerAddress: getConfigContractAddress('AaveV3EtherfiPoolAddressesProvider', networkId),
98
- lendingPool: 'AaveV3EtherfiLendingPool',
99
- lendingPoolAddress: getConfigContractAddress('AaveV3EtherfiLendingPool', networkId),
100
- protocolData: 'AaveV3EtherfiProtocolDataProvider',
101
- protocolDataAddress: getConfigContractAddress('AaveV3EtherfiProtocolDataProvider', networkId),
102
- // icon: SvgAdapter(protocolIcons.aave),
103
- protocolName: 'aave',
104
- });
105
-
106
- export const MORPHO_AAVE_V2: MorphoAaveV2MarketInfo = {
107
- chainIds: [1],
108
- label: 'Morpho-Aave V2',
109
- shortLabel: 'morpho-aave-v2',
110
- value: AaveVersions.MorphoAaveV2,
111
- url: '',
112
- assets: morphoAaveV2AssetDefaultMarket,
113
- providerAddress: getConfigContractAddress('LendingPoolAddressesProvider', 1),
114
- lendingPoolAddress: getConfigContractAddress('MorphoAaveV2Proxy', 1),
115
- // icon: SvgAdapter(protocolIcons.morpho),
116
- protocolName: 'morpho',
117
- };
118
-
119
- export const MORPHO_AAVE_V3_ETH = (networkId: NetworkNumber = NetworkNumber.Eth): MorphoAaveV3MarketInfo => ({
120
- chainIds: [1],
121
- label: 'Morpho-Aave V3',
122
- shortLabel: 'morpho-aave-v3',
123
- subVersionLabel: 'ETH Optimizer',
124
- value: AaveVersions.MorphoAaveV3Eth,
125
- url: 'eth-optimizer',
126
- assets: morphoAaveV3AssetEthMarket,
127
- providerAddress: getConfigContractAddress('AaveV3PoolAddressesProvider', networkId), // TODO - check if used and if value is good?
128
- protocolData: 'AaveV3ProtocolDataProvider',
129
- protocolDataAddress: getConfigContractAddress('AaveV3ProtocolDataProvider', networkId),
130
- aaveLendingPool: 'AaveV3LendingPool',
131
- aaveLendingPoolAddress: getConfigContractAddress('AaveV3LendingPool', networkId),
132
- lendingPool: 'MorphoAaveV3ProxyEthMarket',
133
- lendingPoolAddress: getConfigContractAddress('MorphoAaveV3ProxyEthMarket', 1),
134
- // icon: SvgAdapter(protocolIcons.morpho),
135
- protocolName: 'morpho',
136
- });
137
-
138
-
139
- export const AaveMarkets = (networkId: NetworkNumber) => ({
140
- [AaveVersions.AaveV1]: AAVE_V1,
141
- [AaveVersions.AaveV2]: AAVE_V2,
142
- [AaveVersions.AaveV3]: AAVE_V3(networkId),
143
- [AaveVersions.AaveV3Lido]: AAVE_V3_LIDO(networkId),
144
- [AaveVersions.AaveV3Etherfi]: AAVE_V3_ETHERFI(networkId),
145
- [AaveVersions.MorphoAaveV3Eth]: MORPHO_AAVE_V3_ETH(networkId),
146
- [AaveVersions.MorphoAaveV2]: MORPHO_AAVE_V2,
147
- }) as const;
148
-
149
- export const getAaveV3MarketByMarketAddress = (marketAddress: string, network = NetworkNumber.Eth): AaveMarketInfo | MorphoAaveV2MarketInfo | MorphoAaveV3MarketInfo | undefined => {
150
- const markets = AaveMarkets(network);
151
- return Object.values(markets).filter((m) => (![AaveVersions.MorphoAaveV3Eth, AaveVersions.MorphoAaveV2].includes(m.value))).find((m) => compareAddresses(m.providerAddress, marketAddress));
152
- };
1
+ import { getConfigContractAddress } from '../../contracts';
2
+ import { compareAddresses } from '../../services/utils';
3
+ import {
4
+ AaveMarketInfo, AaveVersions, MorphoAaveV2MarketInfo, MorphoAaveV3MarketInfo,
5
+ } from '../../types';
6
+ import { NetworkNumber } from '../../types/common';
7
+ import {
8
+ aaveV1AssetsDefaultMarket, aaveV2AssetsDefaultMarket, aaveV3AssetsDefaultMarket, aaveV3AssetsEtherfiMarket, aaveV3AssetsLidoMarket, morphoAaveV2AssetDefaultMarket, morphoAaveV3AssetEthMarket,
9
+ } from './marketAssets';
10
+
11
+ export {
12
+ aaveV1AssetsDefaultMarket,
13
+ aaveV2AssetsDefaultMarket,
14
+ aaveV3AssetsDefaultMarket,
15
+ morphoAaveV2AssetDefaultMarket,
16
+ morphoAaveV3AssetEthMarket,
17
+ aaveV3AssetsLidoMarket,
18
+ };
19
+
20
+ export const AAVE_V1: AaveMarketInfo = {
21
+ chainIds: [NetworkNumber.Eth],
22
+ label: 'Aave v1',
23
+ shortLabel: 'v1',
24
+ url: '',
25
+ value: AaveVersions.AaveV1,
26
+ assets: aaveV1AssetsDefaultMarket.map((a) => a.underlyingAsset),
27
+ provider: '',
28
+ providerAddress: '',
29
+ lendingPool: '',
30
+ lendingPoolAddress: '',
31
+ protocolData: '',
32
+ protocolDataAddress: '',
33
+ // icon: SvgAdapter(protocolIcons.aave),
34
+ disabled: true,
35
+ protocolName: 'aave',
36
+ };
37
+
38
+ export const AAVE_V2: AaveMarketInfo = {
39
+ chainIds: [NetworkNumber.Eth],
40
+ label: 'Aave v2',
41
+ shortLabel: 'v2',
42
+ value: AaveVersions.AaveV2,
43
+ url: 'default',
44
+ assets: aaveV2AssetsDefaultMarket,
45
+ provider: 'LendingPoolAddressesProvider',
46
+ providerAddress: getConfigContractAddress('LendingPoolAddressesProvider', 1), // rename
47
+ lendingPool: 'AaveLendingPoolV2',
48
+ lendingPoolAddress: getConfigContractAddress('AaveLendingPoolV2', 1),
49
+ protocolData: 'AaveProtocolDataProvider',
50
+ protocolDataAddress: getConfigContractAddress('AaveProtocolDataProvider', 1),
51
+ // icon: SvgAdapter(protocolIcons.aave),
52
+ protocolName: 'aave',
53
+ };
54
+
55
+ export const AAVE_V3 = (networkId: NetworkNumber): AaveMarketInfo => ({
56
+ chainIds: [NetworkNumber.Eth, NetworkNumber.Opt, NetworkNumber.Arb, NetworkNumber.Base],
57
+ label: networkId === 1 ? 'Aave v3 Core' : 'Aave v3',
58
+ shortLabel: 'v3',
59
+ value: AaveVersions.AaveV3,
60
+ url: 'default',
61
+ assets: networkId ? aaveV3AssetsDefaultMarket[networkId] : [],
62
+ provider: 'AaveV3PoolAddressesProvider',
63
+ providerAddress: getConfigContractAddress('AaveV3PoolAddressesProvider', networkId),
64
+ lendingPool: 'AaveV3LendingPool',
65
+ lendingPoolAddress: getConfigContractAddress('AaveV3LendingPool', networkId),
66
+ protocolData: 'AaveV3ProtocolDataProvider',
67
+ protocolDataAddress: getConfigContractAddress('AaveV3ProtocolDataProvider', networkId),
68
+ // icon: SvgAdapter(protocolIcons.aave),
69
+ protocolName: 'aave',
70
+ });
71
+
72
+ export const AAVE_V3_LIDO = (networkId: NetworkNumber): AaveMarketInfo => ({
73
+ chainIds: [NetworkNumber.Eth],
74
+ label: 'Aave v3 Prime',
75
+ shortLabel: 'v3',
76
+ value: AaveVersions.AaveV3Lido,
77
+ url: 'lido',
78
+ assets: networkId ? aaveV3AssetsLidoMarket[networkId] : [],
79
+ provider: 'AaveV3LidoPoolAddressesProvider',
80
+ providerAddress: getConfigContractAddress('AaveV3LidoPoolAddressesProvider', networkId),
81
+ lendingPool: 'AaveV3LidoLendingPool',
82
+ lendingPoolAddress: getConfigContractAddress('AaveV3LidoLendingPool', networkId),
83
+ protocolData: 'AaveV3LidoProtocolDataProvider',
84
+ protocolDataAddress: getConfigContractAddress('AaveV3LidoProtocolDataProvider', networkId),
85
+ // icon: SvgAdapter(protocolIcons.aave),
86
+ protocolName: 'aave',
87
+ });
88
+
89
+ export const AAVE_V3_ETHERFI = (networkId: NetworkNumber): AaveMarketInfo => ({
90
+ chainIds: [NetworkNumber.Eth],
91
+ label: 'Aave v3 EtherFi',
92
+ shortLabel: 'v3',
93
+ value: AaveVersions.AaveV3Etherfi,
94
+ url: 'etherfi',
95
+ assets: networkId ? aaveV3AssetsEtherfiMarket[networkId] : [],
96
+ provider: 'AaveV3EtherfiPoolAddressesProvider',
97
+ providerAddress: getConfigContractAddress('AaveV3EtherfiPoolAddressesProvider', networkId),
98
+ lendingPool: 'AaveV3EtherfiLendingPool',
99
+ lendingPoolAddress: getConfigContractAddress('AaveV3EtherfiLendingPool', networkId),
100
+ protocolData: 'AaveV3EtherfiProtocolDataProvider',
101
+ protocolDataAddress: getConfigContractAddress('AaveV3EtherfiProtocolDataProvider', networkId),
102
+ // icon: SvgAdapter(protocolIcons.aave),
103
+ protocolName: 'aave',
104
+ });
105
+
106
+ export const MORPHO_AAVE_V2: MorphoAaveV2MarketInfo = {
107
+ chainIds: [1],
108
+ label: 'Morpho-Aave V2',
109
+ shortLabel: 'morpho-aave-v2',
110
+ value: AaveVersions.MorphoAaveV2,
111
+ url: '',
112
+ assets: morphoAaveV2AssetDefaultMarket,
113
+ providerAddress: getConfigContractAddress('LendingPoolAddressesProvider', 1),
114
+ lendingPoolAddress: getConfigContractAddress('MorphoAaveV2Proxy', 1),
115
+ // icon: SvgAdapter(protocolIcons.morpho),
116
+ protocolName: 'morpho',
117
+ };
118
+
119
+ export const MORPHO_AAVE_V3_ETH = (networkId: NetworkNumber = NetworkNumber.Eth): MorphoAaveV3MarketInfo => ({
120
+ chainIds: [1],
121
+ label: 'Morpho-Aave V3',
122
+ shortLabel: 'morpho-aave-v3',
123
+ subVersionLabel: 'ETH Optimizer',
124
+ value: AaveVersions.MorphoAaveV3Eth,
125
+ url: 'eth-optimizer',
126
+ assets: morphoAaveV3AssetEthMarket,
127
+ providerAddress: getConfigContractAddress('AaveV3PoolAddressesProvider', networkId), // TODO - check if used and if value is good?
128
+ protocolData: 'AaveV3ProtocolDataProvider',
129
+ protocolDataAddress: getConfigContractAddress('AaveV3ProtocolDataProvider', networkId),
130
+ aaveLendingPool: 'AaveV3LendingPool',
131
+ aaveLendingPoolAddress: getConfigContractAddress('AaveV3LendingPool', networkId),
132
+ lendingPool: 'MorphoAaveV3ProxyEthMarket',
133
+ lendingPoolAddress: getConfigContractAddress('MorphoAaveV3ProxyEthMarket', 1),
134
+ // icon: SvgAdapter(protocolIcons.morpho),
135
+ protocolName: 'morpho',
136
+ });
137
+
138
+
139
+ export const AaveMarkets = (networkId: NetworkNumber) => ({
140
+ [AaveVersions.AaveV1]: AAVE_V1,
141
+ [AaveVersions.AaveV2]: AAVE_V2,
142
+ [AaveVersions.AaveV3]: AAVE_V3(networkId),
143
+ [AaveVersions.AaveV3Lido]: AAVE_V3_LIDO(networkId),
144
+ [AaveVersions.AaveV3Etherfi]: AAVE_V3_ETHERFI(networkId),
145
+ [AaveVersions.MorphoAaveV3Eth]: MORPHO_AAVE_V3_ETH(networkId),
146
+ [AaveVersions.MorphoAaveV2]: MORPHO_AAVE_V2,
147
+ }) as const;
148
+
149
+ export const getAaveV3MarketByMarketAddress = (marketAddress: string, network = NetworkNumber.Eth): AaveMarketInfo | MorphoAaveV2MarketInfo | MorphoAaveV3MarketInfo | undefined => {
150
+ const markets = AaveMarkets(network);
151
+ return Object.values(markets).filter((m) => (![AaveVersions.MorphoAaveV3Eth, AaveVersions.MorphoAaveV2].includes(m.value))).find((m) => compareAddresses(m.providerAddress, marketAddress));
152
+ };
@@ -1,45 +1,45 @@
1
- import { getAssetInfo } from '@defisaver/tokens';
2
- import { NetworkNumber } from '../../types/common';
3
-
4
- export const aaveV1AssetsDefaultMarket = [
5
- 'aETH', 'aDAI', 'aUSDC', 'aSUSD', 'aTUSD', 'aUSDT', 'aBUSD', 'aBAT', 'aLEND',
6
- 'aLINK', 'aMANA', 'aMKR', 'aREP', 'aSNX', 'aWBTC', 'aZRX', 'aENJ', 'aREN', 'aYFI', 'aUNI', 'aAAVE',
7
- ].map((symbol) => getAssetInfo(symbol));
8
-
9
- export const aaveV2AssetsDefaultMarket = ['USDT', 'WBTC', 'ETH', 'YFI', 'ZRX', 'UNI', 'AAVE', 'BAT', 'BUSD', 'DAI', 'ENJ', 'KNCL', 'LINK', 'MANA', 'MKR', 'REN', 'SNX', 'SUSD', 'TUSD', 'USDC', 'CRV', 'GUSD', 'BAL', 'xSUSHI', 'RENFIL', 'RAI', 'AMPL', 'USDP', 'DPI', 'FRAX', 'FEI', 'stETH', 'ENS', 'UST', 'CVX', '1INCH', 'LUSD'];
10
- export const morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WBTC', 'stETH', 'CRV'];
11
-
12
- export const morphoAaveV3AssetEthMarket = ['ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT'];
13
-
14
- export const aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH', 'USDe', 'ETHx', 'sUSDe', 'tBTC', 'cbBTC', 'USDS', 'rsETH', 'LBTC'];
15
- export const aaveV3AssetsDefaultMarketOpt = [
16
- 'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
17
- ];
18
- export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH'];
19
- export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'wrsETH', 'LBTC', 'EURC', 'GHO'];
20
-
21
- // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
22
- export const aaveV3AssetsDefaultMarket = {
23
- [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
24
- [NetworkNumber.Opt]: aaveV3AssetsDefaultMarketOpt,
25
- [NetworkNumber.Arb]: aaveV3AssetsDefaultMarketArb,
26
- [NetworkNumber.Base]: aaveV3AssetsDefaultMarketBase,
27
- } as const;
28
-
29
- export const aaveV3AssetsLidoMarketEth = ['ETH', 'wstETH', 'USDS', 'USDC', 'ezETH', 'sUSDe', 'GHO', 'rsETH'];
30
-
31
- export const aaveV3AssetsLidoMarket = {
32
- [NetworkNumber.Eth]: aaveV3AssetsLidoMarketEth,
33
- [NetworkNumber.Opt]: [],
34
- [NetworkNumber.Arb]: [],
35
- [NetworkNumber.Base]: [],
36
- } as const;
37
-
38
- export const aaveV3AssetsEtherfiMarketEth = ['weETH', 'USDC', 'PYUSD', 'FRAX'];
39
-
40
- export const aaveV3AssetsEtherfiMarket = {
41
- [NetworkNumber.Eth]: aaveV3AssetsEtherfiMarketEth,
42
- [NetworkNumber.Opt]: [],
43
- [NetworkNumber.Arb]: [],
44
- [NetworkNumber.Base]: [],
1
+ import { getAssetInfo } from '@defisaver/tokens';
2
+ import { NetworkNumber } from '../../types/common';
3
+
4
+ export const aaveV1AssetsDefaultMarket = [
5
+ 'aETH', 'aDAI', 'aUSDC', 'aSUSD', 'aTUSD', 'aUSDT', 'aBUSD', 'aBAT', 'aLEND',
6
+ 'aLINK', 'aMANA', 'aMKR', 'aREP', 'aSNX', 'aWBTC', 'aZRX', 'aENJ', 'aREN', 'aYFI', 'aUNI', 'aAAVE',
7
+ ].map((symbol) => getAssetInfo(symbol));
8
+
9
+ export const aaveV2AssetsDefaultMarket = ['USDT', 'WBTC', 'ETH', 'YFI', 'ZRX', 'UNI', 'AAVE', 'BAT', 'BUSD', 'DAI', 'ENJ', 'KNCL', 'LINK', 'MANA', 'MKR', 'REN', 'SNX', 'SUSD', 'TUSD', 'USDC', 'CRV', 'GUSD', 'BAL', 'xSUSHI', 'RENFIL', 'RAI', 'AMPL', 'USDP', 'DPI', 'FRAX', 'FEI', 'stETH', 'ENS', 'UST', 'CVX', '1INCH', 'LUSD'];
10
+ export const morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WBTC', 'stETH', 'CRV'];
11
+
12
+ export const morphoAaveV3AssetEthMarket = ['ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT'];
13
+
14
+ export const aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH', 'USDe', 'ETHx', 'sUSDe', 'tBTC', 'cbBTC', 'USDS', 'rsETH', 'LBTC'];
15
+ export const aaveV3AssetsDefaultMarketOpt = [
16
+ 'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
17
+ ];
18
+ export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH'];
19
+ export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'wrsETH', 'LBTC', 'EURC', 'GHO'];
20
+
21
+ // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
22
+ export const aaveV3AssetsDefaultMarket = {
23
+ [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
24
+ [NetworkNumber.Opt]: aaveV3AssetsDefaultMarketOpt,
25
+ [NetworkNumber.Arb]: aaveV3AssetsDefaultMarketArb,
26
+ [NetworkNumber.Base]: aaveV3AssetsDefaultMarketBase,
27
+ } as const;
28
+
29
+ export const aaveV3AssetsLidoMarketEth = ['ETH', 'wstETH', 'USDS', 'USDC', 'ezETH', 'sUSDe', 'GHO', 'rsETH'];
30
+
31
+ export const aaveV3AssetsLidoMarket = {
32
+ [NetworkNumber.Eth]: aaveV3AssetsLidoMarketEth,
33
+ [NetworkNumber.Opt]: [],
34
+ [NetworkNumber.Arb]: [],
35
+ [NetworkNumber.Base]: [],
36
+ } as const;
37
+
38
+ export const aaveV3AssetsEtherfiMarketEth = ['weETH', 'USDC', 'PYUSD', 'FRAX'];
39
+
40
+ export const aaveV3AssetsEtherfiMarket = {
41
+ [NetworkNumber.Eth]: aaveV3AssetsEtherfiMarketEth,
42
+ [NetworkNumber.Opt]: [],
43
+ [NetworkNumber.Arb]: [],
44
+ [NetworkNumber.Base]: [],
45
45
  } as const;