在整个 Aave 协议中,我们需要可靠、最新且安全的报价。我们的代理价格提供商合于提供了此功能,其工作原理是:

  1. 首先从 Chainlink 聚合器查看价格
  2. 如果加个低于或等于零,我们就会调用我们的 fallback price oracle

    1. 未来,Aave 治理机制将管理来源的选择和 fallback price oracle。

源码:https://github.com/aave/docs-v2/blob/main/deployed-contracts/deployed-contracts.md

始终通过在 LendingPoolAddressProvider合约上调用 getPriceOracle()来获取最新的价格预言机地址

View Methods

getAssetPrice()

function getAssetPrice(address _asset) public view returns(uint256)

返回支持的 _asset的价格,以 ETH wei 为单位。

参数名称 类型 描述
_asset address 基础资产的地址

getAssetPrices()

function getAssetPrices(address[] calldata _assets) external view returns(uint256[] memory)

返回以 ETH wei 为单位的任意价格数组

参数名称 类型 描述
_assets address 基础资产的地址数组

getSourceOfAsset()

function getSourceOfAsset(address _asset) external view returns(uint256)

返回 _asset价格源的地址

参数名称 类型 描述
_asset address 基础资产的地址

getFallbackOracle()

function getFallbackOracle() external view returns(uint256)

返回 fallback oracle 的地址。

ABI

[
    {
        "inputs": [
            {
                "internalType": "address[]",
                "name": "assets",
                "type": "address[]"
            },
            {
                "internalType": "address[]",
                "name": "sources",
                "type": "address[]"
            },
            {
                "internalType": "address",
                "name": "fallbackOracle",
                "type": "address"
            },
            {
                "internalType": "address",
                "name": "weth",
                "type": "address"
            }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "asset",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "source",
                "type": "address"
            }
        ],
        "name": "AssetSourceUpdated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "fallbackOracle",
                "type": "address"
            }
        ],
        "name": "FallbackOracleUpdated",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "previousOwner",
                "type": "address"
            },
            {
                "indexed": true,
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "OwnershipTransferred",
        "type": "event"
    },
    {
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "address",
                "name": "weth",
                "type": "address"
            }
        ],
        "name": "WethSet",
        "type": "event"
    },
    {
        "inputs": [],
        "name": "WETH",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "asset",
                "type": "address"
            }
        ],
        "name": "getAssetPrice",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address[]",
                "name": "assets",
                "type": "address[]"
            }
        ],
        "name": "getAssetsPrices",
        "outputs": [
            {
                "internalType": "uint256[]",
                "name": "",
                "type": "uint256[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "getFallbackOracle",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "asset",
                "type": "address"
            }
        ],
        "name": "getSourceOfAsset",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "owner",
        "outputs": [
            {
                "internalType": "address",
                "name": "",
                "type": "address"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [],
        "name": "renounceOwnership",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address[]",
                "name": "assets",
                "type": "address[]"
            },
            {
                "internalType": "address[]",
                "name": "sources",
                "type": "address[]"
            }
        ],
        "name": "setAssetSources",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "fallbackOracle",
                "type": "address"
            }
        ],
        "name": "setFallbackOracle",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "newOwner",
                "type": "address"
            }
        ],
        "name": "transferOwnership",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }
]

IPriceOracle

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;

interface IPriceOracleGetter {
    function getAssetPrice(address _asset) external view returns (uint256);
    function getAssetsPrices(address[] calldata _assets) external view returns(uint256[] memory);
    function getSourceOfAsset(address _asset) external view returns(address);
    function getFallbackOracle() external view returns(address);
}