Contract 0x1AA108E2392Cd316be9255F78A3673E9f6f65447

Contract Overview

Balance:
0 AVAX
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x26bbc4fd0111419e45d88759088af08e1ea201852b7da094b07721b11868964dChange Oracle72200522022-03-12 20:29:48571 days 6 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.00106335 25
0xb8d18d2f014da8a2e480d124203a2d7b9ea8b80ce675735ec468587360f2ca55Change Oracle72199582022-03-12 20:26:40571 days 6 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.00106335 25
0xc56f8cef97b4cd5b4e956764f34158e9d15e88ce776335bc95d2a90492c4b43aAdd Collateral69707952022-03-06 23:52:07577 days 3 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0xd0dd667e818a325eba682ac8b2694db7683108ac3186f0e8bfb1321aeef2c5e9Deprecate Collat...69703822022-03-06 23:37:28577 days 3 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.000991925 25
0xfcd502d1feab3cdce3b871869f07593e83a65b9ffc9c2a53779a50dc4f6fa47fAdd Collateral68433592022-03-03 23:25:20580 days 3 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0xb3d8af90196157a124e3d0da80c9787c9268428ffa701ae3bde3c29adb1a2009Change Oracle66026652022-02-26 7:32:52585 days 19 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.00106335 25
0xf41fabe489c92286b5ea039039cec1917b4f3fad7a61126ff8e74774f06cf3d6Change Oracle66025552022-02-26 7:29:12585 days 19 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.00106335 25
0xbcd8ad6dbd82cff76cf8a5130f160f0f5cc2367671b0fd25a4e62c3b92f8d4d4Undeprecate Coll...61616792022-02-16 6:53:41595 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.000992725 25
0x7eb03838783f9438414a3bc7acfd0a6a5062b4642ebb68749f6532c249c6a605Deprecate Collat...61601962022-02-16 6:03:38595 days 21 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.000991925 25
0xbfba8d8f4eecd1c906528cbb0e6d758167d6157a494d01edeec18970f5ff0011Change Price Cur...61601732022-02-16 6:02:52595 days 21 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001577625 25
0x40ae89e0d886032a260dafe96f792618a18b7e9bf9498eb2c0e139b797cd5555Add Collateral61582722022-02-16 4:58:29595 days 22 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.055573769209 148.046302848
0x57ce26b399e0548e5930adf6a3c5d3ba2b87ab30a24b1f6b9c5422dedb7cb738Change Price Cur...60758962022-02-14 6:25:38597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001437625 25
0xc5283146a145d5f55e29ca193bf168635e6a854e3164041ee55799aed018fe9bChange Price Cur...60758892022-02-14 6:25:24597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001437325 25
0xbb0a6906b20c1aa6879eb8815e6164d31a8a67fb85d988c4c34130728d37d735Change Price Cur...60758812022-02-14 6:25:08597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001437625 25
0xd489da39d7c532ad9c00f5cf905e57dedbdb5c0d922998055fa2c1d3e8c1b455Change Price Cur...60758742022-02-14 6:24:54597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001437625 25
0xd35bcaff1fd88e88e0f817288dad5b5f5355076fbefaef457fa2ab03a9265aa6Change Price Cur...60758672022-02-14 6:24:40597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.001437625 25
0x13738d3d864ea5c112ed6230eec78b7a5757d561a89f836a56342ec4b673a68eChange Price Cur...60758632022-02-14 6:24:27597 days 20 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.0013821 25
0x0803e9ef3a99e983aa3cabab349e03a023877578ed38958cadccd380de2f0992Add Collateral60699072022-02-14 2:58:18598 days 13 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0xb655628b09441861f5fe65ff53ae725f46f86cbf337d5482a3098ff3a978c539Add Collateral60698922022-02-14 2:57:46598 days 13 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384225 25
0x05446ba6c8c751484d7de398c78d2c8acf5f62ffca269da43c061218a17d51a6Add Collateral60698762022-02-14 2:57:15598 days 14 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0x034864d10ec0dd9ea41aa5bc60a6ac7341aa21e1aa991834b8fe8bdec149767dAdd Collateral60698582022-02-14 2:56:39598 days 15 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0xe3d7754cbd0c687419aa926bc55350181294c6f37e4d1cfc9111ee7a89ccb7f1Add Collateral60698502022-02-14 2:56:24598 days 15 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.009384525 25
0x3f002f24eedf0862b6740476edbd7c36f8919de0e73578599ff04a3d77d7aeecAdd Collateral60698292022-02-14 2:55:42598 days 16 mins ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.013100325 25
0x61e8b5d7874bedfb3d60da02b57d41990fc306c0c75fed3983cd1979481023aaSet Addresses60673282022-02-14 1:31:41598 days 1 hr ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN 0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX0.004113065 27.5
0x37e9bd1964d69a72f894428e7db93515af020fce59e7e7fd9fa6e29b140efb010x6080604060665692022-02-14 1:05:46598 days 2 hrs ago0x9e97ae5d91da840eed47a5b07fdabbc2bfad8ada IN  Contract Creation0 AVAX0.09772128 45
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xa2dd603e316c87d460cba331784c1385caf92796c8b3c2b8600e7a072c1bdc13190600092023-02-18 20:12:41228 days 6 hrs ago 0x9ab04cd8b701e5bb4fdf31378af679d2f4534f8a0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa2dd603e316c87d460cba331784c1385caf92796c8b3c2b8600e7a072c1bdc13190600092023-02-18 20:12:41228 days 6 hrs ago 0x9ab04cd8b701e5bb4fdf31378af679d2f4534f8a0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xcb74a8f05537e346ac54c173652e57c96b4339d20x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470x5d6fe4b5c594cb3b948943621d8753f005e514eb0 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xf519b2a0d432d15968f4d5556fcb12b7f15ffe050 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470x8ee4ba8912be2ed8889a527299d1f12de5a936340 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xbf6804f2f5f14cf5c510204716154f351ff511ff0 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xde9ce01e6eafcfab2e69e3424ad3652ecb365f520 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xf7312cdb5fa74eb7070f915fac5e6fadbaf64a4c0 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xe167b3c0761fea59385ad2800c6276e5d7b5a0fe0 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470x6d72321943542247430a08159b75073ca3b3b5570 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470x4be6e0d4f8a8e987dc2e29bba25a777a16f1c9810 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0xf7d924a8f414a16a54f2cf9a98ac266281239ffb0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470x5d6fe4b5c594cb3b948943621d8753f005e514eb0 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x0db336c1ab0cc14972b53caa4f100068731c54aa0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x1aa108e2392cd316be9255f78a3673e9f6f654470xf519b2a0d432d15968f4d5556fcb12b7f15ffe050 AVAX
0xa5e4f1986a442e0a970b3a0b1eb60a2d5dbc48f571ee03b15f21b4df4e400713156436772022-11-11 1:51:47328 days 1 hr ago 0x0db336c1ab0cc14972b53caa4f100068731c54aa0x1aa108e2392cd316be9255f78a3673e9f6f654470 AVAX
[ Download CSV Export 
Index Block
Loading

Similar Match Source Code
This contract matches the deployed ByteCode of the Source Code for Contract 0x8d0a27BBc7111369340EF5FDdd4891AC48e7679c
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
Whitelist

Compiler Version
v0.6.11+commit.5ef660b1

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 18 : Whitelist.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./Ownable.sol";
import "../Interfaces/IBaseOracle.sol";
import "../Interfaces/IWhitelist.sol";
import "../Interfaces/IPriceFeed.sol";
import "../Interfaces/IPriceCurve.sol";
import "../Interfaces/IActivePool.sol";
import "../Interfaces/IDefaultPool.sol";
import "../Interfaces/IStabilityPool.sol";
import "../Interfaces/ICollSurplusPool.sol";
import "../Interfaces/IERC20.sol";
import "./LiquityMath.sol";
import "./CheckContract.sol";


/**
 * Whitelist is the contract that keeps track of all the assets that the system takes as collateral.
 * It has onlyOwner functions to add or deprecate collaterals from the whitelist, change the price
 * curve, price feed, safety ratio, etc.
 */

contract Whitelist is Ownable, IWhitelist, IBaseOracle, CheckContract {
    using SafeMath for uint256;

    struct CollateralParams {
        // Safety ratio
        uint256 ratio; // 10**18 * the ratio. i.e. ratio = .95 * 10**18 for 95%. More risky collateral has a lower ratio
        address oracle;
        uint256 decimals;
        bool active;
        address priceCurve;
        uint256 index;
        bool isWrapped;
        address defaultRouter;
    }

    IActivePool activePool;
    IDefaultPool defaultPool;
    IStabilityPool stabilityPool;
    ICollSurplusPool collSurplusPool;
    address borrowerOperationsAddress;

    mapping(address => CollateralParams) public collateralParams;

    mapping(address => bool) public validRouter;

    // list of all collateral types in collateralParams (active and deprecated)
    // Addresses for easy access
    address[] public validCollateral; // index maps to token address.

    event CollateralAdded(address _collateral);
    event CollateralDeprecated(address _collateral);
    event CollateralUndeprecated(address _collateral);
    event CollateralRemoved(address _collateral);
    event OracleChanged(address _collateral);
    event PriceCurveChanged(address _collateral);
    event RatioChanged(address _collateral);

    // Require that the collateral exists in the whitelist. If it is not the 0th index, and the
    // index is still 0 then it does not exist in the mapping.
    // no require here for valid collateral 0 index because that means it exists. 
    modifier exists(address _collateral) {
        if (validCollateral.length != 0 && validCollateral[0] != _collateral) {
            require(collateralParams[_collateral].index != 0, "collateral does not exists");
        }
        _;
    }

    // ----------Only Owner Setter Functions----------

    function setAddresses(
        address _activePoolAddress,
        address _defaultPoolAddress,
        address _stabilityPoolAddress,
        address _collSurplusPoolAddress,
        address _borrowerOperationsAddress
    ) external override onlyOwner {
        checkContract(_activePoolAddress);
        checkContract(_defaultPoolAddress);
        checkContract(_stabilityPoolAddress);
        checkContract(_collSurplusPoolAddress);
        checkContract(_borrowerOperationsAddress);

        activePool = IActivePool(_activePoolAddress);
        defaultPool = IDefaultPool(_defaultPoolAddress);
        stabilityPool = IStabilityPool(_stabilityPoolAddress);
        collSurplusPool = ICollSurplusPool(_collSurplusPoolAddress);
        borrowerOperationsAddress = _borrowerOperationsAddress;
    }

    function addCollateral(
        address _collateral,
        uint256 _minRatio,
        address _oracle,
        uint256 _decimals,
        address _priceCurve, 
        bool _isWrapped, 
        address _routerAddress
    ) external onlyOwner {
        checkContract(_collateral);
        checkContract(_oracle);
        checkContract(_priceCurve);
        checkContract(_routerAddress);
        // If collateral list is not 0, and if the 0th index is not equal to this collateral,
        // then if index is 0 that means it is not set yet.
        if (validCollateral.length != 0) {
            require(validCollateral[0] != _collateral && collateralParams[_collateral].index == 0, "collateral already exists");
        }

        validCollateral.push(_collateral);
        collateralParams[_collateral] = CollateralParams(
            _minRatio,
            _oracle,
            _decimals,
            true,
            _priceCurve,
            validCollateral.length - 1, 
            _isWrapped,
            _routerAddress
        );

        activePool.addCollateralType(_collateral);
        defaultPool.addCollateralType(_collateral);
        stabilityPool.addCollateralType(_collateral);
        collSurplusPool.addCollateralType(_collateral);

        // throw event
        emit CollateralAdded(_collateral);
    }

    /**
     * Deprecate collateral by not allowing any more collateral to be added of this type.
     * Still can interact with it via validCollateral and CollateralParams
     */
    function deprecateCollateral(address _collateral) external exists(_collateral) onlyOwner {
        checkContract(_collateral);

        require(collateralParams[_collateral].active, "collateral already deprecated");

        collateralParams[_collateral].active = false;

        // throw event
        emit CollateralDeprecated(_collateral);
    }

    /**
     * Undeprecate collateral by allowing more collateral to be added of this type.
     * Still can interact with it via validCollateral and CollateralParams
     */
    function undeprecateCollateral(address _collateral) external exists(_collateral) onlyOwner {
        checkContract(_collateral);

        require(!collateralParams[_collateral].active, "collateral is already active");

        collateralParams[_collateral].active = true;

        // throw event
        emit CollateralUndeprecated(_collateral);
    }

    /**
     * Function to change oracles
     */
    function changeOracle(address _collateral, address _oracle)
        external
        exists(_collateral)
        onlyOwner
    {
        checkContract(_collateral);
        checkContract(_oracle);
        collateralParams[_collateral].oracle = _oracle;

        // throw event
        emit OracleChanged(_collateral);
    }

    /**
     * Function to change price curve
     */
    function changePriceCurve(address _collateral, address _priceCurve)
        external
        exists(_collateral)
        onlyOwner
    {
        checkContract(_collateral);
        checkContract(_priceCurve);
        uint lastFeePercent;
        uint lastFeeTime; 
        (lastFeePercent, lastFeeTime) = IPriceCurve(collateralParams[_collateral].priceCurve).getFeeCapAndTime();
        IPriceCurve(_priceCurve).setFeeCapAndTime(lastFeePercent, lastFeeTime);
        collateralParams[_collateral].priceCurve = _priceCurve;

        // throw event
        emit PriceCurveChanged(_collateral);
    }

    /**
     * Function to change Safety ratio.
     */
    function changeRatio(address _collateral, uint256 _ratio)
        external
        exists(_collateral)
        onlyOwner
    {
        checkContract(_collateral);
        require(_ratio < 1100000000000000000, "ratio must be less than 1.10 => greater than 1.1 would mean taking out more YUSD than collateral VC");
        require(collateralParams[_collateral].ratio < _ratio, "New SR must be greater than previous SR");
        collateralParams[_collateral].ratio = _ratio;

        // throw event
        emit RatioChanged(_collateral);
    }

    // -----------Routers--------------

    function setDefaultRouter(address _collateral, address _router) external override onlyOwner exists(_collateral) {
        checkContract(_router);
        collateralParams[_collateral].defaultRouter = _router;
    }

    function getDefaultRouterAddress(address _collateral) external view override exists(_collateral) returns (address) {
        return collateralParams[_collateral].defaultRouter;
    }


    // ---------- View Functions -----------


    function isValidRouter(address _router) external override view returns (bool) {
        return validRouter[_router];
    }

    function isWrapped(address _collateral) external view override returns (bool) {
        return collateralParams[_collateral].isWrapped;
    }

    function getValidCollateral() external view override returns (address[] memory) {
        return validCollateral;
    }

    function getRatio(address _collateral)
        public
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        return collateralParams[_collateral].ratio;
    }

    function getOracle(address _collateral)
        external
        view
        override
        exists(_collateral)
        returns (address)
    {
        return collateralParams[_collateral].oracle;
    }

    function getPriceCurve(address _collateral)
        external
        view
        override
        exists(_collateral)
        returns (address)
    {
        return collateralParams[_collateral].priceCurve;
    }

    function getIsActive(address _collateral)
        external
        view
        override
        exists(_collateral)
        returns (bool)
    {
        return collateralParams[_collateral].active;
    }

    function getDecimals(address _collateral)
        external
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        return collateralParams[_collateral].decimals;
    }

    function getIndex(address _collateral)
        public
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        return (collateralParams[_collateral].index);
    }

    // Returned as fee percentage * 10**18. View function for external callers.
    function getFee(
        address _collateral,
        uint256 _collateralVCInput,
        uint256 _collateralVCBalancePost,
        uint256 _totalVCBalancePre,
        uint256 _totalVCBalancePost
    ) external view override exists(_collateral) returns (uint256 fee) {
        IPriceCurve priceCurve = IPriceCurve(collateralParams[_collateral].priceCurve);
        return priceCurve.getFee(_collateralVCInput, _collateralVCBalancePost, _totalVCBalancePre, _totalVCBalancePost);
    }

    // Returned as fee percentage * 10**18. Non view function for just borrower operations to call.
    function getFeeAndUpdate(
        address _collateral,
        uint256 _collateralVCInput,
        uint256 _collateralVCBalancePost,
        uint256 _totalVCBalancePre,
        uint256 _totalVCBalancePost
    ) external override exists(_collateral) returns (uint256 fee) {
        require(
            msg.sender == borrowerOperationsAddress,
            "only borrower operations can call this function"
        );
        IPriceCurve priceCurve = IPriceCurve(collateralParams[_collateral].priceCurve);
        return
            priceCurve.getFeeAndUpdate(
                _collateralVCInput,
                _collateralVCBalancePost,
                _totalVCBalancePre,
                _totalVCBalancePost
            );
    }

    // should return 10**18 times the price in USD of 1 of the given _collateral
    function getPrice(address _collateral)
        public
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        IPriceFeed collateral_priceFeed = IPriceFeed(collateralParams[_collateral].oracle);
        uint256 price = collateral_priceFeed.fetchPrice_v();
        return price;
    }

    // Gets the value of that collateral type, of that amount, in USD terms.
    function getValueUSD(address _collateral, uint256 _amount)
        external
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        uint256 decimals = collateralParams[_collateral].decimals;
        uint256 price = getPrice(_collateral);
        return price.mul(_amount).div(10**decimals);
    }

    // Gets the value of that collateral type, of that amount, in VC terms.
    function getValueVC(address _collateral, uint256 _amount)
        public
        view
        override
        exists(_collateral)
        returns (uint256)
    {
        uint256 price = getPrice(_collateral);
        uint256 decimals = collateralParams[_collateral].decimals;
        uint256 ratio = collateralParams[_collateral].ratio;

        // div by 10**18 for price adjustment
        // and divide by 10 ** decimals for decimal adjustment
        return (price.mul(_amount).mul(ratio).div(10**(18 + decimals)));
    }


}

