ProtocolDataProvider
该合约的目的是帮助集成商和开发人员更轻松的利用 Aave 协议的数据和功能。
每个市场都有一个单独的协议数据提供商。要获取特定市场的地址,请使用值 0x1
调用getAddress()
Methods
getAllReservesTokens()
function getAllReservesTokens()
返回当前市场所有储备代币的数组,其形式为 TokenData 结构体,由代币符号和代币地址组成。
返回值
类型 | 描述 |
---|---|
TokenData[] |
有字符串类型的符号symbol 和地址类型的 tokenAddress 组成的结构体 |
getAllTokens()
function getAllTokens()
返回当前市场的所有 aToken 的数组,以 TokenData 结构体的形式返回,该结构体由 Token symbol 和 Token address 组成。
返回值
类型 | 描述 |
---|---|
TokenData[] |
一个结构体,由 string 类型的 symbol 和 address 类型的 tokenAddress 组成。 |
getReserveConfigurationData()
function getReserveConfigurationData(address asset)
返回asset
的配置数据
返回值
类型 | 描述 |
---|---|
uint256 |
decimals :储备使用的 decimals |
uint256 |
ltv :贷款价值 |
uint256 |
liquidationThreshold :储备金的强平阈值 |
uint256 |
liquidationBonus :授予清算人的赏金 |
uint256 |
reserveFactor :储备因子 |
bool |
usageAsCollateralEnable :是否开启 reserve 作为抵押品 |
bool |
borrowingEnable :是否在 reserve 上启用借款 |
bool |
stableBorrowRateEnable :是否开启稳定利率借款 |
bool |
isActive :储备是否处于活跃状态 |
bool |
isFrozen :储备是否被冻结/禁用 |
getReserveData()
function getReserveData(address asset)
返回 asset
相关联的数据。
返回值
类型 | 描述 |
---|---|
uint256 |
availableLiquidity :可用的流动性数量 |
uint256 |
totalStableDebt :以稳定利率借款的债务总额 |
uint256 |
totalVariableDebt :以浮动利率借款的债务总额 |
uint256 |
liquidityRate :存款/添加流动性的利率 |
uint256 |
variableBorrowRate : 浮动利率借款的利率 |
uint256 |
stableBorrowRate :稳定利率借款的利率 |
uint256 |
averageStableBorrowRate :当前平均稳定借款利率 |
uint256 |
liquidityIndex :用于流动性计算的指数 |
uint256 |
variableBorrowIndex :用于浮动利率债务计算的指数 |
uint40 |
lastUpdateTimestamp :储备上次更新的时间戳 |
getUserReserveData()
function getUserReserveData(address asset, address user)
返回用户user
的指定资产 asset
储备数据。
返回值
类型 | 描述 |
---|---|
uint256 |
currentATokenBalance :user 当前的 aToken 余额 |
uint256 |
currentStableDebt :user 当前的稳定利率债务 |
uint256 |
currentVariableDebt :user 当前的浮动利率债务 |
uint256 |
principalStableDebt :user 的本金稳定利率债务 |
uint256 |
scaledVariableDebt :user 的可变利率债务缩放值 |
uint256 |
stableBorrowRate :user 的稳定利率借款利率 |
uint256 |
liquidityRate :user 通过 deposit 获得的利率 |
uint40 |
stableRateLastUpdated :上次稳定利率更新的时间戳 |
bool |
usageAsCollateralEnabled :该资产是否已启用作为用户的抵押品 |
什么是“本金稳定利率债务”?
以下回答来着 ChatGPT-4o:
“用户的本金稳定利率债务” 是指用户通过稳定利率借款的 本金部分。在 DeFi 借贷协议中,本金指的是最初借入的金额,而稳定利率则是该笔借款的利率类型,即在借款期内利率相对稳定,不会频繁波动。
具体来说,本金稳定利率债务 是用户在 Aave 协议中借入的、以稳定利率计算的初始债务金额,不包括利息部分。例如,如果用户借了 100 DAI 以稳定利率形式进行贷款,那么这 100 DAI 就是“本金稳定利率债务”,后续会基于这个金额计算利息。
这种区分对于理解 DeFi 借贷中的利率和债务结构非常重要,因为在一笔借款中,本金和累积的利息会影响用户的还款总额。
getReserveTokensAddresses()
function getReserveTokensAddresses(address asset)
返回资产asset
的关联地址。
返回值
类型 | 描述 |
---|---|
address |
aTokenAddress :代币化存款的地址 |
address |
stableDebtTokenAddress :稳定利率债务代币的地址 |
address |
variableDebtTokenAddress :可变利率债务代币的地址 |
ABI
[
{
"inputs": [
{
"internalType": "contract ILendingPoolAddressesProvider",
"name": "addressesProvider",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "ADDRESSES_PROVIDER",
"outputs": [
{
"internalType": "contract ILendingPoolAddressesProvider",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAllATokens",
"outputs": [
{
"components": [
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
}
],
"internalType": "struct AaveProtocolDataProvider.TokenData[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getAllReservesTokens",
"outputs": [
{
"components": [
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
}
],
"internalType": "struct AaveProtocolDataProvider.TokenData[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveConfigurationData",
"outputs": [
{
"internalType": "uint256",
"name": "decimals",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "ltv",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "liquidationThreshold",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "liquidationBonus",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "reserveFactor",
"type": "uint256"
},
{
"internalType": "bool",
"name": "usageAsCollateralEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "borrowingEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "stableBorrowRateEnabled",
"type": "bool"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
},
{
"internalType": "bool",
"name": "isFrozen",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveData",
"outputs": [
{
"internalType": "uint256",
"name": "availableLiquidity",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalStableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalVariableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "liquidityRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "variableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "stableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "averageStableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "liquidityIndex",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "variableBorrowIndex",
"type": "uint256"
},
{
"internalType": "uint40",
"name": "lastUpdateTimestamp",
"type": "uint40"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "getReserveTokensAddresses",
"outputs": [
{
"internalType": "address",
"name": "aTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "stableDebtTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "variableDebtTokenAddress",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getUserReserveData",
"outputs": [
{
"internalType": "uint256",
"name": "currentATokenBalance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "currentStableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "currentVariableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "principalStableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "scaledVariableDebt",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "stableBorrowRate",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "liquidityRate",
"type": "uint256"
},
{
"internalType": "uint40",
"name": "stableRateLastUpdated",
"type": "uint40"
},
{
"internalType": "bool",
"name": "usageAsCollateralEnabled",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
IProtocolDataProvider
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol';
interface IProtocolDataProvider {
struct TokenData {
string symbol;
address tokenAddress;
}
function ADDRESSES_PROVIDER() external view returns (ILendingPoolAddressesProvider);
function getAllReservesTokens() external view returns (TokenData[] memory);
function getAllATokens() external view returns (TokenData[] memory);
function getReserveConfigurationData(address asset) external view returns (uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen);
function getReserveData(address asset) external view returns (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp);
function getUserReserveData(address asset, address user) external view returns (uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled);
function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress);
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Q1ngying!