@defisaver/positions-sdk 2.1.22-dev-xpl-2 → 2.1.22-dev-savings-4

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 (143) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +64 -64
  4. package/cjs/config/contracts.d.ts +149 -0
  5. package/cjs/config/contracts.js +15 -1
  6. package/cjs/contracts.d.ts +1344 -0
  7. package/cjs/contracts.js +20 -1
  8. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  9. package/cjs/index.d.ts +2 -1
  10. package/cjs/index.js +3 -1
  11. package/cjs/markets/aave/marketAssets.js +1 -1
  12. package/cjs/savings/index.d.ts +6 -0
  13. package/cjs/savings/index.js +68 -0
  14. package/cjs/savings/morphoVaults/index.d.ts +7 -0
  15. package/cjs/savings/morphoVaults/index.js +118 -0
  16. package/cjs/savings/morphoVaults/options.d.ts +16 -0
  17. package/cjs/savings/morphoVaults/options.js +99 -0
  18. package/cjs/savings/yearnVaults/index.d.ts +7 -0
  19. package/cjs/savings/yearnVaults/index.js +97 -0
  20. package/cjs/savings/yearnVaults/options.d.ts +6 -0
  21. package/cjs/savings/yearnVaults/options.js +26 -0
  22. package/cjs/types/index.d.ts +1 -0
  23. package/cjs/types/index.js +1 -0
  24. package/cjs/types/savings/index.d.ts +13 -0
  25. package/cjs/types/savings/index.js +18 -0
  26. package/cjs/types/savings/morphoVaults.d.ts +22 -0
  27. package/cjs/types/savings/morphoVaults.js +19 -0
  28. package/cjs/types/savings/yearnVaults.d.ts +11 -0
  29. package/cjs/types/savings/yearnVaults.js +9 -0
  30. package/esm/config/contracts.d.ts +149 -0
  31. package/esm/config/contracts.js +14 -0
  32. package/esm/contracts.d.ts +1344 -0
  33. package/esm/contracts.js +17 -0
  34. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  35. package/esm/index.d.ts +2 -1
  36. package/esm/index.js +2 -1
  37. package/esm/markets/aave/marketAssets.js +1 -1
  38. package/esm/savings/index.d.ts +6 -0
  39. package/esm/savings/index.js +30 -0
  40. package/esm/savings/morphoVaults/index.d.ts +7 -0
  41. package/esm/savings/morphoVaults/index.js +77 -0
  42. package/esm/savings/morphoVaults/options.d.ts +16 -0
  43. package/esm/savings/morphoVaults/options.js +95 -0
  44. package/esm/savings/yearnVaults/index.d.ts +7 -0
  45. package/esm/savings/yearnVaults/index.js +56 -0
  46. package/esm/savings/yearnVaults/options.d.ts +6 -0
  47. package/esm/savings/yearnVaults/options.js +22 -0
  48. package/esm/types/index.d.ts +1 -0
  49. package/esm/types/index.js +1 -0
  50. package/esm/types/savings/index.d.ts +13 -0
  51. package/esm/types/savings/index.js +2 -0
  52. package/esm/types/savings/morphoVaults.d.ts +22 -0
  53. package/esm/types/savings/morphoVaults.js +16 -0
  54. package/esm/types/savings/yearnVaults.d.ts +11 -0
  55. package/esm/types/savings/yearnVaults.js +6 -0
  56. package/package.json +48 -47
  57. package/src/aaveV2/index.ts +240 -240
  58. package/src/aaveV3/index.ts +614 -614
  59. package/src/aaveV3/merit.ts +97 -97
  60. package/src/aaveV3/merkl.ts +74 -74
  61. package/src/claiming/aaveV3.ts +154 -154
  62. package/src/claiming/compV3.ts +22 -22
  63. package/src/claiming/index.ts +12 -12
  64. package/src/claiming/king.ts +66 -66
  65. package/src/claiming/morphoBlue.ts +118 -118
  66. package/src/claiming/spark.ts +225 -225
  67. package/src/compoundV2/index.ts +244 -244
  68. package/src/compoundV3/index.ts +274 -274
  69. package/src/config/contracts.ts +1273 -1259
  70. package/src/constants/index.ts +10 -10
  71. package/src/contracts.ts +141 -121
  72. package/src/curveUsd/index.ts +254 -254
  73. package/src/eulerV2/index.ts +324 -324
  74. package/src/exchange/index.ts +25 -25
  75. package/src/fluid/index.ts +1774 -1774
  76. package/src/helpers/aaveHelpers/index.ts +187 -187
  77. package/src/helpers/compoundHelpers/index.ts +283 -283
  78. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  79. package/src/helpers/eulerHelpers/index.ts +222 -222
  80. package/src/helpers/fluidHelpers/index.ts +326 -326
  81. package/src/helpers/index.ts +10 -10
  82. package/src/helpers/liquityV2Helpers/index.ts +82 -82
  83. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  84. package/src/helpers/makerHelpers/index.ts +52 -52
  85. package/src/helpers/morphoBlueHelpers/index.ts +396 -396
  86. package/src/helpers/sparkHelpers/index.ts +158 -158
  87. package/src/index.ts +49 -47
  88. package/src/liquity/index.ts +159 -159
  89. package/src/liquityV2/index.ts +703 -703
  90. package/src/llamaLend/index.ts +305 -305
  91. package/src/maker/index.ts +223 -223
  92. package/src/markets/aave/index.ts +116 -116
  93. package/src/markets/aave/marketAssets.ts +54 -54
  94. package/src/markets/compound/index.ts +238 -238
  95. package/src/markets/compound/marketsAssets.ts +97 -97
  96. package/src/markets/curveUsd/index.ts +69 -69
  97. package/src/markets/euler/index.ts +26 -26
  98. package/src/markets/fluid/index.ts +2900 -2900
  99. package/src/markets/index.ts +25 -25
  100. package/src/markets/liquityV2/index.ts +102 -102
  101. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  102. package/src/markets/llamaLend/index.ts +235 -235
  103. package/src/markets/morphoBlue/index.ts +971 -971
  104. package/src/markets/spark/index.ts +29 -29
  105. package/src/markets/spark/marketAssets.ts +12 -12
  106. package/src/moneymarket/moneymarketCommonService.ts +84 -84
  107. package/src/morphoBlue/index.ts +274 -274
  108. package/src/portfolio/index.ts +572 -572
  109. package/src/savings/index.ts +35 -0
  110. package/src/savings/morphoVaults/index.ts +81 -0
  111. package/src/savings/morphoVaults/options.ts +110 -0
  112. package/src/savings/yearnVaults/index.ts +58 -0
  113. package/src/savings/yearnVaults/options.ts +27 -0
  114. package/src/services/priceService.ts +278 -278
  115. package/src/services/utils.ts +115 -115
  116. package/src/services/viem.ts +34 -34
  117. package/src/setup.ts +8 -8
  118. package/src/spark/index.ts +456 -456
  119. package/src/staking/eligibility.ts +53 -53
  120. package/src/staking/index.ts +1 -1
  121. package/src/staking/staking.ts +183 -183
  122. package/src/types/aave.ts +189 -189
  123. package/src/types/claiming.ts +109 -109
  124. package/src/types/common.ts +107 -107
  125. package/src/types/compound.ts +136 -136
  126. package/src/types/curveUsd.ts +123 -123
  127. package/src/types/euler.ts +175 -175
  128. package/src/types/fluid.ts +483 -483
  129. package/src/types/index.ts +15 -14
  130. package/src/types/liquity.ts +30 -30
  131. package/src/types/liquityV2.ts +126 -126
  132. package/src/types/llamaLend.ts +159 -159
  133. package/src/types/maker.ts +63 -63
  134. package/src/types/merit.ts +1 -1
  135. package/src/types/merkl.ts +70 -70
  136. package/src/types/morphoBlue.ts +200 -200
  137. package/src/types/portfolio.ts +60 -60
  138. package/src/types/savings/index.ts +16 -0
  139. package/src/types/savings/morphoVaults.ts +24 -0
  140. package/src/types/savings/yearnVaults.ts +13 -0
  141. package/src/types/spark.ts +133 -133
  142. package/src/umbrella/index.ts +69 -69
  143. package/src/umbrella/umbrellaUtils.ts +29 -29
