Contract 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x22d2c8cc30bc3babf26c3c641f0b8285846fdbbbf64d23c4fb7e44c553038bcd0x6080604056477412022-02-08 15:16:12147 days 9 hrs ago0x4d78eaad745354de3d8442587a4b31ec21e297de IN  Create: LoanTokenLogicStandard0 ETH0.055959357029 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x9aff9008d6a936cf6986d8ccd7914accafeb39e97fa2ff3f3d252c4073197cd197094302022-04-12 20:51:1884 days 3 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x9aff9008d6a936cf6986d8ccd7914accafeb39e97fa2ff3f3d252c4073197cd197094302022-04-12 20:51:1884 days 3 hrs ago 0xe487a866b0f6b1b663b4566ff7e998af6116fba9 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x661ab270ab27a8fb4272af646ea6435d23da9afff095f9f90845cf42608f21a296872812022-04-12 11:32:1684 days 12 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xda3845c0a8933144559f5fcf885671ff8f0ffc7271c7da8abcdee98faaf75bed96576642022-04-11 20:30:2785 days 3 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xda3845c0a8933144559f5fcf885671ff8f0ffc7271c7da8abcdee98faaf75bed96576642022-04-11 20:30:2785 days 3 hrs ago 0x3fda2d22e7853f548c3a74df3663a9427ffbb362 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xeef83fa5b752d420b10bb958d8ef39f8acac67753ad2c5b4da098363c84b49bd96482842022-04-11 16:35:5385 days 7 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xeef83fa5b752d420b10bb958d8ef39f8acac67753ad2c5b4da098363c84b49bd96482842022-04-11 16:35:5385 days 7 hrs ago 0x87f92db0476b9627d29e922781b1cc892602380c 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x90458fb2cfc05a64a67b4c752c3c0da1d9de06b030169f1830e9ed1d746cff7896208142022-04-11 5:31:3485 days 18 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x90458fb2cfc05a64a67b4c752c3c0da1d9de06b030169f1830e9ed1d746cff7896208142022-04-11 5:31:3485 days 18 hrs ago 0x87f92db0476b9627d29e922781b1cc892602380c 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x39c1357e63bae1dddaed645329bcfe59fd2a046dd305182478cc2d635bc27cd396094452022-04-10 23:29:2186 days 47 mins ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x39c1357e63bae1dddaed645329bcfe59fd2a046dd305182478cc2d635bc27cd396094452022-04-10 23:29:2186 days 47 mins ago 0x92774c03881baa1f27fe5ab4f2121d26eaafc101 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xa493379bfb1cae2849ffb6d7e247274f3d54ebbcb22c0c61cd073c3f40137bd095395362022-04-09 8:02:5087 days 16 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xa493379bfb1cae2849ffb6d7e247274f3d54ebbcb22c0c61cd073c3f40137bd095395362022-04-09 8:02:5087 days 16 hrs ago 0x92774c03881baa1f27fe5ab4f2121d26eaafc101 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x535c3619e87dc43b8c188dad6b28fdeb3d5b473b1d6811f1451c2c576d421b1b94215792022-04-06 23:44:4590 days 32 mins ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x535c3619e87dc43b8c188dad6b28fdeb3d5b473b1d6811f1451c2c576d421b1b94215792022-04-06 23:44:4590 days 32 mins ago 0x9030b78a312147dba34359d1a8819336fd054230 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x67deb315e5a595132effcb59ee374600be377929fc2a1ede0d692c58a09535f793815752022-04-06 7:00:0490 days 17 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x67deb315e5a595132effcb59ee374600be377929fc2a1ede0d692c58a09535f793815752022-04-06 7:00:0490 days 17 hrs ago 0xfb5c1bfd82100b58e98a45e23dc6756ae24c0615 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x4672695f64ae5b03749e851ec94c119ac5501e72f6eceb8e6288b883eba45f7f92797802022-04-04 6:31:0192 days 17 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x4672695f64ae5b03749e851ec94c119ac5501e72f6eceb8e6288b883eba45f7f92797802022-04-04 6:31:0192 days 17 hrs ago 0xfb5c1bfd82100b58e98a45e23dc6756ae24c0615 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0xa1f567a3d83de53827cf7aecfc9ee91043ca084bee5858c5b289807faaadc05492253772022-04-03 7:25:3693 days 16 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x9bdaf40059c527814cde0ab585eb0cc486884b47cc1786886f205c4bb7a7015292252682022-04-03 7:23:3093 days 16 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x9bdaf40059c527814cde0ab585eb0cc486884b47cc1786886f205c4bb7a7015292252682022-04-03 7:23:3093 days 16 hrs ago 0xe487a866b0f6b1b663b4566ff7e998af6116fba9 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x91a04cca22a089061fab12a278f8835202c610f7fa38c1fd3df6dc94eafdc3dd92252452022-04-03 7:22:2993 days 16 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x537e4c839ea8deb8f4d993a0c4869fbf646a9d8ce358347413ccd782e58f13b192009872022-04-02 20:45:3494 days 3 hrs ago 0x37407f3178ffe07a6cf5c847f8f680fecf319fab 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
0x537e4c839ea8deb8f4d993a0c4869fbf646a9d8ce358347413ccd782e58f13b192009872022-04-02 20:45:3494 days 3 hrs ago 0xe487a866b0f6b1b663b4566ff7e998af6116fba9 0x6e1e6f1b49b46dfeb61e52441cc942ed717e77da0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LoanTokenLogicStandard

Compiler Version
v0.5.17+commit.d19bba13

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 18 : LoanTokenLogicStandard.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;
pragma experimental ABIEncoderV2;

import "AdvancedToken.sol";
import "StorageExtension.sol";
import "IBZx.sol";
import "IPriceFeeds.sol";

