@defisaver/positions-sdk 2.1.22-dev-savings-4 → 2.1.23-dev-sena

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 (152) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +64 -64
  4. package/cjs/claiming/ethena.d.ts +3 -0
  5. package/cjs/claiming/ethena.js +73 -0
  6. package/cjs/config/contracts.d.ts +0 -149
  7. package/cjs/config/contracts.js +1 -15
  8. package/cjs/contracts.d.ts +0 -1344
  9. package/cjs/contracts.js +1 -20
  10. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  11. package/cjs/index.d.ts +1 -2
  12. package/cjs/index.js +1 -3
  13. package/cjs/portfolio/index.js +26 -0
  14. package/cjs/types/claiming.d.ts +6 -2
  15. package/cjs/types/claiming.js +1 -0
  16. package/cjs/types/index.d.ts +0 -1
  17. package/cjs/types/index.js +0 -1
  18. package/esm/claiming/ethena.d.ts +3 -0
  19. package/esm/claiming/ethena.js +65 -0
  20. package/esm/config/contracts.d.ts +0 -149
  21. package/esm/config/contracts.js +0 -14
  22. package/esm/contracts.d.ts +0 -1344
  23. package/esm/contracts.js +0 -17
  24. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  25. package/esm/index.d.ts +1 -2
  26. package/esm/index.js +1 -2
  27. package/esm/portfolio/index.js +26 -0
  28. package/esm/types/claiming.d.ts +6 -2
  29. package/esm/types/claiming.js +1 -0
  30. package/esm/types/index.d.ts +0 -1
  31. package/esm/types/index.js +0 -1
  32. package/package.json +47 -48
  33. package/src/aaveV2/index.ts +240 -240
  34. package/src/aaveV3/index.ts +614 -614
  35. package/src/aaveV3/merit.ts +97 -97
  36. package/src/aaveV3/merkl.ts +74 -74
  37. package/src/claiming/aaveV3.ts +154 -154
  38. package/src/claiming/compV3.ts +22 -22
  39. package/src/claiming/ethena.ts +67 -0
  40. package/src/claiming/index.ts +12 -12
  41. package/src/claiming/king.ts +66 -66
  42. package/src/claiming/morphoBlue.ts +118 -118
  43. package/src/claiming/spark.ts +225 -225
  44. package/src/compoundV2/index.ts +244 -244
  45. package/src/compoundV3/index.ts +274 -274
  46. package/src/config/contracts.ts +1259 -1273
  47. package/src/constants/index.ts +10 -10
  48. package/src/contracts.ts +121 -141
  49. package/src/curveUsd/index.ts +254 -254
  50. package/src/eulerV2/index.ts +324 -324
  51. package/src/exchange/index.ts +25 -25
  52. package/src/fluid/index.ts +1774 -1774
  53. package/src/helpers/aaveHelpers/index.ts +187 -187
  54. package/src/helpers/compoundHelpers/index.ts +283 -283
  55. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  56. package/src/helpers/eulerHelpers/index.ts +222 -222
  57. package/src/helpers/fluidHelpers/index.ts +326 -326
  58. package/src/helpers/index.ts +10 -10
  59. package/src/helpers/liquityV2Helpers/index.ts +82 -82
  60. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  61. package/src/helpers/makerHelpers/index.ts +52 -52
  62. package/src/helpers/morphoBlueHelpers/index.ts +396 -396
  63. package/src/helpers/sparkHelpers/index.ts +158 -158
  64. package/src/index.ts +47 -49
  65. package/src/liquity/index.ts +159 -159
  66. package/src/liquityV2/index.ts +703 -703
  67. package/src/llamaLend/index.ts +305 -305
  68. package/src/maker/index.ts +223 -223
  69. package/src/markets/aave/index.ts +116 -116
  70. package/src/markets/aave/marketAssets.ts +54 -54
  71. package/src/markets/compound/index.ts +238 -238
  72. package/src/markets/compound/marketsAssets.ts +97 -97
  73. package/src/markets/curveUsd/index.ts +69 -69
  74. package/src/markets/euler/index.ts +26 -26
  75. package/src/markets/fluid/index.ts +2900 -2900
  76. package/src/markets/index.ts +25 -25
  77. package/src/markets/liquityV2/index.ts +102 -102
  78. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  79. package/src/markets/llamaLend/index.ts +235 -235
  80. package/src/markets/morphoBlue/index.ts +971 -971
  81. package/src/markets/spark/index.ts +29 -29
  82. package/src/markets/spark/marketAssets.ts +12 -12
  83. package/src/moneymarket/moneymarketCommonService.ts +84 -84
  84. package/src/morphoBlue/index.ts +274 -274
  85. package/src/portfolio/index.ts +598 -572
  86. package/src/services/priceService.ts +278 -278
  87. package/src/services/utils.ts +115 -115
  88. package/src/services/viem.ts +34 -34
  89. package/src/setup.ts +8 -8
  90. package/src/spark/index.ts +456 -456
  91. package/src/staking/eligibility.ts +53 -53
  92. package/src/staking/index.ts +1 -1
  93. package/src/staking/staking.ts +183 -183
  94. package/src/types/aave.ts +189 -189
  95. package/src/types/claiming.ts +114 -109
  96. package/src/types/common.ts +107 -107
  97. package/src/types/compound.ts +136 -136
  98. package/src/types/curveUsd.ts +123 -123
  99. package/src/types/euler.ts +175 -175
  100. package/src/types/fluid.ts +483 -483
  101. package/src/types/index.ts +14 -15
  102. package/src/types/liquity.ts +30 -30
  103. package/src/types/liquityV2.ts +126 -126
  104. package/src/types/llamaLend.ts +159 -159
  105. package/src/types/maker.ts +63 -63
  106. package/src/types/merit.ts +1 -1
  107. package/src/types/merkl.ts +70 -70
  108. package/src/types/morphoBlue.ts +200 -200
  109. package/src/types/portfolio.ts +60 -60
  110. package/src/types/spark.ts +133 -133
  111. package/src/umbrella/index.ts +69 -69
  112. package/src/umbrella/umbrellaUtils.ts +29 -29
  113. package/cjs/savings/index.d.ts +0 -6
  114. package/cjs/savings/index.js +0 -68
  115. package/cjs/savings/morphoVaults/index.d.ts +0 -7
  116. package/cjs/savings/morphoVaults/index.js +0 -118
  117. package/cjs/savings/morphoVaults/options.d.ts +0 -16
  118. package/cjs/savings/morphoVaults/options.js +0 -99
  119. package/cjs/savings/yearnVaults/index.d.ts +0 -7
  120. package/cjs/savings/yearnVaults/index.js +0 -97
  121. package/cjs/savings/yearnVaults/options.d.ts +0 -6
  122. package/cjs/savings/yearnVaults/options.js +0 -26
  123. package/cjs/types/savings/index.d.ts +0 -13
  124. package/cjs/types/savings/index.js +0 -18
  125. package/cjs/types/savings/morphoVaults.d.ts +0 -22
  126. package/cjs/types/savings/morphoVaults.js +0 -19
  127. package/cjs/types/savings/yearnVaults.d.ts +0 -11
  128. package/cjs/types/savings/yearnVaults.js +0 -9
  129. package/esm/savings/index.d.ts +0 -6
  130. package/esm/savings/index.js +0 -30
  131. package/esm/savings/morphoVaults/index.d.ts +0 -7
  132. package/esm/savings/morphoVaults/index.js +0 -77
  133. package/esm/savings/morphoVaults/options.d.ts +0 -16
  134. package/esm/savings/morphoVaults/options.js +0 -95
  135. package/esm/savings/yearnVaults/index.d.ts +0 -7
  136. package/esm/savings/yearnVaults/index.js +0 -56
  137. package/esm/savings/yearnVaults/options.d.ts +0 -6
  138. package/esm/savings/yearnVaults/options.js +0 -22
  139. package/esm/types/savings/index.d.ts +0 -13
  140. package/esm/types/savings/index.js +0 -2
  141. package/esm/types/savings/morphoVaults.d.ts +0 -22
  142. package/esm/types/savings/morphoVaults.js +0 -16
  143. package/esm/types/savings/yearnVaults.d.ts +0 -11
  144. package/esm/types/savings/yearnVaults.js +0 -6
  145. package/src/savings/index.ts +0 -35
  146. package/src/savings/morphoVaults/index.ts +0 -81
  147. package/src/savings/morphoVaults/options.ts +0 -110
  148. package/src/savings/yearnVaults/index.ts +0 -58
  149. package/src/savings/yearnVaults/options.ts +0 -27
  150. package/src/types/savings/index.ts +0 -16
  151. package/src/types/savings/morphoVaults.ts +0 -24
  152. package/src/types/savings/yearnVaults.ts +0 -13
