@defisaver/positions-sdk 2.1.23 → 2.1.24-dev-savings-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/config/contracts.d.ts +173 -0
- package/cjs/config/contracts.js +23 -1
- package/cjs/contracts.d.ts +1650 -0
- package/cjs/contracts.js +22 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/savings/index.d.ts +7 -0
- package/cjs/savings/index.js +75 -0
- package/cjs/savings/makerDSR/index.d.ts +7 -0
- package/cjs/savings/makerDSR/index.js +94 -0
- package/cjs/savings/makerDSR/options.d.ts +2 -0
- package/cjs/savings/makerDSR/options.js +11 -0
- package/cjs/savings/morphoVaults/index.d.ts +7 -0
- package/cjs/savings/morphoVaults/index.js +118 -0
- package/cjs/savings/morphoVaults/options.d.ts +16 -0
- package/cjs/savings/morphoVaults/options.js +112 -0
- package/cjs/savings/yearnVaults/index.d.ts +9 -0
- package/cjs/savings/yearnVaults/index.js +113 -0
- package/cjs/savings/yearnVaults/options.d.ts +6 -0
- package/cjs/savings/yearnVaults/options.js +29 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/savings/index.d.ts +15 -0
- package/cjs/types/savings/index.js +19 -0
- package/cjs/types/savings/makerDsr.d.ts +11 -0
- package/cjs/types/savings/makerDsr.js +7 -0
- package/cjs/types/savings/morphoVaults.d.ts +23 -0
- package/cjs/types/savings/morphoVaults.js +19 -0
- package/cjs/types/savings/yearnVaults.d.ts +12 -0
- package/cjs/types/savings/yearnVaults.js +9 -0
- package/esm/config/contracts.d.ts +173 -0
- package/esm/config/contracts.js +22 -0
- package/esm/contracts.d.ts +1650 -0
- package/esm/contracts.js +18 -0
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/savings/index.d.ts +7 -0
- package/esm/savings/index.js +36 -0
- package/esm/savings/makerDSR/index.d.ts +7 -0
- package/esm/savings/makerDSR/index.js +53 -0
- package/esm/savings/makerDSR/options.d.ts +2 -0
- package/esm/savings/makerDSR/options.js +8 -0
- package/esm/savings/morphoVaults/index.d.ts +7 -0
- package/esm/savings/morphoVaults/index.js +77 -0
- package/esm/savings/morphoVaults/options.d.ts +16 -0
- package/esm/savings/morphoVaults/options.js +108 -0
- package/esm/savings/yearnVaults/index.d.ts +9 -0
- package/esm/savings/yearnVaults/index.js +70 -0
- package/esm/savings/yearnVaults/options.d.ts +6 -0
- package/esm/savings/yearnVaults/options.js +25 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/savings/index.d.ts +15 -0
- package/esm/types/savings/index.js +3 -0
- package/esm/types/savings/makerDsr.d.ts +11 -0
- package/esm/types/savings/makerDsr.js +4 -0
- package/esm/types/savings/morphoVaults.d.ts +23 -0
- package/esm/types/savings/morphoVaults.js +16 -0
- package/esm/types/savings/yearnVaults.d.ts +12 -0
- package/esm/types/savings/yearnVaults.js +6 -0
- package/package.json +48 -47
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +614 -614
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1282 -1260
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +143 -121
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1774 -1774
- package/src/helpers/aaveHelpers/index.ts +187 -187
- package/src/helpers/compoundHelpers/index.ts +283 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -222
- package/src/helpers/fluidHelpers/index.ts +326 -326
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +396 -396
- package/src/helpers/sparkHelpers/index.ts +158 -158
- package/src/index.ts +49 -47
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +238 -238
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +971 -971
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +84 -84
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +598 -598
- package/src/savings/index.ts +43 -0
- package/src/savings/makerDsr/index.ts +54 -0
- package/src/savings/makerDsr/options.ts +9 -0
- package/src/savings/morphoVaults/index.ts +81 -0
- package/src/savings/morphoVaults/options.ts +123 -0
- package/src/savings/yearnVaults/index.ts +74 -0
- package/src/savings/yearnVaults/options.ts +30 -0
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +34 -34
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +456 -456
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +183 -183
- package/src/types/aave.ts +189 -189
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +107 -107
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +175 -175
- package/src/types/fluid.ts +483 -483
- package/src/types/index.ts +15 -14
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +200 -200
- package/src/types/portfolio.ts +60 -60
- package/src/types/savings/index.ts +18 -0
- package/src/types/savings/makerDsr.ts +13 -0
- package/src/types/savings/morphoVaults.ts +25 -0
- package/src/types/savings/yearnVaults.ts +14 -0
- package/src/types/spark.ts +133 -133
- package/src/umbrella/index.ts +69 -69
- 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,5 @@ 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');
|
|
109
|
+
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
@@ -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'];
|
|
18
|
+
export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL'];
|
|
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,7 @@
|
|
|
1
|
+
import { MakerDsrType, 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
|
+
import * as makerDsr from './makerDSR';
|
|
6
|
+
export { morphoVaults, yearnVaults, makerDsr, };
|
|
7
|
+
export declare const getSavingsData: (provider: EthereumProvider, network: NetworkNumber, accounts: EthAddress[]) => Promise<Partial<Record<MakerDsrType | MorphoVaultType | YearnVaultType, import("../types").SavingsVaultData>>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { MakerDsrType, } from '../types';
|
|
11
|
+
import * as morphoVaults from './morphoVaults';
|
|
12
|
+
import * as yearnVaults from './yearnVaults';
|
|
13
|
+
import * as makerDsr from './makerDSR';
|
|
14
|
+
export { morphoVaults, yearnVaults, makerDsr, };
|
|
15
|
+
export const getSavingsData = (provider, network, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const morphoVaultsList = Object.keys(morphoVaults.morphoVaultsOptions.MORPHO_VAULTS);
|
|
17
|
+
const yearnVaultsList = Object.keys(yearnVaults.yearnVaultsOptions.YEARN_VAULTS);
|
|
18
|
+
const savingsData = {};
|
|
19
|
+
yield Promise.all([
|
|
20
|
+
...morphoVaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const vault = morphoVaults.morphoVaultsOptions.getMorphoVault(vaultKey);
|
|
22
|
+
const data = yield morphoVaults.getMorphoVaultData(provider, network, vault, accounts);
|
|
23
|
+
savingsData[vaultKey] = data;
|
|
24
|
+
})),
|
|
25
|
+
...yearnVaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const vault = yearnVaults.yearnVaultsOptions.getYearnVault(vaultKey);
|
|
27
|
+
const data = yield yearnVaults.getYearnVaultData(provider, network, vault, accounts);
|
|
28
|
+
savingsData[vaultKey] = data;
|
|
29
|
+
})),
|
|
30
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const data = yield makerDsr.getMakerDsrData(provider, network, accounts);
|
|
32
|
+
savingsData[MakerDsrType.MakerDsrVault] = data;
|
|
33
|
+
}))(),
|
|
34
|
+
]);
|
|
35
|
+
return savingsData;
|
|
36
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import { SavingsVaultData } from '../../types';
|
|
3
|
+
import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
|
|
4
|
+
import * as makerDsrOptions from './options';
|
|
5
|
+
export { makerDsrOptions, };
|
|
6
|
+
export declare const _getMakerDsrData: (provider: Client, network: NetworkNumber, accounts: EthAddress[]) => Promise<SavingsVaultData>;
|
|
7
|
+
export declare function getMakerDsrData(provider: EthereumProvider, network: NetworkNumber, accounts: EthAddress[]): Promise<SavingsVaultData>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { getViemProvider } from '../../services/viem';
|
|
12
|
+
import { MakerDsrType } from '../../types';
|
|
13
|
+
import * as makerDsrOptions from './options';
|
|
14
|
+
import { MakerDsrContractViem } from '../../contracts';
|
|
15
|
+
export { makerDsrOptions, };
|
|
16
|
+
export const _getMakerDsrData = (provider, network, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const contract = MakerDsrContractViem(provider, network);
|
|
18
|
+
const pieAmounts = {};
|
|
19
|
+
const [Pie, chi] = yield Promise.all([
|
|
20
|
+
contract.read.Pie(),
|
|
21
|
+
contract.read.chi(),
|
|
22
|
+
...accounts.map((account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const pieAmount = yield contract.read.pie([account]);
|
|
24
|
+
pieAmounts[account] = pieAmount;
|
|
25
|
+
})),
|
|
26
|
+
]);
|
|
27
|
+
const totalSupplyRad = new Dec(Pie).mul(chi).toString();
|
|
28
|
+
const poolSize = new Dec(totalSupplyRad).div(1e45).toString();
|
|
29
|
+
const supplied = {};
|
|
30
|
+
accounts.forEach((account) => {
|
|
31
|
+
const pie = pieAmounts[account] || BigInt(0);
|
|
32
|
+
const radAmount = new Dec(pie).mul(chi).toString();
|
|
33
|
+
supplied[account.toLowerCase()] = new Dec(radAmount).div(1e45).toString();
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
poolSize,
|
|
37
|
+
liquidity: poolSize,
|
|
38
|
+
supplied,
|
|
39
|
+
asset: 'DAI',
|
|
40
|
+
optionType: MakerDsrType.MakerDsrVault,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
export function getMakerDsrData(provider, network, accounts) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return _getMakerDsrData(getViemProvider(provider, network, {
|
|
46
|
+
batch: {
|
|
47
|
+
multicall: {
|
|
48
|
+
batchSize: 2500000,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}), network, accounts);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -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,108 @@
|
|
|
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
|
+
deploymentBlock: 18927491,
|
|
8
|
+
};
|
|
9
|
+
export const MORPHO_VAULT_GAUNTLET_USDC_CORE = {
|
|
10
|
+
type: MorphoVaultType.MorphoVaultGauntletUSDCCore,
|
|
11
|
+
name: 'Gauntlet USDC Core',
|
|
12
|
+
address: '0x8eB67A509616cd6A7c1B3c8C21D48FF57df3d458',
|
|
13
|
+
asset: 'USDC',
|
|
14
|
+
deploymentBlock: 19777569,
|
|
15
|
+
};
|
|
16
|
+
export const MORPHO_VAULT_GAUNTLET_USDC_PRIME = {
|
|
17
|
+
type: MorphoVaultType.MorphoVaultGauntletUSDCPrime,
|
|
18
|
+
name: 'Gauntlet USDC Prime',
|
|
19
|
+
address: '0xdd0f28e19C1780eb6396170735D45153D261490d',
|
|
20
|
+
asset: 'USDC',
|
|
21
|
+
deploymentBlock: 19777569,
|
|
22
|
+
};
|
|
23
|
+
export const MORPHO_VAULT_RE7_WETH = {
|
|
24
|
+
type: MorphoVaultType.MorphoVaultRe7Weth,
|
|
25
|
+
name: 'RE7 WETH',
|
|
26
|
+
address: '0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0',
|
|
27
|
+
asset: 'ETH',
|
|
28
|
+
deploymentBlock: 19121118,
|
|
29
|
+
};
|
|
30
|
+
export const MORPHO_VAULT_GAUNTLET_WETH_CORE = {
|
|
31
|
+
type: MorphoVaultType.MorphoVaultGauntletWETHCore,
|
|
32
|
+
name: 'Gauntlet WETH Core',
|
|
33
|
+
address: '0x4881Ef0BF6d2365D3dd6499ccd7532bcdBCE0658',
|
|
34
|
+
asset: 'ETH',
|
|
35
|
+
deploymentBlock: 19541126,
|
|
36
|
+
};
|
|
37
|
+
export const MORPHO_VAULT_GAUNTLET_WETH_PRIME = {
|
|
38
|
+
type: MorphoVaultType.MorphoVaultGauntletWETHPrime,
|
|
39
|
+
name: 'Gauntlet WETH Prime',
|
|
40
|
+
address: '0x2371e134e3455e0593363cBF89d3b6cf53740618',
|
|
41
|
+
asset: 'ETH',
|
|
42
|
+
deploymentBlock: 19372149,
|
|
43
|
+
};
|
|
44
|
+
export const MORPHO_VAULT_BOOSTED_USDC = {
|
|
45
|
+
type: MorphoVaultType.MorphoVaultBoostedUSDC,
|
|
46
|
+
name: 'Boosted USDC',
|
|
47
|
+
address: '0xd63070114470f685b75B74D60EEc7c1113d33a3D',
|
|
48
|
+
asset: 'USDC',
|
|
49
|
+
deploymentBlock: 20377233,
|
|
50
|
+
};
|
|
51
|
+
export const MORPHO_VAULT_STEAKHOUSE_PYUSD = {
|
|
52
|
+
type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
53
|
+
name: 'Steakhouse PYUSD',
|
|
54
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
55
|
+
asset: 'PYUSD',
|
|
56
|
+
deploymentBlock: 19043398,
|
|
57
|
+
};
|
|
58
|
+
export const MORPHO_VAULT_FLAGSHIP_USDT = {
|
|
59
|
+
type: MorphoVaultType.MorphoVaultFlagshipUSDT,
|
|
60
|
+
name: 'Flagship USDT',
|
|
61
|
+
address: '0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1',
|
|
62
|
+
asset: 'USDT',
|
|
63
|
+
deploymentBlock: 19127039,
|
|
64
|
+
};
|
|
65
|
+
export const MORPHO_VAULT_STEAKHOUSE_USDT = {
|
|
66
|
+
type: MorphoVaultType.MorphoVaultSteakhouseUSDT,
|
|
67
|
+
name: 'Steakhouse USDT',
|
|
68
|
+
address: '0xbEef047a543E45807105E51A8BBEFCc5950fcfBa',
|
|
69
|
+
asset: 'USDT',
|
|
70
|
+
deploymentBlock: 19043398,
|
|
71
|
+
};
|
|
72
|
+
export const MORPHO_VAULT_GAUNTLET_USDA_CORE = {
|
|
73
|
+
type: MorphoVaultType.MorphoVaultGauntletUSDACore,
|
|
74
|
+
name: 'Gauntlet USDA Core',
|
|
75
|
+
address: '0x125D41A6e5dbf455cD9Df8F80BCC6fd172D52Cc6',
|
|
76
|
+
asset: 'USDA',
|
|
77
|
+
deploymentBlock: 19633608,
|
|
78
|
+
};
|
|
79
|
+
export const MORPHO_VAULT_GAUNTLET_USDT_PRIME = {
|
|
80
|
+
type: MorphoVaultType.MorphoVaultGauntletUSDTPrime,
|
|
81
|
+
name: 'Gauntlet USDT Prime',
|
|
82
|
+
address: '0x8CB3649114051cA5119141a34C200D65dc0Faa73',
|
|
83
|
+
asset: 'USDT',
|
|
84
|
+
deploymentBlock: 19486541,
|
|
85
|
+
};
|
|
86
|
+
export const MORPHO_VAULT_GAUNTLET_RESOLV_USDC = {
|
|
87
|
+
type: MorphoVaultType.MorphoVaultGauntletResolvUSDC,
|
|
88
|
+
name: 'Gauntlet Resolv USDC',
|
|
89
|
+
address: '0x132E6C9C33A62D7727cd359b1f51e5B566E485Eb',
|
|
90
|
+
asset: 'USDC',
|
|
91
|
+
deploymentBlock: 21487882,
|
|
92
|
+
};
|
|
93
|
+
export const MORPHO_VAULTS = {
|
|
94
|
+
[MorphoVaultType.MorphoVaultFlagshipEth]: MORPHO_VAULT_FLAGSHIP_ETH,
|
|
95
|
+
[MorphoVaultType.MorphoVaultGauntletUSDCCore]: MORPHO_VAULT_GAUNTLET_USDC_CORE,
|
|
96
|
+
[MorphoVaultType.MorphoVaultGauntletUSDCPrime]: MORPHO_VAULT_GAUNTLET_USDC_PRIME,
|
|
97
|
+
[MorphoVaultType.MorphoVaultRe7Weth]: MORPHO_VAULT_RE7_WETH,
|
|
98
|
+
[MorphoVaultType.MorphoVaultGauntletWETHCore]: MORPHO_VAULT_GAUNTLET_WETH_CORE,
|
|
99
|
+
[MorphoVaultType.MorphoVaultGauntletWETHPrime]: MORPHO_VAULT_GAUNTLET_WETH_PRIME,
|
|
100
|
+
[MorphoVaultType.MorphoVaultBoostedUSDC]: MORPHO_VAULT_BOOSTED_USDC,
|
|
101
|
+
[MorphoVaultType.MorphoVaultSteakhousePYUSD]: MORPHO_VAULT_STEAKHOUSE_PYUSD,
|
|
102
|
+
[MorphoVaultType.MorphoVaultFlagshipUSDT]: MORPHO_VAULT_FLAGSHIP_USDT,
|
|
103
|
+
[MorphoVaultType.MorphoVaultSteakhouseUSDT]: MORPHO_VAULT_STEAKHOUSE_USDT,
|
|
104
|
+
[MorphoVaultType.MorphoVaultGauntletUSDACore]: MORPHO_VAULT_GAUNTLET_USDA_CORE,
|
|
105
|
+
[MorphoVaultType.MorphoVaultGauntletUSDTPrime]: MORPHO_VAULT_GAUNTLET_USDT_PRIME,
|
|
106
|
+
[MorphoVaultType.MorphoVaultGauntletResolvUSDC]: MORPHO_VAULT_GAUNTLET_RESOLV_USDC,
|
|
107
|
+
};
|
|
108
|
+
export const getMorphoVault = (type) => MORPHO_VAULTS[type];
|
|
@@ -0,0 +1,9 @@
|
|
|
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>;
|
|
8
|
+
export declare const _getYearnVaultExchangeRate: (provider: Client, yearnVault: YearnVault) => Promise<string>;
|
|
9
|
+
export declare function getYearnVaultExchangeRate(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault): Promise<string>;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
}
|
|
57
|
+
export const _getYearnVaultExchangeRate = (provider, yearnVault) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const yearnVaultContract = getYearnVaultContractViem(provider, yearnVault.address);
|
|
59
|
+
const [tokenSupply, underlyingSupply] = yield Promise.all([
|
|
60
|
+
yearnVaultContract.read.totalSupply(),
|
|
61
|
+
yearnVaultContract.read.totalAssets(),
|
|
62
|
+
]);
|
|
63
|
+
const exchangeRate = new Dec(underlyingSupply).div(tokenSupply).toString();
|
|
64
|
+
return exchangeRate;
|
|
65
|
+
});
|
|
66
|
+
export function getYearnVaultExchangeRate(provider, network, yearnVault) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return _getYearnVaultExchangeRate(getViemProvider(provider, network), yearnVault);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -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,25 @@
|
|
|
1
|
+
import { YearnVaultType } from '../../types/savings/yearnVaults';
|
|
2
|
+
export const YEARN_VAULT_DAI = {
|
|
3
|
+
type: YearnVaultType.YearnVaultDAI,
|
|
4
|
+
address: '0xdA816459F1AB5631232FE5e97a05BBBb94970c95',
|
|
5
|
+
asset: 'DAI',
|
|
6
|
+
deploymentBlock: 12796965,
|
|
7
|
+
};
|
|
8
|
+
export const YEARN_VAULT_USDC = {
|
|
9
|
+
type: YearnVaultType.YearnVaultUSDC,
|
|
10
|
+
address: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE',
|
|
11
|
+
asset: 'USDC',
|
|
12
|
+
deploymentBlock: 13513457,
|
|
13
|
+
};
|
|
14
|
+
export const YEARN_VAULT_USDT = {
|
|
15
|
+
type: YearnVaultType.YearnVaultUSDT,
|
|
16
|
+
address: '0x3B27F92C0e212C671EA351827EDF93DB27cc0c65',
|
|
17
|
+
asset: 'USDT',
|
|
18
|
+
deploymentBlock: 14980240,
|
|
19
|
+
};
|
|
20
|
+
export const YEARN_VAULTS = {
|
|
21
|
+
[YearnVaultType.YearnVaultDAI]: YEARN_VAULT_DAI,
|
|
22
|
+
[YearnVaultType.YearnVaultUSDC]: YEARN_VAULT_USDC,
|
|
23
|
+
[YearnVaultType.YearnVaultUSDT]: YEARN_VAULT_USDT,
|
|
24
|
+
};
|
|
25
|
+
export const getYearnVault = (type) => YEARN_VAULTS[type];
|
package/esm/types/index.d.ts
CHANGED