@defisaver/positions-sdk 2.1.174 → 2.1.175-looping-2-dev-dev
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/cjs/aaveV2/index.d.ts +4 -4
- package/cjs/aaveV2/index.js +7 -7
- package/cjs/aaveV3/index.d.ts +5 -14
- package/cjs/aaveV3/index.js +14 -10
- package/cjs/aaveV3/merkl.d.ts +5 -1
- package/cjs/aaveV3/merkl.js +8 -3
- package/cjs/aaveV3/sgho.d.ts +2 -16
- package/cjs/aaveV4/index.d.ts +4 -3
- package/cjs/aaveV4/index.js +19 -16
- package/cjs/aaveV4/lend.d.ts +2 -43
- package/cjs/aaveV4/merkl.d.ts +10 -2
- package/cjs/aaveV4/merkl.js +15 -6
- package/cjs/claiming/aaveV3.d.ts +3 -3
- package/cjs/claiming/aaveV3.js +5 -4
- package/cjs/claiming/ethena.d.ts +2 -1
- package/cjs/claiming/king.d.ts +3 -2
- package/cjs/claiming/king.js +3 -2
- package/cjs/claiming/spark.d.ts +4 -4
- package/cjs/claiming/spark.js +8 -7
- package/cjs/claiming/uniswap.d.ts +2 -2
- package/cjs/claiming/uniswap.js +3 -2
- package/cjs/compoundV2/index.d.ts +4 -4
- package/cjs/compoundV2/index.js +9 -9
- package/cjs/compoundV3/index.d.ts +5 -4
- package/cjs/compoundV3/index.js +17 -13
- package/cjs/compoundV3/merkl.d.ts +1 -1
- package/cjs/compoundV3/merkl.js +2 -5
- package/cjs/curveUsd/index.d.ts +5 -5
- package/cjs/curveUsd/index.js +17 -17
- package/cjs/fluid/index.d.ts +23 -66
- package/cjs/fluid/index.js +75 -72
- package/cjs/fluid/merkl.d.ts +5 -3
- package/cjs/fluid/merkl.js +11 -6
- package/cjs/helpers/aaveHelpers/index.js +1 -1
- package/cjs/helpers/aaveV4Helpers/index.js +14 -2
- package/cjs/helpers/compoundHelpers/index.js +2 -2
- package/cjs/helpers/curveUsdHelpers/index.js +1 -1
- package/cjs/helpers/fluidHelpers/index.js +1 -1
- package/cjs/helpers/liquityV2Helpers/index.js +1 -1
- package/cjs/helpers/llamaLendHelpers/index.js +1 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +1 -1
- package/cjs/helpers/morphoMidnightHelpers/index.js +1 -1
- package/cjs/helpers/sparkHelpers/index.js +1 -1
- package/cjs/liquity/index.d.ts +5 -15
- package/cjs/liquity/index.js +23 -23
- package/cjs/liquityV2/index.d.ts +16 -31
- package/cjs/liquityV2/index.js +96 -78
- package/cjs/llamaLend/index.d.ts +5 -5
- package/cjs/llamaLend/index.js +13 -13
- package/cjs/maker/index.d.ts +6 -6
- package/cjs/maker/index.js +16 -16
- package/cjs/moneymarket/moneymarketCommonService.js +13 -2
- package/cjs/morphoBlue/index.d.ts +7 -7
- package/cjs/morphoBlue/index.js +28 -26
- package/cjs/morphoBlue/merkl.d.ts +5 -3
- package/cjs/morphoBlue/merkl.js +6 -8
- package/cjs/morphoMidnight/index.d.ts +5 -5
- package/cjs/morphoMidnight/index.js +18 -18
- package/cjs/portfolio/customDeFiData.d.ts +3 -0
- package/cjs/portfolio/customDeFiData.js +267 -0
- package/cjs/portfolio/index.d.ts +17 -8
- package/cjs/portfolio/index.js +459 -520
- package/cjs/portfolio/lendingProtocols.d.ts +184 -0
- package/cjs/portfolio/lendingProtocols.js +196 -0
- package/cjs/savings/index.d.ts +8 -2
- package/cjs/savings/index.js +33 -4
- package/cjs/services/merkl.d.ts +46 -2
- package/cjs/services/merkl.js +190 -19
- package/cjs/services/priceService.d.ts +12 -12
- package/cjs/services/priceService.js +30 -29
- package/cjs/services/viem.d.ts +10 -2
- package/cjs/services/viem.js +27 -1
- package/cjs/spark/index.d.ts +4 -4
- package/cjs/spark/index.js +9 -9
- package/cjs/types/aave.d.ts +98 -2
- package/cjs/types/aaveV4.d.ts +45 -0
- package/cjs/types/common.d.ts +1 -0
- package/cjs/types/common.js +1 -0
- package/cjs/types/compound.d.ts +26 -2
- package/cjs/types/curveUsd.d.ts +9 -1
- package/cjs/types/fluid.d.ts +13 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquity.d.ts +12 -0
- package/cjs/types/liquityV2.d.ts +24 -0
- package/cjs/types/llamaLend.d.ts +12 -1
- package/cjs/types/merkl.d.ts +18 -0
- package/cjs/types/morphoBlue.d.ts +2 -0
- package/cjs/types/portfolio.d.ts +162 -5
- package/cjs/types/portfolio.js +18 -0
- package/cjs/types/savings/index.d.ts +9 -1
- package/cjs/types/spark.d.ts +21 -1
- package/cjs/umbrella/index.d.ts +3 -4
- package/cjs/umbrella/index.js +5 -4
- package/esm/aaveV2/index.d.ts +4 -4
- package/esm/aaveV2/index.js +8 -8
- package/esm/aaveV3/index.d.ts +5 -14
- package/esm/aaveV3/index.js +15 -11
- package/esm/aaveV3/merkl.d.ts +5 -1
- package/esm/aaveV3/merkl.js +9 -4
- package/esm/aaveV3/sgho.d.ts +2 -16
- package/esm/aaveV4/index.d.ts +4 -3
- package/esm/aaveV4/index.js +20 -17
- package/esm/aaveV4/lend.d.ts +2 -43
- package/esm/aaveV4/merkl.d.ts +10 -2
- package/esm/aaveV4/merkl.js +16 -7
- package/esm/claiming/aaveV3.d.ts +3 -3
- package/esm/claiming/aaveV3.js +6 -5
- package/esm/claiming/ethena.d.ts +2 -1
- package/esm/claiming/king.d.ts +3 -2
- package/esm/claiming/king.js +3 -2
- package/esm/claiming/spark.d.ts +4 -4
- package/esm/claiming/spark.js +9 -8
- package/esm/claiming/uniswap.d.ts +2 -2
- package/esm/claiming/uniswap.js +3 -2
- package/esm/compoundV2/index.d.ts +4 -4
- package/esm/compoundV2/index.js +9 -9
- package/esm/compoundV3/index.d.ts +5 -4
- package/esm/compoundV3/index.js +19 -15
- package/esm/compoundV3/merkl.d.ts +1 -1
- package/esm/compoundV3/merkl.js +3 -6
- package/esm/curveUsd/index.d.ts +5 -5
- package/esm/curveUsd/index.js +17 -17
- package/esm/fluid/index.d.ts +23 -66
- package/esm/fluid/index.js +76 -73
- package/esm/fluid/merkl.d.ts +5 -3
- package/esm/fluid/merkl.js +12 -7
- package/esm/helpers/aaveHelpers/index.js +1 -1
- package/esm/helpers/aaveV4Helpers/index.js +15 -3
- package/esm/helpers/compoundHelpers/index.js +2 -2
- package/esm/helpers/curveUsdHelpers/index.js +1 -1
- package/esm/helpers/fluidHelpers/index.js +1 -1
- package/esm/helpers/liquityV2Helpers/index.js +1 -1
- package/esm/helpers/llamaLendHelpers/index.js +1 -1
- package/esm/helpers/morphoBlueHelpers/index.js +1 -1
- package/esm/helpers/morphoMidnightHelpers/index.js +1 -1
- package/esm/helpers/sparkHelpers/index.js +1 -1
- package/esm/liquity/index.d.ts +5 -15
- package/esm/liquity/index.js +23 -23
- package/esm/liquityV2/index.d.ts +16 -31
- package/esm/liquityV2/index.js +95 -78
- package/esm/llamaLend/index.d.ts +5 -5
- package/esm/llamaLend/index.js +13 -13
- package/esm/maker/index.d.ts +6 -6
- package/esm/maker/index.js +16 -16
- package/esm/moneymarket/moneymarketCommonService.js +13 -2
- package/esm/morphoBlue/index.d.ts +7 -7
- package/esm/morphoBlue/index.js +29 -27
- package/esm/morphoBlue/merkl.d.ts +5 -3
- package/esm/morphoBlue/merkl.js +7 -9
- package/esm/morphoMidnight/index.d.ts +5 -5
- package/esm/morphoMidnight/index.js +18 -18
- package/esm/portfolio/customDeFiData.d.ts +3 -0
- package/esm/portfolio/customDeFiData.js +261 -0
- package/esm/portfolio/index.d.ts +17 -8
- package/esm/portfolio/index.js +459 -522
- package/esm/portfolio/lendingProtocols.d.ts +184 -0
- package/esm/portfolio/lendingProtocols.js +189 -0
- package/esm/savings/index.d.ts +8 -2
- package/esm/savings/index.js +31 -3
- package/esm/services/merkl.d.ts +46 -2
- package/esm/services/merkl.js +180 -18
- package/esm/services/priceService.d.ts +12 -12
- package/esm/services/priceService.js +31 -30
- package/esm/services/viem.d.ts +10 -2
- package/esm/services/viem.js +25 -0
- package/esm/spark/index.d.ts +4 -4
- package/esm/spark/index.js +10 -10
- package/esm/types/aave.d.ts +98 -2
- package/esm/types/aaveV4.d.ts +45 -0
- package/esm/types/common.d.ts +1 -0
- package/esm/types/common.js +1 -0
- package/esm/types/compound.d.ts +26 -2
- package/esm/types/curveUsd.d.ts +9 -1
- package/esm/types/fluid.d.ts +13 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquity.d.ts +12 -0
- package/esm/types/liquityV2.d.ts +24 -0
- package/esm/types/llamaLend.d.ts +12 -1
- package/esm/types/merkl.d.ts +18 -0
- package/esm/types/morphoBlue.d.ts +2 -0
- package/esm/types/portfolio.d.ts +162 -5
- package/esm/types/portfolio.js +17 -1
- package/esm/types/savings/index.d.ts +9 -1
- package/esm/types/spark.d.ts +21 -1
- package/esm/umbrella/index.d.ts +3 -4
- package/esm/umbrella/index.js +5 -4
- package/package.json +1 -1
- package/src/aaveV2/index.ts +7 -7
- package/src/aaveV3/index.ts +16 -11
- package/src/aaveV3/merkl.ts +9 -4
- package/src/aaveV3/sgho.ts +2 -17
- package/src/aaveV4/index.ts +19 -16
- package/src/aaveV4/lend.ts +2 -48
- package/src/aaveV4/merkl.ts +16 -7
- package/src/claiming/aaveV3.ts +9 -5
- package/src/claiming/ethena.ts +5 -5
- package/src/claiming/king.ts +8 -5
- package/src/claiming/spark.ts +15 -10
- package/src/claiming/uniswap.ts +4 -3
- package/src/compoundV2/index.ts +10 -9
- package/src/compoundV3/index.ts +20 -14
- package/src/compoundV3/merkl.ts +5 -4
- package/src/curveUsd/index.ts +19 -17
- package/src/fluid/index.ts +91 -72
- package/src/fluid/merkl.ts +12 -7
- package/src/helpers/aaveHelpers/index.ts +1 -1
- package/src/helpers/aaveV4Helpers/index.ts +16 -2
- package/src/helpers/compoundHelpers/index.ts +2 -2
- package/src/helpers/curveUsdHelpers/index.ts +1 -1
- package/src/helpers/fluidHelpers/index.ts +1 -1
- package/src/helpers/liquityV2Helpers/index.ts +1 -1
- package/src/helpers/llamaLendHelpers/index.ts +1 -1
- package/src/helpers/morphoBlueHelpers/index.ts +1 -1
- package/src/helpers/morphoMidnightHelpers/index.ts +1 -1
- package/src/helpers/sparkHelpers/index.ts +1 -1
- package/src/liquity/index.ts +24 -24
- package/src/liquityV2/index.ts +110 -76
- package/src/llamaLend/index.ts +15 -13
- package/src/maker/index.ts +19 -16
- package/src/moneymarket/moneymarketCommonService.ts +14 -2
- package/src/morphoBlue/index.ts +23 -20
- package/src/morphoBlue/merkl.ts +9 -6
- package/src/morphoMidnight/index.ts +13 -13
- package/src/portfolio/customDeFiData.ts +385 -0
- package/src/portfolio/index.ts +307 -331
- package/src/portfolio/lendingProtocols.ts +281 -0
- package/src/savings/index.ts +41 -4
- package/src/services/merkl.ts +209 -19
- package/src/services/priceService.ts +33 -30
- package/src/services/viem.ts +16 -0
- package/src/spark/index.ts +11 -8
- package/src/types/aave.ts +104 -1
- package/src/types/aaveV4.ts +50 -0
- package/src/types/common.ts +1 -0
- package/src/types/compound.ts +38 -2
- package/src/types/curveUsd.ts +17 -1
- package/src/types/fluid.ts +14 -0
- package/src/types/index.ts +1 -0
- package/src/types/liquity.ts +13 -1
- package/src/types/liquityV2.ts +26 -1
- package/src/types/llamaLend.ts +19 -1
- package/src/types/merkl.ts +20 -0
- package/src/types/morphoBlue.ts +3 -0
- package/src/types/portfolio.ts +191 -5
- package/src/types/savings/index.ts +12 -1
- package/src/types/spark.ts +25 -1
- package/src/umbrella/index.ts +7 -5
|
@@ -10,36 +10,39 @@ import {
|
|
|
10
10
|
WeETHPriceFeedContractViem,
|
|
11
11
|
WstETHPriceFeedContractViem,
|
|
12
12
|
} from '../contracts';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Blockish, EthAddress, NetworkNumber, HexString,
|
|
15
|
+
} from '../types/common';
|
|
14
16
|
import { getEthAmountForDecimals } from './utils';
|
|
17
|
+
import { setViemBlockNumber } from './viem';
|
|
15
18
|
import { USD_QUOTE } from '../constants';
|
|
16
19
|
|
|
17
|
-
export const getEthPrice = async (client: Client) => {
|
|
20
|
+
export const getEthPrice = async (client: Client, block: Blockish = 'latest') => {
|
|
18
21
|
const contract = ETHPriceFeedContractViem(client, NetworkNumber.Eth);
|
|
19
|
-
const price = await contract.read.latestAnswer();
|
|
22
|
+
const price = await contract.read.latestAnswer(setViemBlockNumber(block));
|
|
20
23
|
return new Dec(price.toString()).div(1e8).toString();
|
|
21
24
|
};
|
|
22
25
|
|
|
23
|
-
export const getUSDCPrice = async (client: Client) => {
|
|
26
|
+
export const getUSDCPrice = async (client: Client, block: Blockish = 'latest') => {
|
|
24
27
|
const contract = USDCPriceFeedContractViem(client, NetworkNumber.Eth);
|
|
25
|
-
const price = await contract.read.latestAnswer();
|
|
28
|
+
const price = await contract.read.latestAnswer(setViemBlockNumber(block));
|
|
26
29
|
return new Dec(price.toString()).div(1e8).toString();
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
export const getCompPrice = async (client: Client) => {
|
|
32
|
+
export const getCompPrice = async (client: Client, block: Blockish = 'latest') => {
|
|
30
33
|
const contract = COMPPriceFeedContractViem(client, NetworkNumber.Eth);
|
|
31
|
-
const price = await contract.read.latestAnswer();
|
|
34
|
+
const price = await contract.read.latestAnswer(setViemBlockNumber(block));
|
|
32
35
|
return new Dec(price.toString()).div(1e8).toString();
|
|
33
36
|
};
|
|
34
37
|
|
|
35
|
-
export const getWstETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth) => {
|
|
38
|
+
export const getWstETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth, block: Blockish = 'latest') => {
|
|
36
39
|
const wstETHFeedContract = WstETHPriceFeedContractViem(client, network);
|
|
37
40
|
const ethFeedContract = ETHPriceFeedContractViem(client, network);
|
|
38
41
|
|
|
39
42
|
const [ethPriceWei, wstETHRateWei, decimals] = await Promise.all([
|
|
40
|
-
ethFeedContract.read.latestAnswer(),
|
|
41
|
-
wstETHFeedContract.read.latestRoundData(),
|
|
42
|
-
wstETHFeedContract.read.decimals(),
|
|
43
|
+
ethFeedContract.read.latestAnswer(setViemBlockNumber(block)),
|
|
44
|
+
wstETHFeedContract.read.latestRoundData(setViemBlockNumber(block)),
|
|
45
|
+
wstETHFeedContract.read.decimals(setViemBlockNumber(block)),
|
|
43
46
|
]);
|
|
44
47
|
|
|
45
48
|
const ethPrice = new Dec(ethPriceWei.toString()).div(1e8);
|
|
@@ -49,14 +52,14 @@ export const getWstETHPrice = async (client: Client, network: NetworkNumber = Ne
|
|
|
49
52
|
return new Dec(ethPrice).mul(wstETHRate).toString();
|
|
50
53
|
};
|
|
51
54
|
|
|
52
|
-
export const getWeETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth) => {
|
|
55
|
+
export const getWeETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth, block: Blockish = 'latest') => {
|
|
53
56
|
const weETHFeedContract = WeETHPriceFeedContractViem(client, network);
|
|
54
57
|
const ethFeedContract = ETHPriceFeedContractViem(client, network);
|
|
55
58
|
|
|
56
59
|
const [ethPriceWei, weETHRateWei, decimals] = await Promise.all([
|
|
57
|
-
ethFeedContract.read.latestAnswer(),
|
|
58
|
-
weETHFeedContract.read.latestRoundData(),
|
|
59
|
-
weETHFeedContract.read.decimals(),
|
|
60
|
+
ethFeedContract.read.latestAnswer(setViemBlockNumber(block)),
|
|
61
|
+
weETHFeedContract.read.latestRoundData(setViemBlockNumber(block)),
|
|
62
|
+
weETHFeedContract.read.decimals(setViemBlockNumber(block)),
|
|
60
63
|
]);
|
|
61
64
|
|
|
62
65
|
const ethPrice = new Dec(ethPriceWei.toString()).div(1e8);
|
|
@@ -66,11 +69,11 @@ export const getWeETHPrice = async (client: Client, network: NetworkNumber = Net
|
|
|
66
69
|
return new Dec(ethPrice).mul(weETHRate).toString();
|
|
67
70
|
};
|
|
68
71
|
|
|
69
|
-
export const getWsrETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth) => {
|
|
72
|
+
export const getWsrETHPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth, block: Blockish = 'latest') => {
|
|
70
73
|
const feedRegistryContract = DFSFeedRegistryContractViem(client, network);
|
|
71
74
|
const [ethPriceWei, wrsETHRateWei] = await Promise.all([
|
|
72
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('WETH', network).address as HexString, USD_QUOTE]),
|
|
73
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('wrsETH', network).address as HexString, getAssetInfo('WETH', network).address as HexString]),
|
|
75
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('WETH', network).address as HexString, USD_QUOTE], setViemBlockNumber(block)),
|
|
76
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('wrsETH', network).address as HexString, getAssetInfo('WETH', network).address as HexString], setViemBlockNumber(block)),
|
|
74
77
|
]);
|
|
75
78
|
|
|
76
79
|
const ethPrice = new Dec(ethPriceWei[1].toString()).div(1e8);
|
|
@@ -80,11 +83,11 @@ export const getWsrETHPrice = async (client: Client, network: NetworkNumber = Ne
|
|
|
80
83
|
return new Dec(ethPrice).mul(wrsETHRate).toString();
|
|
81
84
|
};
|
|
82
85
|
|
|
83
|
-
export const getSyrupUSDTPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth) => {
|
|
86
|
+
export const getSyrupUSDTPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth, block: Blockish = 'latest') => {
|
|
84
87
|
const feedRegistryContract = DFSFeedRegistryContractViem(client, network);
|
|
85
88
|
const [usdtPriceWei, syrupUSDTRateWei] = await Promise.all([
|
|
86
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('USDT', network).address as HexString, USD_QUOTE]),
|
|
87
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('syrupUSDT', network).address as HexString, getAssetInfo('USDT', network).address as HexString]),
|
|
89
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('USDT', network).address as HexString, USD_QUOTE], setViemBlockNumber(block)),
|
|
90
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('syrupUSDT', network).address as HexString, getAssetInfo('USDT', network).address as HexString], setViemBlockNumber(block)),
|
|
88
91
|
]);
|
|
89
92
|
|
|
90
93
|
const usdtPrice = new Dec(usdtPriceWei[1].toString()).div(1e8);
|
|
@@ -94,11 +97,11 @@ export const getSyrupUSDTPrice = async (client: Client, network: NetworkNumber =
|
|
|
94
97
|
return new Dec(usdtPrice).mul(syrupUSDTPrice).toString();
|
|
95
98
|
};
|
|
96
99
|
|
|
97
|
-
export const getWstUSRPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth) => {
|
|
100
|
+
export const getWstUSRPrice = async (client: Client, network: NetworkNumber = NetworkNumber.Eth, block: Blockish = 'latest') => {
|
|
98
101
|
const feedRegistryContract = DFSFeedRegistryContractViem(client, network);
|
|
99
102
|
const [usrPriceWei, wstUSRRateWei] = await Promise.all([
|
|
100
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('USR', network).address as HexString, USD_QUOTE]),
|
|
101
|
-
feedRegistryContract.read.latestRoundData([getAssetInfo('wstUSR', network).address as HexString, getAssetInfo('USR', network).address as HexString]),
|
|
103
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('USR', network).address as HexString, USD_QUOTE], setViemBlockNumber(block)),
|
|
104
|
+
feedRegistryContract.read.latestRoundData([getAssetInfo('wstUSR', network).address as HexString, getAssetInfo('USR', network).address as HexString], setViemBlockNumber(block)),
|
|
102
105
|
]);
|
|
103
106
|
|
|
104
107
|
const usrPrice = new Dec(usrPriceWei[1].toString()).div(1e8);
|
|
@@ -248,24 +251,24 @@ export const parseWeETHPriceCalls = (_ethPrice: string, weETHrateAnswer: string,
|
|
|
248
251
|
};
|
|
249
252
|
|
|
250
253
|
// this is a fixed version, the original version is above but requires to refactor comp v3 function, so it's easier to just copy the function for now
|
|
251
|
-
export const getWstETHPriceFluid = async (client: PublicClient, network: NetworkNumber) => {
|
|
254
|
+
export const getWstETHPriceFluid = async (client: PublicClient, network: NetworkNumber, block: Blockish = 'latest') => {
|
|
252
255
|
const calls = getWstETHChainLinkPriceCalls(client, network);
|
|
253
|
-
const results = await client.multicall({ contracts: calls });
|
|
256
|
+
const results = await client.multicall({ contracts: calls, ...setViemBlockNumber(block) });
|
|
254
257
|
// @ts-ignore
|
|
255
258
|
const { ethPrice, wstETHRate } = parseWstETHPriceCalls(results[0].result!.toString(), results[1].result[1]!.toString(), results[2].result!.toString());
|
|
256
259
|
|
|
257
260
|
return new Dec(ethPrice).mul(wstETHRate).toString();
|
|
258
261
|
};
|
|
259
262
|
|
|
260
|
-
export const getBTCPriceForFluid = async (client: PublicClient, network: NetworkNumber) => {
|
|
263
|
+
export const getBTCPriceForFluid = async (client: PublicClient, network: NetworkNumber, block: Blockish = 'latest') => {
|
|
261
264
|
const contract = BTCPriceFeedContractViem(client, network);
|
|
262
|
-
const price = await contract.read.latestAnswer();
|
|
265
|
+
const price = await contract.read.latestAnswer(setViemBlockNumber(block));
|
|
263
266
|
return new Dec(price).div(1e8).toString();
|
|
264
267
|
};
|
|
265
268
|
|
|
266
|
-
export const getEthPriceForFluid = async (client: PublicClient, network: NetworkNumber) => {
|
|
269
|
+
export const getEthPriceForFluid = async (client: PublicClient, network: NetworkNumber, block: Blockish = 'latest') => {
|
|
267
270
|
const contract = ETHPriceFeedContractViem(client, network);
|
|
268
|
-
const price = await contract.read.latestAnswer();
|
|
271
|
+
const price = await contract.read.latestAnswer(setViemBlockNumber(block));
|
|
269
272
|
return new Dec(price).div(1e8).toString();
|
|
270
273
|
};
|
|
271
274
|
|
package/src/services/viem.ts
CHANGED
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
custom,
|
|
4
4
|
encodeFunctionData,
|
|
5
5
|
type Abi,
|
|
6
|
+
type Client,
|
|
6
7
|
} from 'viem';
|
|
8
|
+
import { getBlock } from 'viem/actions';
|
|
7
9
|
import {
|
|
8
10
|
arbitrum, base, mainnet, optimism, linea, plasma,
|
|
9
11
|
} from 'viem/chains';
|
|
@@ -34,6 +36,20 @@ export const getViemProvider = (provider: EthereumProvider, network: NetworkNumb
|
|
|
34
36
|
...options,
|
|
35
37
|
});
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Unix timestamp (seconds) of the block, for data sources keyed by time rather than block (Merkl
|
|
41
|
+
* reward history). `'latest'` resolves to `undefined` without an RPC call, since live sources need
|
|
42
|
+
* no timestamp. A numeric block costs one `eth_getBlockByNumber` unless the caller already knows
|
|
43
|
+
* its timestamp and passes it — flows that fetch many markets at one block resolve it once and
|
|
44
|
+
* hand it down.
|
|
45
|
+
*/
|
|
46
|
+
export const getBlockTimestamp = async (client: Client, block: Blockish, blockTimestamp?: number): Promise<number | undefined> => {
|
|
47
|
+
if (block === 'latest') return undefined;
|
|
48
|
+
if (blockTimestamp !== undefined) return blockTimestamp;
|
|
49
|
+
const { timestamp } = await getBlock(client, { blockNumber: BigInt(block) });
|
|
50
|
+
return Number(timestamp);
|
|
51
|
+
};
|
|
52
|
+
|
|
37
53
|
export const setViemBlockNumber = (block: Blockish) => {
|
|
38
54
|
if (block === 'latest') return {};
|
|
39
55
|
return { blockNumber: BigInt(block) };
|
package/src/spark/index.ts
CHANGED
|
@@ -62,7 +62,7 @@ export const sparkEmodeCategoriesMapping = (extractedState: { assetsData: SparkA
|
|
|
62
62
|
return categoriesMapping;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
export const _getSparkMarketsData = async (provider: Client, network: NetworkNumber, selectedMarket: SparkMarketData): Promise<SparkMarketsData> => {
|
|
65
|
+
export const _getSparkMarketsData = async (provider: Client, network: NetworkNumber, selectedMarket: SparkMarketData, blockNumber: Blockish = 'latest'): Promise<SparkMarketsData> => {
|
|
66
66
|
const marketAddress = selectedMarket.providerAddress;
|
|
67
67
|
|
|
68
68
|
const loanInfoContract = SparkViewContractViem(provider, network);
|
|
@@ -70,8 +70,8 @@ export const _getSparkMarketsData = async (provider: Client, network: NetworkNum
|
|
|
70
70
|
|
|
71
71
|
// eslint-disable-next-line prefer-const
|
|
72
72
|
let [loanInfo, rewardInfo] = await Promise.all([
|
|
73
|
-
loanInfoContract.read.getFullTokensInfo([marketAddress, selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address) as EthAddress[]]),
|
|
74
|
-
sparkIncentivesContract.read.getReservesIncentivesData([marketAddress]),
|
|
73
|
+
loanInfoContract.read.getFullTokensInfo([marketAddress, selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address) as EthAddress[]], setViemBlockNumber(blockNumber)),
|
|
74
|
+
sparkIncentivesContract.read.getReservesIncentivesData([marketAddress], setViemBlockNumber(blockNumber)),
|
|
75
75
|
]);
|
|
76
76
|
|
|
77
77
|
rewardInfo = rewardInfo.reduce((all: any, market: any) => {
|
|
@@ -246,7 +246,8 @@ export const getSparkMarketsData = async (
|
|
|
246
246
|
provider: EthereumProvider,
|
|
247
247
|
network: NetworkNumber,
|
|
248
248
|
selectedMarket: SparkMarketData,
|
|
249
|
-
|
|
249
|
+
blockNumber: Blockish = 'latest',
|
|
250
|
+
): Promise<SparkMarketsData> => _getSparkMarketsData(getViemProvider(provider, network), network, selectedMarket, blockNumber);
|
|
250
251
|
|
|
251
252
|
export const EMPTY_SPARK_DATA = {
|
|
252
253
|
usedAssets: {},
|
|
@@ -287,6 +288,7 @@ export const _getSparkAccountData = async (
|
|
|
287
288
|
network: NetworkNumber,
|
|
288
289
|
address: EthAddress,
|
|
289
290
|
extractedState: { selectedMarket: SparkMarketData, assetsData: SparkAssetsData, eModeCategoriesData: EModeCategoriesData },
|
|
291
|
+
blockNumber: Blockish = 'latest',
|
|
290
292
|
) => {
|
|
291
293
|
const {
|
|
292
294
|
selectedMarket: market, assetsData,
|
|
@@ -313,9 +315,9 @@ export const _getSparkAccountData = async (
|
|
|
313
315
|
const middleAddressIndex = Math.floor(_addresses.length / 2); // split addresses in half to avoid gas limit by multicall
|
|
314
316
|
|
|
315
317
|
const [userEMode, tokenBalances1, tokenBalances2] = await Promise.all([
|
|
316
|
-
lendingPoolContract.read.getUserEMode([address]),
|
|
317
|
-
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(0, middleAddressIndex) as EthAddress[]]),
|
|
318
|
-
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length) as EthAddress[]]),
|
|
318
|
+
lendingPoolContract.read.getUserEMode([address], setViemBlockNumber(blockNumber)),
|
|
319
|
+
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(0, middleAddressIndex) as EthAddress[]], setViemBlockNumber(blockNumber)),
|
|
320
|
+
loanInfoContract.read.getTokenBalances([marketAddress, address, _addresses.slice(middleAddressIndex, _addresses.length) as EthAddress[]], setViemBlockNumber(blockNumber)),
|
|
319
321
|
]);
|
|
320
322
|
|
|
321
323
|
|
|
@@ -406,7 +408,8 @@ export const getSparkAccountData = async (
|
|
|
406
408
|
network: NetworkNumber,
|
|
407
409
|
address: EthAddress,
|
|
408
410
|
extractedState: { selectedMarket: SparkMarketData, assetsData: SparkAssetsData, eModeCategoriesData: EModeCategoriesData },
|
|
409
|
-
|
|
411
|
+
blockNumber: Blockish = 'latest',
|
|
412
|
+
) => _getSparkAccountData(getViemProvider(provider, network), network, address, extractedState, blockNumber);
|
|
410
413
|
|
|
411
414
|
export const getSparkFullPositionData = async (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, market: SparkMarketData): Promise<SparkPositionData> => {
|
|
412
415
|
const marketData = await getSparkMarketsData(provider, network, market);
|
package/src/types/aave.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EthAddress,
|
|
2
3
|
IncentiveData,
|
|
3
4
|
LeverageType,
|
|
4
5
|
MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber,
|
|
@@ -97,6 +98,9 @@ export interface AaveV3AssetData extends AaveAssetData {
|
|
|
97
98
|
liquidationBonus: string,
|
|
98
99
|
supplyIncentives: IncentiveData[];
|
|
99
100
|
borrowIncentives: IncentiveData[];
|
|
101
|
+
// Set by _getAaveV3MarketData. Optional, so objects built by hand still type-check.
|
|
102
|
+
aTokenAddress?: EthAddress,
|
|
103
|
+
vTokenAddress?: EthAddress,
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
export type EModeCategoriesData = Record<number, EModeCategoryData>;
|
|
@@ -138,7 +142,15 @@ export type AaveV2UsedAssets = AaveUsedAssets<AaveV2UsedAsset>;
|
|
|
138
142
|
|
|
139
143
|
export type AaveV3UsedAssets = AaveUsedAssets<AaveV3UsedAsset>;
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Fields aaveAnyGetAggregatedPositionData adds to every Aave V2/V3 position at runtime, on top of those declared
|
|
147
|
+
* below. Optional, so code that builds a position by hand keeps compiling.
|
|
148
|
+
*/
|
|
149
|
+
export type AavePositionAggregatedFields = Partial<Omit<AaveV3AggregatedPositionData,
|
|
150
|
+
| keyof MMPositionData | 'ratio' | 'collRatio' | 'safetyRatioWithLtvZeroFallback' | 'suppliedUsd' | 'borrowedUsd'
|
|
151
|
+
| 'borrowLimitUsd' | 'suppliedCollateralUsd' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
152
|
+
|
|
153
|
+
export interface AavePositionData extends MMPositionData, AavePositionAggregatedFields {
|
|
142
154
|
ratio: string,
|
|
143
155
|
minRatio: string,
|
|
144
156
|
collRatio: string,
|
|
@@ -159,6 +171,11 @@ export interface AavePositionData extends MMPositionData {
|
|
|
159
171
|
|
|
160
172
|
export interface AaveV2PositionData extends AavePositionData {
|
|
161
173
|
usedAssets: AaveV2UsedAssets,
|
|
174
|
+
// Always their empty values: _getAaveV2AccountData starts from Aave V3's EMPTY_AAVE_DATA, which carries them.
|
|
175
|
+
eModeCategory?: number,
|
|
176
|
+
isInIsolationMode?: boolean,
|
|
177
|
+
isInSiloedMode?: boolean,
|
|
178
|
+
eModeCategories?: { [key: number]: EModeCategoryDataMapping },
|
|
162
179
|
}
|
|
163
180
|
|
|
164
181
|
export interface AaveV3PositionData extends AavePositionData {
|
|
@@ -206,3 +223,89 @@ export interface AaveHelperCommon {
|
|
|
206
223
|
selectedMarket: Partial<AaveMarketInfo>,
|
|
207
224
|
network?: NetworkNumber,
|
|
208
225
|
}
|
|
226
|
+
|
|
227
|
+
export interface SghoUserData {
|
|
228
|
+
shares: string;
|
|
229
|
+
balance: string;
|
|
230
|
+
maxDeposit: string;
|
|
231
|
+
maxWithdraw: string;
|
|
232
|
+
underlyingBalance: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface SghoData {
|
|
236
|
+
totalAssets: string;
|
|
237
|
+
totalSupply: string;
|
|
238
|
+
supplyCap: string;
|
|
239
|
+
/** Target savings rate as an APY percent (e.g. "4.25" for 4.25%). */
|
|
240
|
+
targetRate: string;
|
|
241
|
+
paused: boolean;
|
|
242
|
+
user: SghoUserData;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** stkAAVE, stkGHO and sGHO of an address, from getStakeAaveData. */
|
|
246
|
+
export interface StakeAaveData {
|
|
247
|
+
activatedCooldown: string,
|
|
248
|
+
activatedCooldownAmount: string,
|
|
249
|
+
stkAaveRewardsBalance: string,
|
|
250
|
+
aaveRewardsBalance: string,
|
|
251
|
+
stkAaveBalance: string,
|
|
252
|
+
stkGhoBalance: string,
|
|
253
|
+
ghoMeritApy: string,
|
|
254
|
+
stkAaveApy: string,
|
|
255
|
+
sgho: SghoData,
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface UmbrellaTokenInfo {
|
|
259
|
+
token: EthAddress,
|
|
260
|
+
/** USD, converted from the oracle's 8 decimals. */
|
|
261
|
+
price: string,
|
|
262
|
+
name: string,
|
|
263
|
+
symbol: string,
|
|
264
|
+
decimals: number,
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface UmbrellaRewardTokenData {
|
|
268
|
+
rewardTokenData: UmbrellaTokenInfo,
|
|
269
|
+
maxEmissionPerSecond: bigint,
|
|
270
|
+
distributionEnd: bigint,
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface UmbrellaStakingAccountData {
|
|
274
|
+
stakeUserBalance: string,
|
|
275
|
+
rewardsTokenUserData: { reward: EthAddress, currentReward: string }[],
|
|
276
|
+
userCooldownAmount: string,
|
|
277
|
+
// Passed through unconverted: the view's bigint, or '0' when the view returns none.
|
|
278
|
+
userEndOfCooldown: bigint | string,
|
|
279
|
+
userWithdrawalWindow: bigint | string,
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* One Umbrella stake token of an address, from getUmbrellaData: the view contracts' structs merged, with the amounts
|
|
284
|
+
* the app reads converted to decimal strings. The bigint fields are the views' raw values, as the SDK passes them.
|
|
285
|
+
*/
|
|
286
|
+
export interface UmbrellaStakingTokenData {
|
|
287
|
+
stakeTokenData: UmbrellaTokenInfo,
|
|
288
|
+
totalAssets: string,
|
|
289
|
+
targetLiquidity: string,
|
|
290
|
+
isStakeConfigured: boolean,
|
|
291
|
+
rewardsTokenData: UmbrellaRewardTokenData[],
|
|
292
|
+
stakeToken: EthAddress,
|
|
293
|
+
stakeUserBalance: bigint,
|
|
294
|
+
rewardsTokenUserData: { reward: EthAddress, currentReward: bigint }[],
|
|
295
|
+
stkToken: EthAddress,
|
|
296
|
+
totalShares: string,
|
|
297
|
+
stkUnderlyingToken: EthAddress,
|
|
298
|
+
aToken: EthAddress,
|
|
299
|
+
cooldownPeriod: bigint,
|
|
300
|
+
unstakeWindow: bigint,
|
|
301
|
+
stkTokenToWaTokenRate: string,
|
|
302
|
+
waTokenToATokenRate: string,
|
|
303
|
+
rewardsEmissionRates: string[],
|
|
304
|
+
userCooldownAmount: bigint,
|
|
305
|
+
userEndOfCooldown: bigint,
|
|
306
|
+
userWithdrawalWindow: bigint,
|
|
307
|
+
account: UmbrellaStakingAccountData,
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Keyed by Umbrella stake (UmbrellaGHO, UmbrellaUSDC, UmbrellaUSDT, UmbrellaETH). */
|
|
311
|
+
export type UmbrellaStakingData = Record<string, UmbrellaStakingTokenData>;
|
package/src/types/aaveV4.ts
CHANGED
|
@@ -198,6 +198,7 @@ export interface AaveV4AggregatedPositionData {
|
|
|
198
198
|
totalInterestUsd: string,
|
|
199
199
|
currentVolatilePairRatio?: string,
|
|
200
200
|
minRatio: string,
|
|
201
|
+
exposure: string,
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
export type AaveV4UsedReserveAssets = Record<string, AaveV4UsedReserveAsset>;
|
|
@@ -207,3 +208,52 @@ export interface AaveV4AccountData extends AaveV4AggregatedPositionData {
|
|
|
207
208
|
healthFactor: string,
|
|
208
209
|
riskPremiumBps: number,
|
|
209
210
|
}
|
|
211
|
+
|
|
212
|
+
/** One Aave V4 tokenized spoke (Lend vault) as the view contract returns it for a user. */
|
|
213
|
+
export interface AaveV4TokenizationSpokeData {
|
|
214
|
+
underlyingAsset: EthAddress;
|
|
215
|
+
assetId: string;
|
|
216
|
+
decimals: number;
|
|
217
|
+
spoke: EthAddress;
|
|
218
|
+
spokeActive: boolean;
|
|
219
|
+
spokeHalted: boolean;
|
|
220
|
+
spokeDepositCap: string;
|
|
221
|
+
spokeTotalAssets: string;
|
|
222
|
+
spokeTotalShares: string;
|
|
223
|
+
hub: EthAddress;
|
|
224
|
+
hubLiquidity: string;
|
|
225
|
+
hubDrawnRate: string;
|
|
226
|
+
convertToShares: string;
|
|
227
|
+
convertToAssets: string;
|
|
228
|
+
user: EthAddress;
|
|
229
|
+
userSuppliedAssets: string;
|
|
230
|
+
userSuppliedShares: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Parsed tokenization spoke data with human-readable supplied amounts for display */
|
|
234
|
+
export interface AaveV4TokenizationSpokeDataParsed {
|
|
235
|
+
vaultAddress: EthAddress;
|
|
236
|
+
key: string | null;
|
|
237
|
+
symbol: string;
|
|
238
|
+
hubKey: string;
|
|
239
|
+
// ---- Spoke ----
|
|
240
|
+
spokeActive: boolean;
|
|
241
|
+
spokeHalted: boolean;
|
|
242
|
+
/** Deposit cap in asset units (wei string) */
|
|
243
|
+
spokeDepositCap: string;
|
|
244
|
+
/** Total assets currently in spoke in asset units (wei string) */
|
|
245
|
+
spokeTotalAssets: string;
|
|
246
|
+
// ---- Hub ----
|
|
247
|
+
/** Available hub liquidity in asset units (wei string) */
|
|
248
|
+
hubLiquidity: string;
|
|
249
|
+
/** The conversion rate from assets to shares expressed in asset units. */
|
|
250
|
+
convertToShares: string;
|
|
251
|
+
// ---- User ----
|
|
252
|
+
userSuppliedAssetsEth: string;
|
|
253
|
+
userSuppliedSharesEth: string;
|
|
254
|
+
userSuppliedAssets: string;
|
|
255
|
+
userSuppliedShares: string;
|
|
256
|
+
underlyingAsset: EthAddress;
|
|
257
|
+
spoke: EthAddress;
|
|
258
|
+
decimals: number;
|
|
259
|
+
}
|
package/src/types/common.ts
CHANGED
package/src/types/compound.ts
CHANGED
|
@@ -70,6 +70,8 @@ export interface CompoundAssetData extends MMAssetData {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface CompoundV2AssetData extends CompoundAssetData {
|
|
73
|
+
// Set by _getCompoundV2MarketsData. Optional, so objects built by hand still type-check.
|
|
74
|
+
exchangeRate?: string,
|
|
73
75
|
}
|
|
74
76
|
export interface CompoundV3AssetData extends CompoundAssetData {
|
|
75
77
|
borrowCollateralFactor: string,
|
|
@@ -81,6 +83,20 @@ export interface CompoundV3AssetData extends CompoundAssetData {
|
|
|
81
83
|
supplyCap: string,
|
|
82
84
|
priceInBaseAsset: string,
|
|
83
85
|
canBeWithdrawn: boolean,
|
|
86
|
+
// The rest are set by formatMarketData and formatBaseData, which also spread in the view contract's raw asset
|
|
87
|
+
// data. Optional, so objects built by hand still type-check.
|
|
88
|
+
tokenAddr?: EthAddress,
|
|
89
|
+
// The base asset's only.
|
|
90
|
+
isBase?: boolean,
|
|
91
|
+
baseBorrowMin?: string,
|
|
92
|
+
baseTrackingBorrowRewardsSpeed?: string,
|
|
93
|
+
baseTrackingSupplyRewardsSpeed?: string,
|
|
94
|
+
borrowIndex?: string,
|
|
95
|
+
supplyIndex?: string,
|
|
96
|
+
trackingBorrowIndex?: string,
|
|
97
|
+
trackingSupplyIndex?: string,
|
|
98
|
+
rewardSupplySpeed?: string,
|
|
99
|
+
rewardBorrowSpeed?: string,
|
|
84
100
|
}
|
|
85
101
|
|
|
86
102
|
export interface CompoundAssetsData<T> {
|
|
@@ -143,10 +159,30 @@ export interface CompoundPositionData extends MMPositionData {
|
|
|
143
159
|
automationResubscribeRequired?: boolean,
|
|
144
160
|
}
|
|
145
161
|
|
|
146
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Fields getCompoundV2AggregatedData adds to every Compound V2 position at runtime — a subset of
|
|
164
|
+
* CompoundAggregatedPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
165
|
+
*/
|
|
166
|
+
export type CompoundV2PositionAggregatedFields = Partial<Pick<CompoundAggregatedPositionData,
|
|
167
|
+
| 'suppliedCollateralUsd' | 'liquidationLimitUsd' | 'leftToBorrowUsd' | 'collRatio' | 'leveragedType'
|
|
168
|
+
| 'leveragedAsset' | 'liquidationPrice'>>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Fields getCompoundV3AggregatedData adds to every Compound V3 position at runtime, on top of those declared in
|
|
172
|
+
* CompoundPositionData. Optional, so code that builds a position by hand keeps compiling.
|
|
173
|
+
*/
|
|
174
|
+
export type CompoundV3PositionAggregatedFields = Partial<Omit<CompoundAggregatedPositionData,
|
|
175
|
+
| keyof MMPositionData | 'ratio' | 'minRatio' | 'suppliedUsd' | 'borrowedUsd' | 'borrowLimitUsd' | 'incentiveUsd'
|
|
176
|
+
| 'totalInterestUsd'>>;
|
|
177
|
+
|
|
178
|
+
export interface CompoundV2PositionData extends CompoundPositionData, CompoundV2PositionAggregatedFields {
|
|
147
179
|
usedAssets: CompoundV2UsedAssets,
|
|
180
|
+
// Always false: _getCompoundV2AccountData starts from EMPTY_COMPOUND_DATA, which carries it.
|
|
181
|
+
borrowStableSupplyUnstable?: boolean,
|
|
148
182
|
}
|
|
149
183
|
|
|
150
|
-
export interface CompoundV3PositionData extends CompoundPositionData {
|
|
184
|
+
export interface CompoundV3PositionData extends CompoundPositionData, CompoundV3PositionAggregatedFields {
|
|
151
185
|
usedAssets: CompoundV3UsedAssets,
|
|
186
|
+
// Whether the user's smart wallet is allowed to manage the account on Comet (Comet.isAllowed).
|
|
187
|
+
isAllowed?: boolean,
|
|
152
188
|
}
|
package/src/types/curveUsd.ts
CHANGED
|
@@ -66,6 +66,9 @@ export interface CrvUSDGlobalMarketData {
|
|
|
66
66
|
leftToBorrow: string,
|
|
67
67
|
bands: BandData[],
|
|
68
68
|
loanDiscount: string;
|
|
69
|
+
// crvUSDView's globalData field that _getCurveUsdGlobalData spreads in unconverted. Optional, so objects built by
|
|
70
|
+
// hand still type-check.
|
|
71
|
+
A?: bigint,
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
export interface CrvUSDAggregatedPositionData {
|
|
@@ -105,7 +108,12 @@ export interface CrvUSDUsedAssets {
|
|
|
105
108
|
[key: string]: CrvUSDUsedAsset,
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
// Set by getCrvUsdAggregatedData, which _getCurveUsdUserData spreads in. Optional, so objects built by hand still
|
|
112
|
+
// type-check.
|
|
113
|
+
export type CrvUSDPositionAggregatedFields = Partial<Pick<CrvUSDAggregatedPositionData,
|
|
114
|
+
| 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'>>;
|
|
115
|
+
|
|
116
|
+
export interface CrvUSDUserData extends CrvUSDPositionAggregatedFields {
|
|
109
117
|
debtAmount: string,
|
|
110
118
|
health: string,
|
|
111
119
|
healthPercent: string,
|
|
@@ -130,4 +138,12 @@ export interface CrvUSDUserData {
|
|
|
130
138
|
netApy: string,
|
|
131
139
|
totalInterestUsd: string,
|
|
132
140
|
incentiveUsd: string,
|
|
141
|
+
// Fields of crvUSDView's userData that _getCurveUsdUserData spreads in unconverted. Optional, so objects built by
|
|
142
|
+
// hand still type-check.
|
|
143
|
+
marketCollateralAmount?: bigint,
|
|
144
|
+
curveUsdCollateralAmount?: bigint,
|
|
145
|
+
N?: bigint,
|
|
146
|
+
bandRange?: readonly [bigint, bigint],
|
|
147
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]],
|
|
148
|
+
isInSoftLiquidation?: boolean,
|
|
133
149
|
}
|
package/src/types/fluid.ts
CHANGED
|
@@ -488,3 +488,17 @@ export interface FluidFTokenDataStructOutput {
|
|
|
488
488
|
rewardsRate: bigint;
|
|
489
489
|
withdrawable: bigint;
|
|
490
490
|
}
|
|
491
|
+
|
|
492
|
+
/** One Fluid lending (fToken) deposit of an address, from getAllUserEarnPositionsWithFTokens and getFluidDepositData. */
|
|
493
|
+
export interface FluidEarnPositionData {
|
|
494
|
+
fTokenAddress: string | undefined,
|
|
495
|
+
fTokenSymbol: string,
|
|
496
|
+
decimals: string,
|
|
497
|
+
totalDeposited: string,
|
|
498
|
+
withdrawable: string,
|
|
499
|
+
apy: string,
|
|
500
|
+
depositRate: string,
|
|
501
|
+
withdrawRate: string,
|
|
502
|
+
deposited: string,
|
|
503
|
+
depositedShares: string,
|
|
504
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/liquity.ts
CHANGED
|
@@ -35,4 +35,16 @@ export interface LiquityTroveInfo {
|
|
|
35
35
|
netApy: string,
|
|
36
36
|
totalInterestUsd: string,
|
|
37
37
|
incentiveUsd: string,
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
|
+
/** LQTY staking and the LUSD stability pool deposit of an address, from getLiquityStakingData. */
|
|
40
|
+
export interface LiquityStakingData {
|
|
41
|
+
totalLUSDDeposited: string,
|
|
42
|
+
totalLQTYStaked: string,
|
|
43
|
+
stakedLQTY: string,
|
|
44
|
+
stakedLUSDBalance: string,
|
|
45
|
+
rewardETH: string,
|
|
46
|
+
rewardLUSD: string,
|
|
47
|
+
stabilityRewardETH: string,
|
|
48
|
+
stabilityRewardLQTY: string,
|
|
49
|
+
showStakingBalances: boolean,
|
|
50
|
+
}
|
package/src/types/liquityV2.ts
CHANGED
|
@@ -133,4 +133,29 @@ export interface LiquityV2TroveData {
|
|
|
133
133
|
debtInFront: string,
|
|
134
134
|
lastInterestRateAdjTime: string,
|
|
135
135
|
exposure: string,
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
|
+
/** The stability pool deposit of an address in one market, from getLiquityV2Staking. */
|
|
138
|
+
export interface LiquityV2StakingData {
|
|
139
|
+
totalBOLDDeposited: string,
|
|
140
|
+
stakedBOLDBalance: string,
|
|
141
|
+
stabilityRewardColl: string,
|
|
142
|
+
stabilityRewardYield: string,
|
|
143
|
+
showStakingBalances: boolean,
|
|
144
|
+
debtTokenBalance: string,
|
|
145
|
+
stabilityPoolApy: string,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** sBOLD, yBOLD and stYBOLD of an address, from getLiquitySAndYBold. */
|
|
149
|
+
export interface LiquityV2SBoldYBoldData {
|
|
150
|
+
spApy: string,
|
|
151
|
+
yBoldApy: string,
|
|
152
|
+
totalBoldDepositedSBold: string,
|
|
153
|
+
boldRateSBold: string,
|
|
154
|
+
maxWithdrawSBold: string,
|
|
155
|
+
totalBoldDepositedYBold: string,
|
|
156
|
+
boldRateYBold: string,
|
|
157
|
+
maxWithdrawYBold: string,
|
|
158
|
+
sBoldBalance: string,
|
|
159
|
+
yBoldBalance: string,
|
|
160
|
+
stYBoldBalance: string,
|
|
161
|
+
}
|
package/src/types/llamaLend.ts
CHANGED
|
@@ -141,7 +141,13 @@ export interface LlamaLendUsedAssets {
|
|
|
141
141
|
[key: string]: LlamaLendUsedAsset,
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
// Set by getLlamaLendAggregatedData, which _getLlamaLendUserData spreads in. Optional, so objects built by hand still
|
|
145
|
+
// type-check.
|
|
146
|
+
export type LlamaLendPositionAggregatedFields = Partial<Pick<LlamaLendAggregatedPositionData,
|
|
147
|
+
| 'borrowLimitUsd' | 'minAllowedRatio' | 'collFactor' | 'leveragedType' | 'leveragedAsset' | 'liquidationPrice'
|
|
148
|
+
| 'netApy' | 'incentiveUsd' | 'totalInterestUsd'>>;
|
|
149
|
+
|
|
150
|
+
export interface LlamaLendUserData extends LlamaLendPositionAggregatedFields {
|
|
145
151
|
debtAmount: string,
|
|
146
152
|
health: string,
|
|
147
153
|
healthPercent: string,
|
|
@@ -160,4 +166,16 @@ export interface LlamaLendUserData {
|
|
|
160
166
|
loanExists: boolean,
|
|
161
167
|
borrowRate?: string,
|
|
162
168
|
exposure: string,
|
|
169
|
+
// Fields of LlamaLendView's userData that _getLlamaLendUserData spreads in unconverted. Optional, so objects built
|
|
170
|
+
// by hand still type-check.
|
|
171
|
+
collateralPrice?: bigint,
|
|
172
|
+
marketCollateralAmount?: bigint,
|
|
173
|
+
debtTokenCollateralAmount?: bigint,
|
|
174
|
+
N?: bigint,
|
|
175
|
+
bandRange?: readonly [bigint, bigint],
|
|
176
|
+
usersBands?: readonly [readonly bigint[], readonly bigint[]],
|
|
177
|
+
collRatio?: bigint,
|
|
178
|
+
isInSoftLiquidation?: boolean,
|
|
179
|
+
debtTokenSuppliedShares?: bigint,
|
|
180
|
+
debtTokenSuppliedAssets?: bigint,
|
|
163
181
|
}
|