@@ -1,95 +0,0 @@
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];
@@ -1,7 +0,0 @@
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>;
@@ -1,56 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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;
@@ -1,22 +0,0 @@
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];
@@ -1,13 +0,0 @@
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>>;
@@ -1,2 +0,0 @@
1
- export * from './morphoVaults';
2
- export * from './yearnVaults';
@@ -1,22 +0,0 @@
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
- }
@@ -1,16 +0,0 @@
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 = {}));
@@ -1,11 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
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 = {}));
@@ -1,35 +0,0 @@
1
- import { MorphoVaultType, SavingsData, YearnVaultType } from '../types';
2
- import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
3
- import * as morphoVaults from './morphoVaults';
4
- import * as yearnVaults from './yearnVaults';
5
-
6
- export {
7
- morphoVaults,
8
- yearnVaults,
9
- };
10
-
11
- export const getSavingsData = async (
12
- provider: EthereumProvider,
13
- network: NetworkNumber,
14
- accounts: EthAddress[],
15
- ) => {
16
- const morphoVaultsList = Object.keys(morphoVaults.morphoVaultsOptions.MORPHO_VAULTS) as MorphoVaultType[];
17
- const yearnVaultsList = Object.keys(yearnVaults.yearnVaultsOptions.YEARN_VAULTS) as YearnVaultType[];
18
-
19
- const savingsData: SavingsData = {};
20
-
21
- await Promise.all([
22
- ...morphoVaultsList.map(async (vaultKey) => {
23
- const vault = morphoVaults.morphoVaultsOptions.getMorphoVault(vaultKey);
24
- const data = await morphoVaults.getMorphoVaultData(provider, network, vault, accounts);
25
- savingsData[vaultKey] = data;
26
- }),
27
- ...yearnVaultsList.map(async (vaultKey) => {
28
- const vault = yearnVaults.yearnVaultsOptions.getYearnVault(vaultKey);
29
- const data = await yearnVaults.getYearnVaultData(provider, network, vault, accounts);
30
- savingsData[vaultKey] = data;
31
- }),
32
- ]);
33
-
34
- return savingsData;
35
- };
@@ -1,81 +0,0 @@
1
- import { Client } from 'viem';
2
- import Dec from 'decimal.js';
3
- import { request as graphqlRequest } from 'graphql-request';
4
- import { assetAmountInEth } from '@defisaver/tokens';
5
- import * as morphoVaultsOptions from './options';
6
- import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
7
- import { getViemProvider } from '../../services/viem';
8
- import { getMorphoVaultContractViem } from '../../contracts';
9
- import { MorphoVault, SavingsVaultData } from '../../types';
10
-
11
- export {
12
- morphoVaultsOptions,
13
- };
14
-
15
- const vaultDataQuery = (vaultAddress: EthAddress) => `query vaultByAddress {
16
- vaultByAddress(chainId: 1, address: "${vaultAddress}") {
17
- id,
18
- dailyApy,
19
- dailyApys {
20
- apy, netApy
21
- },
22
- monthlyApys {
23
- apy, netApy
24
- },
25
- liquidity {
26
- underlying, usd,
27
- },
28
- asset {
29
- priceUsd
30
- }
31
- }
32
- }`;
33
-
34
- const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
35
-
36
- export const _getMorphoVaultData = async (provider: Client, network: NetworkNumber, morphoVault: MorphoVault, accounts: EthAddress[]): Promise<SavingsVaultData> => {
37
- const morphoVaultContract = getMorphoVaultContractViem(provider, morphoVault.address);
38
-
39
- const shares: Record<EthAddress, bigint> = {};
40
-
41
- const [totalAssets, totalSupply, decimals, decimalsOffset, vaultData] = await Promise.all([
42
- morphoVaultContract.read.totalAssets(),
43
- morphoVaultContract.read.totalSupply(),
44
- morphoVaultContract.read.decimals(),
45
- morphoVaultContract.read.DECIMALS_OFFSET(),
46
- graphqlRequest(MORPHO_BLUE_API, vaultDataQuery(morphoVault.address)),
47
- ...accounts.map(async (account) => {
48
- const share = await morphoVaultContract.read.balanceOf([account]);
49
- shares[account] = share;
50
- }),
51
- ]);
52
-
53
- const poolSize = assetAmountInEth(totalAssets.toString(), morphoVault.asset);
54
- const liquidity = assetAmountInEth((vaultData as any).vaultByAddress.liquidity.underlying, morphoVault.asset);
55
-
56
- const supplied: Record<EthAddress, string> = {};
57
- accounts.forEach((account) => {
58
- const share = shares[account] || BigInt(0);
59
- supplied[account.toLowerCase() as EthAddress] = new Dec(new Dec(share.toString()).mul(new Dec(totalAssets.toString()).add(1)).div(new Dec(totalSupply.toString()).add(10 ** decimalsOffset)).div(10 ** 18)
60
- .toFixed(decimals)).mul(10 ** decimalsOffset)
61
- .toString();
62
- });
63
-
64
- return {
65
- poolSize,
66
- supplied,
67
- liquidity,
68
- asset: morphoVault.asset,
69
- optionType: morphoVault.type,
70
- };
71
- };
72
-
73
- export async function getMorphoVaultData(provider: EthereumProvider, network: NetworkNumber, morphoVault: MorphoVault, accounts: EthAddress[]): Promise<SavingsVaultData> {
74
- return _getMorphoVaultData(getViemProvider(provider, network, {
75
- batch: {
76
- multicall: {
77
- batchSize: 2500000,
78
- },
79
- },
80
- }), network, morphoVault, accounts);
81
- }
@@ -1,110 +0,0 @@
1
- import { MorphoVault, MorphoVaultType } from '../../types';
2
-
3
- export const MORPHO_VAULT_FLAGSHIP_ETH: MorphoVault = {
4
- type: MorphoVaultType.MorphoVaultFlagshipEth,
5
- name: 'Flagship ETH',
6
- address: '0x38989BBA00BDF8181F4082995b3DEAe96163aC5D',
7
- asset: 'ETH',
8
- };
9
-
10
- export const MORPHO_VAULT_GAUNTLET_USDC_CORE: MorphoVault = {
11
- type: MorphoVaultType.MorphoVaultGauntletUSDCCore,
12
- name: 'Gauntlet USDC Core',
13
- address: '0x8eB67A509616cd6A7c1B3c8C21D48FF57df3d458',
14
- asset: 'USDC',
15
- };
16
-
17
- export const MORPHO_VAULT_GAUNTLET_USDC_PRIME: MorphoVault = {
18
- type: MorphoVaultType.MorphoVaultGauntletUSDCPrime,
19
- name: 'Gauntlet USDC Prime',
20
- address: '0xdd0f28e19C1780eb6396170735D45153D261490d',
21
- asset: 'USDC',
22
- };
23
-
24
- export const MORPHO_VAULT_RE7_WETH: MorphoVault = {
25
- type: MorphoVaultType.MorphoVaultRe7Weth,
26
- name: 'RE7 WETH',
27
- address: '0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0',
28
- asset: 'ETH',
29
- };
30
-
31
- export const MORPHO_VAULT_GAUNTLET_WETH_CORE: MorphoVault = {
32
- type: MorphoVaultType.MorphoVaultGauntletWETHCore,
33
- name: 'Gauntlet WETH Core',
34
- address: '0x4881Ef0BF6d2365D3dd6499ccd7532bcdBCE0658',
35
- asset: 'ETH',
36
- };
37
-
38
- export const MORPHO_VAULT_GAUNTLET_WETH_PRIME: MorphoVault = {
39
- type: MorphoVaultType.MorphoVaultGauntletWETHPrime,
40
- name: 'Gauntlet WETH Prime',
41
- address: '0x2371e134e3455e0593363cBF89d3b6cf53740618',
42
- asset: 'ETH',
43
- };
44
-
45
- export const MORPHO_VAULT_BOOSTED_USDC: MorphoVault = {
46
- type: MorphoVaultType.MorphoVaultBoostedUSDC,
47
- name: 'Boosted USDC',
48
- address: '0xd63070114470f685b75B74D60EEc7c1113d33a3D',
49
- asset: 'USDC',
50
- };
51
-
52
- export const MORPHO_VAULT_STEAKHOUSE_PYUSD: MorphoVault = {
53
- type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
54
- name: 'Steakhouse PYUSD',
55
- address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
56
- asset: 'PYUSD',
57
- };
58
-
59
- export const MORPHO_VAULT_FLAGSHIP_USDT: MorphoVault = {
60
- type: MorphoVaultType.MorphoVaultFlagshipUSDT,
61
- name: 'Flagship USDT',
62
- address: '0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1',
63
- asset: 'USDT',
64
- };
65
-
66
- export const MORPHO_VAULT_STEAKHOUSE_USDT: MorphoVault = {
67
- type: MorphoVaultType.MorphoVaultSteakhouseUSDT,
68
- name: 'Steakhouse USDT',
69
- address: '0xbEef047a543E45807105E51A8BBEFCc5950fcfBa',
70
- asset: 'USDT',
71
- };
72
-
73
- export const MORPHO_VAULT_GAUNTLET_USDA_CORE: MorphoVault = {
74
- type: MorphoVaultType.MorphoVaultGauntletUSDACore,
75
- name: 'Gauntlet USDA Core',
76
- address: '0x125D41A6e5dbf455cD9Df8F80BCC6fd172D52Cc6',
77
- asset: 'USDA',
78
- };
79
-
80
- export const MORPHO_VAULT_GAUNTLET_USDT_PRIME: MorphoVault = {
81
- type: MorphoVaultType.MorphoVaultGauntletUSDTPrime,
82
- name: 'Gauntlet USDT Prime',
83
- address: '0x8CB3649114051cA5119141a34C200D65dc0Faa73',
84
- asset: 'USDT',
85
- };
86
-
87
- export const MORPHO_VAULT_GAUNTLET_RESOLV_USDC: MorphoVault = {
88
- type: MorphoVaultType.MorphoVaultGauntletResolvUSDC,
89
- name: 'Gauntlet Resolv USDC',
90
- address: '0x132E6C9C33A62D7727cd359b1f51e5B566E485Eb',
91
- asset: 'USDC',
92
- };
93
-
94
- export const MORPHO_VAULTS: Record<MorphoVaultType, MorphoVault> = {
95
- [MorphoVaultType.MorphoVaultFlagshipEth]: MORPHO_VAULT_FLAGSHIP_ETH,
96
- [MorphoVaultType.MorphoVaultGauntletUSDCCore]: MORPHO_VAULT_GAUNTLET_USDC_CORE,
97
- [MorphoVaultType.MorphoVaultGauntletUSDCPrime]: MORPHO_VAULT_GAUNTLET_USDC_PRIME,
98
- [MorphoVaultType.MorphoVaultRe7Weth]: MORPHO_VAULT_RE7_WETH,
99
- [MorphoVaultType.MorphoVaultGauntletWETHCore]: MORPHO_VAULT_GAUNTLET_WETH_CORE,
100
- [MorphoVaultType.MorphoVaultGauntletWETHPrime]: MORPHO_VAULT_GAUNTLET_WETH_PRIME,
101
- [MorphoVaultType.MorphoVaultBoostedUSDC]: MORPHO_VAULT_BOOSTED_USDC,
102
- [MorphoVaultType.MorphoVaultSteakhousePYUSD]: MORPHO_VAULT_STEAKHOUSE_PYUSD,
103
- [MorphoVaultType.MorphoVaultFlagshipUSDT]: MORPHO_VAULT_FLAGSHIP_USDT,
104
- [MorphoVaultType.MorphoVaultSteakhouseUSDT]: MORPHO_VAULT_STEAKHOUSE_USDT,
105
- [MorphoVaultType.MorphoVaultGauntletUSDACore]: MORPHO_VAULT_GAUNTLET_USDA_CORE,
106
- [MorphoVaultType.MorphoVaultGauntletUSDTPrime]: MORPHO_VAULT_GAUNTLET_USDT_PRIME,
107
- [MorphoVaultType.MorphoVaultGauntletResolvUSDC]: MORPHO_VAULT_GAUNTLET_RESOLV_USDC,
108
- };
109
-
110
- export const getMorphoVault = (type: MorphoVaultType): MorphoVault => MORPHO_VAULTS[type];
@@ -1,58 +0,0 @@
1
- import Dec from 'decimal.js';
2
- import { Client } from 'viem';
3
- import { assetAmountInEth } from '@defisaver/tokens';
4
- import { getViemProvider } from '../../services/viem';
5
- import { SavingsVaultData, YearnVault } from '../../types';
6
- import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
7
- import * as yearnVaultsOptions from './options';
8
- import { getYearnVaultContractViem, YearnViewContractViem } from '../../contracts';
9
-
10
- export {
11
- yearnVaultsOptions,
12
- };
13
-
14
- export const _getYearnVaultData = async (provider: Client, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]): Promise<SavingsVaultData> => {
15
- const yearnVaultContract = getYearnVaultContractViem(provider, yearnVault.address);
16
- const viewContract = YearnViewContractViem(provider, network);
17
-
18
- const yvAmountsWei: Record<EthAddress, bigint> = {};
19
-
20
- const [tokenSupply, underlyingSupply, poolLiquidity] = await Promise.all([
21
- yearnVaultContract.read.totalSupply(),
22
- yearnVaultContract.read.totalAssets(),
23
- viewContract.read.getPoolLiquidity([yearnVault.address]),
24
- ...accounts.map(async (account) => {
25
- const yvAmount = await yearnVaultContract.read.balanceOf([account]);
26
- yvAmountsWei[account] = yvAmount;
27
- }),
28
- ]);
29
-
30
- const exchangeRate = new Dec(underlyingSupply).div(tokenSupply).toString();
31
- const poolSize = assetAmountInEth(underlyingSupply.toString(), yearnVault.asset);
32
- const liquidity = assetAmountInEth(poolLiquidity.toString(), yearnVault.asset);
33
-
34
- const supplied: Record<EthAddress, string> = {};
35
- accounts.forEach((account) => {
36
- const yvAmountWei = yvAmountsWei[account] || BigInt(0);
37
- const underlyingAmountWei = new Dec(yvAmountWei).mul(exchangeRate).toString();
38
- supplied[account.toLowerCase() as EthAddress] = assetAmountInEth(underlyingAmountWei, yearnVault.asset);
39
- });
40
-
41
- return {
42
- poolSize,
43
- liquidity,
44
- supplied,
45
- asset: yearnVault.asset,
46
- optionType: yearnVault.type,
47
- };
48
- };
49
-
50
- export async function getYearnVaultData(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]): Promise<SavingsVaultData> {
51
- return _getYearnVaultData(getViemProvider(provider, network, {
52
- batch: {
53
- multicall: {
54
- batchSize: 2500000,
55
- },
56
- },
57
- }), network, yearnVault, accounts);
58
- }
@@ -1,27 +0,0 @@
1
- import { YearnVault, YearnVaultType } from '../../types/savings/yearnVaults';
2
-
3
- export const YEARN_VAULT_DAI: YearnVault = {
4
- type: YearnVaultType.YearnVaultDAI,
5
- address: '0xdA816459F1AB5631232FE5e97a05BBBb94970c95',
6
- asset: 'DAI',
7
- };
8
-
9
- export const YEARN_VAULT_USDC: YearnVault = {
10
- type: YearnVaultType.YearnVaultUSDC,
11
- address: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE',
12
- asset: 'USDC',
13
- };
14
-
15
- export const YEARN_VAULT_USDT: YearnVault = {
16
- type: YearnVaultType.YearnVaultUSDT,
17
- address: '0x3B27F92C0e212C671EA351827EDF93DB27cc0c65',
18
- asset: 'USDT',
19
- };
20
-
21
- export const YEARN_VAULTS: Record<YearnVaultType, YearnVault> = {
22
- [YearnVaultType.YearnVaultDAI]: YEARN_VAULT_DAI,
23
- [YearnVaultType.YearnVaultUSDC]: YEARN_VAULT_USDC,
24
- [YearnVaultType.YearnVaultUSDT]: YEARN_VAULT_USDT,
25
- };
26
-
27
- export const getYearnVault = (type: YearnVaultType): YearnVault => YEARN_VAULTS[type];
@@ -1,16 +0,0 @@
1
- import { EthAddress } from '../common';
2
- import { MorphoVaultType } from './morphoVaults';
3
- import { YearnVaultType } from './yearnVaults';
4
-
5
- export * from './morphoVaults';
6
- export * from './yearnVaults';
7
-
8
- export interface SavingsVaultData {
9
- poolSize: string,
10
- liquidity: string,
11
- supplied: Record<EthAddress, string>,
12
- asset: string,
13
- optionType: string,
14
- }
15
-
16
- export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType, SavingsVaultData>>;
@@ -1,24 +0,0 @@
1
- import { EthAddress } from '../common';
2
-
3
- export enum MorphoVaultType {
4
- MorphoVaultFlagshipEth = 'morpho_vault_flagship_eth',
5
- MorphoVaultGauntletUSDCCore = 'morpho_vault_gauntlet_usdc_core',
6
- MorphoVaultGauntletUSDCPrime = 'morpho_vault_gauntlet_usdc_prime',
7
- MorphoVaultRe7Weth = 'morpho_vault_re7_weth',
8
- MorphoVaultGauntletWETHCore = 'morpho_vault_gauntlet_weth_core',
9
- MorphoVaultGauntletWETHPrime = 'morpho_vault_gauntlet_weth_prime',
10
- MorphoVaultBoostedUSDC = 'morpho_vault_usual_boosted_usdc',
11
- MorphoVaultSteakhousePYUSD = 'morpho_vault_steakhouse_pyusd',
12
- MorphoVaultFlagshipUSDT = 'morpho_vault_flagship_usdt',
13
- MorphoVaultSteakhouseUSDT = 'morpho_vault_steakhouse_usdt',
14
- MorphoVaultGauntletUSDACore = 'morpho_vault_gauntlet_usda_core',
15
- MorphoVaultGauntletUSDTPrime = 'morpho_vault_gauntlet_usdt_prime',
16
- MorphoVaultGauntletResolvUSDC = 'morpho_vault_gauntlet_resolv_usdc',
17
- }
18
-
19
- export interface MorphoVault {
20
- type: MorphoVaultType;
21
- name: string;
22
- address: EthAddress;
23
- asset: string;
24
- }
@@ -1,13 +0,0 @@
1
- import { EthAddress } from '../common';
2
-
3
- export enum YearnVaultType {
4
- YearnVaultDAI = 'yearn_vault_dai',
5
- YearnVaultUSDC = 'yearn_vault_usdc',
6
- YearnVaultUSDT = 'yearn_vault_usdt',
7
- }
8
-
9
- export interface YearnVault {
10
- type: YearnVaultType;
11
- address: EthAddress;
12
- asset: string;
13
- }