contract LoanTokenLogicStandard is AdvancedToken, StorageExtension {
    using SafeMath for uint256;
    using SignedSafeMath for int256;


    //// CONSTANTS ////

    uint256 public constant VERSION = 7;

    //address internal constant arbitraryCaller = 0x000F400e6818158D541C3EBE45FE3AA0d47372FF; // mainnet
    //address internal constant arbitraryCaller = 0x81e7dddFAD37E6FAb0eccE95f0B508fd40996e6d; // bsc
    //address internal constant arbitraryCaller = 0x81e7dddFAD37E6FAb0eccE95f0B508fd40996e6d; // polygon
    address internal constant arbitraryCaller = 0x01207468F48822f8535BC96D1Cf18EddDE4A2392; // arbitrum

    //address public constant bZxContract = 0xD8Ee69652E4e4838f2531732a46d1f7F584F0b7f; // mainnet
    //address public constant wethToken = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // mainnet

    //address public constant bZxContract = 0x5cfba2639a3db0D9Cc264Aa27B2E6d134EeA486a; // kovan
    //address public constant wethToken = 0xd0A1E359811322d97991E03f863a0C30C2cF029C; // kovan

    //address public constant bZxContract = 0xD154eE4982b83a87b0649E5a7DDA1514812aFE1f; // bsc
    //address public constant wethToken = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; // bsc

    //address public constant bZxContract = 0x059D60a9CEfBc70b9Ea9FFBb9a041581B1dFA6a8; // polygon
    //address public constant wethToken = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // polygon

    address public constant bZxContract = 0x37407F3178ffE07a6cF5C847F8f680FEcf319FAB; // arbitrum
    address public constant wethToken = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1; // arbitrum

    bytes32 internal constant iToken_ProfitSoFar = 0x37aa2b7d583612f016e4a4de4292cb015139b3d7762663d06a53964912ea2fb6;          // keccak256("iToken_ProfitSoFar")
    bytes32 internal constant iToken_LowerAdminAddress = 0x7ad06df6a0af6bd602d90db766e0d5f253b45187c3717a0f9026ea8b10ff0d4b;    // keccak256("iToken_LowerAdminAddress")
    bytes32 internal constant iToken_LowerAdminContract = 0x34b31cff1dbd8374124bd4505521fc29cab0f9554a5386ba7d784a4e611c7e31;   // keccak256("iToken_LowerAdminContract")

    constructor(
        address _newOwner)
        public
    {
        transferOwnership(_newOwner);
    }

    function()
        external
    {
        revert("fallback not allowed");
    }

    /* Public functions */

    function mint(
        address receiver,
        uint256 depositAmount)
        external
        nonReentrant
        returns (uint256) // mintAmount
    {
        return _mintToken(
            receiver,
            depositAmount
        );
    }

    function burn(
        address receiver,
        uint256 burnAmount)
        external
        nonReentrant
        returns (uint256 loanAmountPaid)
    {
        loanAmountPaid = _burnToken(
            burnAmount
        );

        if (loanAmountPaid != 0) {
            _safeTransfer(loanTokenAddress, receiver, loanAmountPaid, "5");
        }
    }

    function flashBorrow(
        uint256 borrowAmount,
        address borrower,
        address target,
        string calldata signature,
        bytes calldata data)
        external
        payable
        nonReentrant
        pausable
        returns (bytes memory)
    {
        require(borrowAmount != 0, "38");

        _settleInterest(0);

        // save before balances
        uint256 beforeEtherBalance = address(this).balance.sub(msg.value);
        uint256 beforeAssetsBalance = _underlyingBalance()
            .add(_totalAssetBorrowStored());

        // lock totalAssetSupply for duration of flash loan
        _flTotalAssetSupply = beforeAssetsBalance;

        // transfer assets to calling contract
        _safeTransfer(loanTokenAddress, borrower, borrowAmount, "39");

        emit FlashBorrow(borrower, target, loanTokenAddress, borrowAmount);

        bytes memory callData;
        if (bytes(signature).length == 0) {
            callData = data;
        } else {
            callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);
        }

        // arbitrary call
        (bool success, bytes memory returnData) = arbitraryCaller.call.value(msg.value)(
            abi.encodeWithSelector(
                0xde064e0d, // sendCall(address,bytes)
                target,
                callData
            )
        );
        require(success, "call failed");

        // unlock totalAssetSupply
        _flTotalAssetSupply = 0;
		
		// pay flash borrow fees
        IBZx(bZxContract).payFlashBorrowFees(
            borrower,
            borrowAmount,
            flashBorrowFeePercent
        );
	
        // verifies return of flash loan
        require(
            address(this).balance >= beforeEtherBalance &&
            _underlyingBalance()
                .add(_totalAssetBorrowStored()) >= beforeAssetsBalance,
            "40"
        );

        return returnData;
    }

    function borrow(
        bytes32 loanId,                 // 0 if new loan
        uint256 withdrawAmount,
        uint256 initialLoanDuration,    // duration in seconds
        uint256 collateralTokenSent,    // if 0, loanId must be provided; any ETH sent must equal this value
        address collateralTokenAddress, // if address(0), this means ETH and ETH must be sent with the call or loanId must be provided
        address borrower,
        address receiver,
        bytes memory /*loanDataBytes*/) // arbitrary order data
        public
        payable
        nonReentrant
        returns (IBZx.LoanOpenData memory)
    {
        return _borrow(
            loanId,
            withdrawAmount,
            initialLoanDuration,
            collateralTokenSent,
            collateralTokenAddress,
            borrower,
            receiver,
            ""
        );
    }

    // Called to borrow and immediately get into a position
    function marginTrade(
        bytes32 loanId,                 // 0 if new loan
        uint256 leverageAmount,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress,
        address trader,
        bytes memory loanDataBytes)     // arbitrary order data
        public
        payable
        nonReentrant
        returns (IBZx.LoanOpenData memory)
    {
        return _marginTrade(
            loanId,
            leverageAmount,
            loanTokenSent,
            collateralTokenSent,
            collateralTokenAddress,
            trader,
            loanDataBytes
        );
    }

    function transfer(
        address _to,
        uint256 _value)
        external
        returns (bool)
    {
        return _internalTransferFrom(
            msg.sender,
            _to,
            _value,
            uint256(-1)
        );
    }

    function transferFrom(
        address _from,
        address _to,
        uint256 _value)
        external
        returns (bool)
    {
        return _internalTransferFrom(
            _from,
            _to,
            _value,
            allowed[_from][msg.sender]
            /*IBZx(bZxContract).isLoanPool(msg.sender) ?
                uint256(-1) :
                allowed[_from][msg.sender]*/
        );
    }

    function _internalTransferFrom(
        address _from,
        address _to,
        uint256 _value,
        uint256 _allowanceAmount)
        internal
        returns (bool)
    {
        if (_allowanceAmount != uint256(-1)) {
            allowed[_from][msg.sender] = _allowanceAmount.sub(_value, "14");
        }

        require(_to != address(0), "15");

        uint256 _balancesFrom = balances[_from];
        uint256 _balancesFromNew = _balancesFrom
            .sub(_value, "16");
        balances[_from] = _balancesFromNew;

        uint256 _balancesTo = balances[_to];
        uint256 _balancesToNew = _balancesTo
            .add(_value);
        balances[_to] = _balancesToNew;

        // handle checkpoint update
        uint256 _currentPrice = tokenPrice();

        _updateCheckpoints(
            _from,
            _balancesFrom,
            _balancesFromNew,
            _currentPrice
        );
        _updateCheckpoints(
            _to,
            _balancesTo,
            _balancesToNew,
            _currentPrice
        );

        emit Transfer(_from, _to, _value);
        return true;
    }

    function _updateCheckpoints(
        address _user,
        uint256 _oldBalance,
        uint256 _newBalance,
        uint256 _currentPrice)
        internal
    {
        bytes32 slot = keccak256(
            abi.encodePacked(_user, iToken_ProfitSoFar)
        );

        int256 _currentProfit;
        if (_newBalance == 0) {
            _currentPrice = 0;
        } else if (_oldBalance != 0) {
            _currentProfit = _profitOf(
                slot,
                _oldBalance,
                _currentPrice,
                checkpointPrices_[_user]
            );
        }

        assembly {
            sstore(slot, _currentProfit)
        }

        checkpointPrices_[_user] = _currentPrice;
    }

    /* Public View functions */

    function profitOf(
        address user)
        public
        view
        returns (int256)
    {
        bytes32 slot = keccak256(
            abi.encodePacked(user, iToken_ProfitSoFar)
        );

        return _profitOf(
            slot,
            balances[user],
            tokenPrice(),
            checkpointPrices_[user]
        );
    }

    function _profitOf(
        bytes32 slot,
        uint256 _balance,
        uint256 _currentPrice,
        uint256 _checkpointPrice)
        internal
        view
        returns (int256 profitSoFar)
    {
        if (_checkpointPrice == 0) {
            return 0;
        }

        assembly {
            profitSoFar := sload(slot)
        }

        profitSoFar = int256(_currentPrice)
            .sub(int256(_checkpointPrice))
            .mul(int256(_balance))
            .div(sWEI_PRECISION)
            .add(profitSoFar);
    }

    function tokenPrice()
        public
        view
        returns (uint256) // price
    {
        return _tokenPrice(_totalAssetSupply(totalAssetBorrow()));
    }

    function checkpointPrice(
        address _user)
        public
        view
        returns (uint256) // price
    {
        return checkpointPrices_[_user];
    }

    function marketLiquidity()
        public
        view
        returns (uint256)
    {
        return _underlyingBalance();
    }

    // legacy function
    function avgBorrowInterestRate()
        external
        view
        returns (uint256)
    {
        return borrowInterestRate();
    }

    // the current rate being paid by borrowers in active loans
    function borrowInterestRate()
        public
        view
        returns (uint256)
    {
        return _nextBorrowInterestRate(
            _totalAssetBorrowStored(),
            0,
            poolLastInterestRate()
        );
    }

    // the minimum rate that new and existing borrowers will pay after the next borrow
    function nextBorrowInterestRate(
        uint256 borrowAmount)
        external
        view
        returns (uint256)
    {
        return _nextBorrowInterestRate(
            totalAssetBorrow(),
            borrowAmount,
            poolLastInterestRate()
        );
    }

    // the current rate being received by suppliers
    function supplyInterestRate()
        external
        view
        returns (uint256)
    {
        uint256 assetBorrow = _totalAssetBorrowStored();
        return _nextSupplyInterestRate(
            _nextBorrowInterestRate(assetBorrow, 0, poolLastInterestRate()),
            assetBorrow,
            _totalAssetSupply(assetBorrow)
        );
    }

    // the minimum rate new and existing suppliers will receive after the next supply
    function nextSupplyInterestRate(
        uint256 supplyAmount)
        external
        view
        returns (uint256)
    {
        uint256 assetBorrow = totalAssetBorrow();
        return _nextSupplyInterestRate(
            _nextBorrowInterestRate(assetBorrow, 0, poolLastInterestRate()),
            assetBorrow,
            _totalAssetSupply(assetBorrow).add(supplyAmount)
        );
    }

    function totalAssetBorrow()
        public
        view
        returns (uint256)
    {
        return IBZx(bZxContract).getTotalPrincipal(
            address(this),
            address(0) // loanTokenAddress (depreciated)
        );
    }

    function _totalAssetBorrowStored()
        internal
        view
        returns (uint256)
    {
        return IBZx(bZxContract).getPoolPrincipalStored(address(this));
    }

    function totalAssetSupply()
        external
        view
        returns (uint256)
    {
        return _totalAssetSupply(totalAssetBorrow());
    }

    function poolLastInterestRate()
        public
        view
        returns (uint256)
    {
        return IBZx(bZxContract).getPoolLastInterestRate(address(this));
    }

    function getMaxEscrowAmount(
        uint256 leverageAmount)
        external
        view
        returns (uint256)
    {
        uint256 initialMargin = SafeMath.div(WEI_PRECISION * WEI_PERCENT_PRECISION, leverageAmount);
        return marketLiquidity()
            .mul(initialMargin)
            .div(WEI_PERCENT_PRECISION);
    }

    // returns the user's balance of underlying token
    function assetBalanceOf(
        address _owner)
        external
        view
        returns (uint256)
    {
        return balanceOf(_owner)
            .mul(tokenPrice())
            .div(WEI_PRECISION);
    }

    function getEstimatedMarginDetails(
        uint256 leverageAmount,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress)     // address(0) means ETH
        external
        view
        returns (uint256 principal, uint256 collateral, uint256 interestRate, uint256 collateralToLoanRate)
    {
        if (collateralTokenAddress == address(0)) {
            collateralTokenAddress = wethToken;
        }

        uint256 collateralToLoanPrecision;
        (collateralToLoanRate, collateralToLoanPrecision) = IPriceFeeds(IBZx(bZxContract).priceFeeds()).queryRate(
            collateralTokenAddress,
            loanTokenAddress
        );
        require(collateralToLoanRate != 0 && collateralToLoanPrecision != 0, "20");
        collateralToLoanRate = collateralToLoanRate
            .mul(WEI_PRECISION)
            .div(collateralToLoanPrecision);

        collateral = IBZx(bZxContract).getEstimatedMarginExposure(
            loanTokenAddress,
            collateralTokenAddress,
            loanTokenSent,
            collateralTokenSent,
            0, // interestRate (depreciated)
            0 // principal
        );
    }

    function getDepositAmountForBorrow(
        uint256 borrowAmount,
        uint256 initialLoanDuration,        // duration in seconds
        address collateralTokenAddress)     // address(0) means ETH
        external
        view
        returns (uint256) // depositAmount
    {
        if (borrowAmount != 0) {
            if (borrowAmount <= _underlyingBalance()) {
                if (collateralTokenAddress == address(0)) {
                    collateralTokenAddress = wethToken;
                }
                return IBZx(bZxContract).getRequiredCollateralByParams(
                    loanParamsIds[uint256(keccak256(abi.encodePacked(
                        collateralTokenAddress,
                        true
                    )))],
                    borrowAmount
                ).add(10); // some dust to compensate for rounding errors
            }
        }
    }

    function getBorrowAmountForDeposit(
        uint256 depositAmount,
        uint256 initialLoanDuration,        // duration in seconds
        address collateralTokenAddress)     // address(0) means ETH
        external
        view
        returns (uint256 borrowAmount)
    {
        if (depositAmount != 0) {
            if (collateralTokenAddress == address(0)) {
                collateralTokenAddress = wethToken;
            }
            borrowAmount = IBZx(bZxContract).getBorrowAmountByParams(
                loanParamsIds[uint256(keccak256(abi.encodePacked(
                    collateralTokenAddress,
                    true
                )))],
                depositAmount
            );

            if (borrowAmount > _underlyingBalance()) {
                borrowAmount = 0;
            }
        }
    }

    function getPoolUtilization()
        external
        view
        returns (uint256)
    {
        uint256 totalBorrow = totalAssetBorrow();
        return _utilizationRate(
            totalBorrow,
            _totalAssetSupply(totalBorrow)
        );
    }

    /* Internal functions */

    function _mintToken(
        address receiver,
        uint256 depositAmount)
        internal
        pausable
        returns (uint256 mintAmount)
    {
        require (depositAmount != 0, "17");

        _settleInterest(0);

        uint256 currentPrice = _tokenPrice(_totalAssetSupply(_totalAssetBorrowStored()));
        mintAmount = depositAmount
            .mul(WEI_PRECISION)
            .div(currentPrice);

        if (msg.value == 0) {
            _safeTransferFrom(loanTokenAddress, msg.sender, address(this), depositAmount, "18");
        } else {
            require(msg.value == depositAmount, "18");
            IWeth(wethToken).deposit.value(depositAmount)();
        }

        _updateCheckpoints(
            receiver,
            balances[receiver],
            _mint(receiver, mintAmount, depositAmount, currentPrice), // newBalance
            currentPrice
        );
    }

    function _burnToken(
        uint256 burnAmount)
        internal
        pausable
        returns (uint256 loanAmountPaid)
    {
        require(burnAmount != 0, "19");

        _settleInterest(0);

        if (burnAmount > balanceOf(msg.sender)) {
            require(burnAmount == uint256(-1), "32");
            burnAmount = balanceOf(msg.sender);
        }

        uint256 currentPrice = _tokenPrice(_totalAssetSupply(_totalAssetBorrowStored()));

        uint256 loanAmountOwed = burnAmount
            .mul(currentPrice)
            .div(WEI_PRECISION);
        uint256 loanAmountAvailableInContract = _underlyingBalance();

        loanAmountPaid = loanAmountOwed;
        require(loanAmountPaid <= loanAmountAvailableInContract, "37");

        _updateCheckpoints(
            msg.sender,
            balances[msg.sender],
            _burn(msg.sender, burnAmount, loanAmountPaid, currentPrice), // newBalance
            currentPrice
        );
    }

    function _borrow(
        bytes32 loanId,                 // 0 if new loan
        uint256 withdrawAmount,
        uint256 initialLoanDuration,    // duration in seconds
        uint256 collateralTokenSent,    // if 0, loanId must be provided; any ETH sent must equal this value
        address collateralTokenAddress, // if address(0), this means ETH and ETH must be sent with the call or loanId must be provided
        address borrower,
        address receiver,
        bytes memory /*loanDataBytes*/) // arbitrary order data
        internal
        pausable
        returns (IBZx.LoanOpenData memory)
    {
        require(withdrawAmount != 0, "6");

        require(msg.value == 0 || msg.value == collateralTokenSent, "7");
        require(collateralTokenSent != 0 || loanId != 0, "8");
        require(collateralTokenAddress != address(0) || msg.value != 0 || loanId != 0, "9");

        // ensures authorized use of existing loan
        require(loanId == 0 || msg.sender == borrower, "13");

        _settleInterest(loanId);

        if (loanId == 0) {
            loanId = keccak256(abi.encodePacked(
                collateralTokenAddress,
                address(this),
                msg.sender,
                borrower,
                block.timestamp
            ));
        }

        if (collateralTokenAddress == address(0)) {
            collateralTokenAddress = wethToken;
        }
        require(collateralTokenAddress != loanTokenAddress, "10");

        address[4] memory sentAddresses;
        uint256[5] memory sentAmounts;

        sentAddresses[0] = address(this); // lender
        sentAddresses[1] = borrower;
        sentAddresses[2] = receiver;
        //sentAddresses[3] = address(0); // manager

        //sentAmounts[0] = 0; // interestRate (found later)
        //sentAmounts[1] = 0; // borrowAmount (found later)
        //sentAmounts[2] = 0; // interestInitialAmount (found later)
        //sentAmounts[3] = 0; // loanTokenSent
        sentAmounts[4] = collateralTokenSent;

        sentAmounts[1] = withdrawAmount;
        sentAmounts[2] = 0; // interestInitialAmount (depreciated)

        return _borrowOrTrade(
            loanId,
            withdrawAmount,
            0, // leverageAmount (calculated later)
            collateralTokenAddress,
            sentAddresses,
            sentAmounts,
            "" // loanDataBytes
        );
    }

    function _marginTrade(
        bytes32 loanId,                 // 0 if new loan
        uint256 leverageAmount,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress,
        address trader,
        bytes memory loanDataBytes)
        internal
        pausable
        returns (IBZx.LoanOpenData memory loanOpenData)
    {
        // ensures authorized use of existing loan
        require(loanId == 0 || msg.sender == trader, "13");

        _settleInterest(loanId);

        if (loanId == 0) {
            loanId = keccak256(abi.encodePacked(
                collateralTokenAddress,
                address(this),
                msg.sender,
                trader,
                block.timestamp
            ));
        }

        if (collateralTokenAddress == address(0)) {
            collateralTokenAddress = wethToken;
        }
        require(collateralTokenAddress != loanTokenAddress, "11");

        address[4] memory sentAddresses;
        uint256[5] memory sentAmounts;

        sentAddresses[0] = address(this); // lender
        sentAddresses[1] = trader;
        sentAddresses[2] = trader;
        //sentAddresses[3] = address(0); // manager

        //sentAmounts[0] = 0; // interestRate (found later)
        //sentAmounts[1] = 0; // borrowAmount (found later)
        //sentAmounts[2] = 0; // interestInitialAmount (interest is calculated based on fixed-term loan)
        sentAmounts[3] = loanTokenSent;
        sentAmounts[4] = collateralTokenSent;

        uint256 totalDeposit;
        uint256 collateralToLoanRate;
        (sentAmounts[1],, totalDeposit, collateralToLoanRate) = _getPreMarginData( // borrowAmount, interestRate, totalDeposit, collateralToLoanRate
            collateralTokenAddress,
            collateralTokenSent,
            loanTokenSent,
            leverageAmount
        );
        require(totalDeposit != 0, "12");

        loanOpenData = _borrowOrTrade(
            loanId,
            0, // withdrawAmount
            leverageAmount,
            collateralTokenAddress,
            sentAddresses,
            sentAmounts,
            loanDataBytes
        );

        IBZx(bZxContract).setDepositAmount(
            loanOpenData.loanId,
            totalDeposit,
            totalDeposit
                .mul(WEI_PRECISION)
                .div(collateralToLoanRate)
        );

        return loanOpenData;
    }

    function _settleInterest(
        bytes32 loanId)
        internal
    {   
        IBZx(bZxContract).settleInterest(loanId);
    }

    function _totalDeposit(
        address collateralTokenAddress,
        uint256 collateralTokenSent,
        uint256 loanTokenSent)
        internal
        view
        returns (uint256 totalDeposit, uint256 collateralToLoanRate)
    {
        uint256 collateralToLoanPrecision;
        (collateralToLoanRate, collateralToLoanPrecision) = IPriceFeeds(IBZx(bZxContract).priceFeeds()).queryRate(
            collateralTokenAddress,
            loanTokenAddress
        );
        require(collateralToLoanRate != 0 && collateralToLoanPrecision != 0, "20");
        collateralToLoanRate = collateralToLoanRate
            .mul(WEI_PRECISION)
            .div(collateralToLoanPrecision);

        totalDeposit = loanTokenSent;
        if (collateralTokenSent != 0) {
            totalDeposit = collateralTokenSent
                .mul(collateralToLoanRate)
                .div(WEI_PRECISION)
                .add(totalDeposit);
        }
    }

    // returns newPrincipal
    function _borrowOrTrade(
        bytes32 loanId,
        uint256 withdrawAmount,
        uint256 leverageAmount,
        address collateralTokenAddress,
        address[4] memory sentAddresses,
        uint256[5] memory sentAmounts,
        bytes memory loanDataBytes)
        internal
        returns (IBZx.LoanOpenData memory)
    {
        require (sentAmounts[1] <= _underlyingBalance() && // newPrincipal
            sentAddresses[1] != address(0), // borrower
            "24"
        );

	    if (sentAddresses[2] == address(0)) {
            sentAddresses[2] = sentAddresses[1]; // receiver = borrower
        }

        // handle transfers prior to adding newPrincipal to loanTokenSent
        uint256 msgValue = _verifyTransfers(
            collateralTokenAddress,
            sentAddresses,
            sentAmounts,
            withdrawAmount
        );

        // adding the loan token portion from the lender to loanTokenSent
        sentAmounts[3] = sentAmounts[3]
            .add(sentAmounts[1]); // newPrincipal

        if (withdrawAmount != 0) {
            // withdrawAmount already sent to the borrower, so we aren't sending it to the protocol
            sentAmounts[3] = sentAmounts[3]
                .sub(withdrawAmount);
        }

        bool isTorqueLoan = withdrawAmount != 0 ?
            true :
            false;

        bytes32 loanParamsId = loanParamsIds[uint256(keccak256(abi.encodePacked(
            collateralTokenAddress,
            isTorqueLoan
        )))];

        // converting to initialMargin
        if (leverageAmount != 0) {
            leverageAmount = SafeMath.div(WEI_PRECISION * WEI_PERCENT_PRECISION, leverageAmount);
        }

        return IBZx(bZxContract).borrowOrTradeFromPool.value(msgValue)(
            loanParamsId,
            loanId,
            isTorqueLoan,
            leverageAmount, // initialMargin
            sentAddresses,
            sentAmounts,
            loanDataBytes
        );
    }

    // sentAddresses[0]: lender
    // sentAddresses[1]: borrower
    // sentAddresses[2]: receiver
    // sentAddresses[3]: manager
    // sentAmounts[0]: interestRate
    // sentAmounts[1]: newPrincipal
    // sentAmounts[2]: interestInitialAmount
    // sentAmounts[3]: loanTokenSent
    // sentAmounts[4]: collateralTokenSent
    function _verifyTransfers(
        address collateralTokenAddress,
        address[4] memory sentAddresses,
        uint256[5] memory sentAmounts,
        uint256 withdrawalAmount)
        internal
        returns (uint256 msgValue)
    {
        address _wethToken = wethToken;
        address _loanTokenAddress = loanTokenAddress;
        address receiver = sentAddresses[2];
        uint256 newPrincipal = sentAmounts[1];
        uint256 loanTokenSent = sentAmounts[3];
        uint256 collateralTokenSent = sentAmounts[4];

        require(_loanTokenAddress != collateralTokenAddress, "26");

        msgValue = msg.value;

        if (withdrawalAmount != 0) { // withdrawOnOpen == true
            _safeTransfer(_loanTokenAddress, receiver, withdrawalAmount, "27");
            if (newPrincipal > withdrawalAmount) {
                _safeTransfer(_loanTokenAddress, bZxContract, newPrincipal - withdrawalAmount, "27");
            }
        } else {
            _safeTransfer(_loanTokenAddress, bZxContract, newPrincipal, "27");
        }

        if (collateralTokenSent != 0) {
            if (collateralTokenAddress == _wethToken && msgValue != 0 && msgValue >= collateralTokenSent) {
                IWeth(_wethToken).deposit.value(collateralTokenSent)();
                _safeTransfer(collateralTokenAddress, bZxContract, collateralTokenSent, "28");
                msgValue -= collateralTokenSent;
            } else {
                _safeTransferFrom(collateralTokenAddress, msg.sender, bZxContract, collateralTokenSent, "28");
            }
        }

        if (loanTokenSent != 0) {
            _safeTransferFrom(_loanTokenAddress, msg.sender, bZxContract, loanTokenSent, "29");
        }
    }

    function _safeTransfer(
        address token,
        address to,
        uint256 amount,
        string memory errorMsg)
        internal
    {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(IERC20(token).transfer.selector, to, amount),
            errorMsg
        );
    }

    function _safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 amount,
        string memory errorMsg)
        internal
    {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(IERC20(token).transferFrom.selector, from, to, amount),
            errorMsg
        );
    }

    function _callOptionalReturn(
        address token,
        bytes memory data,
        string memory errorMsg)
        internal
    {
        (bool success, bytes memory returndata) = token.call(data);
        require(success, errorMsg);

        if (returndata.length != 0) {
            require(abi.decode(returndata, (bool)), errorMsg);
        }
    }

    function _underlyingBalance()
        internal
        view
        returns (uint256)
    {
        return IERC20(loanTokenAddress).balanceOf(address(this));
    }

    function _nextSupplyInterestRate(
        uint256 nextBorrowRate,
        uint256 assetBorrow,
        uint256 assetSupply)
        public
        view
        returns (uint256)
    {
        if (assetBorrow != 0 && assetSupply >= assetBorrow) {
            return nextBorrowRate
                .mul(_utilizationRate(assetBorrow, assetSupply))
                .mul(SafeMath.sub(WEI_PERCENT_PRECISION, IBZx(bZxContract).lendingFeePercent()))
                .div(WEI_PERCENT_PRECISION * WEI_PERCENT_PRECISION);
        }
    }

    function _nextBorrowInterestRate(
        uint256 totalBorrow,
        uint256 newBorrowNotYetRealized,
        uint256 lastIR)
        public
        view
        returns (uint256 nextRate)
    {
        uint256 utilRate = _utilizationRate(
            totalBorrow.add(newBorrowNotYetRealized),
            _totalAssetSupply(totalBorrow)
        );

        //utilRate from 0e18 to 100e18
        nextRate = rateHelper.calculateIR(utilRate, lastIR);
    }

    /* Internal View functions */

    function _tokenPrice(
        uint256 assetSupply)
        internal
        view
        returns (uint256)
    {
        uint256 totalTokenSupply = totalSupply_;

        return totalTokenSupply != 0 ?
            assetSupply
                .mul(WEI_PRECISION)
                .div(totalTokenSupply) : initialPrice;
    }

    function _getPreMarginData(
        address collateralTokenAddress,
        uint256 collateralTokenSent,
        uint256 loanTokenSent,
        uint256 leverageAmount)
        internal
        view
        returns (uint256 borrowAmount, uint256 interestRate, uint256 totalDeposit, uint256 collateralToLoanRate)
    {
        (totalDeposit, collateralToLoanRate) = _totalDeposit(
            collateralTokenAddress,
            collateralTokenSent,
            loanTokenSent
        );

        uint256 initialMargin = SafeMath.div(WEI_PRECISION * WEI_PERCENT_PRECISION, leverageAmount);

        // assumes that loan and collateral token are the same
        borrowAmount = totalDeposit
            .mul(WEI_PERCENT_PRECISION)
            .div(initialMargin);
    }

    function _totalAssetSupply(
        uint256 totalBorrow)
        internal
        view
        returns (uint256 totalSupply)
    {
        totalSupply = _flTotalAssetSupply; // temporary locked totalAssetSupply during a flash loan transaction
        if (totalSupply == 0) {
            totalSupply = _underlyingBalance()
                .add(totalBorrow);
        }
    }

    function _utilizationRate(
        uint256 assetBorrow,
        uint256 assetSupply)
        internal
        pure
        returns (uint256)
    {
        if (assetSupply != 0) {
            // U = total_borrow / total_supply
            return assetBorrow
                .mul(WEI_PERCENT_PRECISION)
                .div(assetSupply);
        }
    }


    /* Owner-Only functions */

    function updateSettings(
        address settingsTarget,
        bytes memory callData)
        public
    {
        if (msg.sender != owner()) {
            address _lowerAdmin;
            address _lowerAdminContract;
            assembly {
                _lowerAdmin := sload(iToken_LowerAdminAddress)
                _lowerAdminContract := sload(iToken_LowerAdminContract)
            }
            require(msg.sender == _lowerAdmin && settingsTarget == _lowerAdminContract);
        }

        address currentTarget = target_;
        target_ = settingsTarget;

        (bool result,) = address(this).call(callData);

        uint256 size;
        uint256 ptr;
        assembly {
            size := returndatasize
            ptr := mload(0x40)
            returndatacopy(ptr, 0, size)
            if eq(result, 0) { revert(ptr, size) }
        }

        target_ = currentTarget;

        assembly {
            return(ptr, size)
        }
    }

    function updateFlashBorrowFeePercent(uint256 newFeePercent) public onlyOwner {
        flashBorrowFeePercent = newFeePercent;
    }
}