File 2 of 18 : Ownable.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

/**
 * Based on OpenZeppelin's Ownable contract:
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
 *
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        _owner = msg.sender;
        emit OwnershipTransferred(address(0), msg.sender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(isOwner(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Returns true if the caller is the current owner.
     */
    function isOwner() public view returns (bool) {
        return msg.sender == _owner;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     *
     * NOTE: This function is not safe, as it doesn’t check owner is calling it.
     * Make sure you check it before calling it.
     */
    function _renounceOwnership() internal {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
}

File 3 of 18 : IBaseOracle.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

interface IBaseOracle {
  /// @dev Return the value of the given input as USD per unit.
  /// @param token The ERC-20 token to check the value.
  function getPrice(address token) external view returns (uint);

}

File 4 of 18 : IWhitelist.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;


interface IWhitelist {
    function getValidCollateral() view external returns (address[] memory);

    function setAddresses(
        address _activePoolAddress,
        address _defaultPoolAddress,
        address _stabilityPoolAddress,
        address _collSurplusPoolAddress, 
        address _borrowerOperationsAddress
    ) external;

    function isValidRouter(address _router) external view returns (bool);
    function getOracle(address _collateral) view external returns (address);
    function getRatio(address _collateral) view external returns (uint256);
    function getIsActive(address _collateral) view external returns (bool);
    function getPriceCurve(address _collateral) external view returns (address);
    function getDecimals(address _collateral) external view returns (uint256);
    function getFee(address _collateral, uint _collateralVCInput, uint256 _collateralVCBalancePost, uint256 _totalVCBalancePre, uint256 _totalVCBalancePost) external view returns (uint256 fee);
    function getFeeAndUpdate(address _collateral, uint _collateralVCInput, uint256 _collateralVCBalancePost, uint256 _totalVCBalancePre, uint256 _totalVCBalancePost) external returns (uint256 fee);
    function getIndex(address _collateral) external view returns (uint256);
    function isWrapped(address _collateral) external view returns (bool);
    function setDefaultRouter(address _collateral, address _router) external;

    function getValueVC(address _collateral, uint _amount) view external returns (uint);
    function getValueUSD(address _collateral, uint _amount) view external returns (uint256);
    function getDefaultRouterAddress(address _collateral) external view returns (address);
}

File 5 of 18 : IPriceFeed.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

interface IPriceFeed {

    // --- Events ---
    event LastGoodPriceUpdated(uint _lastGoodPrice);

    // --- Function ---
    // function fetchPrice() external returns (uint);

    function fetchPrice_v() view external returns (uint);
}

File 6 of 18 : IPriceCurve.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

interface IPriceCurve {
    function setAddresses(address _whitelistAddress) external;

    function setDecayTime(uint _decayTime) external;

    /** 
     * Returns fee based on inputted collateral VC balance and total VC balance of system. 
     * fee is in terms of percentage * 1e18. 
     * If the fee were 1%, this would be 0.01 * 1e18 = 1e16
     */
    function getFee(uint256 _collateralVCInput, uint256 _collateralVCBalancePost, uint256 _totalVCBalancePre, uint256 _totalVCBalancePost) external view returns (uint256 fee);

    // Same function, updates the fee as well. Called only by whitelist. 
    function getFeeAndUpdate(uint256 _collateralVCInput, uint256 _totalCollateralVCBalance, uint256 _totalVCBalancePre, uint256 _totalVCBalancePost) external returns (uint256 fee);

    // Function for setting the old price curve's last fee cap / value to the new fee cap / value. 
    // Called only by whitelist. 
    function setFeeCapAndTime(uint256 _lastFeePercent, uint256 _lastFeeTime) external;

    // Gets the fee cap and time currently. Used for setting new values for next price curve. 
    function getFeeCapAndTime() external view returns (uint256 _lastFeePercent, uint256 _lastFeeTime);

    /** 
     * Returns fee based on decay since last fee calculation, which we take to be 
     * a reasonable fee amount. If it has decayed a certain amount since then, we let
     * the new fee amount slide. 
     */
    function calculateDecayedFee() external view returns (uint256 fee);
}

File 7 of 18 : IActivePool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./IPool.sol";

    
interface IActivePool is IPool {
    // --- Events ---
    event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
    event TroveManagerAddressChanged(address _newTroveManagerAddress);
    event ActivePoolYUSDDebtUpdated(uint _YUSDDebt);
    event ActivePoolCollateralBalanceUpdated(address _collateral, uint _amount);

    // --- Functions ---
    
    function sendCollaterals(address _to, address[] memory _tokens, uint[] memory _amounts) external returns (bool);
    function sendCollateralsUnwrap(
        address _to,
        address[] memory _tokens,
        uint[] memory _amounts,
        bool _collectRewards) external returns (bool);
    function getCollateralVC(address collateralAddress) external view returns (uint);
    function addCollateralType(address _collateral) external;
}

File 8 of 18 : IDefaultPool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./IPool.sol";

interface IDefaultPool is IPool {
    // --- Events ---
    event TroveManagerAddressChanged(address _newTroveManagerAddress);
    event DefaultPoolYUSDDebtUpdated(uint _YUSDDebt);
    event DefaultPoolETHBalanceUpdated(uint _ETH);

    // --- Functions ---
    
    function sendCollsToActivePool(address[] memory _collaterals, uint[] memory _amounts, address _borrower) external;
    function addCollateralType(address _collateral) external;
    function getCollateralVC(address collateralAddress) external view returns (uint);
}

File 9 of 18 : IStabilityPool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./ICollateralReceiver.sol";

/*
 * The Stability Pool holds YUSD tokens deposited by Stability Pool depositors.
 *
 * When a trove is liquidated, then depending on system conditions, some of its YUSD debt gets offset with
 * YUSD in the Stability Pool:  that is, the offset debt evaporates, and an equal amount of YUSD tokens in the Stability Pool is burned.
 *
 * Thus, a liquidation causes each depositor to receive a YUSD loss, in proportion to their deposit as a share of total deposits.
 * They also receive an ETH gain, as the ETH collateral of the liquidated trove is distributed among Stability depositors,
 * in the same proportion.
 *
 * When a liquidation occurs, it depletes every deposit by the same fraction: for example, a liquidation that depletes 40%
 * of the total YUSD in the Stability Pool, depletes 40% of each deposit.
 *
 * A deposit that has experienced a series of liquidations is termed a "compounded deposit": each liquidation depletes the deposit,
 * multiplying it by some factor in range ]0,1[
 *
 * Please see the implementation spec in the proof document, which closely follows on from the compounded deposit / ETH gain derivations:
 * https://github.com/liquity/liquity/blob/master/papers/Scalable_Reward_Distribution_with_Compounding_Stakes.pdf
 *
 * --- YETI ISSUANCE TO STABILITY POOL DEPOSITORS ---
 *
 * An YETI issuance event occurs at every deposit operation, and every liquidation.
 *
 * Each deposit is tagged with the address of the front end through which it was made.
 *
 * All deposits earn a share of the issued YETI in proportion to the deposit as a share of total deposits. The YETI earned
 * by a given deposit, is split between the depositor and the front end through which the deposit was made, based on the front end's kickbackRate.
 *
 * Please see the system Readme for an overview:
 * https://github.com/liquity/dev/blob/main/README.md#yeti-issuance-to-stability-providers
 */
interface IStabilityPool is ICollateralReceiver {

    // --- Events ---
    
    event StabilityPoolETHBalanceUpdated(uint _newBalance);
    event StabilityPoolYUSDBalanceUpdated(uint _newBalance);

    event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
    event TroveManagerAddressChanged(address _newTroveManagerAddress);
    event ActivePoolAddressChanged(address _newActivePoolAddress);
    event DefaultPoolAddressChanged(address _newDefaultPoolAddress);
    event YUSDTokenAddressChanged(address _newYUSDTokenAddress);
    event SortedTrovesAddressChanged(address _newSortedTrovesAddress);
    event PriceFeedAddressChanged(address _newPriceFeedAddress);
    event CommunityIssuanceAddressChanged(address _newCommunityIssuanceAddress);

    event P_Updated(uint _P);
    event S_Updated(uint _S, uint128 _epoch, uint128 _scale);
    event G_Updated(uint _G, uint128 _epoch, uint128 _scale);
    event EpochUpdated(uint128 _currentEpoch);
    event ScaleUpdated(uint128 _currentScale);

    event FrontEndRegistered(address indexed _frontEnd, uint _kickbackRate);
    event FrontEndTagSet(address indexed _depositor, address indexed _frontEnd);

    event DepositSnapshotUpdated(address indexed _depositor, uint _P, uint _S, uint _G);
    event FrontEndSnapshotUpdated(address indexed _frontEnd, uint _P, uint _G);
    event UserDepositChanged(address indexed _depositor, uint _newDeposit);
    event FrontEndStakeChanged(address indexed _frontEnd, uint _newFrontEndStake, address _depositor);

    event ETHGainWithdrawn(address indexed _depositor, uint _ETH, uint _YUSDLoss);
    event YETIPaidToDepositor(address indexed _depositor, uint _YETI);
    event YETIPaidToFrontEnd(address indexed _frontEnd, uint _YETI);
    event EtherSent(address _to, uint _amount);

    // --- Functions ---

    /*
     * Called only once on init, to set addresses of other Liquity contracts
     * Callable only by owner, renounces ownership at the end
     */
    function setAddresses(
        address _borrowerOperationsAddress,
        address _troveManagerAddress,
        address _activePoolAddress,
        address _yusdTokenAddress,
        address _sortedTrovesAddress,
        address _communityIssuanceAddress,
        address _whitelistAddress,
        address _troveManagerLiquidationsAddress
    )
        external;

    /*
     * Initial checks:
     * - Frontend is registered or zero address
     * - Sender is not a registered frontend
     * - _amount is not zero
     * ---
     * - Triggers a YETI issuance, based on time passed since the last issuance. The YETI issuance is shared between *all* depositors and front ends
     * - Tags the deposit with the provided front end tag param, if it's a new deposit
     * - Sends depositor's accumulated gains (YETI, ETH) to depositor
     * - Sends the tagged front end's accumulated YETI gains to the tagged front end
     * - Increases deposit and tagged front end's stake, and takes new snapshots for each.
     */
    function provideToSP(uint _amount, address _frontEndTag) external;

    /*
     * Initial checks:
     * - _amount is zero or there are no under collateralized troves left in the system
     * - User has a non zero deposit
     * ---
     * - Triggers a YETI issuance, based on time passed since the last issuance. The YETI issuance is shared between *all* depositors and front ends
     * - Removes the deposit's front end tag if it is a full withdrawal
     * - Sends all depositor's accumulated gains (YETI, ETH) to depositor
     * - Sends the tagged front end's accumulated YETI gains to the tagged front end
     * - Decreases deposit and tagged front end's stake, and takes new snapshots for each.
     *
     * If _amount > userDeposit, the user withdraws all of their compounded deposit.
     */
    function withdrawFromSP(uint _amount) external;


    /*
     * Initial checks:
     * - Frontend (sender) not already registered
     * - User (sender) has no deposit
     * - _kickbackRate is in the range [0, 100%]
     * ---
     * Front end makes a one-time selection of kickback rate upon registering
     */
    function registerFrontEnd(uint _kickbackRate) external;

    /*
     * Initial checks:
     * - Caller is TroveManager
     * ---
     * Cancels out the specified debt against the YUSD contained in the Stability Pool (as far as possible)
     * and transfers the Trove's ETH collateral from ActivePool to StabilityPool.
     * Only called by liquidation functions in the TroveManager.
     */
    function offset(uint _debt, address[] memory _assets, uint[] memory _amountsAdded) external;

//    /*
//     * Returns the total amount of ETH held by the pool, accounted in an internal variable instead of `balance`,
//     * to exclude edge cases like ETH received from a self-destruct.
//     */
//    function getETH() external view returns (uint);
    
     //*
//     * Calculates and returns the total gains a depositor has accumulated 
//     */
    function  getDepositorGains(address _depositor) external view returns (address[] memory assets, uint[] memory amounts);


    /*
     * Returns the total amount of VC held by the pool, accounted for by multipliying the
     * internal balances of collaterals by the price that is found at the time getVC() is called.
     */
    function getVC() external view returns (uint);

    /*
     * Returns YUSD held in the pool. Changes when users deposit/withdraw, and when Trove debt is offset.
     */
    function getTotalYUSDDeposits() external view returns (uint);

    /*
     * Calculate the YETI gain earned by a deposit since its last snapshots were taken.
     * If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned.
     * Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through
     * which they made their deposit.
     */
    function getDepositorYETIGain(address _depositor) external view returns (uint);

    /*
     * Return the YETI gain earned by the front end.
     */
    function getFrontEndYETIGain(address _frontEnd) external view returns (uint);

    /*
     * Return the user's compounded deposit.
     */
    function getCompoundedYUSDDeposit(address _depositor) external view returns (uint);

    /*
     * Return the front end's compounded stake.
     *
     * The front end's compounded stake is equal to the sum of its depositors' compounded deposits.
     */
    function getCompoundedFrontEndStake(address _frontEnd) external view returns (uint);

    /*
     * Add collateral type to totalColl 
     */
    function addCollateralType(address _collateral) external;

    function getDepositSnapshotS(address depositor, address collateral) external view returns (uint);

    function getCollateral(address _collateral) external view returns (uint);

    function getAllCollateral() external view returns (address[] memory, uint256[] memory);

}

File 10 of 18 : ICollSurplusPool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "../Dependencies/YetiCustomBase.sol";
import "./ICollateralReceiver.sol";


interface ICollSurplusPool is ICollateralReceiver {

    // --- Events ---
    
    event BorrowerOperationsAddressChanged(address _newBorrowerOperationsAddress);
    event TroveManagerAddressChanged(address _newTroveManagerAddress);
    event ActivePoolAddressChanged(address _newActivePoolAddress);

    event CollBalanceUpdated(address indexed _account);
    event CollateralSent(address _to);

    // --- Contract setters ---

    function setAddresses(
        address _borrowerOperationsAddress,
        address _troveManagerAddress,
        address _troveManagerRedemptionsAddress,
        address _activePoolAddress,
        address _whitelistAddress
    ) external;

    function getCollVC() external view returns (uint);

    function getAmountClaimable(address _account, address _collateral) external view returns (uint);

    function getCollateral(address _collateral) external view returns (uint);

    function getAllCollateral() external view returns (address[] memory, uint256[] memory);

    function accountSurplus(address _account, address[] memory _tokens, uint[] memory _amounts) external;

    function claimColl(address _account) external;

    function addCollateralType(address _collateral) external;
}

File 11 of 18 : IERC20.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

/**
 * Based on the OpenZeppelin IER20 interface:
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol
 *
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);
    function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 12 of 18 : LiquityMath.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./SafeMath.sol";

library LiquityMath {
    using SafeMath for uint;

    uint internal constant DECIMAL_PRECISION = 1e18;

    function _min(uint _a, uint _b) internal pure returns (uint) {
        return (_a < _b) ? _a : _b;
    }

    function _max(uint _a, uint _b) internal pure returns (uint) {
        return (_a >= _b) ? _a : _b;
    }

    /* 
    * Multiply two decimal numbers and use normal rounding rules:
    * -round product up if 19'th mantissa digit >= 5
    * -round product down if 19'th mantissa digit < 5
    *
    * Used only inside the exponentiation, _decPow().
    */
    function decMul(uint x, uint y) internal pure returns (uint decProd) {
        uint prod_xy = x.mul(y);

        decProd = prod_xy.add(DECIMAL_PRECISION / 2).div(DECIMAL_PRECISION);
    }

    /* 
    * _decPow: Exponentiation function for 18-digit decimal base, and integer exponent n.
    * 
    * Uses the efficient "exponentiation by squaring" algorithm. O(log(n)) complexity. 
    * 
    * Called by two functions that represent time in units of minutes:
    * 1) TroveManager._calcDecayedBaseRate
    * 2) CommunityIssuance._getCumulativeIssuanceFraction 
    * 
    * The exponent is capped to avoid reverting due to overflow. The cap 525600000 equals
    * "minutes in 1000 years": 60 * 24 * 365 * 1000
    * 
    * If a period of > 1000 years is ever used as an exponent in either of the above functions, the result will be
    * negligibly different from just passing the cap, since: 
    *
    * In function 1), the decayed base rate will be 0 for 1000 years or > 1000 years
    * In function 2), the difference in tokens issued at 1000 years and any time > 1000 years, will be negligible
    */
    function _decPow(uint _base, uint _minutes) internal pure returns (uint) {
       
        if (_minutes > 525600000) {_minutes = 525600000;}  // cap to avoid overflow
    
        if (_minutes == 0) {return DECIMAL_PRECISION;}

        uint y = DECIMAL_PRECISION;
        uint x = _base;
        uint n = _minutes;

        // Exponentiation-by-squaring
        while (n > 1) {
            if (n % 2 == 0) {
                x = decMul(x, x);
                n = n.div(2);
            } else { // if (n % 2 != 0)
                y = decMul(x, y);
                x = decMul(x, x);
                n = (n.sub(1)).div(2);
            }
        }

        return decMul(x, y);
  }

    function _getAbsoluteDifference(uint _a, uint _b) internal pure returns (uint) {
        return (_a >= _b) ? _a.sub(_b) : _b.sub(_a);
    }

    //  _coll should be the amount of VC and _debt is debt of YUSD\
    // new collateral ratio is 10**18 times the collateral ratio. (150% => 1.5e18)
    function _computeCR(uint _coll, uint _debt) internal pure returns (uint) {
        if (_debt > 0) {
            uint newCollRatio = _coll.mul(10**18).div(_debt);
            return newCollRatio;
        }
        // Return the maximal value for uint256 if the Trove has a debt of 0. Represents "infinite" CR.
        else { // if (_debt == 0)
            return 2**256 - 1; 
        }
    }

}

