@1delta/margin-fetcher 0.0.1 → 0.0.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/dist/abis/aave-v3/YLDR.d.ts +36 -0
- package/dist/abis/aave-v3/YLDR.d.ts.map +1 -0
- package/dist/abis/aave-v3/YLDR.js +46 -0
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/lending/aave-v3-type/types.d.ts +7 -0
- package/dist/lending/aave-v3-type/types.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/types.js +8 -0
- package/dist/lending/addresses/compoundV3.d.ts.map +1 -1
- package/dist/lending/addresses/compoundV3.js +1 -1
- package/dist/lending/compound-v3/publicCallParse.js +1 -1
- package/dist/lending/init/publicCallParse.js +1 -1
- package/dist/lending/user-data/aave-v2-type/userCallParse.js +3 -2
- package/dist/lending/user-data/aave-v3-type/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/aave-v3-type/userCallBuild.js +11 -8
- package/dist/lending/user-data/aave-v3-type/userCallParse.js +4 -3
- package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts +9 -0
- package/dist/lending/user-data/aave-v3-type/userCallParseYldr.d.ts.map +1 -0
- package/dist/lending/user-data/aave-v3-type/userCallParseYldr.js +75 -0
- package/dist/lending/user-data/abis.d.ts +667 -0
- package/dist/lending/user-data/abis.d.ts.map +1 -1
- package/dist/lending/user-data/abis.js +7 -1
- package/dist/lending/user-data/compound-v3/addresses.d.ts.map +1 -1
- package/dist/lending/user-data/compound-v3/addresses.js +1 -1
- package/dist/lending/user-data/compound-v3/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/compound-v3/userCallParse.js +7 -5
- package/dist/lending/user-data/fetchUserData.d.ts.map +1 -1
- package/dist/lending/user-data/fetchUserData.js +5 -3
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts +6 -7
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/aaveOracles.js +6 -7
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/parsing.d.ts.map +1 -1
- package/dist/utils/parsing.js +1 -1
- package/package.json +5 -2
- package/src/abis/aave-v3/YLDR.ts +46 -0
- package/src/assets/index.ts +1 -1
- package/src/lending/aave-v3-type/types.ts +8 -0
- package/src/lending/addresses/compoundV3.ts +1 -1
- package/src/lending/compound-v3/publicCallParse.ts +1 -1
- package/src/lending/init/publicCallParse.ts +1 -1
- package/src/lending/user-data/aave-v2-type/userCallParse.ts +9 -7
- package/src/lending/user-data/aave-v3-type/userCallBuild.ts +13 -8
- package/src/lending/user-data/aave-v3-type/userCallParse.ts +5 -3
- package/src/lending/user-data/aave-v3-type/userCallParseYldr.ts +116 -0
- package/src/lending/user-data/abis.ts +33 -28
- package/src/lending/user-data/compound-v3/addresses.ts +1 -1
- package/src/lending/user-data/compound-v3/userCallParse.ts +7 -5
- package/src/lending/user-data/fetchUserData.ts +4 -2
- package/src/prices/main-prices/addresses/aaveOracles.ts +6 -7
- package/src/utils/index.ts +5 -3
- package/src/utils/parsing.ts +1 -1
- package/test/lenderData.test.ts +1 -1
- package/test/userdata.test.ts +21 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Lender } from "@1delta/asset-registry"
|
|
2
|
+
import { getAaveAssets, getAssetMeta, toGenericPriceKey, toOracleKey } from "../../../assets"
|
|
3
|
+
import { AaveV3UserReserveResponse } from "../types"
|
|
4
|
+
import { createBaseTypeUserState } from "../utils"
|
|
5
|
+
import { YldrTypeGetUserReserveIndexes } from "../../aave-v3-type/types"
|
|
6
|
+
import { parseRawAmount } from "../../../utils/parsing"
|
|
7
|
+
|
|
8
|
+
/** Like Aave V3, not stable debt data and no emode */
|
|
9
|
+
export const getYldrUserDataConverter = (
|
|
10
|
+
lender: Lender,
|
|
11
|
+
chainId: string,
|
|
12
|
+
account: string,
|
|
13
|
+
prices: { [asset: string]: number },
|
|
14
|
+
pricesHist: { [asset: string]: number },
|
|
15
|
+
lenderData: any
|
|
16
|
+
): [(data: any[]) => AaveV3UserReserveResponse | undefined, number] => {
|
|
17
|
+
|
|
18
|
+
const assetsToQuery = getAaveAssets(chainId, lender)
|
|
19
|
+
const expectedNumberOfCalls = assetsToQuery.length * 4
|
|
20
|
+
return [
|
|
21
|
+
(data: any[]) => {
|
|
22
|
+
if (data.length !== expectedNumberOfCalls) {
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
const lendingPositions: { [asset: string]: any } = {}
|
|
26
|
+
|
|
27
|
+
let totalDebt24h = 0
|
|
28
|
+
let totalDeposits24h = 0
|
|
29
|
+
|
|
30
|
+
for (let i = 0; i < assetsToQuery.length; i++) {
|
|
31
|
+
const asset = assetsToQuery[i]
|
|
32
|
+
const {
|
|
33
|
+
dataForAsset,
|
|
34
|
+
addedDebt,
|
|
35
|
+
addedDeposits
|
|
36
|
+
} = createAaveV3Entry(
|
|
37
|
+
i,
|
|
38
|
+
data,
|
|
39
|
+
chainId,
|
|
40
|
+
asset,
|
|
41
|
+
prices,
|
|
42
|
+
pricesHist,
|
|
43
|
+
)
|
|
44
|
+
totalDebt24h += addedDebt
|
|
45
|
+
totalDeposits24h += addedDeposits
|
|
46
|
+
lendingPositions[asset] = dataForAsset
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const payload = {
|
|
50
|
+
chainId,
|
|
51
|
+
account,
|
|
52
|
+
lendingPositions: { "0": lendingPositions },
|
|
53
|
+
rewards: {},
|
|
54
|
+
userEMode: 0,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const userData = createBaseTypeUserState(payload, lenderData, totalDeposits24h, totalDebt24h)
|
|
58
|
+
return {
|
|
59
|
+
...payload,
|
|
60
|
+
...userData
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
expectedNumberOfCalls,
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function createAaveV3Entry(
|
|
68
|
+
i: number,
|
|
69
|
+
data: any[],
|
|
70
|
+
chainId: string,
|
|
71
|
+
asset: string,
|
|
72
|
+
prices: any,
|
|
73
|
+
pricesHist: any,
|
|
74
|
+
) {
|
|
75
|
+
const reserveData = data[i * 4]
|
|
76
|
+
|
|
77
|
+
const currentATokenBalanceRaw = reserveData[YldrTypeGetUserReserveIndexes.currentYTokenBalance]?.toString()
|
|
78
|
+
const currentVariableDebtRaw = reserveData[YldrTypeGetUserReserveIndexes.currentVariableDebt]?.toString()
|
|
79
|
+
|
|
80
|
+
const assetMeta = getAssetMeta(chainId, asset)
|
|
81
|
+
const decimals = assetMeta?.decimals ?? 18
|
|
82
|
+
|
|
83
|
+
const currentATokenBalance = parseRawAmount(currentATokenBalanceRaw, decimals)
|
|
84
|
+
const currentVariableDebt = parseRawAmount(currentVariableDebtRaw, decimals)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const key = toOracleKey(assetMeta?.assetGroup) ?? toGenericPriceKey(asset, chainId)
|
|
88
|
+
// prices
|
|
89
|
+
const price = prices[key] ?? 1
|
|
90
|
+
const priceHist = pricesHist?.[key] ?? price
|
|
91
|
+
|
|
92
|
+
const dataForAsset = {
|
|
93
|
+
poolId: asset,
|
|
94
|
+
underlying: asset,
|
|
95
|
+
deposits: currentATokenBalance,
|
|
96
|
+
depositsRaw: currentATokenBalanceRaw,
|
|
97
|
+
debtStable: "0",
|
|
98
|
+
debt: currentVariableDebt,
|
|
99
|
+
depositsUSD: Number(currentATokenBalance) * price,
|
|
100
|
+
debtStableUSD: 0,
|
|
101
|
+
debtUSD: Number(currentVariableDebt) * price,
|
|
102
|
+
stableBorrowRate: 0,
|
|
103
|
+
collateralActive: Boolean(reserveData[YldrTypeGetUserReserveIndexes.usageAsCollateralEnabled]),
|
|
104
|
+
claimableRewards: 0,
|
|
105
|
+
// allowances
|
|
106
|
+
allowanceWithdrawal: data[i * 4 + 1]?.toString(),
|
|
107
|
+
allowanceBorrowingVariable: "0",
|
|
108
|
+
allowanceBorrowingStable: data[i * 4 + 3]?.toString(),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
dataForAsset,
|
|
113
|
+
addedDeposits: Number(currentATokenBalance) * priceHist,
|
|
114
|
+
addedDebt: Number(currentVariableDebt) * priceHist
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Lender } from "@1delta/asset-registry"
|
|
2
|
-
import { isAaveV2Type, isAaveV3Type, isCompoundV3, isInit, isAaveV32Type } from "../../utils"
|
|
2
|
+
import { isAaveV2Type, isAaveV3Type, isCompoundV3, isInit, isAaveV32Type, isYLDR } from "../../utils"
|
|
3
3
|
import { IncentivesControllerAbi } from "../../abis/lendle/IncentivesController"
|
|
4
4
|
import { RewarderAbi } from "../../abis/aurelius/Rewarder"
|
|
5
5
|
import { AavePoolV3UpgradedAbi } from "../../abis/aave/AavePoolV3Upgraded"
|
|
@@ -14,32 +14,37 @@ import { VariableDebtTokenAbi } from "../../abis/aave/VariableDebtToken"
|
|
|
14
14
|
import { MultiFeeDistributionAbi } from "../../abis/lendle/MultiFeeDistribution"
|
|
15
15
|
import { PullRewardsIncentivesController } from "../../abis/meridian/PullRewardsIncentivesController"
|
|
16
16
|
import { CometRewardsAbi } from "../../abis/compound-v3/CometRewards"
|
|
17
|
+
import { YLDRAbi } from "../../abis/aave-v3/YLDR"
|
|
17
18
|
|
|
18
19
|
export const getAbi = (lender: Lender) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
if (isAaveV2Type(lender as any)) return [
|
|
21
|
+
...AavePoolAndDataProviderAbi,
|
|
22
|
+
...VariableDebtTokenAbi,
|
|
23
|
+
...RewarderAbi,
|
|
24
|
+
...PullRewardsIncentivesController,
|
|
25
|
+
...IncentivesControllerAbi,
|
|
26
|
+
...MultiFeeDistributionAbi
|
|
27
|
+
]
|
|
28
|
+
if (isYLDR(lender as any)) return [
|
|
29
|
+
...VariableDebtTokenAbi,
|
|
30
|
+
...YLDRAbi
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
if (isAaveV32Type(lender as any)) return [
|
|
34
|
+
...AavePoolV3UpgradedAbi,
|
|
35
|
+
...AaveV3ProtocolDataProviderAbi
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
if (isAaveV3Type(lender as any)) return [
|
|
39
|
+
...AavePoolLegacyAbi,
|
|
40
|
+
...VariableDebtTokenAbi,
|
|
41
|
+
...AavePoolDataProviderLegacyAbi
|
|
42
|
+
]
|
|
43
|
+
if (isCompoundV3(lender as any)) return [
|
|
44
|
+
...CometAbi,
|
|
45
|
+
...CometExtAbi,
|
|
46
|
+
...CometRewardsAbi,
|
|
47
|
+
]
|
|
48
|
+
if (isInit(lender as any)) return InitLensAbi
|
|
49
|
+
return []
|
|
50
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chain, COMETS_PER_CHAIN_MAP, COMPOUND_BASE_TOKENS, Lender, SWAYLEND_BASE_TOKENS } from "@1delta/asset-registry"
|
|
2
2
|
|
|
3
|
-
export function getCompoundV3CometAddress(chainId: string, lender = Lender.
|
|
3
|
+
export function getCompoundV3CometAddress(chainId: string, lender = Lender.COMPOUND_V3_USDCE): string | undefined {
|
|
4
4
|
return COMETS_PER_CHAIN_MAP[chainId]?.[lender]
|
|
5
5
|
}
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Lender } from "@1delta/asset-registry"
|
|
2
2
|
import { formatUnits } from "viem"
|
|
3
3
|
import { CompoundV3UserReserveResponse, UserLendingPosition, UserRewardEntry } from "../types"
|
|
4
|
-
import { getAssetMeta, getCompoundV3Assets, toOracleKey } from "../../../assets"
|
|
4
|
+
import { getAssetMeta, getCompoundV3Assets, toGenericPriceKey, toOracleKey } from "../../../assets"
|
|
5
5
|
import { getCompoundV3BaseAsset } from "./addresses"
|
|
6
6
|
import { parseRawAmount } from "../../../utils/parsing"
|
|
7
7
|
import { Asset as SupportedAssets } from "@1delta/asset-registry"
|
|
@@ -38,9 +38,10 @@ export const getCompoundV3UserDataConverter = (
|
|
|
38
38
|
const decimals = assetMeta?.decimals ?? 18
|
|
39
39
|
const depositsRaw = data[i][0]?.toString()
|
|
40
40
|
const deposits = parseRawAmount(depositsRaw, decimals)
|
|
41
|
-
const
|
|
41
|
+
const key = toOracleKey(assetMeta?.assetGroup) ?? toGenericPriceKey(assetMeta.baseAsset, chainId)
|
|
42
|
+
const price = prices[key] ?? 1
|
|
42
43
|
|
|
43
|
-
const priceHist = pricesHist?.[
|
|
44
|
+
const priceHist = pricesHist?.[key] ?? price
|
|
44
45
|
|
|
45
46
|
// accure
|
|
46
47
|
totalDeposits24h += Number(deposits) * priceHist
|
|
@@ -67,8 +68,9 @@ export const getCompoundV3UserDataConverter = (
|
|
|
67
68
|
const baseDecimals = baseMeta.decimals ?? 18
|
|
68
69
|
const deposits = parseRawAmount(depositsRaw, baseDecimals)
|
|
69
70
|
const debt = parseRawAmount(debtRaw, baseDecimals)
|
|
70
|
-
const
|
|
71
|
-
const
|
|
71
|
+
const oracleKeyBase = toOracleKey(baseMeta?.assetGroup) ?? toGenericPriceKey(baseMeta.baseAsset, chainId)
|
|
72
|
+
const priceBase = prices[oracleKeyBase]
|
|
73
|
+
const priceBaseHist = pricesHist?.[oracleKeyBase] ?? priceBase
|
|
72
74
|
|
|
73
75
|
// accrue base data
|
|
74
76
|
totalDebt24h += Number(debt) * priceBaseHist
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Call, multicallViemAbiArray } from "../../utils/multicall"
|
|
2
2
|
import { Lender } from "@1delta/asset-registry"
|
|
3
|
-
import { isAaveV2Type, isAaveV3Type, isInit } from "../../utils"
|
|
3
|
+
import { isAaveV2Type, isAaveV3Type, isInit, isYLDR } from "../../utils"
|
|
4
4
|
import { LenderUserQuery } from "./types"
|
|
5
5
|
import { GetEvmClientFunction } from "../../types"
|
|
6
6
|
import { buildAaveV2UserCall } from "./aave-v2-type/userCallBuild"
|
|
@@ -12,6 +12,7 @@ import { getAaveV2UserDataConverter } from "./aave-v2-type/userCallParse"
|
|
|
12
12
|
import { getAaveV3UserDataConverter } from "./aave-v3-type/userCallParse"
|
|
13
13
|
import { getInitUserDataConverter } from "./init/userCallParse"
|
|
14
14
|
import { getCompoundV3UserDataConverter } from "./compound-v3/userCallParse"
|
|
15
|
+
import { getYldrUserDataConverter } from "./aave-v3-type/userCallParseYldr"
|
|
15
16
|
|
|
16
17
|
function buildUserCall(
|
|
17
18
|
chainId: string,
|
|
@@ -32,9 +33,10 @@ function getUserDataConverter(
|
|
|
32
33
|
pricesHist: { [a: string]: number },
|
|
33
34
|
lenderPublicState: any
|
|
34
35
|
) {
|
|
36
|
+
if (isYLDR(lender)) return getYldrUserDataConverter(lender, chainId, account, prices, pricesHist, lenderPublicState)
|
|
35
37
|
if (isAaveV2Type(lender)) return getAaveV2UserDataConverter(lender, chainId, account, prices, pricesHist, lenderPublicState)
|
|
36
38
|
if (isAaveV3Type(lender)) return getAaveV3UserDataConverter(lender, chainId, account, prices, pricesHist, lenderPublicState)
|
|
37
|
-
if (lender
|
|
39
|
+
if (isInit(lender)) return getInitUserDataConverter(lender, chainId, account, prices, pricesHist, lenderPublicState)
|
|
38
40
|
return getCompoundV3UserDataConverter(lender, chainId, account, prices, pricesHist, lenderPublicState)
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -82,24 +82,24 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
82
82
|
"COLEND_LSTBTC": {
|
|
83
83
|
"1116": "0xE48Cd3BBb290b317FC5651b145556A3c821f6a7A",
|
|
84
84
|
},
|
|
85
|
-
"
|
|
85
|
+
"PAC": {
|
|
86
86
|
"81457": "0xAf77325317F109ee21459AFeEDE51b16C231e6b1",
|
|
87
87
|
},
|
|
88
|
-
"
|
|
88
|
+
"AVALON_SOLVBTC": {
|
|
89
89
|
"1": "0x7db0217b628240f583fA8Cb01fb98B79B80e99F1",
|
|
90
90
|
"56": "0xC204f75f22Ec427869aBf80b1b8Cf98e028f7Fc1",
|
|
91
91
|
"34443": "0x90Ad8dCAD1455cD7FacE0f72De8eB5AB5ea1E6E6",
|
|
92
92
|
"167000": "0xde32a52507BA4829fd433BCA44df340d96e1927E",
|
|
93
93
|
"21000000": "0x8d116e023E3751C950C690B3f803cE2904D66783",
|
|
94
94
|
},
|
|
95
|
-
"
|
|
95
|
+
"AVALON_PUMPBTC": {
|
|
96
96
|
"1": "0x1C0F8bfCc56D44d6a6f29b2B986E655D75853e8b",
|
|
97
97
|
"56": "0x16e6B2BdAA245819989425dcA8E70EF4f5C86323",
|
|
98
98
|
"7000": "0x90Ad8dCAD1455cD7FacE0f72De8eB5AB5ea1E6E6",
|
|
99
99
|
"42161": "0x406010dA9450f62339FBF9e0aBBB2cEF6e426918",
|
|
100
100
|
"21000000": "0xDc6b05dA37cEC58F0F31CCeb857503f1df0D0Ad9",
|
|
101
101
|
},
|
|
102
|
-
"
|
|
102
|
+
"AVALON_SWELLBTC": {
|
|
103
103
|
"1": "0x82c3D86Ad6A48204b9e8953a98a5013d8B91D0Ad",
|
|
104
104
|
},
|
|
105
105
|
"AVALON_EBTC_LBTC": {
|
|
@@ -110,7 +110,6 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
110
110
|
"4200": "0x5223FDB92ce3f183AB40215be8b89bcc6a2021E0",
|
|
111
111
|
"4689": "0xcC61B45A0F4C886afaB3be7051ffa1e55314ce30",
|
|
112
112
|
"34443": "0x6f1e7D4cEDc797955417A7f0f6006b5B78D2696c",
|
|
113
|
-
"42161": "0x406010dA9450f62339FBF9e0aBBB2cEF6e426918",
|
|
114
113
|
"60808": "0x89d2E832EDaAfF8C228A57a1602a1f7950Ea2D39",
|
|
115
114
|
"200901": "0x7595DAC82A694cb03bfa4E83a2FEb5Fda55d481d",
|
|
116
115
|
},
|
|
@@ -244,7 +243,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
244
243
|
"8453": "0xe9E53c7d3cF37aeb73e8f9b92bfA6150a7EC6a68",
|
|
245
244
|
"42161": "0x2a61760f0413C7FC9e3120E3d51c961f6bb17452",
|
|
246
245
|
},
|
|
247
|
-
"
|
|
246
|
+
"IRONCLAD": {
|
|
248
247
|
"34443": "0xE4F4F36FcBb2D53c0bAB95F5D117489579553CaA",
|
|
249
248
|
},
|
|
250
249
|
"MOLEND": {
|
|
@@ -273,7 +272,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
273
272
|
"KLAYBANK": {
|
|
274
273
|
"8217": "0x4649B164EA320488c6129A9508D7eb1AD7E10fDC",
|
|
275
274
|
},
|
|
276
|
-
"
|
|
275
|
+
"VALAS": {
|
|
277
276
|
"56": "0x3436c4B4A27B793539844090e271591cbCb0303c",
|
|
278
277
|
},
|
|
279
278
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export const AAVE_V3_2_PROTOCOLS = [
|
|
|
6
6
|
Lender.AAVE_V3,
|
|
7
7
|
Lender.AAVE_V3_ETHER_FI,
|
|
8
8
|
Lender.AAVE_V3_PRIME,
|
|
9
|
-
|
|
9
|
+
]
|
|
10
10
|
|
|
11
11
|
export function isAaveV3Type(lender: string) { return AAVE_V3_LENDERS.includes(lender as any) }
|
|
12
12
|
|
|
@@ -15,6 +15,8 @@ export function isAaveV3Original(lender: string) { return lender.startsWith(AAVE
|
|
|
15
15
|
|
|
16
16
|
export function isAaveV2Type(lender: string) { return AAVE_V2_LENDERS.includes(lender as any) }
|
|
17
17
|
|
|
18
|
+
export function isYLDR(lender: string) { return lender === Lender.YLDR }
|
|
19
|
+
|
|
18
20
|
export function isAaveV32Type(lender: Lender) { return AAVE_V3_2_PROTOCOLS.includes(lender) }
|
|
19
21
|
|
|
20
22
|
export function isAaveType(lender: string) { return [...AAVE_V3_LENDERS, ...AAVE_V2_LENDERS].includes(lender as any) }
|
|
@@ -77,11 +79,11 @@ export const getComposerAddress = (chainId: string): string => {
|
|
|
77
79
|
export const getLenderAssets = (
|
|
78
80
|
chainId: string | number | undefined,
|
|
79
81
|
lendingProtocol = Lender.AAVE_V3
|
|
80
|
-
|
|
82
|
+
): string[] => {
|
|
81
83
|
if (!chainId) return []
|
|
82
84
|
if (isAaveType(lendingProtocol)) return AAVE_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
83
85
|
if (isCompoundV3(lendingProtocol)) return COMPOUND_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
84
86
|
if (isInit(lendingProtocol)) return INIT_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
85
87
|
if (isSwaylend(lendingProtocol)) return SWAYLEND_RESERVE_ASSETS[lendingProtocol]?.[chainId ?? 0] ?? []
|
|
86
88
|
return []
|
|
87
|
-
|
|
89
|
+
}
|
package/src/utils/parsing.ts
CHANGED
|
@@ -46,7 +46,7 @@ export const formatAaveYieldToNumber = (n?: string | bigint): number => {
|
|
|
46
46
|
export const calculateRateForCompound = (
|
|
47
47
|
n: string,
|
|
48
48
|
chainId: string,
|
|
49
|
-
lender = Lender.
|
|
49
|
+
lender = Lender.COMPOUND_V3_USDCE,
|
|
50
50
|
): number => {
|
|
51
51
|
let scale = TimeScale.MS
|
|
52
52
|
if (isCompoundV3(lender) || Lender.COMPOUND_V2) {
|
package/test/lenderData.test.ts
CHANGED
package/test/userdata.test.ts
CHANGED
|
@@ -62,6 +62,26 @@ describe(
|
|
|
62
62
|
]);
|
|
63
63
|
}, 30000);
|
|
64
64
|
|
|
65
|
+
|
|
66
|
+
it(
|
|
67
|
+
"should fetch user data for YLDR on Polygon",
|
|
68
|
+
async () => {
|
|
69
|
+
try {
|
|
70
|
+
const { userData } = await getUserData(Chain.POLYGON_MAINNET, [Lender.YLDR]);
|
|
71
|
+
|
|
72
|
+
console.log("YLSE Polygon user data:", userData);
|
|
73
|
+
|
|
74
|
+
// Basic validation
|
|
75
|
+
expect(userData).toBeDefined();
|
|
76
|
+
expect(typeof userData).toBe("object");
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.log("Error fetching YLSE Polygon data:", error);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{ timeout: 30000 }
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
|
|
65
85
|
it(
|
|
66
86
|
"should fetch user data for AAVE V3 on Base",
|
|
67
87
|
async () => {
|
|
@@ -86,7 +106,7 @@ describe(
|
|
|
86
106
|
try {
|
|
87
107
|
const { userData, queries } = await getUserData(
|
|
88
108
|
Chain.ARBITRUM_ONE,
|
|
89
|
-
[Lender.AAVE_V3, Lender.COMPOUND_V3_USDC, Lender.
|
|
109
|
+
[Lender.AAVE_V3, Lender.COMPOUND_V3_USDC, Lender.COMPOUND_V3_USDCE]
|
|
90
110
|
);
|
|
91
111
|
|
|
92
112
|
console.log("Arbitrum multi-protocol user data:", userData);
|