@defisaver/positions-sdk 2.1.42 → 2.1.43-aave-v4-dev-1
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/aaveV4/index.d.ts +7 -0
- package/cjs/aaveV4/index.js +99 -0
- package/cjs/config/contracts.d.ts +1069 -0
- package/cjs/config/contracts.js +9 -0
- package/cjs/contracts.d.ts +18265 -0
- package/cjs/contracts.js +2 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/aaveV4/index.d.ts +6 -0
- package/cjs/markets/aaveV4/index.js +20 -0
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/savings/morphoVaults/options.js +1 -1
- package/cjs/types/aaveV4.d.ts +73 -0
- package/cjs/types/aaveV4.js +11 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/esm/aaveV4/index.d.ts +7 -0
- package/esm/aaveV4/index.js +90 -0
- package/esm/config/contracts.d.ts +1069 -0
- package/esm/config/contracts.js +8 -0
- package/esm/contracts.d.ts +18265 -0
- package/esm/contracts.js +1 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/aaveV4/index.d.ts +6 -0
- package/esm/markets/aaveV4/index.js +15 -0
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/savings/morphoVaults/options.js +1 -1
- package/esm/types/aaveV4.d.ts +73 -0
- package/esm/types/aaveV4.js +8 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/package.json +2 -2
- package/src/aaveV4/index.ts +90 -0
- package/src/config/contracts.ts +8 -0
- package/src/contracts.ts +3 -1
- package/src/index.ts +2 -0
- package/src/markets/aaveV4/index.ts +17 -0
- package/src/markets/index.ts +1 -0
- package/src/savings/morphoVaults/options.ts +1 -1
- package/src/types/aaveV4.ts +81 -0
- package/src/types/index.ts +2 -1
package/esm/contracts.js
CHANGED
|
@@ -132,3 +132,4 @@ export const StkAAVEViem = createViemContractFromConfigFunc('StkAAVE');
|
|
|
132
132
|
export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView');
|
|
133
133
|
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
134
134
|
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
135
|
+
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
import * as fluid from './fluid';
|
|
3
|
+
import * as aaveV4 from './aaveV4';
|
|
3
4
|
import * as aaveV3 from './aaveV3';
|
|
4
5
|
import * as aaveV2 from './aaveV2';
|
|
5
6
|
import * as compoundV3 from './compoundV3';
|
|
@@ -21,4 +22,4 @@ import * as portfolio from './portfolio';
|
|
|
21
22
|
import * as claiming from './claiming';
|
|
22
23
|
import * as savings from './savings';
|
|
23
24
|
export * from './types';
|
|
24
|
-
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
|
25
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
import * as fluid from './fluid';
|
|
3
|
+
import * as aaveV4 from './aaveV4';
|
|
3
4
|
import * as aaveV3 from './aaveV3';
|
|
4
5
|
import * as aaveV2 from './aaveV2';
|
|
5
6
|
import * as compoundV3 from './compoundV3';
|
|
@@ -21,4 +22,4 @@ import * as portfolio from './portfolio';
|
|
|
21
22
|
import * as claiming from './claiming';
|
|
22
23
|
import * as savings from './savings';
|
|
23
24
|
export * from './types';
|
|
24
|
-
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
|
25
|
+
export { aaveV2, aaveV3, aaveV4, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, savings, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AaveV4SpokeInfo } from '../../types';
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
4
|
+
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
5
|
+
readonly aave_v4_core_spoke: AaveV4SpokeInfo;
|
|
6
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AaveV4SpokesType } from '../../types';
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
export const AAVE_V4_CORE_SPOKE = (networkId) => ({
|
|
4
|
+
chainIds: [NetworkNumber.Eth],
|
|
5
|
+
label: 'Core Spoke',
|
|
6
|
+
value: AaveV4SpokesType.AaveV4CoreSpoke,
|
|
7
|
+
url: 'core',
|
|
8
|
+
address: '0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC',
|
|
9
|
+
hubs: [
|
|
10
|
+
'0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
11
|
+
],
|
|
12
|
+
});
|
|
13
|
+
export const AaveV4Spokes = (networkId) => ({
|
|
14
|
+
[AaveV4SpokesType.AaveV4CoreSpoke]: AAVE_V4_CORE_SPOKE(networkId),
|
|
15
|
+
});
|
package/esm/markets/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { LlamaLendMarkets } from './llamaLend';
|
|
|
7
7
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
8
8
|
export { EulerV2Markets } from './euler';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
|
+
export { AaveV4Spokes } from './aaveV4';
|
package/esm/markets/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { LlamaLendMarkets } from './llamaLend';
|
|
|
7
7
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
8
8
|
export { EulerV2Markets } from './euler';
|
|
9
9
|
export { FluidMarkets, getFluidVersionsDataForNetwork, getFluidMarketInfoById, getFTokenAddress, getFluidMarketInfoByAddress, } from './fluid';
|
|
10
|
+
export { AaveV4Spokes } from './aaveV4';
|
|
@@ -115,7 +115,7 @@ export const MORPHO_VAULT_STEAKHOUSE_ETH = {
|
|
|
115
115
|
export const MORPHO_VAULT_STEAKHOUSE_PYUSD = {
|
|
116
116
|
type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
117
117
|
name: 'Steakhouse PYUSD',
|
|
118
|
-
address: '
|
|
118
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
119
119
|
asset: 'PYUSD',
|
|
120
120
|
deploymentBlock: 19043398,
|
|
121
121
|
isLegacy: false,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EthAddress, NetworkNumber } from './common';
|
|
2
|
+
export declare enum AaveV4SpokesType {
|
|
3
|
+
AaveV4CoreSpoke = "aave_v4_core_spoke"
|
|
4
|
+
}
|
|
5
|
+
export declare enum AaveV4HubsType {
|
|
6
|
+
AaveV4CoreHub = "aave_v4_core_hub"
|
|
7
|
+
}
|
|
8
|
+
export interface AaveV4SpokeInfo {
|
|
9
|
+
chainIds: NetworkNumber[];
|
|
10
|
+
label: string;
|
|
11
|
+
value: AaveV4SpokesType;
|
|
12
|
+
url: string;
|
|
13
|
+
address: EthAddress;
|
|
14
|
+
hubs: EthAddress[];
|
|
15
|
+
}
|
|
16
|
+
export interface AaveV4HubAssetOnChainData {
|
|
17
|
+
assetId: number;
|
|
18
|
+
drawnRate: bigint;
|
|
19
|
+
}
|
|
20
|
+
export interface AaveV4HubOnChainData {
|
|
21
|
+
assets: Record<number, AaveV4HubAssetOnChainData>;
|
|
22
|
+
}
|
|
23
|
+
export interface AaveV4ReserveAssetOnChain {
|
|
24
|
+
underlying: EthAddress;
|
|
25
|
+
hub: EthAddress;
|
|
26
|
+
assetId: number;
|
|
27
|
+
decimals: number;
|
|
28
|
+
paused: boolean;
|
|
29
|
+
frozen: boolean;
|
|
30
|
+
borrowable: boolean;
|
|
31
|
+
collateralRisk: number;
|
|
32
|
+
collateralFactor: number;
|
|
33
|
+
maxLiquidationBonus: number;
|
|
34
|
+
liquidationFee: number;
|
|
35
|
+
price: bigint;
|
|
36
|
+
totalSupplied: bigint;
|
|
37
|
+
totalDrawn: bigint;
|
|
38
|
+
totalPremium: bigint;
|
|
39
|
+
totalDebt: bigint;
|
|
40
|
+
supplyCap: bigint;
|
|
41
|
+
borrowCap: bigint;
|
|
42
|
+
deficitRay: bigint;
|
|
43
|
+
spokeActive: boolean;
|
|
44
|
+
spokePaused: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface AaveV4ReserveAssetData {
|
|
47
|
+
symbol: string;
|
|
48
|
+
underlying: EthAddress;
|
|
49
|
+
hub: EthAddress;
|
|
50
|
+
assetId: number;
|
|
51
|
+
paused: boolean;
|
|
52
|
+
frozen: boolean;
|
|
53
|
+
borrowable: boolean;
|
|
54
|
+
collateralRisk: number;
|
|
55
|
+
collateralFactor: number;
|
|
56
|
+
liquidationFee: number;
|
|
57
|
+
price: string;
|
|
58
|
+
totalSupplied: string;
|
|
59
|
+
totalDrawn: string;
|
|
60
|
+
totalPremium: string;
|
|
61
|
+
totalDebt: string;
|
|
62
|
+
supplyCap: string;
|
|
63
|
+
borrowCap: string;
|
|
64
|
+
spokeActive: boolean;
|
|
65
|
+
spokePaused: boolean;
|
|
66
|
+
drawnRate: string;
|
|
67
|
+
}
|
|
68
|
+
export interface AaveV4SpokeData {
|
|
69
|
+
assetsData: Record<string, AaveV4ReserveAssetData>;
|
|
70
|
+
oracle: EthAddress;
|
|
71
|
+
oracleDecimals: number;
|
|
72
|
+
address: EthAddress;
|
|
73
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var AaveV4SpokesType;
|
|
2
|
+
(function (AaveV4SpokesType) {
|
|
3
|
+
AaveV4SpokesType["AaveV4CoreSpoke"] = "aave_v4_core_spoke";
|
|
4
|
+
})(AaveV4SpokesType || (AaveV4SpokesType = {}));
|
|
5
|
+
export var AaveV4HubsType;
|
|
6
|
+
(function (AaveV4HubsType) {
|
|
7
|
+
AaveV4HubsType["AaveV4CoreHub"] = "aave_v4_core_hub";
|
|
8
|
+
})(AaveV4HubsType || (AaveV4HubsType = {}));
|
package/esm/types/index.d.ts
CHANGED
package/esm/types/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.43-aave-v4-dev-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dev": "tsc -p tsconfig.json --watch",
|
|
13
13
|
"lint": "eslint src/ --fix",
|
|
14
14
|
"lint-check": "eslint src/",
|
|
15
|
-
"test": "mocha tests
|
|
15
|
+
"test": "mocha tests/aaveV4.ts",
|
|
16
16
|
"test-single": "mocha ./tests/$npm_config_name.ts",
|
|
17
17
|
"test:debugger": "mocha --inspect-brk tests/*",
|
|
18
18
|
"version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import Dec from 'decimal.js';
|
|
3
|
+
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
4
|
+
import { getViemProvider } from '../services/viem';
|
|
5
|
+
import {
|
|
6
|
+
AaveV4HubAssetOnChainData,
|
|
7
|
+
AaveV4HubOnChainData,
|
|
8
|
+
AaveV4ReserveAssetData, AaveV4ReserveAssetOnChain, AaveV4SpokeData, AaveV4SpokeInfo,
|
|
9
|
+
} from '../types';
|
|
10
|
+
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
11
|
+
import { AaveV4ViewContractViem } from '../contracts';
|
|
12
|
+
|
|
13
|
+
const fetchHubData = async (viewContract: ReturnType<typeof AaveV4ViewContractViem>, hubAddress: EthAddress): Promise<AaveV4HubOnChainData> => {
|
|
14
|
+
const hubData = await viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
15
|
+
console.log('hubData', hubData);
|
|
16
|
+
return {
|
|
17
|
+
assets: hubData.reduce((acc: Record<number, AaveV4HubAssetOnChainData>, assetOnChainData) => {
|
|
18
|
+
acc[assetOnChainData.assetId] = {
|
|
19
|
+
assetId: assetOnChainData.assetId,
|
|
20
|
+
drawnRate: assetOnChainData.drawnRate,
|
|
21
|
+
};
|
|
22
|
+
return acc;
|
|
23
|
+
}, {}),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const formatReserveAsset = (reserveAsset: AaveV4ReserveAssetOnChain, hubAsset: AaveV4HubAssetOnChainData, oracleDecimals: number): AaveV4ReserveAssetData => {
|
|
28
|
+
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying);
|
|
29
|
+
return ({
|
|
30
|
+
symbol: assetInfo.symbol,
|
|
31
|
+
underlying: reserveAsset.underlying,
|
|
32
|
+
hub: reserveAsset.hub,
|
|
33
|
+
assetId: reserveAsset.assetId,
|
|
34
|
+
paused: reserveAsset.paused,
|
|
35
|
+
frozen: reserveAsset.frozen,
|
|
36
|
+
borrowable: reserveAsset.borrowable,
|
|
37
|
+
collateralRisk: new Dec(reserveAsset.collateralRisk).div(10000).toNumber(),
|
|
38
|
+
collateralFactor: new Dec(reserveAsset.collateralFactor).div(10000).toNumber(),
|
|
39
|
+
liquidationFee: new Dec(reserveAsset.liquidationFee).div(10000).toNumber(),
|
|
40
|
+
price: new Dec(reserveAsset.price).div(new Dec(10).pow(oracleDecimals)).toString(),
|
|
41
|
+
totalSupplied: assetAmountInEth(reserveAsset.totalSupplied.toString(), assetInfo.symbol),
|
|
42
|
+
totalDrawn: assetAmountInEth(reserveAsset.totalDrawn.toString(), assetInfo.symbol),
|
|
43
|
+
totalPremium: assetAmountInEth(reserveAsset.totalPremium.toString(), assetInfo.symbol),
|
|
44
|
+
totalDebt: assetAmountInEth(reserveAsset.totalDebt.toString(), assetInfo.symbol),
|
|
45
|
+
supplyCap: assetAmountInEth(reserveAsset.supplyCap.toString(), assetInfo.symbol),
|
|
46
|
+
borrowCap: assetAmountInEth(reserveAsset.borrowCap.toString(), assetInfo.symbol),
|
|
47
|
+
spokeActive: reserveAsset.spokeActive,
|
|
48
|
+
spokePaused: reserveAsset.spokePaused,
|
|
49
|
+
drawnRate: new Dec(hubAsset.drawnRate).div(new Dec(10).pow(27)).toString(),
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export async function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
54
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
55
|
+
|
|
56
|
+
const hubsData: Record<EthAddress, AaveV4HubOnChainData> = {};
|
|
57
|
+
const [spokeData] = await Promise.all([
|
|
58
|
+
viewContract.read.getSpokeDataFull([market.address]),
|
|
59
|
+
...market.hubs.map(async (hubAddress) => {
|
|
60
|
+
hubsData[hubAddress] = await fetchHubData(viewContract, hubAddress);
|
|
61
|
+
}),
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
const reserveAssetsArray = spokeData[1].map((reserveAssetOnChain: AaveV4ReserveAssetOnChain) => formatReserveAsset(reserveAssetOnChain, hubsData[reserveAssetOnChain.hub].assets[reserveAssetOnChain.assetId], +spokeData[0].oracleDecimals.toString()));
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
assetsData: reserveAssetsArray.reduce((acc: Record<string, AaveV4ReserveAssetData>, reserveAsset: AaveV4ReserveAssetData) => {
|
|
68
|
+
acc[reserveAsset.symbol] = reserveAsset;
|
|
69
|
+
return acc;
|
|
70
|
+
}, {}),
|
|
71
|
+
oracle: spokeData[0].oracle,
|
|
72
|
+
oracleDecimals: +spokeData[0].oracleDecimals.toString(),
|
|
73
|
+
address: market.address,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
78
|
+
return _getAaveV4SpokeData(getViemProvider(provider, network), network, spoke, blockNumber);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function _getAaveV4AccountData(provider: Client, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<any> {
|
|
82
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
83
|
+
|
|
84
|
+
const loanData = await viewContract.read.getLoanData([marketData.address, address]);
|
|
85
|
+
console.log('loanData', loanData);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<any> {
|
|
89
|
+
return _getAaveV4AccountData(getViemProvider(provider, network), network, marketData, address, blockNumber);
|
|
90
|
+
}
|
package/src/config/contracts.ts
CHANGED
|
@@ -1293,4 +1293,12 @@ export const SkySavings = {
|
|
|
1293
1293
|
} as const;
|
|
1294
1294
|
export const YearnV3Vault = {
|
|
1295
1295
|
"abi": [{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"addr","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalAssets","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalDebt","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]
|
|
1296
|
+
} as const;
|
|
1297
|
+
export const AaveV4View = {
|
|
1298
|
+
"abi": [{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getHealthFactor","outputs":[{"internalType":"uint256","name":"healthFactor","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"}],"name":"getHubAllAssetsData","outputs":[{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"swept","type":"uint256"},{"internalType":"uint16","name":"liquidityFee","type":"uint16"},{"internalType":"uint120","name":"drawnIndex","type":"uint120"},{"internalType":"uint96","name":"drawnRate","type":"uint96"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"},{"internalType":"address","name":"irStrategy","type":"address"},{"internalType":"address","name":"reinvestmentController","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"uint256","name":"deficitRay","type":"uint256"}],"internalType":"structAaveV4View.HubAssetData[]","name":"hubAssetData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"},{"internalType":"uint256","name":"_assetId","type":"uint256"}],"name":"getHubAssetData","outputs":[{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"swept","type":"uint256"},{"internalType":"uint16","name":"liquidityFee","type":"uint16"},{"internalType":"uint120","name":"drawnIndex","type":"uint120"},{"internalType":"uint96","name":"drawnRate","type":"uint96"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"},{"internalType":"address","name":"irStrategy","type":"address"},{"internalType":"address","name":"reinvestmentController","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"uint256","name":"deficitRay","type":"uint256"}],"internalType":"structAaveV4View.HubAssetData","name":"hubAssetData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getLoanData","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsd","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowedCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"structAaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"structAaveV4View.LoanData","name":"loanData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address[]","name":"_spokes","type":"address[]"}],"name":"getLoanDataForMultipleSpokes","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsd","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowedCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"structAaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"structAaveV4View.LoanData[]","name":"loans","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"getLoanDataForMultipleUsers","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsd","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowedCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"structAaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"structAaveV4View.LoanData[]","name":"loans","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReserveData","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"structAaveV4View.ReserveData","name":"reserveData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReserveDataFull","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokePaused","type":"bool"}],"internalType":"structAaveV4View.ReserveDataFull","name":"reserveData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReservePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservePrices","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservesData","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"structAaveV4View.ReserveData[]","name":"reserveData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservesDataFull","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokePaused","type":"bool"}],"internalType":"structAaveV4View.ReserveDataFull[]","name":"reserveData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"}],"name":"getSpokeData","outputs":[{"components":[{"internalType":"uint128","name":"targetHealthFactor","type":"uint128"},{"internalType":"uint64","name":"healthFactorForMaxBonus","type":"uint64"},{"internalType":"uint16","name":"liquidationBonusFactor","type":"uint16"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint256","name":"oracleDecimals","type":"uint256"},{"internalType":"uint256","name":"reserveCount","type":"uint256"}],"internalType":"structAaveV4View.SpokeData","name":"spokeData","type":"tuple"},{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"structAaveV4View.ReserveData[]","name":"reserves","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"}],"name":"getSpokeDataFull","outputs":[{"components":[{"internalType":"uint128","name":"targetHealthFactor","type":"uint128"},{"internalType":"uint64","name":"healthFactorForMaxBonus","type":"uint64"},{"internalType":"uint16","name":"liquidationBonusFactor","type":"uint16"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint256","name":"oracleDecimals","type":"uint256"},{"internalType":"uint256","name":"reserveCount","type":"uint256"}],"internalType":"structAaveV4View.SpokeData","name":"spokeData","type":"tuple"},{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokePaused","type":"bool"}],"internalType":"structAaveV4View.ReserveDataFull[]","name":"reserves","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"},{"internalType":"uint256","name":"_assetId","type":"uint256"}],"name":"getSpokesForAsset","outputs":[{"internalType":"address[]","name":"spokes","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getUserReserveData","outputs":[{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"structAaveV4View.UserReserveData[]","name":"_userReserves","type":"tuple[]"}],"stateMutability":"view","type":"function"}],
|
|
1299
|
+
"networks": {
|
|
1300
|
+
"1": {
|
|
1301
|
+
"address": "0xBFB1DD9f9609CDeD2E2FdA78611512783A113079",
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1296
1304
|
} as const;
|
package/src/contracts.ts
CHANGED
|
@@ -169,4 +169,6 @@ export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView
|
|
|
169
169
|
|
|
170
170
|
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
171
171
|
|
|
172
|
-
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
172
|
+
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
173
|
+
|
|
174
|
+
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './setup';
|
|
2
2
|
|
|
3
3
|
import * as fluid from './fluid';
|
|
4
|
+
import * as aaveV4 from './aaveV4';
|
|
4
5
|
import * as aaveV3 from './aaveV3';
|
|
5
6
|
import * as aaveV2 from './aaveV2';
|
|
6
7
|
import * as compoundV3 from './compoundV3';
|
|
@@ -27,6 +28,7 @@ export * from './types';
|
|
|
27
28
|
export {
|
|
28
29
|
aaveV2,
|
|
29
30
|
aaveV3,
|
|
31
|
+
aaveV4,
|
|
30
32
|
compoundV2,
|
|
31
33
|
compoundV3,
|
|
32
34
|
spark,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
|
|
4
|
+
export const AAVE_V4_CORE_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
5
|
+
chainIds: [NetworkNumber.Eth],
|
|
6
|
+
label: 'Core Spoke',
|
|
7
|
+
value: AaveV4SpokesType.AaveV4CoreSpoke,
|
|
8
|
+
url: 'core',
|
|
9
|
+
address: '0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC',
|
|
10
|
+
hubs: [
|
|
11
|
+
'0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const AaveV4Spokes = (networkId: NetworkNumber) => ({
|
|
16
|
+
[AaveV4SpokesType.AaveV4CoreSpoke]: AAVE_V4_CORE_SPOKE(networkId),
|
|
17
|
+
}) as const;
|
package/src/markets/index.ts
CHANGED
|
@@ -131,7 +131,7 @@ export const MORPHO_VAULT_STEAKHOUSE_ETH: MorphoVault = {
|
|
|
131
131
|
export const MORPHO_VAULT_STEAKHOUSE_PYUSD: MorphoVault = {
|
|
132
132
|
type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
133
133
|
name: 'Steakhouse PYUSD',
|
|
134
|
-
address: '
|
|
134
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
135
135
|
asset: 'PYUSD',
|
|
136
136
|
deploymentBlock: 19043398,
|
|
137
137
|
isLegacy: false,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EthAddress, NetworkNumber } from './common';
|
|
2
|
+
|
|
3
|
+
export enum AaveV4SpokesType {
|
|
4
|
+
AaveV4CoreSpoke = 'aave_v4_core_spoke',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum AaveV4HubsType {
|
|
8
|
+
AaveV4CoreHub = 'aave_v4_core_hub',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AaveV4SpokeInfo {
|
|
12
|
+
chainIds: NetworkNumber[],
|
|
13
|
+
label: string,
|
|
14
|
+
value: AaveV4SpokesType,
|
|
15
|
+
url: string,
|
|
16
|
+
address: EthAddress,
|
|
17
|
+
hubs: EthAddress[],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AaveV4HubAssetOnChainData {
|
|
21
|
+
assetId: number,
|
|
22
|
+
drawnRate: bigint,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AaveV4HubOnChainData {
|
|
26
|
+
assets: Record<number, AaveV4HubAssetOnChainData>,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AaveV4ReserveAssetOnChain {
|
|
30
|
+
underlying: EthAddress,
|
|
31
|
+
hub: EthAddress,
|
|
32
|
+
assetId: number,
|
|
33
|
+
decimals: number,
|
|
34
|
+
paused: boolean,
|
|
35
|
+
frozen: boolean,
|
|
36
|
+
borrowable: boolean,
|
|
37
|
+
collateralRisk: number,
|
|
38
|
+
collateralFactor: number,
|
|
39
|
+
maxLiquidationBonus: number,
|
|
40
|
+
liquidationFee: number,
|
|
41
|
+
price: bigint,
|
|
42
|
+
totalSupplied: bigint,
|
|
43
|
+
totalDrawn: bigint,
|
|
44
|
+
totalPremium: bigint,
|
|
45
|
+
totalDebt: bigint,
|
|
46
|
+
supplyCap: bigint,
|
|
47
|
+
borrowCap: bigint,
|
|
48
|
+
deficitRay: bigint,
|
|
49
|
+
spokeActive: boolean,
|
|
50
|
+
spokePaused: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface AaveV4ReserveAssetData {
|
|
54
|
+
symbol: string,
|
|
55
|
+
underlying: EthAddress,
|
|
56
|
+
hub: EthAddress,
|
|
57
|
+
assetId: number,
|
|
58
|
+
paused: boolean,
|
|
59
|
+
frozen: boolean,
|
|
60
|
+
borrowable: boolean,
|
|
61
|
+
collateralRisk: number,
|
|
62
|
+
collateralFactor: number,
|
|
63
|
+
liquidationFee: number,
|
|
64
|
+
price: string,
|
|
65
|
+
totalSupplied: string,
|
|
66
|
+
totalDrawn: string,
|
|
67
|
+
totalPremium: string,
|
|
68
|
+
totalDebt: string,
|
|
69
|
+
supplyCap: string,
|
|
70
|
+
borrowCap: string,
|
|
71
|
+
spokeActive: boolean,
|
|
72
|
+
spokePaused: boolean,
|
|
73
|
+
drawnRate: string,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface AaveV4SpokeData {
|
|
77
|
+
assetsData: Record<string, AaveV4ReserveAssetData>,
|
|
78
|
+
oracle: EthAddress,
|
|
79
|
+
oracleDecimals: number,
|
|
80
|
+
address: EthAddress,
|
|
81
|
+
}
|
package/src/types/index.ts
CHANGED