package/esm/contracts.js CHANGED
@@ -45,6 +45,22 @@ export const createViemContractFromConfigFunc = (name, _address) => (client, net
45
45
  client,
46
46
  });
47
47
  };
48
+ export const getMorphoVaultContractViem = (client, address) => {
49
+ const abi = getConfigContractAbi('MorphoVault');
50
+ return getContract({
51
+ address,
52
+ abi,
53
+ client,
54
+ });
55
+ };
56
+ export const getYearnVaultContractViem = (client, address) => {
57
+ const abi = getConfigContractAbi('YearnVault');
58
+ return getContract({
59
+ address,
60
+ abi,
61
+ client,
62
+ });
63
+ };
48
64
  export const MorphoBlueViewContractViem = createViemContractFromConfigFunc('MorphoBlueView');
49
65
  export const AaveLoanInfoV2ContractViem = createViemContractFromConfigFunc('AaveLoanInfoV2');
50
66
  export const AaveV3ViewContractViem = createViemContractFromConfigFunc('AaveV3View');
@@ -89,3 +105,4 @@ export const SparkRewardsControllerViem = createViemContractFromConfigFunc('Spar
89
105
  export const AaveRewardsControllerViem = createViemContractFromConfigFunc('AaveRewardsController');
90
106
  export const LiquityV2sBoldVaultViem = createViemContractFromConfigFunc('LiquityV2sBoldVault');
91
107
  export const StkAAVEViem = createViemContractFromConfigFunc('StkAAVE');
108
+ export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView');
@@ -118,73 +118,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
118
118
  return { borrowRate, supplyRate };
119
119
  });