/*
pragma solidity 0.5.16;

contract ArbitraryCaller {
    function sendCall(
        address target,
        bytes calldata callData)
        external
        payable
    {
        (bool success,) = target.call.value(msg.value)(callData);
        assembly {
            let size := returndatasize()
            let ptr := mload(0x40)
            returndatacopy(ptr, 0, size)
            if eq(success, 0) { revert(ptr, size) }
            return(ptr, size)
        }
    }
}
*/

File 2 of 18 : AdvancedToken.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;

import "AdvancedTokenStorage.sol";


contract AdvancedToken is AdvancedTokenStorage {
    using SafeMath for uint256;

    function approve(
        address _spender,
        uint256 _value)
        public
        returns (bool)
    {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    function increaseApproval(
        address _spender,
        uint256 _addedValue)
        public
        returns (bool)
    {
        uint256 _allowed = allowed[msg.sender][_spender]
            .add(_addedValue);
        allowed[msg.sender][_spender] = _allowed;

        emit Approval(msg.sender, _spender, _allowed);
        return true;
    }

    function decreaseApproval(
        address _spender,
        uint256 _subtractedValue)
        public
        returns (bool)
    {
        uint256 _allowed = allowed[msg.sender][_spender];
        if (_subtractedValue >= _allowed) {
            _allowed = 0;
        } else {
            _allowed -= _subtractedValue;
        }
        allowed[msg.sender][_spender] = _allowed;

        emit Approval(msg.sender, _spender, _allowed);
        return true;
    }

    function _mint(
        address _to,
        uint256 _tokenAmount,
        uint256 _assetAmount,
        uint256 _price)
        internal
        returns (uint256)
    {
        require(_to != address(0), "15");

        uint256 _balance = balances[_to]
            .add(_tokenAmount);
        balances[_to] = _balance;

        totalSupply_ = totalSupply_
            .add(_tokenAmount);

        emit Mint(_to, _tokenAmount, _assetAmount, _price);
        emit Transfer(address(0), _to, _tokenAmount);

        return _balance;
    }

    function _burn(
        address _who,
        uint256 _tokenAmount,
        uint256 _assetAmount,
        uint256 _price)
        internal
        returns (uint256)
    {
        uint256 _balance = balances[_who].sub(_tokenAmount, "16");
        
        // a rounding error may leave dust behind, so we clear this out
        if (_balance <= 10) {
            _tokenAmount = _tokenAmount.add(_balance);
            _balance = 0;
        }
        balances[_who] = _balance;

        totalSupply_ = totalSupply_.sub(_tokenAmount);

        emit Burn(_who, _tokenAmount, _assetAmount, _price);
        emit Transfer(_who, address(0), _tokenAmount);

        return _balance;
    }
}

File 3 of 18 : AdvancedTokenStorage.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;

import "LoanTokenBase.sol";


contract AdvancedTokenStorage is LoanTokenBase {
    using SafeMath for uint256;

    event Transfer(
        address indexed from,
        address indexed to,
        uint256 value
    );

    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    event Mint(
        address indexed minter,
        uint256 tokenAmount,
        uint256 assetAmount,
        uint256 price
    );

    event Burn(
        address indexed burner,
        uint256 tokenAmount,
        uint256 assetAmount,
        uint256 price
    );

    event FlashBorrow(
        address borrower,
        address target,
        address loanToken,
        uint256 loanAmount
    );

    mapping(address => uint256) internal balances;
    mapping (address => mapping (address => uint256)) internal allowed;
    uint256 internal totalSupply_;

    function totalSupply()
        public
        view
        returns (uint256)
    {
        return totalSupply_;
    }

    function balanceOf(
        address _owner)
        public
        view
        returns (uint256)
    {
        return balances[_owner];
    }

    function allowance(
        address _owner,
        address _spender)
        public
        view
        returns (uint256)
    {
        return allowed[_owner][_spender];
    }
}

File 4 of 18 : LoanTokenBase.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;

import "SafeMath.sol";
import "SignedSafeMath.sol";
import "ReentrancyGuard.sol";
import "Ownable.sol";
import "Address.sol";
import "IWethERC20.sol";
import "PausableGuardian.sol";


contract LoanTokenBase is ReentrancyGuard, Ownable, PausableGuardian {

    uint256 internal constant WEI_PRECISION = 10**18;
    uint256 internal constant WEI_PERCENT_PRECISION = 10**20;

    int256 internal constant sWEI_PRECISION = 10**18;

    string public name;
    string public symbol;
    uint8 public decimals;

    // uint88 for tight packing -> 8 + 88 + 160 = 256
    uint88 internal lastSettleTime_;

    address public loanTokenAddress;

    uint256 internal baseRate_UNUSED;
    uint256 internal rateMultiplier_UNUSED;
    uint256 internal lowUtilBaseRate_UNUSED;
    uint256 internal lowUtilRateMultiplier_UNUSED;
    uint256 internal targetLevel_UNUSED;
    uint256 internal kinkLevel_UNUSED;
    uint256 internal maxScaleRate_UNUSED;

    uint256 internal _flTotalAssetSupply;
    uint256 public checkpointSupply;
    uint256 public initialPrice;

    mapping (uint256 => bytes32) public loanParamsIds; // mapping of keccak256(collateralToken, isTorqueLoan) to loanParamsId
    mapping (address => uint256) internal checkpointPrices_; // price of token at last user checkpoint
}

File 5 of 18 : SafeMath.sol
pragma solidity ^0.5.0;

/**
 * @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;
    }
}

File 6 of 18 : SignedSafeMath.sol
pragma solidity >=0.5.0 <0.6.0;

/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMath {
    int256 constant private _INT256_MIN = -2**255;

        /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        // 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;
        }

        require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

        int256 c = a * b;
        require(c / a == b, "SignedSafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two signed 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(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "SignedSafeMath: division by zero");
        require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");

        int256 c = a / b;

        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");

        return c;
    }
}

File 7 of 18 : ReentrancyGuard.sol
pragma solidity >=0.5.0 <0.6.0;


/**
 * @title Helps contracts guard against reentrancy attacks.
 * @author Remco Bloemen <[email protected]Ï€.com>, Eenae <[email protected]>
 * @dev If you mark a function `nonReentrant`, you should also
 * mark it `external`.
 */
contract ReentrancyGuard {

    /// @dev Constant for unlocked guard state - non-zero to prevent extra gas costs.
    /// See: https://github.com/OpenZeppelin/openzeppelin-solidity/issues/1056
    uint256 internal constant REENTRANCY_GUARD_FREE = 1;

    /// @dev Constant for locked guard state
    uint256 internal constant REENTRANCY_GUARD_LOCKED = 2;

    /**
    * @dev We use a single lock for the whole contract.
    */
    uint256 internal reentrancyLock = REENTRANCY_GUARD_FREE;

    /**
    * @dev Prevents a contract from calling itself, directly or indirectly.
    * If you mark a function `nonReentrant`, you should also
    * mark it `external`. Calling one `nonReentrant` function from
    * another is not supported. Instead, you can implement a
    * `private` function doing the actual work, and an `external`
    * wrapper marked as `nonReentrant`.
    */
    modifier nonReentrant() {
        require(reentrancyLock == REENTRANCY_GUARD_FREE, "nonReentrant");
        reentrancyLock = REENTRANCY_GUARD_LOCKED;
        _;
        reentrancyLock = REENTRANCY_GUARD_FREE;
    }

}

File 8 of 18 : Ownable.sol
pragma solidity ^0.5.0;

import "Context.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 is Context {
    address private _owner;

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

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

    /**
     * @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 _msgSender() == _owner;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     */
    function _transferOwnership(address newOwner) internal {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 9 of 18 : Context.sol
pragma solidity ^0.5.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.
    constructor () internal { }
    // solhint-disable-previous-line no-empty-blocks

    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 10 of 18 : Address.sol
pragma solidity ^0.5.5;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following 
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Converts an `address` into `address payable`. Note that this is
     * simply a type cast: the actual underlying value is not changed.
     *
     * _Available since v2.4.0._
     */
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     *
     * _Available since v2.4.0._
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call.value(amount)("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}

File 11 of 18 : IWethERC20.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity >=0.5.0 <0.6.0;

import "IWeth.sol";
import "IERC20.sol";


contract IWethERC20 is IWeth, IERC20 {}

File 12 of 18 : IWeth.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity >=0.5.0 <0.6.0;


interface IWeth {
    function deposit() external payable;
    function withdraw(uint256 wad) external;
}

File 13 of 18 : IERC20.sol
pragma solidity ^0.5.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
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);

    /**
     * @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);

    /**
     * @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 14 of 18 : PausableGuardian.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;

import "Ownable.sol";


contract PausableGuardian is Ownable {

    // keccak256("Pausable_FunctionPause")
    bytes32 internal constant Pausable_FunctionPause = 0xa7143c84d793a15503da6f19bf9119a2dac94448ca45d77c8bf08f57b2e91047;

    // keccak256("Pausable_GuardianAddress")
    bytes32 internal constant Pausable_GuardianAddress = 0x80e6706973d0c59541550537fd6a33b971efad732635e6c3b99fb01006803cdf;

    modifier pausable {
        require(!_isPaused(msg.sig), "paused");
        _;
    }

    function _isPaused(bytes4 sig) public view returns (bool isPaused) {
        bytes32 slot = keccak256(abi.encodePacked(sig, Pausable_FunctionPause));
        assembly {
            isPaused := sload(slot)
        }
    }

    function toggleFunctionPause(bytes4 sig) public {
        require(msg.sender == getGuardian() || msg.sender == owner(), "unauthorized");
        bytes32 slot = keccak256(abi.encodePacked(sig, Pausable_FunctionPause));
        assembly {
            sstore(slot, 1)
        }
    }

    function toggleFunctionUnPause(bytes4 sig) public {
        // only DAO can unpause, and adding guardian temporarily
        require(msg.sender == getGuardian() || msg.sender == owner(), "unauthorized");
        bytes32 slot = keccak256(abi.encodePacked(sig, Pausable_FunctionPause));
        assembly {
            sstore(slot, 0)
        }
    }

    function changeGuardian(address newGuardian) public {
        require(msg.sender == getGuardian() || msg.sender == owner(), "unauthorized");
        assembly {
            sstore(Pausable_GuardianAddress, newGuardian)
        }
    }

    function getGuardian() public view returns (address guardian) {
        assembly {
            guardian := sload(Pausable_GuardianAddress)
        }
    }
}

File 15 of 18 : StorageExtension.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity 0.5.17;

import "ICurvedInterestRate.sol";


contract StorageExtension {

    address internal target_;
    uint256 public flashBorrowFeePercent; // set to 0.03%
    ICurvedInterestRate rateHelper;
}

File 16 of 18 : ICurvedInterestRate.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

// SPDX-License-Identifier: Apache-2.0

pragma solidity >=0.5.0 <0.9.0;

interface ICurvedInterestRate {
    function getInterestRate(
        uint256 _U,
        uint256 _a,
        uint256 _b
    ) external pure returns (uint256 interestRate);

    function getAB(uint256 _IR1) external pure returns (uint256 a, uint256 b);

    function getAB(
        uint256 _IR1,
        uint256 _IR2,
        uint256 _UR1,
        uint256 _UR2
    ) external pure returns (uint256 a, uint256 b);

    function calculateIR(uint256 _U, uint256 _IR1) external pure returns (uint256 interestRate);
}

File 17 of 18 : IBZx.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache-2.0
 */
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.5.0 <=0.8.4;
pragma experimental ABIEncoderV2;

/// @title A proxy interface for The Protocol
/// @author bZeroX
/// @notice This is just an interface, not to be deployed itself.
/// @dev This interface is to be used for the protocol interactions.
interface IBZx {
    ////// Protocol //////

    /// @dev adds or replaces existing proxy module
    /// @param target target proxy module address
    function replaceContract(address target) external;

    /// @dev updates all proxy modules addreses and function signatures.
    /// sigsArr and targetsArr should be of equal length
    /// @param sigsArr array of function signatures
    /// @param targetsArr array of target proxy module addresses
    function setTargets(
        string[] calldata sigsArr,
        address[] calldata targetsArr
    ) external;

    /// @dev returns protocol module address given a function signature
    /// @return module address
    function getTarget(string calldata sig) external view returns (address);

    ////// Protocol Settings //////

    /// @dev sets price feed contract address. The contract on the addres should implement IPriceFeeds interface
    /// @param newContract module address for the IPriceFeeds implementation
    function setPriceFeedContract(address newContract) external;

    /// @dev sets swaps contract address. The contract on the addres should implement ISwapsImpl interface
    /// @param newContract module address for the ISwapsImpl implementation
    function setSwapsImplContract(address newContract) external;

    /// @dev sets loan pool with assets. Accepts two arrays of equal length
    /// @param pools array of address of pools
    /// @param assets array of addresses of assets
    function setLoanPool(address[] calldata pools, address[] calldata assets)
        external;

    /// @dev updates list of supported tokens, it can be use also to disable or enable particualr token
    /// @param addrs array of address of pools
    /// @param toggles array of addresses of assets
    /// @param withApprovals resets tokens to unlimited approval with the swaps integration (kyber, etc.)
    function setSupportedTokens(
        address[] calldata addrs,
        bool[] calldata toggles,
        bool withApprovals
    ) external;

    /// @dev sets lending fee with WEI_PERCENT_PRECISION
    /// @param newValue lending fee percent
    function setLendingFeePercent(uint256 newValue) external;

    /// @dev sets trading fee with WEI_PERCENT_PRECISION
    /// @param newValue trading fee percent
    function setTradingFeePercent(uint256 newValue) external;

    /// @dev sets borrowing fee with WEI_PERCENT_PRECISION
    /// @param newValue borrowing fee percent
    function setBorrowingFeePercent(uint256 newValue) external;

    /// @dev sets affiliate fee with WEI_PERCENT_PRECISION
    /// @param newValue affiliate fee percent
    function setAffiliateFeePercent(uint256 newValue) external;

    /// @dev sets liquidation inncetive percent per loan per token. This is the profit percent
    /// that liquidator gets in the process of liquidating.
    /// @param loanTokens array list of loan tokens
    /// @param collateralTokens array list of collateral tokens
    /// @param amounts array list of liquidation inncetive amount
    function setLiquidationIncentivePercent(
        address[] calldata loanTokens,
        address[] calldata collateralTokens,
        uint256[] calldata amounts
    ) external;

    /// @dev sets max swap rate slippage percent.
    /// @param newAmount max swap rate slippage percent.
    function setMaxDisagreement(uint256 newAmount) external;

    /// TODO
    function setSourceBufferPercent(uint256 newAmount) external;

    /// @dev sets maximum supported swap size in ETH
    /// @param newAmount max swap size in ETH.
    function setMaxSwapSize(uint256 newAmount) external;

    /// @dev sets fee controller address
    /// @param newController address of the new fees controller
    function setFeesController(address newController) external;

    /// @dev withdraws lending fees to receiver. Only can be called by feesController address
    /// @param tokens array of token addresses.
    /// @param receiver fees receiver address
    /// @return amounts array of amounts withdrawn
    function withdrawFees(
        address[] calldata tokens,
        address receiver,
        FeeClaimType feeType
    ) external returns (uint256[] memory amounts);

    /// @dev withdraw protocol token (BZRX) from vesting contract vBZRX
    /// @param receiver address of BZRX tokens claimed
    /// @param amount of BZRX token to be claimed. max is claimed if amount is greater than balance.
    /// @return rewardToken reward token address
    /// @return withdrawAmount amount
    function withdrawProtocolToken(address receiver, uint256 amount)
        external
        returns (address rewardToken, uint256 withdrawAmount);

    /// @dev depozit protocol token (BZRX)
    /// @param amount address of BZRX tokens to deposit
    function depositProtocolToken(uint256 amount) external;

    function grantRewards(address[] calldata users, uint256[] calldata amounts)
        external
        returns (uint256 totalAmount);

    // NOTE: this doesn't sanitize inputs -> inaccurate values may be returned if there are duplicates tokens input
    function queryFees(address[] calldata tokens, FeeClaimType feeType)
        external
        view
        returns (uint256[] memory amountsHeld, uint256[] memory amountsPaid);

    function priceFeeds() external view returns (address);

    function swapsImpl() external view returns (address);

    function logicTargets(bytes4) external view returns (address);

    function loans(bytes32) external view returns (Loan memory);

    function loanParams(bytes32) external view returns (LoanParams memory);

    // we don't use this yet
    // function lenderOrders(address, bytes32) external returns (Order memory);
    // function borrowerOrders(address, bytes32) external returns (Order memory);

    function delegatedManagers(bytes32, address) external view returns (bool);

    function lenderInterest(address, address)
        external
        view
        returns (LenderInterest memory);

    function loanInterest(bytes32) external view returns (LoanInterest memory);

    function feesController() external view returns (address);

    function lendingFeePercent() external view returns (uint256);

    function lendingFeeTokensHeld(address) external view returns (uint256);

    function lendingFeeTokensPaid(address) external view returns (uint256);

    function borrowingFeePercent() external view returns (uint256);

    function borrowingFeeTokensHeld(address) external view returns (uint256);

    function borrowingFeeTokensPaid(address) external view returns (uint256);

    function protocolTokenHeld() external view returns (uint256);

    function protocolTokenPaid() external view returns (uint256);

    function affiliateFeePercent() external view returns (uint256);

    function liquidationIncentivePercent(address, address)
        external
        view
        returns (uint256);

    function loanPoolToUnderlying(address) external view returns (address);

    function underlyingToLoanPool(address) external view returns (address);

    function supportedTokens(address) external view returns (bool);

    function maxDisagreement() external view returns (uint256);

    function sourceBufferPercent() external view returns (uint256);

    function maxSwapSize() external view returns (uint256);

    /// @dev get list of loan pools in the system. Ordering is not guaranteed
    /// @param start start index
    /// @param count number of pools to return
    /// @return loanPoolsList array of loan pools
    function getLoanPoolsList(uint256 start, uint256 count)
        external
        view
        returns (address[] memory loanPoolsList);

    /// @dev checks whether addreess is a loan pool address
    /// @return boolean
    function isLoanPool(address loanPool) external view returns (bool);

    ////// Loan Settings //////

    /// @dev creates new loan param settings
    /// @param loanParamsList array of LoanParams
    /// @return loanParamsIdList array of loan ids created
    function setupLoanParams(LoanParams[] calldata loanParamsList)
        external
        returns (bytes32[] memory loanParamsIdList);

    /// @dev Deactivates LoanParams for future loans. Active loans using it are unaffected.
    /// @param loanParamsIdList array of loan ids
    function disableLoanParams(bytes32[] calldata loanParamsIdList) external;

    /// @dev gets array of LoanParams by given ids
    /// @param loanParamsIdList array of loan ids
    /// @return loanParamsList array of LoanParams
    function getLoanParams(bytes32[] calldata loanParamsIdList)
        external
        view
        returns (LoanParams[] memory loanParamsList);

    /// @dev Enumerates LoanParams in the system by owner
    /// @param owner of the loan params
    /// @param start number of loans to return
    /// @param count total number of the items
    /// @return loanParamsList array of LoanParams
    function getLoanParamsList(
        address owner,
        uint256 start,
        uint256 count
    ) external view returns (bytes32[] memory loanParamsList);

    /// @dev returns total loan principal for token address
    /// @param lender address
    /// @param loanToken address
    /// @return total principal of the loan
    function getTotalPrincipal(address lender, address loanToken)
        external
        view
        returns (uint256);

    /// @dev returns total principal for a loan pool that was last settled
    /// @param pool address
    /// @return total stored principal of the loan
    function getPoolPrincipalStored(address pool)
        external
        view
        returns (uint256);

    /// @dev returns the last interest rate founnd during interest settlement
    /// @param pool address
    /// @return the last interset rate
    function getPoolLastInterestRate(address pool)
        external
        view
        returns (uint256);

    ////// Loan Openings //////

    /// @dev This is THE function that borrows or trades on the protocol
    /// @param loanParamsId id of the LoanParam created beforehand by setupLoanParams function
    /// @param loanId id of existing loan, if 0, start a new loan
    /// @param isTorqueLoan boolean whether it is toreque or non torque loan
    /// @param initialMargin in WEI_PERCENT_PRECISION
    /// @param sentAddresses array of size 4:
    ///         lender: must match loan if loanId provided
    ///         borrower: must match loan if loanId provided
    ///         receiver: receiver of funds (address(0) assumes borrower address)
    ///         manager: delegated manager of loan unless address(0)
    /// @param sentValues array of size 5:
    ///         newRate: new loan interest rate
    ///         newPrincipal: new loan size (borrowAmount + any borrowed interest)
    ///         torqueInterest: new amount of interest to escrow for Torque loan (determines initial loan length)
    ///         loanTokenReceived: total loanToken deposit (amount not sent to borrower in the case of Torque loans)
    ///         collateralTokenReceived: total collateralToken deposit
    /// @param loanDataBytes required when sending ether
    /// @return principal of the loan and collateral amount
    function borrowOrTradeFromPool(
        bytes32 loanParamsId,
        bytes32 loanId,
        bool isTorqueLoan,
        uint256 initialMargin,
        address[4] calldata sentAddresses,
        uint256[5] calldata sentValues,
        bytes calldata loanDataBytes
    ) external payable returns (LoanOpenData memory);

    /// @dev sets/disables/enables the delegated manager for the loan
    /// @param loanId id of the loan
    /// @param delegated delegated manager address
    /// @param toggle boolean set enabled or disabled
    function setDelegatedManager(
        bytes32 loanId,
        address delegated,
        bool toggle
    ) external;

    /// @dev estimates margin exposure for simulated position
    /// @param loanToken address of the loan token
    /// @param collateralToken address of collateral token
    /// @param loanTokenSent amout of loan token sent
    /// @param collateralTokenSent amount of collateral token sent
    /// @param interestRate yearly interest rate
    /// @param newPrincipal principal amount of the loan
    /// @return estimated margin exposure amount
    function getEstimatedMarginExposure(
        address loanToken,
        address collateralToken,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        uint256 interestRate,
        uint256 newPrincipal
    ) external view returns (uint256);

    /// @dev calculates required collateral for simulated position
    /// @param loanToken address of loan token
    /// @param collateralToken address of collateral token
    /// @param newPrincipal principal amount of the loan
    /// @param marginAmount margin amount of the loan
    /// @param isTorqueLoan boolean torque or non torque loan
    /// @return collateralAmountRequired amount required
    function getRequiredCollateral(
        address loanToken,
        address collateralToken,
        uint256 newPrincipal,
        uint256 marginAmount,
        bool isTorqueLoan
    ) external view returns (uint256 collateralAmountRequired);

    function getRequiredCollateralByParams(
        bytes32 loanParamsId,
        uint256 newPrincipal
    ) external view returns (uint256 collateralAmountRequired);

    /// @dev calculates borrow amount for simulated position
    /// @param loanToken address of loan token
    /// @param collateralToken address of collateral token
    /// @param collateralTokenAmount amount of collateral token sent
    /// @param marginAmount margin amount
    /// @param isTorqueLoan boolean torque or non torque loan
    /// @return borrowAmount possible borrow amount
    function getBorrowAmount(
        address loanToken,
        address collateralToken,
        uint256 collateralTokenAmount,
        uint256 marginAmount,
        bool isTorqueLoan
    ) external view returns (uint256 borrowAmount);

    function getBorrowAmountByParams(
        bytes32 loanParamsId,
        uint256 collateralTokenAmount
    ) external view returns (uint256 borrowAmount);

    ////// Loan Closings //////

    /// @dev liquidates unhealty loans
    /// @param loanId id of the loan
    /// @param receiver address receiving liquidated loan collateral
    /// @param closeAmount amount to close denominated in loanToken
    /// @return loanCloseAmount amount of the collateral token of the loan
    /// @return seizedAmount sezied amount in the collateral token
    /// @return seizedToken loan token address
    function liquidate(
        bytes32 loanId,
        address receiver,
        uint256 closeAmount
    )
        external
        payable
        returns (
            uint256 loanCloseAmount,
            uint256 seizedAmount,
            address seizedToken
        );

    /// @dev close position with loan token deposit
    /// @param loanId id of the loan
    /// @param receiver collateral token reciever address
    /// @param depositAmount amount of loan token to deposit
    /// @return loanCloseAmount loan close amount
    /// @return withdrawAmount loan token withdraw amount
    /// @return withdrawToken loan token address
    function closeWithDeposit(
        bytes32 loanId,
        address receiver,
        uint256 depositAmount // denominated in loanToken
    )
        external
        payable
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

    /// @dev close position with swap
    /// @param loanId id of the loan
    /// @param receiver collateral token reciever address
    /// @param swapAmount amount of loan token to swap
    /// @param returnTokenIsCollateral boolean whether to return tokens is collateral
    /// @param loanDataBytes custom payload for specifying swap implementation and data to pass
    /// @return loanCloseAmount loan close amount
    /// @return withdrawAmount loan token withdraw amount
    /// @return withdrawToken loan token address
    function closeWithSwap(
        bytes32 loanId,
        address receiver,
        uint256 swapAmount, // denominated in collateralToken
        bool returnTokenIsCollateral, // true: withdraws collateralToken, false: withdraws loanToken
        bytes calldata loanDataBytes
    )
        external
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

    ////// Loan Closings With Gas Token //////

    /// @dev liquidates unhealty loans by using Gas token
    /// @param loanId id of the loan
    /// @param receiver address receiving liquidated loan collateral
    /// @param gasTokenUser user address of the GAS token
    /// @param closeAmount amount to close denominated in loanToken
    /// @return loanCloseAmount loan close amount
    /// @return seizedAmount loan token withdraw amount
    /// @return seizedToken loan token address
    function liquidateWithGasToken(
        bytes32 loanId,
        address receiver,
        address gasTokenUser,
        uint256 closeAmount // denominated in loanToken
    )
        external
        payable
        returns (
            uint256 loanCloseAmount,
            uint256 seizedAmount,
            address seizedToken
        );

    /// @dev close position with loan token deposit
    /// @param loanId id of the loan
    /// @param receiver collateral token reciever address
    /// @param gasTokenUser user address of the GAS token
    /// @param depositAmount amount of loan token to deposit denominated in loanToken
    /// @return loanCloseAmount loan close amount
    /// @return withdrawAmount loan token withdraw amount
    /// @return withdrawToken loan token address
    function closeWithDepositWithGasToken(
        bytes32 loanId,
        address receiver,
        address gasTokenUser,
        uint256 depositAmount
    )
        external
        payable
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

    /// @dev close position with swap
    /// @param loanId id of the loan
    /// @param receiver collateral token reciever address
    /// @param gasTokenUser user address of the GAS token
    /// @param swapAmount amount of loan token to swap denominated in collateralToken
    /// @param returnTokenIsCollateral  true: withdraws collateralToken, false: withdraws loanToken
    /// @return loanCloseAmount loan close amount
    /// @return withdrawAmount loan token withdraw amount
    /// @return withdrawToken loan token address
    function closeWithSwapWithGasToken(
        bytes32 loanId,
        address receiver,
        address gasTokenUser,
        uint256 swapAmount,
        bool returnTokenIsCollateral,
        bytes calldata loanDataBytes
    )
        external
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

    ////// Loan Maintenance //////

    /// @dev deposit collateral to existing loan
    /// @param loanId existing loan id
    /// @param depositAmount amount to deposit which must match msg.value if ether is sent
    function depositCollateral(bytes32 loanId, uint256 depositAmount)
        external
        payable;

    /// @dev withdraw collateral from existing loan
    /// @param loanId existing loan id
    /// @param receiver address of withdrawn tokens
    /// @param withdrawAmount amount to withdraw
    /// @return actualWithdrawAmount actual amount withdrawn
    function withdrawCollateral(
        bytes32 loanId,
        address receiver,
        uint256 withdrawAmount
    ) external returns (uint256 actualWithdrawAmount);

    /// @dev settles accrued interest for all active loans from a loan pool
    /// @param loanId existing loan id
    function settleInterest(bytes32 loanId) external;

    /*/// @dev withdraw accrued interest rate for a loan given token address
    /// @param loanToken loan token address
    function withdrawAccruedInterest(address loanToken) external;*/

    /*/// @dev extends loan duration by depositing more collateral
    /// @param loanId id of the existing loan
    /// @param depositAmount amount to deposit
    /// @param useCollateral boolean whether to extend using collateral or deposit amount
    /// @return secondsExtended by that number of seconds loan duration was extended
    function extendLoanDuration(
        bytes32 loanId,
        uint256 depositAmount,
        bool useCollateral,
        bytes calldata // for future use loanDataBytes
    ) external payable returns (uint256 secondsExtended);*/

    /*/// @dev reduces loan duration by withdrawing collateral
    /// @param loanId id of the existing loan
    /// @param receiver address to receive tokens
    /// @param withdrawAmount amount to withdraw
    /// @return secondsReduced by that number of seconds loan duration was extended
    function reduceLoanDuration(
        bytes32 loanId,
        address receiver,
        uint256 withdrawAmount
    ) external returns (uint256 secondsReduced);*/

    function setDepositAmount(
        bytes32 loanId,
        uint256 depositValueAsLoanToken,
        uint256 depositValueAsCollateralToken
    ) external;

    function claimRewards(address receiver)
        external
        returns (uint256 claimAmount);

    function transferLoan(bytes32 loanId, address newOwner) external;

    function rewardsBalanceOf(address user)
        external
        view
        returns (uint256 rewardsBalance);

    function getInterestModelValues(
        address pool,
        bytes32 loanId)
        external
        view
        returns (
        uint256 _poolLastUpdateTime,
        uint256 _poolPrincipalTotal,
        uint256 _poolInterestTotal,
        uint256 _poolRatePerTokenStored,
        uint256 _poolLastInterestRate,
        uint256 _loanPrincipalTotal,
        uint256 _loanInterestTotal,
        uint256 _loanRatePerTokenPaid
        );

    /*/// @dev Gets current lender interest data totals for all loans with a specific oracle and interest token
    /// @param lender The lender address
    /// @param loanToken The loan token address
    /// @return interestPaid The total amount of interest that has been paid to a lender so far
    /// @return interestPaidDate The date of the last interest pay out, or 0 if no interest has been withdrawn yet
    /// @return interestOwedPerDay The amount of interest the lender is earning per day
    /// @return interestUnPaid The total amount of interest the lender is owned and not yet withdrawn
    /// @return interestFeePercent The fee retained by the protocol before interest is paid to the lender
    /// @return principalTotal The total amount of outstading principal the lender has loaned
    function getLenderInterestData(address lender, address loanToken)
        external
        view
        returns (
            uint256 interestPaid,
            uint256 interestPaidDate,
            uint256 interestOwedPerDay,
            uint256 interestUnPaid,
            uint256 interestFeePercent,
            uint256 principalTotal
        );

    /// @dev Gets current interest data for a loan
    /// @param loanId A unique id representing the loan
    /// @return loanToken The loan token that interest is paid in
    /// @return interestOwedPerDay The amount of interest the borrower is paying per day
    /// @return interestDepositTotal The total amount of interest the borrower has deposited
    /// @return interestDepositRemaining The amount of deposited interest that is not yet owed to a lender
    function getLoanInterestData(bytes32 loanId)
        external
        view
        returns (
            address loanToken,
            uint256 interestOwedPerDay,
            uint256 interestDepositTotal,
            uint256 interestDepositRemaining
        );*/

    /// @dev gets list of loans of particular user address
    /// @param user address of the loans
    /// @param start of the index
    /// @param count number of loans to return
    /// @param loanType type of the loan: All(0), Margin(1), NonMargin(2)
    /// @param isLender whether to list lender loans or borrower loans
    /// @param unsafeOnly booleat if true return only unsafe loans that are open for liquidation
    /// @return loansData LoanReturnData array of loans
    function getUserLoans(
        address user,
        uint256 start,
        uint256 count,
        LoanType loanType,
        bool isLender,
        bool unsafeOnly
    ) external view returns (LoanReturnData[] memory loansData);

    function getUserLoansCount(address user, bool isLender)
        external
        view
        returns (uint256);

    /// @dev gets existing loan
    /// @param loanId id of existing loan
    /// @return loanData array of loans
    function getLoan(bytes32 loanId)
        external
        view
        returns (LoanReturnData memory loanData);

    /// @dev gets loan principal including interest
    /// @param loanId id of existing loan
    /// @return principal
    function getLoanPrincipal(bytes32 loanId)
        external
        view
        returns (uint256 principal);

    /// @dev gets loan outstanding interest
    /// @param loanId id of existing loan
    /// @return interest
    function getLoanInterestOutstanding(bytes32 loanId)
        external
        view
        returns (uint256 interest);


    /// @dev get current active loans in the system
    /// @param start of the index
    /// @param count number of loans to return
    /// @param unsafeOnly boolean if true return unsafe loan only (open for liquidation)
    function getActiveLoans(
        uint256 start,
        uint256 count,
        bool unsafeOnly
    ) external view returns (LoanReturnData[] memory loansData);

    /// @dev get current active loans in the system
    /// @param start of the index
    /// @param count number of loans to return
    /// @param unsafeOnly boolean if true return unsafe loan only (open for liquidation)
    /// @param isLiquidatable boolean if true return liquidatable loans only
    function getActiveLoansAdvanced(
        uint256 start,
        uint256 count,
        bool unsafeOnly,
        bool isLiquidatable
    ) external view returns (LoanReturnData[] memory loansData);

    function getActiveLoansCount() external view returns (uint256);

    ////// Swap External //////

    /// @dev swap thru external integration
    /// @param sourceToken source token address
    /// @param destToken destintaion token address
    /// @param receiver address to receive tokens
    /// @param returnToSender TODO
    /// @param sourceTokenAmount source token amount
    /// @param requiredDestTokenAmount destination token amount
    /// @param swapData TODO
    /// @return destTokenAmountReceived destination token received
    /// @return sourceTokenAmountUsed source token amount used
    function swapExternal(
        address sourceToken,
        address destToken,
        address receiver,
        address returnToSender,
        uint256 sourceTokenAmount,
        uint256 requiredDestTokenAmount,
        bytes calldata swapData
    )
        external
        payable
        returns (
            uint256 destTokenAmountReceived,
            uint256 sourceTokenAmountUsed
        );

    /// @dev swap thru external integration using GAS
    /// @param sourceToken source token address
    /// @param destToken destintaion token address
    /// @param receiver address to receive tokens
    /// @param returnToSender TODO
    /// @param gasTokenUser user address of the GAS token
    /// @param sourceTokenAmount source token amount
    /// @param requiredDestTokenAmount destination token amount
    /// @param swapData TODO
    /// @return destTokenAmountReceived destination token received
    /// @return sourceTokenAmountUsed source token amount used
    function swapExternalWithGasToken(
        address sourceToken,
        address destToken,
        address receiver,
        address returnToSender,
        address gasTokenUser,
        uint256 sourceTokenAmount,
        uint256 requiredDestTokenAmount,
        bytes calldata swapData
    )
        external
        payable
        returns (
            uint256 destTokenAmountReceived,
            uint256 sourceTokenAmountUsed
        );

    /// @dev calculate simulated return of swap
    /// @param sourceToken source token address
    /// @param destToken destination token address
    /// @param sourceTokenAmount source token amount
    /// @return amoun denominated in destination token
    function getSwapExpectedReturn(
        address sourceToken,
        address destToken,
        uint256 sourceTokenAmount,
        bytes calldata swapData
    ) external view returns (uint256);

    function owner() external view returns (address);

    function transferOwnership(address newOwner) external;


    /// Guardian Interface

    function _isPaused(bytes4 sig) external view returns (bool isPaused);

    function toggleFunctionPause(bytes4 sig) external;

    function toggleFunctionUnPause(bytes4 sig) external;

    function changeGuardian(address newGuardian) external;

    function getGuardian() external view returns (address guardian);

    /// Loan Cleanup Interface

    function cleanupLoans(
        address loanToken,
        bytes32[] calldata loanIds)
        external
        payable
        returns (uint256 totalPrincipalIn);

    struct LoanParams {
        bytes32 id;
        bool active;
        address owner;
        address loanToken;
        address collateralToken;
        uint256 minInitialMargin;
        uint256 maintenanceMargin;
        uint256 maxLoanTerm;
    }

    struct LoanOpenData {
        bytes32 loanId;
        uint256 principal;
        uint256 collateral;
    }

    enum LoanType {
        All,
        Margin,
        NonMargin
    }

    struct LoanReturnData {
        bytes32 loanId;
        uint96 endTimestamp;
        address loanToken;
        address collateralToken;
        uint256 principal;
        uint256 collateral;
        uint256 interestOwedPerDay;
        uint256 interestDepositRemaining;
        uint256 startRate;
        uint256 startMargin;
        uint256 maintenanceMargin;
        uint256 currentMargin;
        uint256 maxLoanTerm;
        uint256 maxLiquidatable;
        uint256 maxSeizable;
        uint256 depositValueAsLoanToken;
        uint256 depositValueAsCollateralToken;
    }

    enum FeeClaimType {
        All,
        Lending,
        Trading,
        Borrowing
    }

    struct Loan {
        bytes32 id; // id of the loan
        bytes32 loanParamsId; // the linked loan params id
        bytes32 pendingTradesId; // the linked pending trades id
        uint256 principal; // total borrowed amount outstanding
        uint256 collateral; // total collateral escrowed for the loan
        uint256 startTimestamp; // loan start time
        uint256 endTimestamp; // for active loans, this is the expected loan end time, for in-active loans, is the actual (past) end time
        uint256 startMargin; // initial margin when the loan opened
        uint256 startRate; // reference rate when the loan opened for converting collateralToken to loanToken
        address borrower; // borrower of this loan
        address lender; // lender of this loan
        bool active; // if false, the loan has been fully closed
    }

    struct LenderInterest {
        uint256 principalTotal; // total borrowed amount outstanding of asset
        uint256 owedPerDay; // interest owed per day for all loans of asset
        uint256 owedTotal; // total interest owed for all loans of asset (assuming they go to full term)
        uint256 paidTotal; // total interest paid so far for asset
        uint256 updatedTimestamp; // last update
    }

    struct LoanInterest {
        uint256 owedPerDay; // interest owed per day for loan
        uint256 depositTotal; // total escrowed interest for loan
        uint256 updatedTimestamp; // last update
    }
	
	////// Flash Borrow Fees //////
    function payFlashBorrowFees(
        address user,
        uint256 borrowAmount,
        uint256 flashBorrowFeePercent)
        external;
}

File 18 of 18 : IPriceFeeds.sol
/**
 * Copyright 2017-2022, OokiDao. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0.
 */

pragma solidity >=0.5.0 <=0.8.4;


interface IPriceFeeds {
    function queryRate(
        address sourceToken,
        address destToken)
        external
        view
        returns (uint256 rate, uint256 precision);

    function queryPrecision(
        address sourceToken,
        address destToken)
        external
        view
        returns (uint256 precision);

    function queryReturn(
        address sourceToken,
        address destToken,
        uint256 sourceAmount)
        external
        view
        returns (uint256 destAmount);

    function checkPriceDisagreement(
        address sourceToken,
        address destToken,
        uint256 sourceAmount,
        uint256 destAmount,
        uint256 maxSlippage)
        external
        view
        returns (uint256 sourceToDestSwapRate);

    function amountInEth(
        address Token,
        uint256 amount)
        external
        view
        returns (uint256 ethAmount);

    function getMaxDrawdown(
        address loanToken,
        address collateralToken,
        uint256 loanAmount,
        uint256 collateralAmount,
        uint256 maintenanceMargin)
        external
        view
        returns (uint256);

    function getCurrentMarginAndCollateralSize(
        address loanToken,
        address collateralToken,
        uint256 loanAmount,
        uint256 collateralAmount)
        external
        view
        returns (uint256 currentMargin, uint256 collateralInEthAmount);

    function getCurrentMargin(
        address loanToken,
        address collateralToken,
        uint256 loanAmount,
        uint256 collateralAmount)
        external
        view
        returns (uint256 currentMargin, uint256 collateralToLoanRate);

    function shouldLiquidate(
        address loanToken,
        address collateralToken,
        uint256 loanAmount,
        uint256 collateralAmount,
        uint256 maintenanceMargin)
        external
        view
        returns (bool);

    function getFastGasPrice(
        address payToken)
        external
        view
        returns (uint256);
}

Settings
{
  "evmVersion": "istanbul",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "LoanTokenLogicStandard.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"burner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"address","name":"loanToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"loanAmount","type":"uint256"}],"name":"FlashBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"},{"constant":true,"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"_isPaused","outputs":[{"internalType":"bool","name":"isPaused","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"totalBorrow","type":"uint256"},{"internalType":"uint256","name":"newBorrowNotYetRealized","type":"uint256"},{"internalType":"uint256","name":"lastIR","type":"uint256"}],"name":"_nextBorrowInterestRate","outputs":[{"internalType":"uint256","name":"nextRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"nextBorrowRate","type":"uint256"},{"internalType":"uint256","name":"assetBorrow","type":"uint256"},{"internalType":"uint256","name":"assetSupply","type":"uint256"}],"name":"_nextSupplyInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"assetBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"avgBorrowInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bZxContract","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"loanId","type":"bytes32"},{"internalType":"uint256","name":"withdrawAmount","type":"uint256"},{"internalType":"uint256","name":"initialLoanDuration","type":"uint256"},{"internalType":"uint256","name":"collateralTokenSent","type":"uint256"},{"internalType":"address","name":"collateralTokenAddress","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"borrow","outputs":[{"components":[{"internalType":"bytes32","name":"loanId","type":"bytes32"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"internalType":"struct IBZx.LoanOpenData","name":"","type":"tuple"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"borrowInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"burnAmount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"uint256","name":"loanAmountPaid","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"changeGuardian","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"checkpointPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"checkpointSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"string","name":"signature","type":"string"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flashBorrow","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"flashBorrowFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"initialLoanDuration","type":"uint256"},{"internalType":"address","name":"collateralTokenAddress","type":"address"}],"name":"getBorrowAmountForDeposit","outputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"initialLoanDuration","type":"uint256"},{"internalType":"address","name":"collateralTokenAddress","type":"address"}],"name":"getDepositAmountForBorrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"leverageAmount","type":"uint256"},{"internalType":"uint256","name":"loanTokenSent","type":"uint256"},{"internalType":"uint256","name":"collateralTokenSent","type":"uint256"},{"internalType":"address","name":"collateralTokenAddress","type":"address"}],"name":"getEstimatedMarginDetails","outputs":[{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"interestRate","type":"uint256"},{"internalType":"uint256","name":"collateralToLoanRate","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getGuardian","outputs":[{"internalType":"address","name":"guardian","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"leverageAmount","type":"uint256"}],"name":"getMaxEscrowAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPoolUtilization","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initialPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loanParamsIds","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"loanTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"loanId","type":"bytes32"},{"internalType":"uint256","name":"leverageAmount","type":"uint256"},{"internalType":"uint256","name":"loanTokenSent","type":"uint256"},{"internalType":"uint256","name":"collateralTokenSent","type":"uint256"},{"internalType":"address","name":"collateralTokenAddress","type":"address"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"bytes","name":"loanDataBytes","type":"bytes"}],"name":"marginTrade","outputs":[{"components":[{"internalType":"bytes32","name":"loanId","type":"bytes32"},{"internalType":"uint256","name":"principal","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"}],"internalType":"struct IBZx.LoanOpenData","name":"","type":"tuple"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"marketLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"depositAmount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"nextBorrowInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"supplyAmount","type":"uint256"}],"name":"nextSupplyInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"poolLastInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"profitOf","outputs":[{"internalType":"int256","name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"supplyInterestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"toggleFunctionPause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"toggleFunctionUnPause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tokenPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalAssetBorrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalAssetSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"newFeePercent","type":"uint256"}],"name":"updateFlashBorrowFeePercent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"settingsTarget","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"updateSettings","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"wethToken","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]

608060405260016000553480156200001657600080fd5b5060405162004ecf38038062004ecf8339810160408190526200003991620001b4565b60006200004e6001600160e01b03620000a616565b600180546001600160a01b0319166001600160a01b0383169081179091556040519192509060009060008051602062004eaf833981519152908290a3506200009f816001600160e01b03620000aa16565b50620002b8565b3390565b620000bd6001600160e01b03620000fc16565b620000e55760405162461bcd60e51b8152600401620000dc9062000274565b60405180910390fd5b620000f9816001600160e01b036200012d16565b50565b6001546000906001600160a01b03166200011e6001600160e01b03620000a616565b6001600160a01b031614905090565b6001600160a01b038116620001565760405162461bcd60e51b8152600401620000dc9062000262565b6001546040516001600160a01b0380841692169060008051602062004eaf83398151915290600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b8051620001ae81620002a1565b92915050565b600060208284031215620001c757600080fd5b6000620001d58484620001a1565b949350505050565b6000620001ec60268362000286565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015260400192915050565b60006200023660208362000286565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b60208082528101620001ae81620001dd565b60208082528101620001ae8162000227565b90815260200190565b60006001600160a01b038216620001ae565b620002ac816200028f565b8114620000f957600080fd5b614be780620002c86000396000f3fe6080604052600436106103505760003560e01c806370a08231116101c6578063a9059cbb116100f7578063d73dd62311610095578063ef4e1fe41161006f578063ef4e1fe414610923578063f2fde38b14610943578063f96b660a14610963578063ffa1ad741461098357610350565b8063d73dd623146108c3578063dd62ed3e146108e3578063eebc50811461090357610350565b8063baa7719c116100d1578063baa7719c14610866578063bf7d653b1461087b578063c5bf0e9d14610890578063d65a5021146108a357610350565b8063a9059cbb14610806578063ab3d9ffa14610826578063b9fe1a8f1461084657610350565b80638da5cb5b1161016457806395d89b411161013e57806395d89b41146107a7578063995363d3146107bc5780639dc29fac146107d1578063a75b87d2146107f157610350565b80638da5cb5b146107685780638f32d59b1461077d5780638fb807c51461079257610350565b80637b7933b4116101a05780637b7933b4146107095780637ff9b5961461071e578063829b38f4146107335780638325a1c01461075357610350565b806370a08231146106bf578063715018a6146106df578063797bf385146106f457610350565b80632ea295fa116102a05780634b57b0be1161023e578063631a3ef811610218578063631a3ef81461062f578063661884631461064f5780636a8cb4c61461066f5780636b40cd401461068f57610350565b80634b57b0be146105d857806354198ce9146105fa578063612ef80b1461061a57610350565b8063323e35b11161027a578063323e35b1146105635780633291c11a1461058357806340c10f19146105a357806344a4a003146105c357610350565b80632ea295fa1461050e5780632fcb4f0414610521578063313ce5671461054157610350565b80630d198dd71161030d5780631d0806ae116102e75780631d0806ae146104a457806320f6d07c146104b957806323b872dd146104ce578063284e2f56146104ee57610350565b80630d198dd71461044d57806314dfe7921461046f57806318160ddd1461048f57610350565b8063047979301461037e57806306b3efd6146103b457806306fdde03146103d4578063095ea7b3146103f657806309ec6b6b146104235780630a24cdce14610438575b34801561035c57600080fd5b5060405162461bcd60e51b815260040161037590614946565b60405180910390fd5b34801561038a57600080fd5b5061039e610399366004613cbf565b610998565b6040516103ab919061471a565b60405180910390f35b3480156103c057600080fd5b5061039e6103cf366004613894565b610aad565b3480156103e057600080fd5b506103e9610aef565b6040516103ab91906147b5565b34801561040257600080fd5b5061041661041136600461399f565b610b7a565b6040516103ab919061470c565b34801561042f57600080fd5b5061039e610be5565b34801561044457600080fd5b5061039e610c13565b34801561045957600080fd5b5061046d610468366004613ba5565b610c19565b005b61048261047d366004613ab5565b610c42565b6040516103ab91906149d6565b34801561049b57600080fd5b5061039e610c91565b3480156104b057600080fd5b5061039e610c97565b3480156104c557600080fd5b5061039e610c9d565b3480156104da57600080fd5b506104166104e936600461390a565b610d28565b3480156104fa57600080fd5b5061046d610509366004613957565b610d63565b61048261051c3660046139ed565b610ea9565b34801561052d57600080fd5b5061046d61053c366004613894565b610f0c565b34801561054d57600080fd5b50610556610f8b565b6040516103ab9190614a0c565b34801561056f57600080fd5b5061046d61057e366004613b69565b610f94565b34801561058f57600080fd5b5061039e61059e366004613ba5565b611045565b3480156105af57600080fd5b5061039e6105be36600461399f565b611057565b3480156105cf57600080fd5b5061039e611098565b3480156105e457600080fd5b506105ed6110a2565b6040516103ab91906145c6565b34801561060657600080fd5b5061039e610615366004613894565b6110ba565b34801561062657600080fd5b5061039e61115b565b34801561063b57600080fd5b5061039e61064a366004613cbf565b611165565b34801561065b57600080fd5b5061041661066a36600461399f565b611284565b34801561067b57600080fd5b5061041661068a366004613b69565b611327565b34801561069b57600080fd5b506106af6106aa366004613d34565b611380565b6040516103ab94939291906149e4565b3480156106cb57600080fd5b5061039e6106da366004613894565b6115af565b3480156106eb57600080fd5b5061046d6115ca565b34801561070057600080fd5b506105ed611638565b34801561071557600080fd5b5061039e61164e565b34801561072a57600080fd5b5061039e611654565b34801561073f57600080fd5b5061039e61074e366004613ba5565b61166e565b34801561075f57600080fd5b5061039e6116a6565b34801561077457600080fd5b506105ed6116bd565b34801561078957600080fd5b506104166116cc565b34801561079e57600080fd5b5061039e6116f2565b3480156107b357600080fd5b506103e96116ff565b3480156107c857600080fd5b506105ed61175a565b3480156107dd57600080fd5b5061039e6107ec36600461399f565b61176c565b3480156107fd57600080fd5b506105ed6117e0565b34801561081257600080fd5b5061041661082136600461399f565b611805565b34801561083257600080fd5b5061046d610841366004613b69565b611815565b34801561085257600080fd5b5061039e610861366004613ba5565b6118c6565b34801561087257600080fd5b5061039e6118d8565b34801561088757600080fd5b5061039e61190c565b6103e961089e366004613be1565b61192b565b3480156108af57600080fd5b5061039e6108be366004613ba5565b611c8d565b3480156108cf57600080fd5b506104166108de36600461399f565b611cb9565b3480156108ef57600080fd5b5061039e6108fe3660046138d0565b611d4a565b34801561090f57600080fd5b5061039e61091e366004613894565b611d75565b34801561092f57600080fd5b5061039e61093e366004613d02565b611d90565b34801561094f57600080fd5b5061046d61095e366004613894565b611e63565b34801561096f57600080fd5b5061039e61097e366004613d02565b611e93565b34801561098f57600080fd5b5061039e611f3e565b60008315610aa6576001600160a01b0382166109c6577382af49447d8a07e3bd95bd0d56f35241523fbab191505b600080516020614b858339815191526001600160a01b03166365df83f6600f60008560016040516020016109fb929190614528565b6040516020818303038152906040528051906020012060001c815260200190815260200160002054866040518363ffffffff1660e01b8152600401610a41929190614799565b60206040518083038186803b158015610a5957600080fd5b505afa158015610a6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a919190810190613bc3565b9050610a9b611f43565b811115610aa6575060005b9392505050565b6000610ae7670de0b6b3a7640000610adb610ac6611654565b610acf866115af565b9063ffffffff611f7b16565b9063ffffffff611fb516565b90505b919050565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610b725780601f10610b4757610100808354040283529160200191610b72565b820191906000526020600020905b815481529060010190602001808311610b5557829003601f168201915b505050505081565b3360008181526012602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610bd390869061471a565b60405180910390a35060015b92915050565b600080610bf0611ff7565b9050610c0d610c0382600061097e6118d8565b8261093e8461202b565b91505090565b60155481565b610c216116cc565b610c3d5760405162461bcd60e51b815260040161037590614906565b601555565b610c4a6136fa565b600160005414610c6c5760405162461bcd60e51b815260040161037590614966565b6002600055610c808888888888888861203f565b600160005598975050505050505050565b60135490565b600e5481565b60405163250f447f60e11b8152600090600080516020614b8583398151915290634a1e88fe90610cd390309085906004016145ef565b60206040518083038186803b158015610ceb57600080fd5b505afa158015610cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d239190810190613bc3565b905090565b6001600160a01b0383166000908152601260209081526040808320338452909152812054610d5b9085908590859061225f565b949350505050565b610d6b6116bd565b6001600160a01b0316336001600160a01b031614610dfc577f7ad06df6a0af6bd602d90db766e0d5f253b45187c3717a0f9026ea8b10ff0d4b547f34b31cff1dbd8374124bd4505521fc29cab0f9554a5386ba7d784a4e611c7e3154336001600160a01b038316148015610df05750806001600160a01b0316846001600160a01b0316145b610df957600080fd5b50505b601480546001600160a01b038481166001600160a01b03198316179092556040519116906000903090610e309085906145ba565b6000604051808303816000865af19150503d8060008114610e6d576040519150601f19603f3d011682016040523d82523d6000602084013e610e72565b606091505b50506040519091503d90816000823e82610e8a578181fd5b601480546001600160a01b0319166001600160a01b0386161790558181f35b610eb16136fa565b600160005414610ed35760405162461bcd60e51b815260040161037590614966565b6002600081905550610efa8989898989898960405180602001604052806000815250612400565b60016000559998505050505050505050565b610f146117e0565b6001600160a01b0316336001600160a01b03161480610f4b5750610f366116bd565b6001600160a01b0316336001600160a01b0316145b610f675760405162461bcd60e51b8152600401610375906148e6565b7f80e6706973d0c59541550537fd6a33b971efad732635e6c3b99fb01006803cdf55565b60045460ff1681565b610f9c6117e0565b6001600160a01b0316336001600160a01b03161480610fd35750610fbe6116bd565b6001600160a01b0316336001600160a01b0316145b610fef5760405162461bcd60e51b8152600401610375906148e6565b6040516000906110259083907fa7143c84d793a15503da6f19bf9119a2dac94448ca45d77c8bf08f57b2e9104790602001614574565b604051602081830303815290604052805190602001209050600081555050565b600f6020526000908152604090205481565b600060016000541461107b5760405162461bcd60e51b815260040161037590614966565b600260005561108a8383612625565b90505b600160005592915050565b6000610d236116a6565b7382af49447d8a07e3bd95bd0d56f35241523fbab181565b600080827f37aa2b7d583612f016e4a4de4292cb015139b3d7762663d06a53964912ea2fb660001b6040516020016110f392919061454e565b604051602081830303815290604052805190602001209050610aa68160116000866001600160a01b03166001600160a01b031681526020019081526020016000205461113d611654565b6001600160a01b0387166000908152601060205260409020546127b6565b6000610d23611f43565b60008315610aa657611175611f43565b8411610aa6576001600160a01b0382166111a1577382af49447d8a07e3bd95bd0d56f35241523fbab191505b61127d600a600080516020614b858339815191526001600160a01b03166313814ca4600f60008760016040516020016111db929190614528565b6040516020818303038152906040528051906020012060001c815260200190815260200160002054886040518363ffffffff1660e01b8152600401611221929190614799565b60206040518083038186803b15801561123957600080fd5b505afa15801561124d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506112719190810190613bc3565b9063ffffffff61281016565b9050610aa6565b3360009081526012602090815260408083206001600160a01b03861684529091528120548083106112b7575060006112bb565b8290035b3360008181526012602090815260408083206001600160a01b03891680855292529182902084905590519091907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061131590859061471a565b60405180910390a35060019392505050565b600080827fa7143c84d793a15503da6f19bf9119a2dac94448ca45d77c8bf08f57b2e9104760001b604051602001611360929190614574565b60408051601f198184030181529190528051602090910120549392505050565b60008080806001600160a01b0385166113ab577382af49447d8a07e3bd95bd0d56f35241523fbab194505b6000600080516020614b858339815191526001600160a01b03166378d849ed6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113f457600080fd5b505afa158015611408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061142c91908101906138b2565b60048054604051630a7549df60e21b81526001600160a01b03938416936329d5277c93611467938c93600160601b90910490921691016145d4565b604080518083038186803b15801561147e57600080fd5b505afa158015611492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114b69190810190613c8f565b909250905081158015906114c957508015155b6114e55760405162461bcd60e51b815260040161037590614846565b61150181610adb84670de0b6b3a764000063ffffffff611f7b16565b6004805460405163d67f707760e01b8152929450600080516020614b858339815191529263d67f70779261155192600160601b90046001600160a01b0316918b918e918e91600091829101614667565b60206040518083038186803b15801561156957600080fd5b505afa15801561157d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506115a19190810190613bc3565b935050945094509450949050565b6001600160a01b031660009081526011602052604090205490565b6115d26116cc565b6115ee5760405162461bcd60e51b815260040161037590614906565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b600454600160601b90046001600160a01b031681565b600d5481565b6000610d23611669611664610c9d565b61202b565b612835565b60008061168b6f4b3b4ca85a86c47a098a22400000000084611fb5565b9050610aa668056bc75e2d63100000610adb83610acf61115b565b6000610d236116b3611ff7565b600061097e6118d8565b6001546001600160a01b031690565b6001546000906001600160a01b03166116e3612864565b6001600160a01b031614905090565b6000610d23611664610c9d565b6003805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610b725780601f10610b4757610100808354040283529160200191610b72565b600080516020614b8583398151915281565b60006001600054146117905760405162461bcd60e51b815260040161037590614966565b600260005561179e82612868565b9050801561108d5761108d6004600c9054906101000a90046001600160a01b03168483604051806040016040528060018152602001603560f81b815250612990565b7f80e6706973d0c59541550537fd6a33b971efad732635e6c3b99fb01006803cdf5490565b6000610aa633848460001961225f565b61181d6117e0565b6001600160a01b0316336001600160a01b03161480611854575061183f6116bd565b6001600160a01b0316336001600160a01b0316145b6118705760405162461bcd60e51b8152600401610375906148e6565b6040516000906118a69083907fa7143c84d793a15503da6f19bf9119a2dac94448ca45d77c8bf08f57b2e9104790602001614574565b604051602081830303815290604052805190602001209050600181555050565b6000610ae76118d3610c9d565b8361097e5b604051635c3ef8ad60e11b8152600090600080516020614b858339815191529063b87df15a90610cd39030906004016145c6565b600080611917610c9d565b9050610c0d816119268361202b565b6129f0565b606060016000541461194f5760405162461bcd60e51b815260040161037590614966565b600260008190555061196c6000356001600160e01b031916611327565b156119895760405162461bcd60e51b8152600401610375906149c6565b876119a65760405162461bcd60e51b815260040161037590614976565b6119b06000612a1c565b60006119c2473463ffffffff612a8216565b905060006119d96119d1611ff7565b611271611f43565b905080600c81905550611a1d6004600c9054906101000a90046001600160a01b03168a8c60405180604001604052806002815260200161333960f01b815250612990565b7fc688ff9bd4a1c369dd44c5cf64efa9db6652fb6b280aa765cd43f17d256b816e89896004600c9054906101000a90046001600160a01b03168d604051611a67949392919061460a565b60405180910390a1606086611ab55785858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929350611af092505050565b8787604051611ac59291906145ad565b604051908190038120611ade9188908890602001614590565b60405160208183030381529060405290505b600060607301207468f48822f8535bc96d1cf18eddde4a23926001600160a01b03163463de064e0d8d86604051602401611b2b9291906146b6565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050604051611b6491906145ba565b60006040518083038185875af1925050503d8060008114611ba1576040519150601f19603f3d011682016040523d82523d6000602084013e611ba6565b606091505b509150915081611bc85760405162461bcd60e51b815260040161037590614926565b6000600c81905550600080516020614b858339815191526001600160a01b031663392544838d8f6015546040518463ffffffff1660e01b8152600401611c10939291906146f1565b600060405180830381600087803b158015611c2a57600080fd5b505af1158015611c3e573d6000803e3d6000fd5b50505050844710158015611c5c575083611c596119d1611ff7565b10155b611c785760405162461bcd60e51b815260040161037590614896565b60016000559c9b505050505050505050505050565b600080611c98610c9d565b9050610aa6611cab82600061097e6118d8565b8261093e866112718661202b565b3360009081526012602090815260408083206001600160a01b03861684529091528120548190611cef908463ffffffff61281016565b3360008181526012602090815260408083206001600160a01b038a168085529252918290208490559051929350917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061131590859061471a565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205490565b6001600160a01b031660009081526010602052604090205490565b60008215801590611da15750828210155b15610aa65761127d68056bc75e2d631000008002610adb611e4968056bc75e2d63100000600080516020614b858339815191526001600160a01b0316634699f8466040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0c57600080fd5b505afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611e449190810190613bc3565b612a82565b610acf611e5688886129f0565b899063ffffffff611f7b16565b611e6b6116cc565b611e875760405162461bcd60e51b815260040161037590614906565b611e9081612ac4565b50565b600080611eb2611ea9868663ffffffff61281016565b6119268761202b565b601654604051635e36559360e01b81529192506001600160a01b031690635e36559390611ee59084908790600401614799565b60206040518083038186803b158015611efd57600080fd5b505afa158015611f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f359190810190613bc3565b95945050505050565b600781565b600480546040516370a0823160e01b8152600092600160601b9092046001600160a01b0316916370a0823191610cd3913091016145c6565b600082611f8a57506000610bdf565b82820282848281611f9757fe5b0414610aa65760405162461bcd60e51b8152600401610375906148d6565b6000610aa683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b46565b60405163157b9bb560e11b8152600090600080516020614b8583398151915290632af7376a90610cd39030906004016145c6565b600c5480610aea57610ae782611271611f43565b6120476136fa565b61205c6000356001600160e01b031916611327565b156120795760405162461bcd60e51b8152600401610375906149c6565b87158061208e5750336001600160a01b038416145b6120aa5760405162461bcd60e51b815260040161037590614866565b6120b388612a1c565b876120ea5783303385426040516020016120d19594939291906144cf565b6040516020818303038152906040528051906020012097505b6001600160a01b038416612110577382af49447d8a07e3bd95bd0d56f35241523fbab193505b6004546001600160a01b03858116600160601b9092041614156121455760405162461bcd60e51b815260040161037590614856565b61214d61371e565b61215561373c565b3082526001600160a01b038516602083018190526040830152606081018890526080810187905260008061218b888a8c8e612b7d565b602087019390935293509091508290506121b75760405162461bcd60e51b815260040161037590614886565b6121c78c60008d8b88888c612bdc565b8051909550600080516020614b858339815191529063b1bb822590846121ff85610adb83670de0b6b3a764000063ffffffff611f7b16565b6040518463ffffffff1660e01b815260040161221d939291906147a7565b600060405180830381600087803b15801561223757600080fd5b505af115801561224b573d6000803e3d6000fd5b50505050505050505b979650505050505050565b600060001982146122bb576040805180820190915260028152610c4d60f21b6020820152612296908390859063ffffffff612da616565b6001600160a01b03861660009081526012602090815260408083203384529091529020555b6001600160a01b0384166122e15760405162461bcd60e51b8152600401610375906147d6565b6001600160a01b03851660009081526011602090815260408083205481518083019092526002825261189b60f11b9282019290925290919061232c908390879063ffffffff612da616565b6001600160a01b03808916600090815260116020526040808220849055918916815290812054919250612365828863ffffffff61281016565b6001600160a01b038916600090815260116020526040812082905590915061238b611654565b90506123998a868684612dd2565b6123a589848484612dd2565b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a6040516123e8919061471a565b60405180910390a35060019998505050505050505050565b6124086136fa565b61241d6000356001600160e01b031916611327565b1561243a5760405162461bcd60e51b8152600401610375906149c6565b876124575760405162461bcd60e51b815260040161037590614996565b34158061246357508534145b61247f5760405162461bcd60e51b815260040161037590614816565b8515158061248c57508815155b6124a85760405162461bcd60e51b8152600401610375906149a6565b6001600160a01b0385161515806124be57503415155b806124c857508815155b6124e45760405162461bcd60e51b815260040161037590614956565b8815806124f95750336001600160a01b038516145b6125155760405162461bcd60e51b815260040161037590614866565b61251e89612a1c565b8861255557843033864260405160200161253c9594939291906144cf565b6040516020818303038152906040528051906020012098505b6001600160a01b03851661257b577382af49447d8a07e3bd95bd0d56f35241523fbab194505b6004546001600160a01b03868116600160601b9092041614156125b05760405162461bcd60e51b8152600401610375906147c6565b6125b861371e565b6125c061373c565b3082526001600160a01b03868116602080850191909152908616604080850191909152608083018a90528282018c905260008382018190528151928301909152808252612616918d918d918b9087908790612bdc565b9b9a5050505050505050505050565b600061263c6000356001600160e01b031916611327565b156126595760405162461bcd60e51b8152600401610375906149c6565b816126765760405162461bcd60e51b8152600401610375906148b6565b6126806000612a1c565b6000612690611669611664611ff7565b90506126ae81610adb85670de0b6b3a764000063ffffffff611f7b16565b9150346126f6576126f16004600c9054906101000a90046001600160a01b031633308660405180604001604052806002815260200161062760f31b815250612e88565b61277e565b8234146127155760405162461bcd60e51b8152600401610375906148c6565b7382af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561276457600080fd5b505af1158015612778573d6000803e3d6000fd5b50505050505b6001600160a01b0384166000908152601160205260409020546127af9085906127a982868887612eac565b84612dd2565b5092915050565b6000816127c557506000610d5b565b508354611f3581612804670de0b6b3a76400006127f8886127ec898963ffffffff612fcd16565b9063ffffffff61301316565b9063ffffffff61307e16565b9063ffffffff6130e216565b600082820183811015610aa65760405162461bcd60e51b8152600401610375906147f6565b6013546000908061284857600e54610aa6565b610aa681610adb85670de0b6b3a764000063ffffffff611f7b16565b3390565b600061287f6000356001600160e01b031916611327565b1561289c5760405162461bcd60e51b8152600401610375906149c6565b816128b95760405162461bcd60e51b8152600401610375906148f6565b6128c36000612a1c565b6128cc336115af565b8211156129005760001982146128f45760405162461bcd60e51b8152600401610375906148a6565b6128fd336115af565b91505b6000612910611669611664611ff7565b90506000612930670de0b6b3a7640000610adb868563ffffffff611f7b16565b9050600061293c611f43565b9050819350808411156129615760405162461bcd60e51b815260040161037590614826565b33600081815260116020526040902054612988919061298282898989613128565b86612dd2565b505050919050565b6040516129ea90859063a9059cbb60e01b906129b290879087906024016146d6565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091528361324d565b50505050565b60008115610bdf57612a1582610adb8568056bc75e2d6310000063ffffffff611f7b16565b9050610bdf565b60405163789b79bf60e11b8152600080516020614b858339815191529063f136f37e90612a4d90849060040161471a565b600060405180830381600087803b158015612a6757600080fd5b505af1158015612a7b573d6000803e3d6000fd5b5050505050565b6000610aa683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612da6565b6001600160a01b038116612aea5760405162461bcd60e51b8152600401610375906147e6565b6001546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600180546001600160a01b0319166001600160a01b0392909216919091179055565b60008183612b675760405162461bcd60e51b815260040161037591906147b5565b506000838581612b7357fe5b0495945050505050565b600080600080612b8e888888613313565b90925090506000612baf6f4b3b4ca85a86c47a098a22400000000087611fb5565b9050612bce81610adb8568056bc75e2d6310000063ffffffff611f7b16565b945050945094509450949050565b612be46136fa565b612bec611f43565b602084015111801590612c0b575060208401516001600160a01b031615155b612c275760405162461bcd60e51b815260040161037590614836565b60408401516001600160a01b0316612c4d5760208401516001600160a01b031660408501525b6000612c5b8686868b6134a3565b60208501516060860151919250612c729190612810565b60608501528715612c92576060840151612c8c9089612a82565b60608501525b600088612ca0576000612ca3565b60015b90506000600f60008984604051602001612cbe929190614528565b6040516020818303038152906040528051906020012060001c815260200190815260200160002054905088600014612d0d57612d0a6f4b3b4ca85a86c47a098a2240000000008a611fb5565b98505b600080516020614b858339815191526001600160a01b031663585314cf84838e868e8d8d8d6040518963ffffffff1660e01b8152600401612d549796959493929190614728565b6060604051808303818588803b158015612d6d57600080fd5b505af1158015612d81573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052506126169190810190613b87565b60008184841115612dca5760405162461bcd60e51b815260040161037591906147b5565b505050900390565b604051600090612e089086907f37aa2b7d583612f016e4a4de4292cb015139b3d7762663d06a53964912ea2fb69060200161454e565b60405160208183030381529060405280519060200120905060008360001415612e345760009250612e65565b8415612e65576001600160a01b038616600090815260106020526040902054612e62908390879086906127b6565b90505b90556001600160a01b039093166000908152601060205260409020929092555050565b604051612a7b9086906323b872dd60e01b906129b29088908890889060240161463f565b60006001600160a01b038516612ed45760405162461bcd60e51b8152600401610375906147d6565b6001600160a01b038516600090815260116020526040812054612efd908663ffffffff61281016565b6001600160a01b0387166000908152601160205260409020819055601354909150612f2e908663ffffffff61281016565b6013556040516001600160a01b038716907fb4c03061fb5b7fed76389d5af8f2e0ddb09f8c70d1333abbb62582835e10accb90612f70908890889088906147a7565b60405180910390a2856001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef87604051612fbc919061471a565b60405180910390a395945050505050565b6000818303818312801590612fe25750838113155b80612ff75750600083128015612ff757508381135b610aa65760405162461bcd60e51b815260040161037590614986565b60008261302257506000610bdf565b826000191480156130365750600160ff1b82145b156130535760405162461bcd60e51b815260040161037590614936565b8282028284828161306057fe5b0514610aa65760405162461bcd60e51b815260040161037590614936565b60008161309d5760405162461bcd60e51b8152600401610375906149b6565b816000191480156130b15750600160ff1b83145b156130ce5760405162461bcd60e51b815260040161037590614876565b60008284816130d957fe5b05949350505050565b60008282018183128015906130f75750838112155b8061310c575060008312801561310c57508381125b610aa65760405162461bcd60e51b815260040161037590614806565b6040805180820182526002815261189b60f11b6020808301919091526001600160a01b038716600090815260119091529182205482916131709190879063ffffffff612da616565b9050600a81116131915761318a858263ffffffff61281016565b9450600090505b6001600160a01b03861660009081526011602052604090208190556013546131bf908663ffffffff612a8216565b6013556040516001600160a01b038716907f743033787f4738ff4d6a7225ce2bd0977ee5f86b91a902a58f5e4d0b297b464490613201908890889088906147a7565b60405180910390a260006001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef87604051612fbc919061471a565b60006060846001600160a01b03168460405161326991906145ba565b6000604051808303816000865af19150503d80600081146132a6576040519150601f19603f3d011682016040523d82523d6000602084013e6132ab565b606091505b50915091508183906132d05760405162461bcd60e51b815260040161037591906147b5565b50805115612a7b57808060200190516132ec91908101906139cf565b839061330b5760405162461bcd60e51b815260040161037591906147b5565b505050505050565b6000806000600080516020614b858339815191526001600160a01b03166378d849ed6040518163ffffffff1660e01b815260040160206040518083038186803b15801561335f57600080fd5b505afa158015613373573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061339791908101906138b2565b60048054604051630a7549df60e21b81526001600160a01b03938416936329d5277c936133d2938c93600160601b90910490921691016145d4565b604080518083038186803b1580156133e957600080fd5b505afa1580156133fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506134219190810190613c8f565b9092509050811580159061343457508015155b6134505760405162461bcd60e51b815260040161037590614846565b61346c81610adb84670de0b6b3a764000063ffffffff611f7b16565b8493509150841561349a5761349783611271670de0b6b3a7640000610adb898763ffffffff611f7b16565b92505b50935093915050565b60045460408401516020840151606085015160808601516000947382af49447d8a07e3bd95bd0d56f35241523fbab1946001600160a01b03600160601b9092048216949093909290918b1685141561350d5760405162461bcd60e51b815260040161037590614916565b349650871561357f5761353c85858a60405180604001604052806002815260200161323760f01b815250612990565b8783111561357a5761357a85600080516020614b858339815191528a860360405180604001604052806002815260200161323760f01b815250612990565b6135b3565b6135b385600080516020614b858339815191528560405180604001604052806002815260200161323760f01b815250612990565b80156136b157856001600160a01b03168b6001600160a01b03161480156135d957508615155b80156135e55750808710155b1561367c57856001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561362557600080fd5b505af1158015613639573d6000803e3d6000fd5b50505050506136728b600080516020614b858339815191528360405180604001604052806002815260200161064760f31b815250612990565b80870396506136b1565b6136b18b33600080516020614b858339815191528460405180604001604052806002815260200161064760f31b815250612e88565b81156136ec576136ec8533600080516020614b858339815191528560405180604001604052806002815260200161323960f01b815250612e88565b505050505050949350505050565b60405180606001604052806000801916815260200160008152602001600081525090565b60405180608001604052806004906020820280388339509192915050565b6040518060a001604052806005906020820280388339509192915050565b8035610bdf81614b55565b8051610bdf81614b55565b8051610bdf81614b69565b8035610bdf81614b72565b8051610bdf81614b72565b8035610bdf81614b7b565b60008083601f8401126137ae57600080fd5b50813567ffffffffffffffff8111156137c657600080fd5b6020830191508360018202830111156137de57600080fd5b9250929050565b600082601f8301126137f657600080fd5b813561380961380482614a41565b614a1a565b9150808252602083016020830185838301111561382557600080fd5b613830838284614adb565b50505092915050565b60006060828403121561384b57600080fd5b6138556060614a1a565b905060006138638484613786565b825250602061387484848301613786565b602083015250604061388884828501613786565b60408301525092915050565b6000602082840312156138a657600080fd5b6000610d5b848461375a565b6000602082840312156138c457600080fd5b6000610d5b8484613765565b600080604083850312156138e357600080fd5b60006138ef858561375a565b92505060206139008582860161375a565b9150509250929050565b60008060006060848603121561391f57600080fd5b600061392b868661375a565b935050602061393c8682870161375a565b925050604061394d8682870161377b565b9150509250925092565b6000806040838503121561396a57600080fd5b6000613976858561375a565b925050602083013567ffffffffffffffff81111561399357600080fd5b613900858286016137e5565b600080604083850312156139b257600080fd5b60006139be858561375a565b92505060206139008582860161377b565b6000602082840312156139e157600080fd5b6000610d5b8484613770565b600080600080600080600080610100898b031215613a0a57600080fd5b6000613a168b8b61377b565b9850506020613a278b828c0161377b565b9750506040613a388b828c0161377b565b9650506060613a498b828c0161377b565b9550506080613a5a8b828c0161375a565b94505060a0613a6b8b828c0161375a565b93505060c0613a7c8b828c0161375a565b92505060e089013567ffffffffffffffff811115613a9957600080fd5b613aa58b828c016137e5565b9150509295985092959890939650565b600080600080600080600060e0888a031215613ad057600080fd5b6000613adc8a8a61377b565b9750506020613aed8a828b0161377b565b9650506040613afe8a828b0161377b565b9550506060613b0f8a828b0161377b565b9450506080613b208a828b0161375a565b93505060a0613b318a828b0161375a565b92505060c088013567ffffffffffffffff811115613b4e57600080fd5b613b5a8a828b016137e5565b91505092959891949750929550565b600060208284031215613b7b57600080fd5b6000610d5b8484613791565b600060608284031215613b9957600080fd5b6000610d5b8484613839565b600060208284031215613bb757600080fd5b6000610d5b848461377b565b600060208284031215613bd557600080fd5b6000610d5b8484613786565b600080600080600080600060a0888a031215613bfc57600080fd5b6000613c088a8a61377b565b9750506020613c198a828b0161375a565b9650506040613c2a8a828b0161375a565b955050606088013567ffffffffffffffff811115613c4757600080fd5b613c538a828b0161379c565b9450945050608088013567ffffffffffffffff811115613c7257600080fd5b613c7e8a828b0161379c565b925092505092959891949750929550565b60008060408385031215613ca257600080fd5b6000613cae8585613786565b925050602061390085828601613786565b600080600060608486031215613cd457600080fd5b6000613ce0868661377b565b9350506020613cf18682870161377b565b925050604061394d8682870161375a565b600080600060608486031215613d1757600080fd5b6000613d23868661377b565b935050602061393c8682870161377b565b60008060008060808587031215613d4a57600080fd5b6000613d56878761377b565b9450506020613d678782880161377b565b9350506040613d788782880161377b565b9250506060613d898782880161375a565b91505092959194509250565b6000613da18383613dd5565b505060200190565b6000613da18383613e90565b613dbe81614aba565b82525050565b613dbe613dd082614a8b565b614b13565b613dbe81614a8b565b613de781614a6c565b613df18184610aea565b9250613dfc82614a69565b8060005b8381101561330b578151613e148782613d95565b9650613e1f83614a7c565b925050600101613e00565b613e3381614a72565b613e3d8184610aea565b9250613e4882614a69565b8060005b8381101561330b578151613e608782613da9565b9650613e6b83614a7c565b925050600101613e4c565b613dbe81614a96565b613dbe613e8b82614a96565b614b1e565b613dbe81614a69565b613dbe613ea582614a69565b614a69565b613dbe613ea582614a9b565b6000613ec28385610aea565b9350613ecf838584614adb565b50500190565b6000613ee082614a78565b613eea8185614a82565b9350613efa818560208601614ae7565b613f0381614b3f565b9093019392505050565b6000613f1882614a78565b613f228185610aea565b9350613f32818560208601614ae7565b9290920192915050565b613dbe81614ac5565b6000613f52600283614a82565b61031360f41b815260200192915050565b6000613f70600283614a82565b61313560f01b815260200192915050565b6000613f8e602683614a82565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015260400192915050565b6000613fd6601b83614a82565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b600061400f602183614a82565b7f5369676e6564536166654d6174683a206164646974696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614052600183614a82565b603760f81b815260200192915050565b600061406f600283614a82565b61333760f01b815260200192915050565b600061408d600283614a82565b610c8d60f21b815260200192915050565b60006140ab600283614a82565b61032360f41b815260200192915050565b60006140c9600283614a82565b61313160f01b815260200192915050565b60006140e7600283614a82565b61313360f01b815260200192915050565b6000614105602183614a82565b7f5369676e6564536166654d6174683a206469766973696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614148600283614a82565b61189960f11b815260200192915050565b6000614166600283614a82565b61034360f41b815260200192915050565b6000614184600283614a82565b61199960f11b815260200192915050565b60006141a2600283614a82565b61313760f01b815260200192915050565b60006141c0600283614a82565b61062760f31b815260200192915050565b60006141de602183614a82565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b6000614221600c83614a82565b6b1d5b985d5d1a1bdc9a5e995960a21b815260200192915050565b6000614249600283614a82565b61313960f01b815260200192915050565b6000614267602083614a82565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b60006142a0600283614a82565b61191b60f11b815260200192915050565b60006142be600b83614a82565b6a18d85b1b0819985a5b195960aa1b815260200192915050565b60006142e5602783614a82565b7f5369676e6564536166654d6174683a206d756c7469706c69636174696f6e206f815266766572666c6f7760c81b602082015260400192915050565b600061432e601483614a82565b7319985b1b189858dac81b9bdd08185b1b1bddd95960621b815260200192915050565b600061435e600183614a82565b603960f81b815260200192915050565b600061437b600c83614a82565b6b1b9bdb9499595b9d1c985b9d60a21b815260200192915050565b60006143a3600283614a82565b61066760f31b815260200192915050565b60006143c1602483614a82565b7f5369676e6564536166654d6174683a207375627472616374696f6e206f766572815263666c6f7760e01b602082015260400192915050565b6000614407600183614a82565b601b60f91b815260200192915050565b6000614424600183614a82565b600760fb1b815260200192915050565b6000614441602083614a82565b7f5369676e6564536166654d6174683a206469766973696f6e206279207a65726f815260200192915050565b600061447a600683614a82565b651c185d5cd95960d21b815260200192915050565b805160608301906144a08482613e90565b5060208201516144b36020850182613e90565b5060408201516129ea6040850182613e90565b613dbe81614ab4565b60006144db8288613dc4565b6014820191506144eb8287613dc4565b6014820191506144fb8286613dc4565b60148201915061450b8285613dc4565b60148201915061451b8284613e99565b5060200195945050505050565b60006145348285613dc4565b6014820191506145448284613e7f565b5060010192915050565b600061455a8285613dc4565b60148201915061456a8284613e99565b5060200192915050565b60006145808285613eaa565b60048201915061456a8284613e99565b600061459c8286613eaa565b600482019150611f35828486613eb6565b6000610d5b828486613eb6565b6000610aa68284613f0d565b60208101610bdf8284613dd5565b604081016145e28285613dd5565b610aa66020830184613dd5565b604081016145fd8285613dd5565b610aa66020830184613db5565b608081016146188287613dd5565b6146256020830186613dd5565b6146326040830185613dd5565b611f356060830184613e90565b6060810161464d8286613dd5565b61465a6020830185613dd5565b610d5b6040830184613e90565b60c081016146758289613dd5565b6146826020830188613dd5565b61468f6040830187613e90565b61469c6060830186613e90565b6146a96080830185613f3c565b61225460a0830184613f3c565b604081016146c48285613dd5565b8181036020830152610d5b8184613ed5565b604081016146e48285613dd5565b610aa66020830184613e90565b606081016146ff8286613dd5565b61465a6020830185613e90565b60208101610bdf8284613e76565b60208101610bdf8284613e90565b6101c08101614737828a613e90565b6147446020830189613e90565b6147516040830188613e76565b61475e6060830187613e90565b61476b6080830186613dde565b614779610100830185613e2a565b8181036101a083015261478c8184613ed5565b9998505050505050505050565b604081016146e48285613e90565b606081016146ff8286613e90565b60208082528101610aa68184613ed5565b60208082528101610ae781613f45565b60208082528101610ae781613f63565b60208082528101610ae781613f81565b60208082528101610ae781613fc9565b60208082528101610ae781614002565b60208082528101610ae781614045565b60208082528101610ae781614062565b60208082528101610ae781614080565b60208082528101610ae78161409e565b60208082528101610ae7816140bc565b60208082528101610ae7816140da565b60208082528101610ae7816140f8565b60208082528101610ae78161413b565b60208082528101610ae781614159565b60208082528101610ae781614177565b60208082528101610ae781614195565b60208082528101610ae7816141b3565b60208082528101610ae7816141d1565b60208082528101610ae781614214565b60208082528101610ae78161423c565b60208082528101610ae78161425a565b60208082528101610ae781614293565b60208082528101610ae7816142b1565b60208082528101610ae7816142d8565b60208082528101610ae781614321565b60208082528101610ae781614351565b60208082528101610ae78161436e565b60208082528101610ae781614396565b60208082528101610ae7816143b4565b60208082528101610ae7816143fa565b60208082528101610ae781614417565b60208082528101610ae781614434565b60208082528101610ae78161446d565b60608101610bdf828461448f565b608081016149f28287613e90565b6149ff6020830186613e90565b6146326040830185613e90565b60208101610bdf82846144c6565b60405181810167ffffffffffffffff81118282101715614a3957600080fd5b604052919050565b600067ffffffffffffffff821115614a5857600080fd5b506020601f91909101601f19160190565b90565b50600490565b50600590565b5190565b60200190565b90815260200190565b6000610ae782614aa8565b151590565b6001600160e01b03191690565b6001600160a01b031690565b60ff1690565b6000610ae782614ad0565b6000610ae782614a69565b6000610ae782614a8b565b82818337506000910152565b60005b83811015614b02578181015183820152602001614aea565b838111156129ea5750506000910152565b6000610ae782614b29565b6000610ae782614b34565b6000610ae782614b4f565b6000610ae782614b49565b601f01601f191690565b60f81b90565b60601b90565b614b5e81614a8b565b8114611e9057600080fd5b614b5e81614a96565b614b5e81614a69565b614b5e81614a9b56fe00000000000000000000000037407f3178ffe07a6cf5c847f8f680fecf319faba365627a7a72315820fb58920d2d6ada2e36fa62adc700662f19f6701d31090c887bec56aa2b122b3a6c6578706572696d656e74616cf564736f6c634300051100408be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000000000000000000000111f9f3e59e44e257b24c5d1de57e05c380c07d2

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000111f9f3e59e44e257b24c5d1de57e05c380c07d2

-----Decoded View---------------
Arg [0] : _newOwner (address): 0x111f9f3e59e44e257b24c5d1de57e05c380c07d2

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000111f9f3e59e44e257b24c5d1de57e05c380c07d2


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.