This commit is contained in:
Georges KABBOUCHI 2021-11-04 01:48:11 +02:00
parent 9ce71fd6b7
commit f7c28366de
2 changed files with 189 additions and 207 deletions

View File

@ -1,215 +1,196 @@
[ [
{ {
"inputs": [ "type": "function",
"stateMutability": "view",
"outputs": [
{ {
"internalType": "address", "type": "tuple[]",
"name": "user", "name": "",
"type": "address" "internalType": "struct AaveHelpers.AaveUserTokenData[]",
"components": [
{
"type": "uint256",
"name": "tokenPriceInEth",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "tokenPriceInUsd",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "supplyBalance",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "stableBorrowBalance",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "variableBorrowBalance",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "supplyRate",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "stableBorrowRate",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "userStableBorrowRate",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "variableBorrowRate",
"internalType": "uint256"
},
{ "type": "bool", "name": "isCollateral", "internalType": "bool" },
{
"type": "tuple",
"name": "aaveTokenData",
"internalType": "struct AaveHelpers.AaveTokenData",
"components": [
{ "type": "uint256", "name": "ltv", "internalType": "uint256" },
{
"type": "uint256",
"name": "threshold",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "reserveFactor",
"internalType": "uint256"
},
{
"type": "bool",
"name": "usageAsCollEnabled",
"internalType": "bool"
},
{
"type": "bool",
"name": "borrowEnabled",
"internalType": "bool"
},
{
"type": "bool",
"name": "stableBorrowEnabled",
"internalType": "bool"
},
{ "type": "bool", "name": "isActive", "internalType": "bool" },
{ "type": "bool", "name": "isFrozen", "internalType": "bool" },
{
"type": "uint256",
"name": "totalSupply",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "availableLiquidity",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "totalStableDebt",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "totalVariableDebt",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "collateralEmission",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "debtEmission",
"internalType": "uint256"
},
{
"type": "address",
"name": "aTokenAddress",
"internalType": "address"
},
{
"type": "address",
"name": "stableDebtTokenAddress",
"internalType": "address"
},
{
"type": "address",
"name": "variableDebtTokenAddress",
"internalType": "address"
}
]
}
]
}, },
{ {
"internalType": "address[]", "type": "tuple",
"name": "tokens", "name": "",
"type": "address[]" "internalType": "struct AaveHelpers.AaveUserData",
"components": [
{
"type": "uint256",
"name": "totalCollateralETH",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "totalBorrowsETH",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "availableBorrowsETH",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "currentLiquidationThreshold",
"internalType": "uint256"
},
{ "type": "uint256", "name": "ltv", "internalType": "uint256" },
{
"type": "uint256",
"name": "healthFactor",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "ethPriceInUsd",
"internalType": "uint256"
},
{
"type": "uint256",
"name": "pendingRewards",
"internalType": "uint256"
}
]
} }
], ],
"name": "getPosition", "name": "getPosition",
"outputs": [ "inputs": [
{ { "type": "address", "name": "user", "internalType": "address" },
"components": [ { "type": "address[]", "name": "tokens", "internalType": "address[]" }
{ ]
"internalType": "uint256",
"name": "tokenPriceInEth",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenPriceInUsd",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "supplyBalance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "stableBorrowBalance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "variableBorrowBalance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "supplyRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "stableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "userStableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "variableBorrowRate",
"type": "uint256"
},
{
"internalType": "bool",
"name": "isCollateral",
"type": "bool"
},
{
"components": [
{
"internalType": "uint256",
"name": "ltv",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "threshold",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserveFactor",
"type": "uint256"
},
{
"internalType": "bool",
"name": "usageAsCollEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "borrowEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "stableBorrowEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
},
{
"internalType": "bool",
"name": "isFrozen",
"type": "bool"
},
{
"internalType": "uint256",
"name": "totalSupply",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "availableLiquidity",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalStableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalVariableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "collateralEmission",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "debtEmission",
"type": "uint256"
}
],
"internalType": "struct AaveHelpers.AaveTokenData",
"name": "aaveTokenData",
"type": "tuple"
}
],
"internalType": "struct AaveHelpers.AaveUserTokenData[]",
"name": "",
"type": "tuple[]"
},
{
"components": [
{
"internalType": "uint256",
"name": "totalCollateralETH",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalBorrowsETH",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "availableBorrowsETH",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "currentLiquidationThreshold",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "ltv",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "healthFactor",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "ethPriceInUsd",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "pendingRewards",
"type": "uint256"
}
],
"internalType": "struct AaveHelpers.AaveUserData",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
}, },
{ {
"inputs": [], "type": "function",
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view", "stateMutability": "view",
"type": "function" "outputs": [{ "type": "string", "name": "", "internalType": "string" }],
"name": "name",
"inputs": []
} }
] ]

View File

@ -13,6 +13,7 @@ import { usePosition } from "~/composables/usePosition";
import { useToken } from "~/composables/useToken"; import { useToken } from "~/composables/useToken";
import { useSorting } from "~/composables/useSorting"; import { useSorting } from "~/composables/useSorting";
import useEventBus from "../useEventBus"; import useEventBus from "../useEventBus";
import addresses from "~/constant/addresses";
const { const {
times, times,
@ -73,10 +74,10 @@ export function useAaveV2Position(
const { byMaxSupplyOrBorrowDesc } = useSorting(); const { byMaxSupplyOrBorrowDesc } = useSorting();
const { onEvent } = useEventBus(); const { onEvent } = useEventBus();
const resolver = computed(() => const resolver = computed(
chainId.value === 1 () =>
? "0xFb3a1D56eD56F046721B9aCa749895100754578b" // @ts-ignore
: "0xD6E0803d0eB34af8Ea135835512D7E77960b28F1" addresses[activeNetworkId.value]?.resolver?.aave_v2
); );
const fetchPosition = async () => { const fetchPosition = async () => {
@ -398,7 +399,7 @@ function calculateAavePosition(res: any[], network: Network = Network.Mainnet) {
debtEmission, debtEmission,
aTokenAddress, aTokenAddress,
stableDebtTokenAddress, stableDebtTokenAddress,
variableDebtTokenAddress, variableDebtTokenAddress
] = AaveTokenData; ] = AaveTokenData;
/* eslint-enable no-unused-vars */ /* eslint-enable no-unused-vars */