120
120
  const API_URL = 'https://blue-api.morpho.org/graphql';
121
- const MARKET_QUERY = `
122
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
123
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
124
- reallocatableLiquidityAssets
125
- targetBorrowUtilization
126
- loanAsset {
127
- address
128
- decimals
129
- priceUsd
130
- }
131
- state {
132
- liquidityAssets
133
- borrowAssets
134
- supplyAssets
135
- }
136
- publicAllocatorSharedLiquidity {
137
- assets
138
- vault {
139
- address
140
- name
141
- }
142
- allocationMarket {
143
- uniqueKey
144
- loanAsset {
145
- address
146
- }
147
- collateralAsset {
148
- address
149
- }
150
- irmAddress
151
- oracle {
152
- address
153
- }
154
- lltv
155
- }
156
- }
157
- loanAsset {
158
- address
159
- }
160
- collateralAsset {
161
- address
162
- }
163
- oracle {
164
- address
165
- }
166
- irmAddress
167
- lltv
168
- }
169
- }
121
+ const MARKET_QUERY = `
122
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
123
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
124
+ reallocatableLiquidityAssets
125
+ targetBorrowUtilization
126
+ loanAsset {
127
+ address
128
+ decimals
129
+ priceUsd
130
+ }
131
+ state {
132
+ liquidityAssets
133
+ borrowAssets
134
+ supplyAssets
135
+ }
136
+ publicAllocatorSharedLiquidity {
137
+ assets
138
+ vault {
139
+ address
140
+ name
141
+ }
142
+ allocationMarket {
143
+ uniqueKey
144
+ loanAsset {
145
+ address
146
+ }
147
+ collateralAsset {
148
+ address
149
+ }
150
+ irmAddress
151
+ oracle {
152
+ address
153
+ }
154
+ lltv
155
+ }
156
+ }
157
+ loanAsset {
158
+ address
159
+ }
160
+ collateralAsset {
161
+ address
162
+ }
163
+ oracle {
164
+ address
165
+ }
166
+ irmAddress
167
+ lltv
168
+ }
169
+ }
170
170
  `;
171
- const REWARDS_QUERY = `
172
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
173
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
174
- uniqueKey
175
- state {
176
- rewards {
177
- amountPerSuppliedToken
178
- supplyApr
179
- amountPerBorrowedToken
180
- borrowApr
181
- asset {
182
- address
183
- }
184
- }
185
- }
186
- }
187
- }
171
+ const REWARDS_QUERY = `
172
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
173
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
174
+ uniqueKey
175
+ state {
176
+ rewards {
177
+ amountPerSuppliedToken
178
+ supplyApr
179
+ amountPerBorrowedToken
180
+ borrowApr
181
+ asset {
182
+ address
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
188
  `;
