Untitled Bank
  • 👀Overview
    • Problem Statement
    • Solution: Aggregated Lending
  • CORE CONCEPT
    • Banks
      • ✔️Layered Bank Structure
      • ✔️Broad Asset Support
      • ✔️ICrosschainERC20 Vault (TBD)
    • Markets
      • ✔️Layered Market Structure
      • ✔️Modular Architecture
      • ✔️Permissionless and Flexible
      • ✔️Advanced Risk Management
      • ✔️Multiply (Leverage) Feature
      • ✔️Bundler
  • How To
    • ✔️Earn
    • ✔️Borrow
    • ✔️Leverage / Repay with Collateral
  • USE CASES
    • ✔️Standard Lending and Borrowing
    • ✔️Customized Vault Strategies
    • ✔️Transform Treasury into a Profitable Vault
    • ✔️Yield Optimization
    • ✔️Impermanent Loss Hedge
  • Developer Docs
    • ✔️How to create a market
    • ✔️How to create a bank
    • ✔️Interest Rate Model
    • ✔️Oracle
  • RESOURCES
    • ✔️Audit Report
  • ✔️Brand Asset
  • Risk Documentation
    • ✔️Risks for Lending Users
Powered by GitBook
On this page
  • Overview
  • Supported Oracles
  • Soneium Mainnet
  • Soneium Minato Testnet
  • PriceProvider Interface
  • Creating a Custom Price Provider
  • Using a Custom Price Provider
  • Important Notes
  • Security Considerations
  1. Developer Docs

Oracle

PreviousInterest Rate ModelNextAudit Report

Last updated 3 months ago

Overview

The Bank contract allows for the use of custom Price Providers (also known as Oracles) to provide price information for collateral tokens in different markets. This feature enables flexible and accurate price feeds tailored to specific assets and market conditions.

Supported Oracles

Soneium Mainnet

Chainlink

Pair
Address

ASTR/USDC

0xd8cf9e97A5A695D778548F20317cBb8ac742EAcF

ETH/USDC

0xeF28882E99D08F19d6Bd2A6C3677b989DdDE02C2

LINK/USDC

0x8B7201C096c52D617Aef8c93111D20623Aa6D7d2

USDC/LINK

0xE4C355CFB514755845DcD8780eEF57924b3c280f

USDC/ETH

0x398b39819c133D40A5F09b82efAa5F62159F6C19

USDC/ASTR

0x26BD767fC3bd1DE7be92bfD31AD41D361C1B0560

ASTR/ETH

0x70cAFdABe3a39644450d12fd30A37C84440b2023

ETH/ASTR

0x2d57521A2aBd60f9d9E0BD76fd3dBBE75c982206

(Chainlink's Primary Oracle sources can be found .)

Pyth

Pair
Address

ASTR/USDC

0xF6401B78c514Ab49Cc28fAd71fe958889Df449Da

ETH/USDC

0xe5dfA038EeaD1c0C717b112AF72994cf271369e8

USDC/ETH

0x2e59F5C6A69B7Cc3C00d5918E1Eabd550A126D16

USDC/ASTR

0x94fdbde6030Ae150d83a19aEf28E3680bf7cEfdA

ASTR/ETH

0xc63C1A77414D5e0F9dFD19cfE30aF31FF75681d1

ETH/ASTR

0xf47A07422a0300fefeBE8c3442C8A8D7bf0aE5dd

Soneium Minato Testnet

Chainlink

Pair
Address

ASTR/USDC

0x0878EAe664c025bA9973aefAb95c08472caE52Bd

ETH/USDC

0x92C87643c91CA8C1B3C1dC36f797Bf9856CBae79

LINK/USDC

0x12F91388568b21fC26A1c18f9a9996aDF08C0E6c

USDC/LINK

0x9644EeF4428CA5d1Da41EE8AE6473E9ddE97fd69

USDC/ETH

0xD3C18CE12bEC4D668b824089601f6ccAC6377Ba2

USDC/ASTR

0xFCc2b860Cb0844cafAdE640DD3424aDeC2e2e11C

ASTR/ETH

0x301477d93Da128ad8543F00CF84f3262a9B8A0A0

ETH/ASTR

0xB4Ff6D357CCc62bD37BeC22F0350219F00a5555b

Pyth

Pair
Address

ASTR/USDC

0x2E435d5129709ACD69Eb32fffB196941cE82C09e

ETH/USDC

0x7fb8456a5482f1736EA3F77Ab64da356a17f5b45

USDC/ETH

0x4B6b6963328f33ca93Acad164E627A60A6938F5a

USDC/ASTR

0xB023666b82EAe12b99A4b9aAf320B5bfe34153C2

ASTR/ETH

0xa97cb0eD84F1Cf4a07bFD4f43Cfb6045674c6E99

ETH/ASTR

0x07f6693C8Cf6c5d019d328572dB89Fa063804bE0

PriceProvider Interface

Custom Price Providers must implement the IPriceProvider interface:

solidityCopyinterface IPriceProvider {
    function isPriceProvider() external view returns (bool);
    function getCollateralTokenPrice() external view returns (uint256 price);
}

Key Functions

  1. isPriceProvider(): Validates that the contract is a legitimate Price Provider.

  2. getCollateralTokenPrice(): Returns the current price of the collateral token denominated in the loan token.

Creating a Custom Price Provider

To create a custom Price Provider:

  1. Implement the IPriceProvider interface.

  2. Define your price fetching logic in the getCollateralTokenPrice() function.

  3. Ensure isPriceProvider() returns true.

Example:

solidityCopycontract MyCustomPriceProvider is IPriceProvider {
    uint256 public price;
    address public owner;

    constructor() {
        owner = msg.sender;
    }

    function isPriceProvider() external pure returns (bool) {
        return true;
    }

    function getCollateralTokenPrice() external view returns (uint256) {
        return price;
    }

    function setCollateralTokenPrice(uint256 _price) external {
        require(msg.sender == owner, "Only owner can set price");
        price = _price;
    }
}

Using a Custom Price Provider

  1. Deploy your custom Price Provider contract.

  2. When creating a new market, include the address of your Price Provider in the marketConfigs.oracle field:

    solidityCopyfunction createMarket(MarketConfigs memory marketConfigs) external payable returns (uint256);

Important Notes

  • Unlike IRMs, Price Providers do not need to be registered with the Bank contract before use.

  • Ensure your Price Provider returns prices in the correct denomination (collateral token price in terms of the loan token).

  • The Bank contract will call the Price Provider's getCollateralTokenPrice() function during various operations, including liquidations, so make sure it's gas-efficient and always returns a valid price.

  • For production use, consider implementing additional security measures such as:

    • Price update frequency limits

    • Multiple data sources for price information

    • Deviation checks to prevent sudden large price changes

    • Test your Price Provider thoroughly before deployment to avoid potential issues in live markets.

    • In the example above, the price is set manually. In a real-world scenario, you would typically fetch this data from reliable external sources.

Security Considerations

  • Ensure that only authorized entities can update the price in your Price Provider.

  • Consider implementing circuit breakers or pause mechanisms for emergency situations.

  • Regularly audit and monitor your Price Provider to ensure it's functioning correctly.

By following these guidelines, you can create and integrate custom Price Providers to provide accurate and reliable price data for various assets within the Bank ecosystem. This flexibility allows for the creation of markets with different collateral types while ensuring proper valuation for lending and liquidation purposes.

✔️
here