File 13 of 18 : CheckContract.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;


contract CheckContract {
    /**
     * Check that the account is an already deployed non-destroyed contract.
     * See: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L12
     */
    function checkContract(address _account) internal view {
        require(_account != address(0), "Account cannot be zero address");

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(_account) }
        require(size > 0, "Account code size cannot be zero");
    }
}

File 14 of 18 : IPool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./ICollateralReceiver.sol";

// Common interface for the Pools.
interface IPool is ICollateralReceiver {
    
    // --- Events ---
    
    event ETHBalanceUpdated(uint _newBalance);
    event YUSDBalanceUpdated(uint _newBalance);
    event ActivePoolAddressChanged(address _newActivePoolAddress);
    event DefaultPoolAddressChanged(address _newDefaultPoolAddress);
    event StabilityPoolAddressChanged(address _newStabilityPoolAddress);
    event WhitelistAddressChanged(address _newWhitelistAddress);
    event EtherSent(address _to, uint _amount);
    event CollateralSent(address _collateral, address _to, uint _amount);

    // --- Functions ---

    function getVC() external view returns (uint);

    function getCollateral(address collateralAddress) external view returns (uint);

    function getAllCollateral() external view returns (address[] memory, uint256[] memory);

    function getYUSDDebt() external view returns (uint);