189
189
  /**
190
190
  * Get reallocatable liquidity to a given market and target borrow utilization
package/esm/index.d.ts CHANGED
@@ -19,5 +19,6 @@ import * as llamaLend from './llamaLend';
19
19
  import * as eulerV2 from './eulerV2';
20
20
  import * as portfolio from './portfolio';
21
21
  import * as claiming from './claiming';
22
+ import * as savings from './savings';
22
23
  export * from './types';
23
- export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, };
24
+ export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
package/esm/index.js CHANGED
@@ -19,5 +19,6 @@ import * as llamaLend from './llamaLend';
19
19
  import * as eulerV2 from './eulerV2';
20
20
  import * as portfolio from './portfolio';
21
21
  import * as claiming from './claiming';
22
+ import * as savings from './savings';
22
23
  export * from './types';
23
- export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, };
24
+ export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
@@ -15,7 +15,7 @@ export const aaveV3AssetsDefaultMarketOpt = [
15
15
  export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
16
16
  export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC'];
17
17
  export const aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC'];
18
- export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL'];
18
+ export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT'];
19
19
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
20
20
  export const aaveV3AssetsDefaultMarket = {
21
21
  [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
@@ -0,0 +1,6 @@
1
+ import { MorphoVaultType, YearnVaultType } from '../types';
2
+ import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
3
+ import * as morphoVaults from './morphoVaults';
4
+ import * as yearnVaults from './yearnVaults';
5
+ export { morphoVaults, yearnVaults, };
6
+ export declare const getSavingsData: (provider: EthereumProvider, network: NetworkNumber, accounts: EthAddress[]) => Promise<Partial<Record<MorphoVaultType | YearnVaultType, import("../types").SavingsVaultData>>>;
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as morphoVaults from './morphoVaults';
11
+ import * as yearnVaults from './yearnVaults';
12
+ export { morphoVaults, yearnVaults, };
13
+ export const getSavingsData = (provider, network, accounts) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const morphoVaultsList = Object.keys(morphoVaults.morphoVaultsOptions.MORPHO_VAULTS);
15
+ const yearnVaultsList = Object.keys(yearnVaults.yearnVaultsOptions.YEARN_VAULTS);
16
+ const savingsData = {};
17
+ yield Promise.all([
18
+ ...morphoVaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const vault = morphoVaults.morphoVaultsOptions.getMorphoVault(vaultKey);
20
+ const data = yield morphoVaults.getMorphoVaultData(provider, network, vault, accounts);
21
+ savingsData[vaultKey] = data;
22
+ })),
23
+ ...yearnVaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
24
+ const vault = yearnVaults.yearnVaultsOptions.getYearnVault(vaultKey);
25
+ const data = yield yearnVaults.getYearnVaultData(provider, network, vault, accounts);
26
+ savingsData[vaultKey] = data;
27
+ })),
28
+ ]);
29
+ return savingsData;
30
+ });
@@ -0,0 +1,7 @@
1
+ import { Client } from 'viem';
2
+ import * as morphoVaultsOptions from './options';
3
+ import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
4
+ import { MorphoVault, SavingsVaultData } from '../../types';
5
+ export { morphoVaultsOptions, };
6
+ export declare const _getMorphoVaultData: (provider: Client, network: NetworkNumber, morphoVault: MorphoVault, accounts: EthAddress[]) => Promise<SavingsVaultData>;
7
+ export declare function getMorphoVaultData(provider: EthereumProvider, network: NetworkNumber, morphoVault: MorphoVault, accounts: EthAddress[]): Promise<SavingsVaultData>;
@@ -0,0 +1,77 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { request as graphqlRequest } from 'graphql-request';
12
+ import { assetAmountInEth } from '@defisaver/tokens';
13
+ import * as morphoVaultsOptions from './options';
14
+ import { getViemProvider } from '../../services/viem';
15
+ import { getMorphoVaultContractViem } from '../../contracts';
16
+ export { morphoVaultsOptions, };
17
+ const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
18
+ vaultByAddress(chainId: 1, address: "${vaultAddress}") {
19
+ id,
20
+ dailyApy,
21
+ dailyApys {
22
+ apy, netApy
23
+ },
24
+ monthlyApys {
25
+ apy, netApy
26
+ },
27
+ liquidity {
28
+ underlying, usd,
29
+ },
30
+ asset {
31
+ priceUsd
32
+ }
33
+ }
34
+ }`;
35
+ const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
36
+ export const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
37
+ const morphoVaultContract = getMorphoVaultContractViem(provider, morphoVault.address);
38
+ const shares = {};
39
+ const [totalAssets, totalSupply, decimals, decimalsOffset, vaultData] = yield Promise.all([
40
+ morphoVaultContract.read.totalAssets(),
41
+ morphoVaultContract.read.totalSupply(),
42
+ morphoVaultContract.read.decimals(),
43
+ morphoVaultContract.read.DECIMALS_OFFSET(),
44
+ graphqlRequest(MORPHO_BLUE_API, vaultDataQuery(morphoVault.address)),
45
+ ...accounts.map((account) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const share = yield morphoVaultContract.read.balanceOf([account]);
47
+ shares[account] = share;
48
+ })),
49
+ ]);
50
+ const poolSize = assetAmountInEth(totalAssets.toString(), morphoVault.asset);
51
+ const liquidity = assetAmountInEth(vaultData.vaultByAddress.liquidity.underlying, morphoVault.asset);
52
+ const supplied = {};
53
+ accounts.forEach((account) => {
54
+ const share = shares[account] || BigInt(0);
55
+ supplied[account.toLowerCase()] = new Dec(new Dec(share.toString()).mul(new Dec(totalAssets.toString()).add(1)).div(new Dec(totalSupply.toString()).add(Math.pow(10, decimalsOffset))).div(Math.pow(10, 18))
56
+ .toFixed(decimals)).mul(Math.pow(10, decimalsOffset))
57
+ .toString();
58
+ });
59
+ return {
60
+ poolSize,
61
+ supplied,
62
+ liquidity,
63
+ asset: morphoVault.asset,
64
+ optionType: morphoVault.type,
65
+ };
66
+ });
67
+ export function getMorphoVaultData(provider, network, morphoVault, accounts) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return _getMorphoVaultData(getViemProvider(provider, network, {
70
+ batch: {
71
+ multicall: {
72
+ batchSize: 2500000,
73
+ },
74
+ },
75
+ }), network, morphoVault, accounts);
76
+ });
77
+ }
@@ -0,0 +1,16 @@
1
+ import { MorphoVault, MorphoVaultType } from '../../types';
2
+ export declare const MORPHO_VAULT_FLAGSHIP_ETH: MorphoVault;
3
+ export declare const MORPHO_VAULT_GAUNTLET_USDC_CORE: MorphoVault;
4
+ export declare const MORPHO_VAULT_GAUNTLET_USDC_PRIME: MorphoVault;
5
+ export declare const MORPHO_VAULT_RE7_WETH: MorphoVault;
6
+ export declare const MORPHO_VAULT_GAUNTLET_WETH_CORE: MorphoVault;
7
+ export declare const MORPHO_VAULT_GAUNTLET_WETH_PRIME: MorphoVault;
8
+ export declare const MORPHO_VAULT_BOOSTED_USDC: MorphoVault;
9
+ export declare const MORPHO_VAULT_STEAKHOUSE_PYUSD: MorphoVault;
10
+ export declare const MORPHO_VAULT_FLAGSHIP_USDT: MorphoVault;
11
+ export declare const MORPHO_VAULT_STEAKHOUSE_USDT: MorphoVault;
12
+ export declare const MORPHO_VAULT_GAUNTLET_USDA_CORE: MorphoVault;
13
+ export declare const MORPHO_VAULT_GAUNTLET_USDT_PRIME: MorphoVault;
14
+ export declare const MORPHO_VAULT_GAUNTLET_RESOLV_USDC: MorphoVault;
15
+ export declare const MORPHO_VAULTS: Record<MorphoVaultType, MorphoVault>;
16
+ export declare const getMorphoVault: (type: MorphoVaultType) => MorphoVault;
@@ -0,0 +1,95 @@
1
+ import { MorphoVaultType } from '../../types';
2
+ export const MORPHO_VAULT_FLAGSHIP_ETH = {
3
+ type: MorphoVaultType.MorphoVaultFlagshipEth,
4
+ name: 'Flagship ETH',
5
+ address: '0x38989BBA00BDF8181F4082995b3DEAe96163aC5D',
6
+ asset: 'ETH',
7
+ };
8
+ export const MORPHO_VAULT_GAUNTLET_USDC_CORE = {
9
+ type: MorphoVaultType.MorphoVaultGauntletUSDCCore,
10
+ name: 'Gauntlet USDC Core',
11
+ address: '0x8eB67A509616cd6A7c1B3c8C21D48FF57df3d458',
12
+ asset: 'USDC',
13
+ };
14
+ export const MORPHO_VAULT_GAUNTLET_USDC_PRIME = {
15
+ type: MorphoVaultType.MorphoVaultGauntletUSDCPrime,
16
+ name: 'Gauntlet USDC Prime',
17
+ address: '0xdd0f28e19C1780eb6396170735D45153D261490d',
18
+ asset: 'USDC',
19
+ };
20
+ export const MORPHO_VAULT_RE7_WETH = {
21
+ type: MorphoVaultType.MorphoVaultRe7Weth,
22
+ name: 'RE7 WETH',
23
+ address: '0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0',
24
+ asset: 'ETH',
25
+ };
26
+ export const MORPHO_VAULT_GAUNTLET_WETH_CORE = {
27
+ type: MorphoVaultType.MorphoVaultGauntletWETHCore,
28
+ name: 'Gauntlet WETH Core',
29
+ address: '0x4881Ef0BF6d2365D3dd6499ccd7532bcdBCE0658',
30
+ asset: 'ETH',
31
+ };
32
+ export const MORPHO_VAULT_GAUNTLET_WETH_PRIME = {
33
+ type: MorphoVaultType.MorphoVaultGauntletWETHPrime,
34
+ name: 'Gauntlet WETH Prime',
35
+ address: '0x2371e134e3455e0593363cBF89d3b6cf53740618',
36
+ asset: 'ETH',
37
+ };
38
+ export const MORPHO_VAULT_BOOSTED_USDC = {
39
+ type: MorphoVaultType.MorphoVaultBoostedUSDC,
40
+ name: 'Boosted USDC',
41
+ address: '0xd63070114470f685b75B74D60EEc7c1113d33a3D',
42
+ asset: 'USDC',
43
+ };
44
+ export const MORPHO_VAULT_STEAKHOUSE_PYUSD = {
45
+ type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
46
+ name: 'Steakhouse PYUSD',
47
+ address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
48
+ asset: 'PYUSD',
49
+ };
50
+ export const MORPHO_VAULT_FLAGSHIP_USDT = {
51
+ type: MorphoVaultType.MorphoVaultFlagshipUSDT,
52
+ name: 'Flagship USDT',
53
+ address: '0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1',
54
+ asset: 'USDT',
55
+ };
56
+ export const MORPHO_VAULT_STEAKHOUSE_USDT = {
57
+ type: MorphoVaultType.MorphoVaultSteakhouseUSDT,
58
+ name: 'Steakhouse USDT',
59
+ address: '0xbEef047a543E45807105E51A8BBEFCc5950fcfBa',
60
+ asset: 'USDT',
61
+ };
62
+ export const MORPHO_VAULT_GAUNTLET_USDA_CORE = {
63
+ type: MorphoVaultType.MorphoVaultGauntletUSDACore,
64
+ name: 'Gauntlet USDA Core',
65
+ address: '0x125D41A6e5dbf455cD9Df8F80BCC6fd172D52Cc6',
66
+ asset: 'USDA',
67
+ };
68
+ export const MORPHO_VAULT_GAUNTLET_USDT_PRIME = {
69
+ type: MorphoVaultType.MorphoVaultGauntletUSDTPrime,
70
+ name: 'Gauntlet USDT Prime',
71
+ address: '0x8CB3649114051cA5119141a34C200D65dc0Faa73',
72
+ asset: 'USDT',
73
+ };
74
+ export const MORPHO_VAULT_GAUNTLET_RESOLV_USDC = {
75
+ type: MorphoVaultType.MorphoVaultGauntletResolvUSDC,
76
+ name: 'Gauntlet Resolv USDC',
77
+ address: '0x132E6C9C33A62D7727cd359b1f51e5B566E485Eb',
78
+ asset: 'USDC',
79
+ };
80
+ export const MORPHO_VAULTS = {
81
+ [MorphoVaultType.MorphoVaultFlagshipEth]: MORPHO_VAULT_FLAGSHIP_ETH,
82
+ [MorphoVaultType.MorphoVaultGauntletUSDCCore]: MORPHO_VAULT_GAUNTLET_USDC_CORE,
83
+ [MorphoVaultType.MorphoVaultGauntletUSDCPrime]: MORPHO_VAULT_GAUNTLET_USDC_PRIME,
84
+ [MorphoVaultType.MorphoVaultRe7Weth]: MORPHO_VAULT_RE7_WETH,
85
+ [MorphoVaultType.MorphoVaultGauntletWETHCore]: MORPHO_VAULT_GAUNTLET_WETH_CORE,
86
+ [MorphoVaultType.MorphoVaultGauntletWETHPrime]: MORPHO_VAULT_GAUNTLET_WETH_PRIME,
87
+ [MorphoVaultType.MorphoVaultBoostedUSDC]: MORPHO_VAULT_BOOSTED_USDC,
88
+ [MorphoVaultType.MorphoVaultSteakhousePYUSD]: MORPHO_VAULT_STEAKHOUSE_PYUSD,
89
+ [MorphoVaultType.MorphoVaultFlagshipUSDT]: MORPHO_VAULT_FLAGSHIP_USDT,
90
+ [MorphoVaultType.MorphoVaultSteakhouseUSDT]: MORPHO_VAULT_STEAKHOUSE_USDT,
91
+ [MorphoVaultType.MorphoVaultGauntletUSDACore]: MORPHO_VAULT_GAUNTLET_USDA_CORE,
92
+ [MorphoVaultType.MorphoVaultGauntletUSDTPrime]: MORPHO_VAULT_GAUNTLET_USDT_PRIME,
93
+ [MorphoVaultType.MorphoVaultGauntletResolvUSDC]: MORPHO_VAULT_GAUNTLET_RESOLV_USDC,
94
+ };
95
+ export const getMorphoVault = (type) => MORPHO_VAULTS[type];
@@ -0,0 +1,7 @@
1
+ import { Client } from 'viem';
2
+ import { SavingsVaultData, YearnVault } from '../../types';
3
+ import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
4
+ import * as yearnVaultsOptions from './options';
5
+ export { yearnVaultsOptions, };
6
+ export declare const _getYearnVaultData: (provider: Client, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]) => Promise<SavingsVaultData>;
7
+ export declare function getYearnVaultData(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]): Promise<SavingsVaultData>;
@@ -0,0 +1,56 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { assetAmountInEth } from '@defisaver/tokens';
12
+ import { getViemProvider } from '../../services/viem';
13
+ import * as yearnVaultsOptions from './options';
14
+ import { getYearnVaultContractViem, YearnViewContractViem } from '../../contracts';
15
+ export { yearnVaultsOptions, };
16
+ export const _getYearnVaultData = (provider, network, yearnVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const yearnVaultContract = getYearnVaultContractViem(provider, yearnVault.address);
18
+ const viewContract = YearnViewContractViem(provider, network);
19
+ const yvAmountsWei = {};
20
+ const [tokenSupply, underlyingSupply, poolLiquidity] = yield Promise.all([
21
+ yearnVaultContract.read.totalSupply(),
22
+ yearnVaultContract.read.totalAssets(),
23
+ viewContract.read.getPoolLiquidity([yearnVault.address]),
24
+ ...accounts.map((account) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const yvAmount = yield yearnVaultContract.read.balanceOf([account]);
26
+ yvAmountsWei[account] = yvAmount;
27
+ })),
28
+ ]);
29
+ const exchangeRate = new Dec(underlyingSupply).div(tokenSupply).toString();
30
+ const poolSize = assetAmountInEth(underlyingSupply.toString(), yearnVault.asset);
31
+ const liquidity = assetAmountInEth(poolLiquidity.toString(), yearnVault.asset);
32
+ const supplied = {};
33
+ accounts.forEach((account) => {
34
+ const yvAmountWei = yvAmountsWei[account] || BigInt(0);
35
+ const underlyingAmountWei = new Dec(yvAmountWei).mul(exchangeRate).toString();
36
+ supplied[account.toLowerCase()] = assetAmountInEth(underlyingAmountWei, yearnVault.asset);
37
+ });
38
+ return {
39
+ poolSize,
40
+ liquidity,
41
+ supplied,
42
+ asset: yearnVault.asset,
43
+ optionType: yearnVault.type,
44
+ };
45
+ });
46
+ export function getYearnVaultData(provider, network, yearnVault, accounts) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ return _getYearnVaultData(getViemProvider(provider, network, {
49
+ batch: {
50
+ multicall: {
51
+ batchSize: 2500000,
52
+ },
53
+ },
54
+ }), network, yearnVault, accounts);
55
+ });
56
+ }
@@ -0,0 +1,6 @@
1
+ import { YearnVault, YearnVaultType } from '../../types/savings/yearnVaults';
2
+ export declare const YEARN_VAULT_DAI: YearnVault;
3
+ export declare const YEARN_VAULT_USDC: YearnVault;
4
+ export declare const YEARN_VAULT_USDT: YearnVault;
5
+ export declare const YEARN_VAULTS: Record<YearnVaultType, YearnVault>;
6
+ export declare const getYearnVault: (type: YearnVaultType) => YearnVault;
@@ -0,0 +1,22 @@
1
+ import { YearnVaultType } from '../../types/savings/yearnVaults';
2
+ export const YEARN_VAULT_DAI = {
3
+ type: YearnVaultType.YearnVaultDAI,
4
+ address: '0xdA816459F1AB5631232FE5e97a05BBBb94970c95',
5
+ asset: 'DAI',
6
+ };
7
+ export const YEARN_VAULT_USDC = {
8
+ type: YearnVaultType.YearnVaultUSDC,
9
+ address: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE',
10
+ asset: 'USDC',
11
+ };
12
+ export const YEARN_VAULT_USDT = {
13
+ type: YearnVaultType.YearnVaultUSDT,
14
+ address: '0x3B27F92C0e212C671EA351827EDF93DB27cc0c65',
15
+ asset: 'USDT',
16
+ };
17
+ export const YEARN_VAULTS = {
18
+ [YearnVaultType.YearnVaultDAI]: YEARN_VAULT_DAI,
19
+ [YearnVaultType.YearnVaultUSDC]: YEARN_VAULT_USDC,
20
+ [YearnVaultType.YearnVaultUSDT]: YEARN_VAULT_USDT,
21
+ };
22
+ export const getYearnVault = (type) => YEARN_VAULTS[type];
@@ -12,3 +12,4 @@ export * from './fluid';
12
12
  export * from './portfolio';
13
13
  export * from './merit';
14
14
  export * from './merkl';
15
+ export * from './savings';
@@ -12,3 +12,4 @@ export * from './fluid';
12
12
  export * from './portfolio';
13
13
  export * from './merit';
14
14
  export * from './merkl';
15
+ export * from './savings';
@@ -0,0 +1,13 @@
1
+ import { EthAddress } from '../common';
2
+ import { MorphoVaultType } from './morphoVaults';
3
+ import { YearnVaultType } from './yearnVaults';
4
+ export * from './morphoVaults';
5
+ export * from './yearnVaults';
6
+ export interface SavingsVaultData {
7
+ poolSize: string;
8
+ liquidity: string;
9
+ supplied: Record<EthAddress, string>;
10
+ asset: string;
11
+ optionType: string;
12
+ }
13
+ export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType, SavingsVaultData>>;
@@ -0,0 +1,2 @@
1
+ export * from './morphoVaults';
2
+ export * from './yearnVaults';
@@ -0,0 +1,22 @@
1
+ import { EthAddress } from '../common';
2
+ export declare enum MorphoVaultType {
3
+ MorphoVaultFlagshipEth = "morpho_vault_flagship_eth",
4
+ MorphoVaultGauntletUSDCCore = "morpho_vault_gauntlet_usdc_core",
5
+ MorphoVaultGauntletUSDCPrime = "morpho_vault_gauntlet_usdc_prime",
6
+ MorphoVaultRe7Weth = "morpho_vault_re7_weth",
7
+ MorphoVaultGauntletWETHCore = "morpho_vault_gauntlet_weth_core",
8
+ MorphoVaultGauntletWETHPrime = "morpho_vault_gauntlet_weth_prime",
9
+ MorphoVaultBoostedUSDC = "morpho_vault_usual_boosted_usdc",
10
+ MorphoVaultSteakhousePYUSD = "morpho_vault_steakhouse_pyusd",
11
+ MorphoVaultFlagshipUSDT = "morpho_vault_flagship_usdt",
12
+ MorphoVaultSteakhouseUSDT = "morpho_vault_steakhouse_usdt",
13
+ MorphoVaultGauntletUSDACore = "morpho_vault_gauntlet_usda_core",
14
+ MorphoVaultGauntletUSDTPrime = "morpho_vault_gauntlet_usdt_prime",
15
+ MorphoVaultGauntletResolvUSDC = "morpho_vault_gauntlet_resolv_usdc"
16
+ }
17
+ export interface MorphoVault {
18
+ type: MorphoVaultType;
19
+ name: string;
20
+ address: EthAddress;
21
+ asset: string;
22
+ }
@@ -0,0 +1,16 @@
1
+ export var MorphoVaultType;
2
+ (function (MorphoVaultType) {
3
+ MorphoVaultType["MorphoVaultFlagshipEth"] = "morpho_vault_flagship_eth";
4
+ MorphoVaultType["MorphoVaultGauntletUSDCCore"] = "morpho_vault_gauntlet_usdc_core";
5
+ MorphoVaultType["MorphoVaultGauntletUSDCPrime"] = "morpho_vault_gauntlet_usdc_prime";
6
+ MorphoVaultType["MorphoVaultRe7Weth"] = "morpho_vault_re7_weth";
7
+ MorphoVaultType["MorphoVaultGauntletWETHCore"] = "morpho_vault_gauntlet_weth_core";
8
+ MorphoVaultType["MorphoVaultGauntletWETHPrime"] = "morpho_vault_gauntlet_weth_prime";
9
+ MorphoVaultType["MorphoVaultBoostedUSDC"] = "morpho_vault_usual_boosted_usdc";
10
+ MorphoVaultType["MorphoVaultSteakhousePYUSD"] = "morpho_vault_steakhouse_pyusd";
11
+ MorphoVaultType["MorphoVaultFlagshipUSDT"] = "morpho_vault_flagship_usdt";
12
+ MorphoVaultType["MorphoVaultSteakhouseUSDT"] = "morpho_vault_steakhouse_usdt";
13
+ MorphoVaultType["MorphoVaultGauntletUSDACore"] = "morpho_vault_gauntlet_usda_core";
14
+ MorphoVaultType["MorphoVaultGauntletUSDTPrime"] = "morpho_vault_gauntlet_usdt_prime";
15
+ MorphoVaultType["MorphoVaultGauntletResolvUSDC"] = "morpho_vault_gauntlet_resolv_usdc";
16
+ })(MorphoVaultType || (MorphoVaultType = {}));
@@ -0,0 +1,11 @@
1
+ import { EthAddress } from '../common';
2
+ export declare enum YearnVaultType {
3
+ YearnVaultDAI = "yearn_vault_dai",
4
+ YearnVaultUSDC = "yearn_vault_usdc",
5
+ YearnVaultUSDT = "yearn_vault_usdt"
6
+ }
7
+ export interface YearnVault {
8
+ type: YearnVaultType;
9
+ address: EthAddress;
10
+ asset: string;
11
+ }
@@ -0,0 +1,6 @@
1
+ export var YearnVaultType;
2
+ (function (YearnVaultType) {
3
+ YearnVaultType["YearnVaultDAI"] = "yearn_vault_dai";
4
+ YearnVaultType["YearnVaultUSDC"] = "yearn_vault_usdc";
5
+ YearnVaultType["YearnVaultUSDT"] = "yearn_vault_usdt";
6
+ })(YearnVaultType || (YearnVaultType = {}));