Skip to content
Verified contractPartialMIT

BeanPriceOracle

Address0x91950c5bbfebf460790afcf7ca2cf3c9333af0ee
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.17

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.17+commit.8df45f5f
Language
solidity
Optimization
Yes, 1,000 runs
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
18,552,791
Creation transaction
0xa627d878c9…9ec2a3b08f

contracts/oracles/BeanPriceOracle.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "../libraries/Constants.sol";
import "../interfaces/ICustomOracle.sol";
import "../interfaces/IBeanstalkPrice.sol";

contract BeanPriceOracle is ICustomOracle {
    /**
     * @notice Get latest oracle price of BEAN normalized to 1e18
     * @dev Use beanstalk price (decimals of beanstalk price is 6, so we multiply 10**12)
     * @return price latest BEAN price
     */
    function latestPrice() external view returns (uint256 price) {
        return IBeanstalkPrice(Constants.BEANSTALK_PRICE).price().price * 1e12;
    }
}

contracts/interfaces/IBeanstalkPrice.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IBeanstalkPrice {
    struct Pool {
        address pool;
        address[2] tokens;
        uint256[2] balances;
        uint256 price;
        uint256 liquidity;
        int256 deltaB;
        // uint256 lpSupply;
        uint256 lpUsd;
        uint256 lpBdv;
    }
    struct Prices {
        uint256 price;
        uint256 liquidity;
        int deltaB;
        Pool[] ps;
    }

    function price() external view returns (Prices memory p);
}

contracts/interfaces/ICustomOracle.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface ICustomOracle {
    /**
     * @notice Get latest oracle price normalized to 1e18
     */
    function latestPrice() external view returns (uint256);
}

contracts/libraries/Constants.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library Constants {
    /// Addresses
    address internal constant CURVE_ROUTER = 0x99a58482BD75cbab83b27EC03CA68fF489b5788f;
    address internal constant BEAN = 0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab;
    address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    address internal constant TRI_CRYPTO_POOL = 0xD51a44d3FaE010294C616388b506AcdA1bfAAE46;
    address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    address internal constant CURVE_BEAN_METAPOOL = 0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49;
    address internal constant BEANSTALK_PRICE = 0xb01CE0008CaD90104651d6A84b6B11e182a9B62A;
    address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address internal constant ZERO = 0x0000000000000000000000000000000000000000;
    address internal constant BEANSTALK = 0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5;
    address internal constant FERTILIZER = 0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6;
    /// bean - weth pool
    address internal constant BEAN_ETH_WELL = 0xBEA0e11282e2bB5893bEcE110cF199501e872bAd;

    /// @notice time out to get price from chainlink
    /// @dev should update before deploying on mainnet
    uint256 internal constant GRACE_PERIOD_TIME = 6 days;

    /// underlying decimals
    uint256 internal constant D18 = 1e18;
    // tranche nft is fractionalized with decimals 6
    uint8 internal constant TRANCHE_DECIMALS = 6;
    uint8 internal constant WATER_DECIMALS = 18;

    bytes internal constant EMPTY = "";

    /// function selectors
    bytes4 internal constant ERC1155_ACCEPTED = 0xf23a6e61; // bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
    bytes4 internal constant ERC1155_BATCH_ACCEPTED = 0xbc197c81; // bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "libraries": {},
  "optimizer": {
    "runs": 1000,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.