    function increaseYUSDDebt(uint _amount) external;

    function decreaseYUSDDebt(uint _amount) external;

}

File 15 of 18 : ICollateralReceiver.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

interface ICollateralReceiver {
    function receiveCollateral(address[] memory _tokens, uint[] memory _amounts) external;
}

File 16 of 18 : YetiCustomBase.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

import "./BaseMath.sol";
import "./SafeMath.sol";
import "../Interfaces/IERC20.sol";
import "../Interfaces/IWhitelist.sol";


contract YetiCustomBase is BaseMath {
    using SafeMath for uint256;

    IWhitelist whitelist;

    struct newColls {
        // tokens and amounts should be the same length
        address[] tokens;
        uint256[] amounts;
    }

    // Collateral math

    // gets the sum of _coll1 and _coll2
    function _sumColls(newColls memory _coll1, newColls memory _coll2)
        internal
        view
        returns (newColls memory finalColls)
    {
        newColls memory coll3;

        coll3.tokens = whitelist.getValidCollateral();
        coll3.amounts = new uint256[](coll3.tokens.length);

        uint256 n = 0;
        for (uint256 i = 0; i < _coll1.tokens.length; i++) {
            uint256 tokenIndex = whitelist.getIndex(_coll1.tokens[i]);
            if (_coll1.amounts[i] > 0) {
                n++;
                coll3.amounts[tokenIndex] = _coll1.amounts[i];
            }
        }

        for (uint256 i = 0; i < _coll2.tokens.length; i++) {
            uint256 tokenIndex = whitelist.getIndex(_coll2.tokens[i]);
            if (_coll2.amounts[i] > 0) {
                if (coll3.amounts[tokenIndex] == 0) {
                    n++;
                }
                coll3.amounts[tokenIndex] = coll3.amounts[tokenIndex].add(_coll2.amounts[i]);
            }
        }

        address[] memory sumTokens = new address[](n);
        uint256[] memory sumAmounts = new uint256[](n);
        uint256 j = 0;

        // should only find n amounts over 0
        for (uint256 i = 0; i < coll3.tokens.length; i++) {
            if (coll3.amounts[i] > 0) {
                sumTokens[j] = coll3.tokens[i];
                sumAmounts[j] = coll3.amounts[i];
                j++;
            }
        }
        finalColls.tokens = sumTokens;
        finalColls.amounts = sumAmounts;
    }


    // gets the sum of coll1 with tokens and amounts
    function _sumColls(
        newColls memory _coll1,
        address[] memory tokens,
        uint256[] memory amounts
    ) internal view returns (newColls memory) {
        newColls memory coll2 = newColls(tokens, amounts);
        return _sumColls(_coll1, coll2);
    }


    function _sumColls(
        address[] memory tokens1,
        uint256[] memory amounts1,
        address[] memory tokens2,
        uint256[] memory amounts2
    ) internal view returns (newColls memory) {
        newColls memory coll1 = newColls(tokens1, amounts1);
        return _sumColls(coll1, tokens2, amounts2);
    }


    // Function for summing colls when coll1 includes all the tokens in the whitelist
    // Used in active, default, stability, and surplus pools
    // assumes _coll1.tokens = all whitelisted tokens
    function _leftSumColls(
        newColls memory _coll1,
        address[] memory _tokens,
        uint256[] memory _amounts
    ) internal view returns (uint[] memory) {
        uint[] memory sumAmounts = _getArrayCopy(_coll1.amounts);

        // assumes that sumAmounts length = whitelist tokens length.
        for (uint256 i = 0; i < _tokens.length; i++) {
            uint tokenIndex = whitelist.getIndex(_tokens[i]);
            sumAmounts[tokenIndex] = sumAmounts[tokenIndex].add(_amounts[i]);
        }

        return sumAmounts;
    }


    // Function for summing colls when one list is all tokens. Used in active, default, stability, and surplus pools
    function _leftSubColls(newColls memory _coll1, address[] memory _subTokens, uint[] memory _subAmounts)
        internal
        view
        returns (uint[] memory)
    {
        uint[] memory diffAmounts = _getArrayCopy(_coll1.amounts);

        //assumes that coll1.tokens = whitelist tokens. Keeps all of coll1's tokens, and subtracts coll2's amounts
        for (uint256 i = 0; i < _subTokens.length; i++) {
            uint256 tokenIndex = whitelist.getIndex(_subTokens[i]);
            diffAmounts[tokenIndex] = diffAmounts[tokenIndex].sub(_subAmounts[i]);
        }
        return diffAmounts;
    }
    

    // Returns _coll1 minus _tokens and _amounts
    // will error if _tokens include a token not in _coll1.tokens
    function _subColls(newColls memory _coll1, address[] memory _tokens, uint[] memory _amounts)
        internal
        view
        returns (newColls memory finalColls)
    {
        require(_tokens.length == _amounts.length, "Sub Colls invalid input");

        newColls memory coll3;
        coll3.tokens = whitelist.getValidCollateral();
        coll3.amounts = new uint256[](coll3.tokens.length);
        uint256 n = 0;

        for (uint256 i = 0; i < _coll1.tokens.length; i++) {
            if (_coll1.amounts[i] > 0) {
                uint256 tokenIndex = whitelist.getIndex(_coll1.tokens[i]);
                coll3.amounts[tokenIndex] = _coll1.amounts[i];
                n++;
            }
        }

        for (uint256 i = 0; i < _tokens.length; i++) {
            uint256 tokenIndex = whitelist.getIndex(_tokens[i]);
            require(coll3.amounts[tokenIndex] >= _amounts[i], "illegal sub");
            coll3.amounts[tokenIndex] = coll3.amounts[tokenIndex].sub(_amounts[i]);
            if (coll3.amounts[tokenIndex] == 0) {
                n--;
            }
        }

        address[] memory diffTokens = new address[](n);
        uint256[] memory diffAmounts = new uint256[](n);
        uint256 j = 0;

        for (uint256 i = 0; i < coll3.tokens.length; i++) {
            if (coll3.amounts[i] > 0) {
                diffTokens[j] = coll3.tokens[i];
                diffAmounts[j] = coll3.amounts[i];
                j++;
            }
        }
        finalColls.tokens = diffTokens;
        finalColls.amounts = diffAmounts;
    }

    function _getArrayCopy(uint[] memory _arr) internal pure returns (uint[] memory){
        uint[] memory copy = new uint[](_arr.length);
        for (uint i = 0; i < _arr.length; i++) {
            copy[i] = _arr[i];
        }
        return copy;
    }
}

File 17 of 18 : BaseMath.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.11;


contract BaseMath {
    uint constant public DECIMAL_PRECISION = 1e18;
}

File 18 of 18 : SafeMath.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.6.11;

/**
 * Based on OpenZeppelin's SafeMath:
 * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol
 *
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"CollateralAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"CollateralDeprecated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"CollateralRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"CollateralUndeprecated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"OracleChanged","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":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"PriceCurveChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_collateral","type":"address"}],"name":"RatioChanged","type":"event"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_minRatio","type":"uint256"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"uint256","name":"_decimals","type":"uint256"},{"internalType":"address","name":"_priceCurve","type":"address"},{"internalType":"bool","name":"_isWrapped","type":"bool"},{"internalType":"address","name":"_routerAddress","type":"address"}],"name":"addCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_oracle","type":"address"}],"name":"changeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_priceCurve","type":"address"}],"name":"changePriceCurve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_ratio","type":"uint256"}],"name":"changeRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collateralParams","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"},{"internalType":"address","name":"priceCurve","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"bool","name":"isWrapped","type":"bool"},{"internalType":"address","name":"defaultRouter","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"deprecateCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getDefaultRouterAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_collateralVCInput","type":"uint256"},{"internalType":"uint256","name":"_collateralVCBalancePost","type":"uint256"},{"internalType":"uint256","name":"_totalVCBalancePre","type":"uint256"},{"internalType":"uint256","name":"_totalVCBalancePost","type":"uint256"}],"name":"getFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_collateralVCInput","type":"uint256"},{"internalType":"uint256","name":"_collateralVCBalancePost","type":"uint256"},{"internalType":"uint256","name":"_totalVCBalancePre","type":"uint256"},{"internalType":"uint256","name":"_totalVCBalancePost","type":"uint256"}],"name":"getFeeAndUpdate","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getIsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getPriceCurve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"getRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getValidCollateral","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"getValueUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"getValueVC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"isValidRouter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"isWrapped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_activePoolAddress","type":"address"},{"internalType":"address","name":"_defaultPoolAddress","type":"address"},{"internalType":"address","name":"_stabilityPoolAddress","type":"address"},{"internalType":"address","name":"_collSurplusPoolAddress","type":"address"},{"internalType":"address","name":"_borrowerOperationsAddress","type":"address"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"name":"setDefaultRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateral","type":"address"}],"name":"undeprecateCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"validCollateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"validRouter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50600080546001600160a01b0319163390811782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a36125e08061005f6000396000f3fe608060405234801561001057600080fd5b50600436106101845760003560e01c806380d4ab9b116100d9578063a992664711610087578063a992664714610594578063b31610db146105ba578063b56181d6146105e0578063c3b7f9fb14610634578063cacabd271461065a578063cf54aaa014610686578063efda2a3a146106ac57610184565b806380d4ab9b14610416578063885db0701461048a5780638d3f8298146104c85780638da5cb5b146105065780638f32d59b1461050e5780639d6aea0a14610516578063a80bdc651461056e57610184565b8063495ee13e11610136578063495ee13e146102d25780634dc809ce146102f85780635dd68acd146103285780636ae294021461037057806374b472ba1461039c578063754b2707146103c25780637d26a269146103e857610184565b806310d3d22e1461018957806317ae1fc5146101cb578063246eae92146102055780632a6e76031461022b5780632e2b1a88146102485780633b6678651461028657806341976e09146102ac575b600080fd5b6101af6004803603602081101561019f57600080fd5b50356001600160a01b03166106da565b604080516001600160a01b039092168252519081900360200190f35b6101f1600480360360208110156101e157600080fd5b50356001600160a01b031661079e565b604080519115158252519081900360200190f35b6101af6004803603602081101561021b57600080fd5b50356001600160a01b0316610862565b6101af6004803603602081101561024157600080fd5b503561092b565b6102746004803603604081101561025e57600080fd5b506001600160a01b038135169060200135610952565b60408051918252519081900360200190f35b6101af6004803603602081101561029c57600080fd5b50356001600160a01b0316610a62565b610274600480360360208110156102c257600080fd5b50356001600160a01b0316610b2b565b6101f1600480360360208110156102e857600080fd5b50356001600160a01b0316610c55565b6103266004803603604081101561030e57600080fd5b506001600160a01b0381358116916020013516610c76565b005b610326600480360360a081101561033e57600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013582169160809091013516610dd9565b6103266004803603604081101561038657600080fd5b506001600160a01b038135169060200135610eac565b610326600480360360208110156103b257600080fd5b50356001600160a01b031661108b565b610274600480360360208110156103d857600080fd5b50356001600160a01b0316611249565b610326600480360360408110156103fe57600080fd5b506001600160a01b0381358116916020013516611307565b61043c6004803603602081101561042c57600080fd5b50356001600160a01b031661156c565b604080519889526001600160a01b0397881660208a0152888101969096529315156060880152918516608087015260a0860152151560c085015290911660e083015251908190036101000190f35b610274600480360360a08110156104a057600080fd5b506001600160a01b0381351690602081013590604081013590606081013590608001356115c1565b610274600480360360a08110156104de57600080fd5b506001600160a01b038135169060208101359060408101359060608101359060800135611713565b6101af61188d565b6101f161189c565b61051e6118ad565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561055a578181015183820152602001610542565b505050509050019250505060405180910390f35b6101f16004803603602081101561058457600080fd5b50356001600160a01b031661190f565b6101f1600480360360208110156105aa57600080fd5b50356001600160a01b0316611924565b610274600480360360208110156105d057600080fd5b50356001600160a01b0316611942565b610326600480360360e08110156105f657600080fd5b506001600160a01b0381358116916020810135916040820135811691606081013591608082013581169160a081013515159160c09091013516611a03565b6103266004803603602081101561064a57600080fd5b50356001600160a01b0316611e07565b6102746004803603604081101561067057600080fd5b506001600160a01b038135169060200135611fc1565b6102746004803603602081101561069c57600080fd5b50356001600160a01b03166120ac565b610326600480360360408110156106c257600080fd5b506001600160a01b038135811691602001351661216d565b60085460009082901580159061071b5750806001600160a01b0316600860008154811061070357fe5b6000918252602090912001546001600160a01b031614155b1561077b576001600160a01b03811660009081526006602052604090206004015461077b576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b039081166000908152600660205260409020600101541690565b6008546000908290158015906107df5750806001600160a01b031660086000815481106107c757fe5b6000918252602090912001546001600160a01b031614155b1561083f576001600160a01b03811660009081526006602052604090206004015461083f576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b031660009081526006602052604090206003015460ff1690565b6008546000908290158015906108a35750806001600160a01b0316600860008154811061088b57fe5b6000918252602090912001546001600160a01b031614155b15610903576001600160a01b038116600090815260066020526040902060040154610903576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b0390811660009081526006602052604090206003015461010090041690565b6008818154811061093857fe5b6000918252602090912001546001600160a01b0316905081565b6008546000908390158015906109935750806001600160a01b0316600860008154811061097b57fe5b6000918252602090912001546001600160a01b031614155b156109f3576001600160a01b0381166000908152600660205260409020600401546109f3576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b60006109fe85610b2b565b6001600160a01b03861660009081526006602052604090206002810154905491925090610a5760128301600a0a610a4b83610a3f878b63ffffffff61229716565b9063ffffffff61229716565b9063ffffffff6122f916565b979650505050505050565b600854600090829015801590610aa35750806001600160a01b03166008600081548110610a8b57fe5b6000918252602090912001546001600160a01b031614155b15610b03576001600160a01b038116600090815260066020526040902060040154610b03576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b0390811660009081526006602052604090206005015461010090041690565b600854600090829015801590610b6c5750806001600160a01b03166008600081548110610b5457fe5b6000918252602090912001546001600160a01b031614155b15610bcc576001600160a01b038116600090815260066020526040902060040154610bcc576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b6001600160a01b038084166000908152600660209081526040808320600101548151634e1de1f360e11b815291519416938492639c3bc3e69260048082019391829003018186803b158015610c2057600080fd5b505afa158015610c34573d6000803e3d6000fd5b505050506040513d6020811015610c4a57600080fd5b505195945050505050565b6001600160a01b031660009081526006602052604090206005015460ff1690565b600854829015801590610cb45750806001600160a01b03166008600081548110610c9c57fe5b6000918252602090912001546001600160a01b031614155b15610d14576001600160a01b038116600090815260066020526040902060040154610d14576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b610d1c61189c565b610d5b576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b610d648361233b565b610d6d8261233b565b6001600160a01b0383811660008181526006602090815260409182902060010180546001600160a01b031916948716949094179093558051918252517f0e05ae75e8b926552cf6fcd744d19f422561e3ced1e426868730852702dbe418929181900390910190a1505050565b610de161189c565b610e20576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b610e298561233b565b610e328461233b565b610e3b8361233b565b610e448261233b565b610e4d8161233b565b600180546001600160a01b03199081166001600160a01b03978816179091556002805482169587169590951790945560038054851693861693909317909255600480548416918516919091179055600580549092169216919091179055565b600854829015801590610eea5750806001600160a01b03166008600081548110610ed257fe5b6000918252602090912001546001600160a01b031614155b15610f4a576001600160a01b038116600090815260066020526040902060040154610f4a576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b610f5261189c565b610f91576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b610f9a8361233b565b670f43fc2c04ee00008210610fe05760405162461bcd60e51b81526004018080602001828103825260638152602001806124b16063913960800191505060405180910390fd5b6001600160a01b03831660009081526006602052604090205482116110365760405162461bcd60e51b81526004018080602001828103825260278152602001806125846027913960400191505060405180910390fd5b6001600160a01b038316600081815260066020908152604091829020859055815192835290517f42003c0e521a93accadda033a276d9888c6eb60ce84258f09b301e5d50e1acda9281900390910190a1505050565b6008548190158015906110c95750806001600160a01b031660086000815481106110b157fe5b6000918252602090912001546001600160a01b031614155b15611129576001600160a01b038116600090815260066020526040902060040154611129576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b61113161189c565b611170576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b6111798261233b565b6001600160a01b03821660009081526006602052604090206003015460ff16156111ea576040805162461bcd60e51b815260206004820152601c60248201527f636f6c6c61746572616c20697320616c72656164792061637469766500000000604482015290519081900360640190fd5b6001600160a01b038216600081815260066020908152604091829020600301805460ff19166001179055815192835290517f075d7641153b3cf9af121a3c31a038deb6bcd961e86618d9a224d1a79e960a709281900390910190a15050565b60085460009082901580159061128a5750806001600160a01b0316600860008154811061127257fe5b6000918252602090912001546001600160a01b031614155b156112ea576001600160a01b0381166000908152600660205260409020600401546112ea576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b031660009081526006602052604090205490565b6008548290158015906113455750806001600160a01b0316600860008154811061132d57fe5b6000918252602090912001546001600160a01b031614155b156113a5576001600160a01b0381166000908152600660205260409020600401546113a5576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b6113ad61189c565b6113ec576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b6113f58361233b565b6113fe8261233b565b6001600160a01b0380841660009081526006602052604080822060030154815163f2cfd55160e01b8152825193948594610100909304169263f2cfd55192600480840193829003018186803b15801561145657600080fd5b505afa15801561146a573d6000803e3d6000fd5b505050506040513d604081101561148057600080fd5b50805160209091015160408051630161b04d60e51b8152600481018490526024810183905290519294509092506001600160a01b03861691632c3609a09160448082019260009290919082900301818387803b1580156114df57600080fd5b505af11580156114f3573d6000803e3d6000fd5b5050506001600160a01b038087166000818152600660209081526040918290206003018054948a1661010002610100600160a81b0319909516949094179093558051918252517f1eece1cb7fa4c337e7dcded9e7ee4ce791cb9e3cdfc1fb0c934549ab055aa19393509081900390910190a15050505050565b60066020526000908152604090208054600182015460028301546003840154600485015460059095015493946001600160a01b0393841694929360ff8084169461010094859004831694918116929190041688565b6008546000908690158015906116025750806001600160a01b031660086000815481106115ea57fe5b6000918252602090912001546001600160a01b031614155b15611662576001600160a01b038116600090815260066020526040902060040154611662576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b6001600160a01b03808816600090815260066020908152604091829020600301548251631cf76bbd60e21b8152600481018b9052602481018a9052604481018990526064810188905292516101009091049093169283926373ddaef4926084808301939192829003018186803b1580156116db57600080fd5b505afa1580156116ef573d6000803e3d6000fd5b505050506040513d602081101561170557600080fd5b505198975050505050505050565b6008546000908690158015906117545750806001600160a01b0316600860008154811061173c57fe5b6000918252602090912001546001600160a01b031614155b156117b4576001600160a01b0381166000908152600660205260409020600401546117b4576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b6005546001600160a01b031633146117fd5760405162461bcd60e51b815260040180806020018281038252602f815260200180612555602f913960400191505060405180910390fd5b6001600160a01b0380881660009081526006602090815260408083206003015481516374c7b0bb60e11b8152600481018c9052602481018b9052604481018a905260648101899052915161010090910490941693849363e98f617693608480850194919392918390030190829087803b15801561187957600080fd5b505af11580156116ef573d6000803e3d6000fd5b6000546001600160a01b031690565b6000546001600160a01b0316331490565b6060600880548060200260200160405190810160405280929190818152602001828054801561190557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116118e7575b5050505050905090565b60076020526000908152604090205460ff1681565b6001600160a01b031660009081526007602052604090205460ff1690565b6008546000908290158015906119835750806001600160a01b0316600860008154811061196b57fe5b6000918252602090912001546001600160a01b031614155b156119e3576001600160a01b0381166000908152600660205260409020600401546119e3576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b031660009081526006602052604090206004015490565b611a0b61189c565b611a4a576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b611a538761233b565b611a5c8561233b565b611a658361233b565b611a6e8161233b565b60085415611b1757866001600160a01b03166008600081548110611a8e57fe5b6000918252602090912001546001600160a01b031614801590611aca57506001600160a01b038716600090815260066020526040902060040154155b611b17576040805162461bcd60e51b8152602060048201526019602482015278636f6c6c61746572616c20616c72656164792065786973747360381b604482015290519081900360640190fd5b60088054600181810183557ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee390910180546001600160a01b03808c166001600160a01b031992831681179093556040805161010081810183528d82528c841660208381019182528385018e8152606085018a81528e8816608087019081529b546000190160a087019081528e151560c088019081528e8a1660e0890190815260008d81526006909652898620985189559551888e018054918c1691909c1617909a5591516002870155516003860180549c5189168602610100600160a81b031992151560ff199e8f1617831617905590516004808701919091559751600590950180549351881690940294151592909a169190911790981691909117905593548451633b03578360e21b8152928301939093529251919092169263ec0d5e0c926024808201939182900301818387803b158015611c7357600080fd5b505af1158015611c87573d6000803e3d6000fd5b505060025460408051633b03578360e21b81526001600160a01b038c81166004830152915191909216935063ec0d5e0c9250602480830192600092919082900301818387803b158015611cd957600080fd5b505af1158015611ced573d6000803e3d6000fd5b505060035460408051633b03578360e21b81526001600160a01b038c81166004830152915191909216935063ec0d5e0c9250602480830192600092919082900301818387803b158015611d3f57600080fd5b505af1158015611d53573d6000803e3d6000fd5b50506004805460408051633b03578360e21b81526001600160a01b038d811694820194909452905192909116935063ec0d5e0c925060248082019260009290919082900301818387803b158015611da957600080fd5b505af1158015611dbd573d6000803e3d6000fd5b5050604080516001600160a01b038b16815290517f7db05e63d635a68c62fd7fd8f3107ae8ab584a383e102d1bd8a40f4c977e465f9350908190036020019150a150505050505050565b600854819015801590611e455750806001600160a01b03166008600081548110611e2d57fe5b6000918252602090912001546001600160a01b031614155b15611ea5576001600160a01b038116600090815260066020526040902060040154611ea5576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b611ead61189c565b611eec576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b611ef58261233b565b6001600160a01b03821660009081526006602052604090206003015460ff16611f65576040805162461bcd60e51b815260206004820152601d60248201527f636f6c6c61746572616c20616c72656164792064657072656361746564000000604482015290519081900360640190fd5b6001600160a01b038216600081815260066020908152604091829020600301805460ff19169055815192835290517f97cc48cf2f097cb5786b83cfac928f0b821dea349f79ae098db30ab260b834589281900390910190a15050565b6008546000908390158015906120025750806001600160a01b03166008600081548110611fea57fe5b6000918252602090912001546001600160a01b031614155b15612062576001600160a01b038116600090815260066020526040902060040154612062576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b6001600160a01b0384166000908152600660205260408120600201549061208886610b2b565b90506120a2600a83900a610a4b838863ffffffff61229716565b9695505050505050565b6008546000908290158015906120ed5750806001600160a01b031660086000815481106120d557fe5b6000918252602090912001546001600160a01b031614155b1561214d576001600160a01b03811660009081526006602052604090206004015461214d576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b50506001600160a01b031660009081526006602052604090206002015490565b61217561189c565b6121b4576040805162461bcd60e51b81526020600482018190526024820152600080516020612535833981519152604482015290519081900360640190fd5b6008548290158015906121f25750806001600160a01b031660086000815481106121da57fe5b6000918252602090912001546001600160a01b031614155b15612252576001600160a01b038116600090815260066020526040902060040154612252576040805162461bcd60e51b815260206004820152601a6024820152600080516020612491833981519152604482015290519081900360640190fd5b61225b8261233b565b506001600160a01b03918216600090815260066020526040902060050180549290911661010002610100600160a81b0319909216919091179055565b6000826122a6575060006122f3565b828202828482816122b357fe5b04146122f05760405162461bcd60e51b81526004018080602001828103825260218152602001806125146021913960400191505060405180910390fd5b90505b92915050565b60006122f083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506123ee565b6001600160a01b038116612396576040805162461bcd60e51b815260206004820152601e60248201527f4163636f756e742063616e6e6f74206265207a65726f20616464726573730000604482015290519081900360640190fd5b803b806123ea576040805162461bcd60e51b815260206004820181905260248201527f4163636f756e7420636f64652073697a652063616e6e6f74206265207a65726f604482015290519081900360640190fd5b5050565b6000818361247a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561243f578181015183820152602001612427565b50505050905090810190601f16801561246c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161248657fe5b049594505050505056fe636f6c6c61746572616c20646f6573206e6f7420657869737473000000000000726174696f206d757374206265206c657373207468616e20312e3130203d3e2067726561746572207468616e20312e3120776f756c64206d65616e2074616b696e67206f7574206d6f72652059555344207468616e20636f6c6c61746572616c205643536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726f6e6c7920626f72726f776572206f7065726174696f6e732063616e2063616c6c20746869732066756e6374696f6e4e6577205352206d7573742062652067726561746572207468616e2070726576696f7573205352a26469706673582212204f9d7928bde66a7c91243cb09b1b5a00c9ed0774c34184e4a6ca2d06562a966464736f6c634300060b0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading