Contract 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c 8

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x5be265cb4839daaa7a6419aabeb577084137f57529d4947df30f6ff9a4890e460x608060407628742021-09-13 23:32:05441 days 18 hrs ago0x9fc5341db9a9cdf8337b4bd286d4cfc03b20ad35 IN  Create: BDeployer0 ETH0.109594813786 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x71662f9a0148ddc72c5c83cb4c46907a89afc7bc50ccb07c02075f56fda05a3040192302021-12-22 12:32:23342 days 5 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x71662f9a0148ddc72c5c83cb4c46907a89afc7bc50ccb07c02075f56fda05a3040192302021-12-22 12:32:23342 days 5 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0xc17e536ce3b90c6d5bc7f8562c7de0dd69d82b923ca68380e224a4da9b21411340192202021-12-22 12:31:05342 days 5 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0xc17e536ce3b90c6d5bc7f8562c7de0dd69d82b923ca68380e224a4da9b21411340192202021-12-22 12:31:05342 days 5 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x5f1c09af59862e27daa4ee2c96407f32c147104375aa14710dbe33a51758bf3e40191492021-12-22 12:27:28342 days 5 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x5f1c09af59862e27daa4ee2c96407f32c147104375aa14710dbe33a51758bf3e40191492021-12-22 12:27:28342 days 5 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x16d1c95878e09da237e47d6d37e2fc60da6d7a9d6bcaa027bad009353fef707e40191462021-12-22 12:27:28342 days 5 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x16d1c95878e09da237e47d6d37e2fc60da6d7a9d6bcaa027bad009353fef707e40191462021-12-22 12:27:28342 days 5 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x0235b67e5d4957da10909a737161fb1ee4523adb0915ff4d07e1fa19c7bb0c9f22114882021-10-14 10:52:11411 days 6 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x0235b67e5d4957da10909a737161fb1ee4523adb0915ff4d07e1fa19c7bb0c9f22114882021-10-14 10:52:11411 days 6 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x3f531bdceb2de60694740de7262cda404d78d82ad63e0a22ab2446f0f17402e022114862021-10-14 10:50:33411 days 6 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x3f531bdceb2de60694740de7262cda404d78d82ad63e0a22ab2446f0f17402e022114862021-10-14 10:50:33411 days 6 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x8ba6dd3ba6de9897de6f5896a4e76882b259515c30444879248b29cde74f233122114562021-10-14 10:50:33411 days 6 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x8ba6dd3ba6de9897de6f5896a4e76882b259515c30444879248b29cde74f233122114562021-10-14 10:50:33411 days 6 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x11bb8968c2e9be14482f2d686c7f3acad4ee0654cb7885f692b86e4b5dae6ed122114542021-10-14 10:50:33411 days 6 hrs ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x11bb8968c2e9be14482f2d686c7f3acad4ee0654cb7885f692b86e4b5dae6ed122114542021-10-14 10:50:33411 days 6 hrs ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0xb7ab73348f9e61575f3462f92fab4dade04e8ae0b0a8ff95a3bda80997fbb27721892302021-10-13 16:00:06412 days 1 hr ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0xb7ab73348f9e61575f3462f92fab4dade04e8ae0b0a8ff95a3bda80997fbb27721892302021-10-13 16:00:06412 days 1 hr ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0xe5da742cf0bc4eb9c5a364521ae7ac1fdb94939d05c1766642e211a4c61d987d21892282021-10-13 16:00:06412 days 1 hr ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0xe5da742cf0bc4eb9c5a364521ae7ac1fdb94939d05c1766642e211a4c61d987d21892282021-10-13 16:00:06412 days 1 hr ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x20d8779cc29038dcefc6e02f9029c671a4aa04d0eddf9e76dad5a2e63db8fd2d21891602021-10-13 15:57:35412 days 1 hr ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x20d8779cc29038dcefc6e02f9029c671a4aa04d0eddf9e76dad5a2e63db8fd2d21891602021-10-13 15:57:35412 days 1 hr ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x9026ffabe32fc4a95b960b07f0204a374bc0cfbd728159aa228ba0724b04d64b21891582021-10-13 15:57:35412 days 1 hr ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
0x9026ffabe32fc4a95b960b07f0204a374bc0cfbd728159aa228ba0724b04d64b21891582021-10-13 15:57:35412 days 1 hr ago Impermax: Factory 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c0 ETH
0x39aece780e36fa0299aadcc6fa64c8a05e2810efe3a3703669537a75a7470cb421891452021-10-13 15:57:35412 days 1 hr ago 0xc12e00de204d58ead5b5ce9054e94aee7747fb6c  Contract Creation0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BDeployer

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 999999 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Arbiscan on 2021-09-13
*/

// File: contracts\libraries\SafeMath.sol

pragma solidity =0.5.16;

// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.

/**
 * @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 addition of two unsigned integers, reverting with custom message on overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot underflow.
     */
    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 multiplication of two unsigned integers, reverting on overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b, string memory errorMessage) 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, errorMessage);

        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.
     */
    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.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

// File: contracts\ImpermaxERC20.sol

pragma solidity =0.5.16;


// This contract is basically UniswapV2ERC20 with small modifications
// src: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol

contract ImpermaxERC20 {
	using SafeMath for uint;
	
	string public name;
	string public symbol;
	uint8 public decimals = 18;
	uint public totalSupply;
	mapping(address => uint) public balanceOf;
	mapping(address => mapping(address => uint)) public allowance;
	
	bytes32 public DOMAIN_SEPARATOR;
	mapping(address => uint) public nonces;
	
	event Transfer(address indexed from, address indexed to, uint value);
	event Approval(address indexed owner, address indexed spender, uint value);

	constructor() public {}	
	
	function _setName(string memory _name, string memory _symbol) internal {
		name = _name;
		symbol = _symbol;
		uint chainId;
		assembly {
			chainId := chainid
		}
		DOMAIN_SEPARATOR = keccak256(
			abi.encode(
				keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
				keccak256(bytes(_name)),
				keccak256(bytes("1")),
				chainId,
				address(this)
			)
		);
	}

	function _mint(address to, uint value) internal {
		totalSupply = totalSupply.add(value);
		balanceOf[to] = balanceOf[to].add(value);
		emit Transfer(address(0), to, value);
	}

	function _burn(address from, uint value) internal {
		balanceOf[from] = balanceOf[from].sub(value);
		totalSupply = totalSupply.sub(value);
		emit Transfer(from, address(0), value);
	}

	function _approve(address owner, address spender, uint value) private {
		allowance[owner][spender] = value;
		emit Approval(owner, spender, value);
	}

	function _transfer(address from, address to, uint value) internal {
		balanceOf[from] = balanceOf[from].sub(value, "Impermax: TRANSFER_TOO_HIGH");
		balanceOf[to] = balanceOf[to].add(value);
		emit Transfer(from, to, value);
	}

	function approve(address spender, uint value) external returns (bool) {
		_approve(msg.sender, spender, value);
		return true;
	}

	function transfer(address to, uint value) external returns (bool) {
		_transfer(msg.sender, to, value);
		return true;
	}

	function transferFrom(address from, address to, uint value) external returns (bool) {
		if (allowance[from][msg.sender] != uint(-1)) {
			allowance[from][msg.sender] = allowance[from][msg.sender].sub(value, "Impermax: TRANSFER_NOT_ALLOWED");
		}
		_transfer(from, to, value);
		return true;
	}
	
	function _checkSignature(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s, bytes32 typehash) internal {
		require(deadline >= block.timestamp, "Impermax: EXPIRED");
		bytes32 digest = keccak256(
			abi.encodePacked(
				'\x19\x01',
				DOMAIN_SEPARATOR,
				keccak256(abi.encode(typehash, owner, spender, value, nonces[owner]++, deadline))
			)
		);
		address recoveredAddress = ecrecover(digest, v, r, s);
		require(recoveredAddress != address(0) && recoveredAddress == owner, "Impermax: INVALID_SIGNATURE");	
	}

	// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
	bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
	function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
		_checkSignature(owner, spender, value, deadline, v, r, s, PERMIT_TYPEHASH);
		_approve(owner, spender, value);
	}
}

// File: contracts\interfaces\IERC20.sol

pragma solidity >=0.5.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);
}

// File: contracts\interfaces\IPoolToken.sol

pragma solidity >=0.5.0;

interface IPoolToken {

	/*** Impermax ERC20 ***/
	
	event Transfer(address indexed from, address indexed to, uint value);
	event Approval(address indexed owner, address indexed spender, uint value);
	
	function name() external pure returns (string memory);
	function symbol() external pure returns (string memory);
	function decimals() external pure returns (uint8);
	function totalSupply() external view returns (uint);
	function balanceOf(address owner) external view returns (uint);
	function allowance(address owner, address spender) external view returns (uint);
	function approve(address spender, uint value) external returns (bool);
	function transfer(address to, uint value) external returns (bool);
	function transferFrom(address from, address to, uint value) external returns (bool);
	
	function DOMAIN_SEPARATOR() external view returns (bytes32);
	function PERMIT_TYPEHASH() external pure returns (bytes32);
	function nonces(address owner) external view returns (uint);
	function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
	
	/*** Pool Token ***/
	
	event Mint(address indexed sender, address indexed minter, uint mintAmount, uint mintTokens);
	event Redeem(address indexed sender, address indexed redeemer, uint redeemAmount, uint redeemTokens);
	event Sync(uint totalBalance);
	
	function underlying() external view returns (address);
	function factory() external view returns (address);
	function totalBalance() external view returns (uint);
	function MINIMUM_LIQUIDITY() external pure returns (uint);

	function exchangeRate() external returns (uint);
	function mint(address minter) external returns (uint mintTokens);
	function redeem(address redeemer) external returns (uint redeemAmount);
	function skim(address to) external;
	function sync() external;
	
	function _setFactory() external;
}

// File: contracts\PoolToken.sol

pragma solidity =0.5.16;





contract PoolToken is IPoolToken, ImpermaxERC20 {
   	uint internal constant initialExchangeRate = 1e18;
	address public underlying;
	address public factory;
	uint public totalBalance;
	uint public constant MINIMUM_LIQUIDITY = 1000;
	
	event Mint(address indexed sender, address indexed minter, uint mintAmount, uint mintTokens);
	event Redeem(address indexed sender, address indexed redeemer, uint redeemAmount, uint redeemTokens);
	event Sync(uint totalBalance);
	
	/*** Initialize ***/
	
	// called once by the factory
	function _setFactory() external {
		require(factory == address(0), "Impermax: FACTORY_ALREADY_SET");
		factory = msg.sender;
	}
	
	/*** PoolToken ***/
	
	function _update() internal {
		totalBalance = IERC20(underlying).balanceOf(address(this));
		emit Sync(totalBalance);
	}

	function exchangeRate() public returns (uint) 
	{
		uint _totalSupply = totalSupply; // gas savings
		uint _totalBalance = totalBalance; // gas savings
		if (_totalSupply == 0 || _totalBalance == 0) return initialExchangeRate;
		return _totalBalance.mul(1e18).div(_totalSupply);
	}
	
	// this low-level function should be called from another contract
	function mint(address minter) external nonReentrant update returns (uint mintTokens) {
		uint balance = IERC20(underlying).balanceOf(address(this));
		uint mintAmount = balance.sub(totalBalance);
		mintTokens = mintAmount.mul(1e18).div(exchangeRate());

		if(totalSupply == 0) {
			// permanently lock the first MINIMUM_LIQUIDITY tokens
			mintTokens = mintTokens.sub(MINIMUM_LIQUIDITY);
			_mint(address(0), MINIMUM_LIQUIDITY);
		}
		require(mintTokens > 0, "Impermax: MINT_AMOUNT_ZERO");
		_mint(minter, mintTokens);
		emit Mint(msg.sender, minter, mintAmount, mintTokens);
	}

	// this low-level function should be called from another contract
	function redeem(address redeemer) external nonReentrant update returns (uint redeemAmount) {
		uint redeemTokens = balanceOf[address(this)];
		redeemAmount = redeemTokens.mul(exchangeRate()).div(1e18);

		require(redeemAmount > 0, "Impermax: REDEEM_AMOUNT_ZERO");
		require(redeemAmount <= totalBalance, "Impermax: INSUFFICIENT_CASH");
		_burn(address(this), redeemTokens);
		_safeTransfer(redeemer, redeemAmount);
		emit Redeem(msg.sender, redeemer, redeemAmount, redeemTokens);		
	}

	// force real balance to match totalBalance
	function skim(address to) external nonReentrant {
		_safeTransfer(to, IERC20(underlying).balanceOf(address(this)).sub(totalBalance));
	}

	// force totalBalance to match real balance
	function sync() external nonReentrant update {}
	
	/*** Utilities ***/
	
	// same safe transfer function used by UniSwapV2 (with fixed underlying)
	bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)")));
	function _safeTransfer(address to, uint amount) internal {
		(bool success, bytes memory data) = underlying.call(abi.encodeWithSelector(SELECTOR, to, amount));
		require(success && (data.length == 0 || abi.decode(data, (bool))), "Impermax: TRANSFER_FAILED");
	}
	
	// prevents a contract from calling itself, directly or indirectly.
	bool internal _notEntered = true;
	modifier nonReentrant() {
		require(_notEntered, "Impermax: REENTERED");
		_notEntered = false;
		_;
		_notEntered = true;
	}
	
	// update totalBalance with current balance
	modifier update() {
		_;
		_update();
	}
}

// File: contracts\BStorage.sol

pragma solidity =0.5.16;

contract BStorage {

	address public collateral;

	mapping (address => mapping (address => uint256)) public borrowAllowance;
	
	struct BorrowSnapshot {
		uint112 principal;		// amount in underlying when the borrow was last updated
		uint112 interestIndex;	// borrow index when borrow was last updated
	}
	mapping(address => BorrowSnapshot) internal borrowBalances;	

	// use one memory slot
	uint112 public borrowIndex = 1e18;
	uint112 public totalBorrows;
	uint32 public accrualTimestamp = uint32(block.timestamp % 2**32);	

	uint public exchangeRateLast;
		
	// use one memory slot
	uint48 public borrowRate;
	uint48 public kinkBorrowRate = 3.1709792e9; //10% per year
	uint32 public rateUpdateTimestamp = uint32(block.timestamp % 2**32);

	uint public reserveFactor = 0.10e18; //10%
	uint public kinkUtilizationRate = 0.70e18; //70%
	uint public adjustSpeed = 0.5787037e12; //5% per day
	address public borrowTracker;

    function safe112(uint n) internal pure returns (uint112) {
        require(n < 2**112, "Impermax: SAFE112");
        return uint112(n);
    }
}

// File: contracts\BAllowance.sol

pragma solidity =0.5.16;



contract BAllowance is PoolToken, BStorage {	

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

	function _borrowApprove(address owner, address spender, uint256 value) private {
		borrowAllowance[owner][spender] = value;
		emit BorrowApproval(owner, spender, value);
	}
	
	function borrowApprove(address spender, uint256 value) external returns (bool) {
		_borrowApprove(msg.sender, spender, value);
		return true;
	}
	
	function _checkBorrowAllowance(address owner, address spender, uint256 value) internal {
		uint _borrowAllowance = borrowAllowance[owner][spender];
		if (spender != owner && _borrowAllowance != uint256(-1)) {
			require(_borrowAllowance >= value, "Impermax: BORROW_NOT_ALLOWED");
			borrowAllowance[owner][spender] = _borrowAllowance - value;
		}	
	}

	// keccak256("BorrowPermit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
	bytes32 public constant BORROW_PERMIT_TYPEHASH = 0xf6d86ed606f871fa1a557ac0ba607adce07767acf53f492fb215a1a4db4aea6f;
	function borrowPermit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
		_checkSignature(owner, spender, value, deadline, v, r, s, BORROW_PERMIT_TYPEHASH);
		_borrowApprove(owner, spender, value);
	}
}

// File: contracts\BInterestRateModel.sol

pragma solidity =0.5.16;



contract BInterestRateModel is PoolToken, BStorage {

	// When utilization is 100% borrowRate is kinkBorrowRate * KINK_MULTIPLIER
	// kinkBorrowRate relative adjustment per second belongs to [1-adjustSpeed, 1+adjustSpeed*(KINK_MULTIPLIER-1)]
	uint public constant KINK_MULTIPLIER = 5;
	uint public constant KINK_BORROW_RATE_MAX = 317.097920e9; //1000% per year
	uint public constant KINK_BORROW_RATE_MIN = 0.31709792e9; //1% per year

	event AccrueInterest(uint interestAccumulated, uint borrowIndex, uint totalBorrows);
	event CalculateKinkBorrowRate(uint kinkBorrowRate);
	event CalculateBorrowRate(uint borrowRate);
		
	function _calculateBorrowRate() internal {
		uint _kinkUtilizationRate = kinkUtilizationRate;		
		uint _adjustSpeed = adjustSpeed;
		uint _borrowRate = borrowRate;	
		uint _kinkBorrowRate = kinkBorrowRate;
		uint32 _rateUpdateTimestamp = rateUpdateTimestamp;		
	
		// update kinkBorrowRate using previous borrowRate
		uint32 timeElapsed = getBlockTimestamp() - _rateUpdateTimestamp; // underflow is desired
		if(timeElapsed > 0) {
			rateUpdateTimestamp = getBlockTimestamp();
			uint adjustFactor;
			
			if (_borrowRate < _kinkBorrowRate) {
				// never overflows, _kinkBorrowRate is never 0
				uint tmp = (_kinkBorrowRate - _borrowRate) * 1e18 / _kinkBorrowRate * _adjustSpeed * timeElapsed / 1e18;
				adjustFactor = tmp > 1e18 ? 0 : 1e18 - tmp;
			} else {
				// never overflows, _kinkBorrowRate is never 0
				uint tmp = (_borrowRate - _kinkBorrowRate) * 1e18 / _kinkBorrowRate * _adjustSpeed * timeElapsed / 1e18;
				adjustFactor = tmp + 1e18;
			}
			
			// never overflows
			_kinkBorrowRate = _kinkBorrowRate * adjustFactor / 1e18;
			if(_kinkBorrowRate > KINK_BORROW_RATE_MAX) _kinkBorrowRate = KINK_BORROW_RATE_MAX;
			if(_kinkBorrowRate < KINK_BORROW_RATE_MIN) _kinkBorrowRate = KINK_BORROW_RATE_MIN;

			kinkBorrowRate = uint48(_kinkBorrowRate);
			emit CalculateKinkBorrowRate(_kinkBorrowRate);
		}
		
		uint _utilizationRate;
		{ // avoid stack to deep
		uint _totalBorrows = totalBorrows; // gas savings
		uint _actualBalance = totalBalance.add(_totalBorrows);
		_utilizationRate = (_actualBalance == 0) ? 0 : _totalBorrows * 1e18 / _actualBalance;
		}
		
		// update borrowRate using the new kinkBorrowRate	
		if(_utilizationRate <= _kinkUtilizationRate) {
			// never overflows, _kinkUtilizationRate is never 0
			_borrowRate = _kinkBorrowRate * _utilizationRate / _kinkUtilizationRate;
		} else {
			// never overflows, _kinkUtilizationRate is always < 1e18
			uint overUtilization = (_utilizationRate - _kinkUtilizationRate) * 1e18 / (1e18 - _kinkUtilizationRate);
			// never overflows
			_borrowRate = ((KINK_MULTIPLIER - 1) * overUtilization + 1e18) * _kinkBorrowRate / 1e18;
		}
		borrowRate = uint48(_borrowRate);
		emit CalculateBorrowRate(_borrowRate);
	}
	
	// applies accrued interest to total borrows and reserves
	function accrueInterest() public {
		uint _borrowIndex = borrowIndex;
		uint _totalBorrows = totalBorrows;
		uint32 _accrualTimestamp = accrualTimestamp;
		
		uint32 blockTimestamp = getBlockTimestamp();
		if (_accrualTimestamp == blockTimestamp) return;
		uint32 timeElapsed = blockTimestamp - _accrualTimestamp; // underflow is desired
		accrualTimestamp = blockTimestamp;
		
		uint interestFactor = uint(borrowRate).mul(timeElapsed);	
		uint interestAccumulated = interestFactor.mul(_totalBorrows).div(1e18);
		_totalBorrows = _totalBorrows.add( interestAccumulated );
		_borrowIndex = _borrowIndex.add( interestFactor.mul(_borrowIndex).div(1e18) );
	
		borrowIndex = safe112(_borrowIndex);
		totalBorrows = safe112(_totalBorrows);
		emit AccrueInterest(interestAccumulated, _borrowIndex, _totalBorrows);
	}
		
	function getBlockTimestamp() public view returns (uint32) {
		return uint32(block.timestamp % 2**32);
	}
}

// File: contracts\interfaces\IFactory.sol

pragma solidity >=0.5.0;

interface IFactory {
	event LendingPoolInitialized(address indexed uniswapV2Pair, address indexed token0, address indexed token1,
		address collateral, address borrowable0, address borrowable1, uint lendingPoolId);
	event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
	event NewAdmin(address oldAdmin, address newAdmin);
	event NewReservesPendingAdmin(address oldReservesPendingAdmin, address newReservesPendingAdmin);
	event NewReservesAdmin(address oldReservesAdmin, address newReservesAdmin);
	event NewReservesManager(address oldReservesManager, address newReservesManager);
	
	function admin() external view returns (address);
	function pendingAdmin() external view returns (address);
	function reservesAdmin() external view returns (address);
	function reservesPendingAdmin() external view returns (address);
	function reservesManager() external view returns (address);

	function getLendingPool(address uniswapV2Pair) external view returns (
		bool initialized, 
		uint24 lendingPoolId, 
		address collateral, 
		address borrowable0, 
		address borrowable1
	);
	function allLendingPools(uint) external view returns (address uniswapV2Pair);
	function allLendingPoolsLength() external view returns (uint);
	
	function bDeployer() external view returns (address);
	function cDeployer() external view returns (address);
	function simpleUniswapOracle() external view returns (address);

	function createCollateral(address uniswapV2Pair) external returns (address collateral);
	function createBorrowable0(address uniswapV2Pair) external returns (address borrowable0);
	function createBorrowable1(address uniswapV2Pair) external returns (address borrowable1);
	function initializeLendingPool(address uniswapV2Pair) external;

	function _setPendingAdmin(address newPendingAdmin) external;
	function _acceptAdmin() external;
	function _setReservesPendingAdmin(address newPendingAdmin) external;
	function _acceptReservesAdmin() external;
	function _setReservesManager(address newReservesManager) external;
}

// File: contracts\BSetter.sol

pragma solidity =0.5.16;




contract BSetter is PoolToken, BStorage {

	uint public constant RESERVE_FACTOR_MAX = 0.20e18; //20%
	uint public constant KINK_UR_MIN = 0.50e18; //50%
	uint public constant KINK_UR_MAX = 0.99e18; //99%
	uint public constant ADJUST_SPEED_MIN = 0.05787037e12; //0.5% per day
	uint public constant ADJUST_SPEED_MAX = 57.87037e12; //500% per day

	event NewReserveFactor(uint newReserveFactor);
	event NewKinkUtilizationRate(uint newKinkUtilizationRate);
	event NewAdjustSpeed(uint newAdjustSpeed);
	event NewBorrowTracker(address newBorrowTracker);
	
	// called once by the factory at time of deployment
	function _initialize (
		string calldata _name, 
		string calldata _symbol,
		address _underlying, 
		address _collateral
	) external {
		require(msg.sender == factory, "Impermax: UNAUTHORIZED"); // sufficient check
		_setName(_name, _symbol);
		underlying = _underlying;
		collateral = _collateral;
		exchangeRateLast = initialExchangeRate;
	}
	
	function _setReserveFactor(uint newReserveFactor) external nonReentrant {
		_checkSetting(newReserveFactor, 0, RESERVE_FACTOR_MAX);
		reserveFactor = newReserveFactor;
		emit NewReserveFactor(newReserveFactor);
	}

	function _setKinkUtilizationRate(uint newKinkUtilizationRate) external nonReentrant {
		_checkSetting(newKinkUtilizationRate, KINK_UR_MIN, KINK_UR_MAX);
		kinkUtilizationRate = newKinkUtilizationRate;
		emit NewKinkUtilizationRate(newKinkUtilizationRate);
	}

	function _setAdjustSpeed(uint newAdjustSpeed) external nonReentrant {
		_checkSetting(newAdjustSpeed, ADJUST_SPEED_MIN, ADJUST_SPEED_MAX);
		adjustSpeed = newAdjustSpeed;
		emit NewAdjustSpeed(newAdjustSpeed);
	}

	function _setBorrowTracker(address newBorrowTracker) external nonReentrant {
		_checkAdmin();
		borrowTracker = newBorrowTracker;
		emit NewBorrowTracker(newBorrowTracker);
	}
	
	function _checkSetting(uint parameter, uint min, uint max) internal view {
		_checkAdmin();
		require(parameter >= min, "Impermax: INVALID_SETTING");
		require(parameter <= max, "Impermax: INVALID_SETTING");
	}
	
	function _checkAdmin() internal view {
		require(msg.sender == IFactory(factory).admin(), "Impermax: UNAUTHORIZED");
	}
}

// File: contracts\interfaces\IBorrowable.sol

pragma solidity >=0.5.0;

interface IBorrowable {

	/*** Impermax ERC20 ***/
	
	event Transfer(address indexed from, address indexed to, uint value);
	event Approval(address indexed owner, address indexed spender, uint value);
	
	function name() external pure returns (string memory);
	function symbol() external pure returns (string memory);
	function decimals() external pure returns (uint8);
	function totalSupply() external view returns (uint);
	function balanceOf(address owner) external view returns (uint);
	function allowance(address owner, address spender) external view returns (uint);
	function approve(address spender, uint value) external returns (bool);
	function transfer(address to, uint value) external returns (bool);
	function transferFrom(address from, address to, uint value) external returns (bool);
	
	function DOMAIN_SEPARATOR() external view returns (bytes32);
	function PERMIT_TYPEHASH() external pure returns (bytes32);
	function nonces(address owner) external view returns (uint);
	function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
	
	/*** Pool Token ***/
	
	event Mint(address indexed sender, address indexed minter, uint mintAmount, uint mintTokens);
	event Redeem(address indexed sender, address indexed redeemer, uint redeemAmount, uint redeemTokens);
	event Sync(uint totalBalance);
	
	function underlying() external view returns (address);
	function factory() external view returns (address);
	function totalBalance() external view returns (uint);
	function MINIMUM_LIQUIDITY() external pure returns (uint);

	function exchangeRate() external returns (uint);
	function mint(address minter) external returns (uint mintTokens);
	function redeem(address redeemer) external returns (uint redeemAmount);
	function skim(address to) external;
	function sync() external;
	
	function _setFactory() external;
	
	/*** Borrowable ***/

	event BorrowApproval(address indexed owner, address indexed spender, uint value);
	event Borrow(address indexed sender, address indexed borrower, address indexed receiver, uint borrowAmount, uint repayAmount, uint accountBorrowsPrior, uint accountBorrows, uint totalBorrows);
	event Liquidate(address indexed sender, address indexed borrower, address indexed liquidator, uint seizeTokens, uint repayAmount, uint accountBorrowsPrior, uint accountBorrows, uint totalBorrows);
	
	function BORROW_FEE() external pure returns (uint);
	function collateral() external view returns (address);
	function reserveFactor() external view returns (uint);
	function exchangeRateLast() external view returns (uint);
	function borrowIndex() external view returns (uint);
	function totalBorrows() external view returns (uint);
	function borrowAllowance(address owner, address spender) external view returns (uint);
	function borrowBalance(address borrower) external view returns (uint);	
	function borrowTracker() external view returns (address);
	
	function BORROW_PERMIT_TYPEHASH() external pure returns (bytes32);
	function borrowApprove(address spender, uint256 value) external returns (bool);
	function borrowPermit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
	function borrow(address borrower, address receiver, uint borrowAmount, bytes calldata data) external;
	function liquidate(address borrower, address liquidator) external returns (uint seizeTokens);
	function trackBorrow(address borrower) external;
	
	/*** Borrowable Interest Rate Model ***/

	event AccrueInterest(uint interestAccumulated, uint borrowIndex, uint totalBorrows);
	event CalculateKink(uint kinkRate);
	event CalculateBorrowRate(uint borrowRate);
	
	function KINK_BORROW_RATE_MAX() external pure returns (uint);
	function KINK_BORROW_RATE_MIN() external pure returns (uint);
	function KINK_MULTIPLIER() external pure returns (uint);
	function borrowRate() external view returns (uint);
	function kinkBorrowRate() external view returns (uint);
	function kinkUtilizationRate() external view returns (uint);
	function adjustSpeed() external view returns (uint);
	function rateUpdateTimestamp() external view returns (uint32);
	function accrualTimestamp() external view returns (uint32);
	
	function accrueInterest() external;
	
	/*** Borrowable Setter ***/

	event NewReserveFactor(uint newReserveFactor);
	event NewKinkUtilizationRate(uint newKinkUtilizationRate);
	event NewAdjustSpeed(uint newAdjustSpeed);
	event NewBorrowTracker(address newBorrowTracker);

	function RESERVE_FACTOR_MAX() external pure returns (uint);
	function KINK_UR_MIN() external pure returns (uint);
	function KINK_UR_MAX() external pure returns (uint);
	function ADJUST_SPEED_MIN() external pure returns (uint);
	function ADJUST_SPEED_MAX() external pure returns (uint);
	
	function _initialize (
		string calldata _name, 
		string calldata _symbol,
		address _underlying, 
		address _collateral
	) external;
	function _setReserveFactor(uint newReserveFactor) external;
	function _setKinkUtilizationRate(uint newKinkUtilizationRate) external;
	function _setAdjustSpeed(uint newAdjustSpeed) external;
	function _setBorrowTracker(address newBorrowTracker) external;
}

// File: contracts\interfaces\ICollateral.sol

pragma solidity >=0.5.0;

interface ICollateral {

	/*** Impermax ERC20 ***/
	
	event Transfer(address indexed from, address indexed to, uint value);
	event Approval(address indexed owner, address indexed spender, uint value);
	
	function name() external pure returns (string memory);
	function symbol() external pure returns (string memory);
	function decimals() external pure returns (uint8);
	function totalSupply() external view returns (uint);
	function balanceOf(address owner) external view returns (uint);
	function allowance(address owner, address spender) external view returns (uint);
	function approve(address spender, uint value) external returns (bool);
	function transfer(address to, uint value) external returns (bool);
	function transferFrom(address from, address to, uint value) external returns (bool);
	
	function DOMAIN_SEPARATOR() external view returns (bytes32);
	function PERMIT_TYPEHASH() external pure returns (bytes32);
	function nonces(address owner) external view returns (uint);
	function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
	
	/*** Pool Token ***/
	
	event Mint(address indexed sender, address indexed minter, uint mintAmount, uint mintTokens);
	event Redeem(address indexed sender, address indexed redeemer, uint redeemAmount, uint redeemTokens);
	event Sync(uint totalBalance);
	
	function underlying() external view returns (address);
	function factory() external view returns (address);
	function totalBalance() external view returns (uint);
	function MINIMUM_LIQUIDITY() external pure returns (uint);

	function exchangeRate() external returns (uint);
	function mint(address minter) external returns (uint mintTokens);
	function redeem(address redeemer) external returns (uint redeemAmount);
	function skim(address to) external;
	function sync() external;
	
	function _setFactory() external;
	
	/*** Collateral ***/
	
	function borrowable0() external view returns (address);
	function borrowable1() external view returns (address);
	function simpleUniswapOracle() external view returns (address);
	function safetyMarginSqrt() external view returns (uint);
	function liquidationIncentive() external view returns (uint);
	
	function getPrices() external returns (uint price0, uint price1);
	function tokensUnlocked(address from, uint value) external returns (bool);
	function accountLiquidityAmounts(address account, uint amount0, uint amount1) external returns (uint liquidity, uint shortfall);
	function accountLiquidity(address account) external returns (uint liquidity, uint shortfall);
	function canBorrow(address account, address borrowable, uint accountBorrows) external returns (bool);
	function seize(address liquidator, address borrower, uint repayAmount) external returns (uint seizeTokens);
	function flashRedeem(address redeemer, uint redeemAmount, bytes calldata data) external;
	
	/*** Collateral Setter ***/
	
	event NewSafetyMargin(uint newSafetyMarginSqrt);
	event NewLiquidationIncentive(uint newLiquidationIncentive);

	function SAFETY_MARGIN_SQRT_MIN() external pure returns (uint);
	function SAFETY_MARGIN_SQRT_MAX() external pure returns (uint);
	function LIQUIDATION_INCENTIVE_MIN() external pure returns (uint);
	function LIQUIDATION_INCENTIVE_MAX() external pure returns (uint);
	
	function _initialize (
		string calldata _name, 
		string calldata _symbol,
		address _underlying, 
		address _borrowable0, 
		address _borrowable1
	) external;
	function _setSafetyMarginSqrt(uint newSafetyMarginSqrt) external;
	function _setLiquidationIncentive(uint newLiquidationIncentive) external;
}

// File: contracts\interfaces\IImpermaxCallee.sol

pragma solidity >=0.5.0;

interface IImpermaxCallee {
    function impermaxBorrow(address sender, address borrower, uint borrowAmount, bytes calldata data) external;
    function impermaxRedeem(address sender, uint redeemAmount, bytes calldata data) external;
}

// File: contracts\interfaces\IBorrowTracker.sol

pragma solidity >=0.5.0;

interface IBorrowTracker {
	function trackBorrow(address borrower, uint borrowBalance, uint borrowIndex) external;
}

// File: contracts\libraries\Math.sol

pragma solidity =0.5.16;

// a library for performing various math operations
// forked from: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/libraries/Math.sol

library Math {
    function min(uint x, uint y) internal pure returns (uint z) {
        z = x < y ? x : y;
    }

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
}

// File: contracts\Borrowable.sol

pragma solidity =0.5.16;













contract Borrowable is IBorrowable, PoolToken, BStorage, BSetter, BInterestRateModel, BAllowance {

	uint public constant BORROW_FEE = 0.001e18; //0.1%

	event Borrow(address indexed sender, address indexed borrower, address indexed receiver, uint borrowAmount, uint repayAmount, uint accountBorrowsPrior, uint accountBorrows, uint totalBorrows);
	event Liquidate(address indexed sender, address indexed borrower, address indexed liquidator, uint seizeTokens, uint repayAmount, uint accountBorrowsPrior, uint accountBorrows, uint totalBorrows);
		
	constructor() public {}

	/*** PoolToken ***/
	
	function _update() internal {
		super._update();
		_calculateBorrowRate();
	}
	
	function _mintReserves(uint _exchangeRate, uint _totalSupply) internal returns (uint) {
		uint _exchangeRateLast = exchangeRateLast;
		if (_exchangeRate > _exchangeRateLast) {
			uint _exchangeRateNew = _exchangeRate.sub( _exchangeRate.sub(_exchangeRateLast).mul(reserveFactor).div(1e18) );
			uint liquidity = _totalSupply.mul(_exchangeRate).div(_exchangeRateNew).sub(_totalSupply);
			if (liquidity == 0) return _exchangeRate;
			address reservesManager = IFactory(factory).reservesManager();
			_mint(reservesManager, liquidity);
			exchangeRateLast = _exchangeRateNew;
			return _exchangeRateNew;
		}
		else return _exchangeRate;
	}
	
	function exchangeRate() public accrue returns (uint)	{
		uint _totalSupply = totalSupply;
		uint _actualBalance = totalBalance.add(totalBorrows);
		if (_totalSupply == 0 || _actualBalance == 0) return initialExchangeRate;
		uint _exchangeRate = _actualBalance.mul(1e18).div(_totalSupply);
		return _mintReserves(_exchangeRate, _totalSupply);
	}
	
	// force totalBalance to match real balance
	function sync() external nonReentrant update accrue {}
	
	/*** Borrowable ***/

	// this is the stored borrow balance; the current borrow balance may be slightly higher
	function borrowBalance(address borrower) public view returns (uint) {
		BorrowSnapshot memory borrowSnapshot = borrowBalances[borrower];
		if (borrowSnapshot.interestIndex == 0) return 0; // not initialized
		return uint(borrowSnapshot.principal).mul(borrowIndex).div(borrowSnapshot.interestIndex);
	}
	
	function _trackBorrow(address borrower, uint accountBorrows, uint _borrowIndex) internal {
		address _borrowTracker = borrowTracker;
		if (_borrowTracker == address(0)) return;
		IBorrowTracker(_borrowTracker).trackBorrow(borrower, accountBorrows, _borrowIndex);
	}
	
	function _updateBorrow(address borrower, uint borrowAmount, uint repayAmount) private returns (uint accountBorrowsPrior, uint accountBorrows, uint _totalBorrows) {
		accountBorrowsPrior = borrowBalance(borrower);
		if (borrowAmount == repayAmount) return (accountBorrowsPrior, accountBorrowsPrior, totalBorrows);
		uint112 _borrowIndex = borrowIndex;
		if (borrowAmount > repayAmount) {
			BorrowSnapshot storage borrowSnapshot = borrowBalances[borrower];
			uint increaseAmount = borrowAmount - repayAmount;
			accountBorrows = accountBorrowsPrior.add(increaseAmount);
			borrowSnapshot.principal = safe112(accountBorrows);
			borrowSnapshot.interestIndex = _borrowIndex;
			_totalBorrows = uint(totalBorrows).add(increaseAmount);	
			totalBorrows = safe112(_totalBorrows);
		}
		else {
			BorrowSnapshot storage borrowSnapshot = borrowBalances[borrower];
			uint decreaseAmount = repayAmount - borrowAmount;		
			accountBorrows = accountBorrowsPrior > decreaseAmount ? accountBorrowsPrior - decreaseAmount : 0;
			borrowSnapshot.principal = safe112(accountBorrows);
			if(accountBorrows == 0) {
				borrowSnapshot.interestIndex = 0;
			} else {
				borrowSnapshot.interestIndex = _borrowIndex;
			}
			uint actualDecreaseAmount = accountBorrowsPrior.sub(accountBorrows);
			_totalBorrows = totalBorrows; // gas savings
			_totalBorrows = _totalBorrows > actualDecreaseAmount ? _totalBorrows - actualDecreaseAmount : 0;
			totalBorrows = safe112(_totalBorrows);			
		}
		_trackBorrow(borrower, accountBorrows, _borrowIndex);
	}
	
	// this low-level function should be called from another contract
	function borrow(address borrower, address receiver, uint borrowAmount, bytes calldata data) external nonReentrant update accrue {		
		uint _totalBalance = totalBalance;
		require(borrowAmount <= _totalBalance, "Impermax: INSUFFICIENT_CASH");
		_checkBorrowAllowance(borrower, msg.sender, borrowAmount);
		
		// optimistically transfer funds
		if (borrowAmount > 0) _safeTransfer(receiver, borrowAmount);
		if (data.length > 0) IImpermaxCallee(receiver).impermaxBorrow(msg.sender, borrower, borrowAmount, data);
		uint balance = IERC20(underlying).balanceOf(address(this));
		
		uint borrowFee = borrowAmount.mul(BORROW_FEE).div(1e18);
		uint adjustedBorrowAmount = borrowAmount.add(borrowFee);
		uint repayAmount = balance.add(borrowAmount).sub(_totalBalance);
		(uint accountBorrowsPrior, uint accountBorrows, uint _totalBorrows) = _updateBorrow(borrower, adjustedBorrowAmount, repayAmount);
		
		if(adjustedBorrowAmount > repayAmount) require(
			ICollateral(collateral).canBorrow(borrower, address(this), accountBorrows),
			"Impermax: INSUFFICIENT_LIQUIDITY"
		);
		
		emit Borrow(msg.sender, borrower, receiver, borrowAmount, repayAmount, accountBorrowsPrior, accountBorrows, _totalBorrows);
	}

	// this low-level function should be called from another contract
	function liquidate(address borrower, address liquidator) external nonReentrant update accrue returns (uint seizeTokens) {
		uint balance = IERC20(underlying).balanceOf(address(this));
		uint repayAmount = balance.sub(totalBalance);		
		
		uint actualRepayAmount = Math.min(borrowBalance(borrower), repayAmount);
		seizeTokens = ICollateral(collateral).seize(liquidator, borrower, actualRepayAmount);	
		(uint accountBorrowsPrior, uint accountBorrows, uint _totalBorrows) = _updateBorrow(borrower, 0, repayAmount);
		
		emit Liquidate(msg.sender, borrower, liquidator, seizeTokens, repayAmount, accountBorrowsPrior, accountBorrows, _totalBorrows);
	}
	
	function trackBorrow(address borrower) external {
		_trackBorrow(borrower, borrowBalance(borrower), borrowIndex);
	}
	
	modifier accrue() {
		accrueInterest();
		_;
	}
}

// File: contracts\interfaces\IBDeployer.sol

pragma solidity >=0.5.0;

interface IBDeployer {
	function deployBorrowable(address uniswapV2Pair, uint8 index) external returns (address borrowable);
}

// File: contracts\BDeployer.sol

pragma solidity =0.5.16;



/*
 * This contract is used by the Factory to deploy Borrowable(s)
 * The bytecode would be too long to fit in the Factory
 */

contract BDeployer is IBDeployer {
	constructor () public {}
	
	function deployBorrowable(address uniswapV2Pair, uint8 index) external returns (address borrowable) {
		bytes memory bytecode = type(Borrowable).creationCode;
		bytes32 salt = keccak256(abi.encodePacked(msg.sender, uniswapV2Pair, index));
		assembly {
			borrowable := create2(0, add(bytecode, 32), mload(bytecode), salt)
		}
	}
}

Contract ABI

[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[{"internalType":"address","name":"uniswapV2Pair","type":"address"},{"internalType":"uint8","name":"index","type":"uint8"}],"name":"deployBorrowable","outputs":[{"internalType":"address","name":"borrowable","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50614722806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806354bcd7ad14610030575b600080fd5b61006c6004803603604081101561004657600080fd5b50803573ffffffffffffffffffffffffffffffffffffffff16906020013560ff16610095565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60006060604051806020016100a990610174565b8181037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09081018352601f90910116604081815233606090811b6020808501919091529088901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016603484015260f887901b7fff00000000000000000000000000000000000000000000000000000000000000166048840152815180840360290181526049909301909152815191810191909120825192935091829184016000f595945050505050565b61456c806101828339019056fe60806040526002805460ff199081166012908117909255600b80549091166001179055600e80546001600160701b031916670de0b6b3a7640000176001600160e01b0316600160e01b4263ffffffff16908102919091179091556010805465ffffffffffff60301b191669bd014d800000000000001763ffffffff60601b19166c0100000000000000000000000090920291909117905567016345785d8a00006011556709b6e64a8ec6000090556486bd6db0206013553480156100c257600080fd5b5061449a806100d26000396000f3fe608060405234801561001057600080fd5b50600436106103995760003560e01c806370a08231116101e9578063b7f1118a1161010f578063c914b437116100ad578063e07660001161007c578063e076600014610b8b578063e12b630614610b93578063fca7820b14610b9b578063fff6cae914610bb857610399565b8063c914b43714610ae2578063d505accf14610aea578063d8dfeb4514610b48578063dd62ed3e14610b5057610399565b8063bc25cf77116100e9578063bc25cf7714610a97578063be340e3214610aca578063c45a015514610ad2578063c72f3fbb14610ada57610399565b8063b7f1118a14610a54578063b95b92a314610a87578063ba9a7a5614610a8f57610399565b806395a2251f11610187578063a6afed9511610156578063a6afed9514610a03578063a9059cbb14610a0b578063aa5af0fd14610a44578063ad7a672f14610a4c57610399565b806395a2251f1461096257806395d89b41146109955780639e79b55c1461099d578063a0715719146109fb57610399565b806386b9d81f116101c357806386b9d81f146108ae57806391b42745146108e9578063926d845b1461090c5780639292b0321461094557610399565b806370a0823114610827578063796b89b91461085a5780637ecebe001461087b57610399565b806335542822116102ce5780634d73e9ba1161026c5780636a030c111161023b5780636a030c11146106d15780636a627842146107b15780636bd76d24146107e45780636f307dc31461081f57610399565b80634d73e9ba1461065d57806355957220146106905780635b2b9d1a146106c157806368544065146106c957610399565b80634322b714116102a85780634322b7141461061a578063452ae95f1461062257806347bd37181461062a5780634a5d316c1461065557610399565b806335542822146105d75780633644e5151461060a5780633ba0b9a91461061257610399565b80632374e8a91161033b57806327549a0b1161031557806327549a0b1461058c5780632d5231d3146105a957806330adf81f146105b1578063313ce567146105b957610399565b80632374e8a91461053957806323b872dd14610541578063253c24f31461058457610399565b8063095ea7b311610377578063095ea7b31461043d57806318160ddd1461048a5780631aebf12f146104925780631e7dcc0d1461049a57610399565b806301f8c1c81461039e57806306fdde03146103b8578063075f4e7f14610435575b600080fd5b6103a6610bc0565b60408051918252519081900360200190f35b6103c0610be4565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103fa5781810151838201526020016103e2565b50505050905090810190601f1680156104275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103a6610c90565b6104766004803603604081101561045357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610c99565b604080519115158252519081900360200190f35b6103a6610cb0565b6103a6610cb6565b610537600480360360808110156104b057600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235811692602081013590911691604082013591908101906080810160608201356401000000008111156104f857600080fd5b82018360208201111561050a57600080fd5b8035906020019184600183028401116401000000008311171561052c57600080fd5b509092509050610cbc565b005b6103a661123c565b6104766004803603606081101561055757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135611248565b6103a661135c565b610537600480360360208110156105a257600080fd5b5035611366565b6103a661147b565b6103a6611481565b6105c16114a5565b6040805160ff9092168252519081900360200190f35b610537600480360360208110156105ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166114ae565b6103a66115f3565b6103a66115f9565b6103a6611692565b6103a6611698565b6106326116a1565b604080516dffffffffffffffffffffffffffff9092168252519081900360200190f35b6105376116c9565b6103a66004803603602081101561067357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661177a565b610698611830565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6103a661184c565b6103a6611851565b610537600480360360808110156106e757600080fd5b81019060208101813564010000000081111561070257600080fd5b82018360208201111561071457600080fd5b8035906020019184600183028401116401000000008311171561073657600080fd5b91939092909160208101903564010000000081111561075457600080fd5b82018360208201111561076657600080fd5b8035906020019184600183028401116401000000008311171561078857600080fd5b919350915073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661185d565b6103a6600480360360208110156107c757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166119de565b6103a6600480360360408110156107fa57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611c8c565b610698611ca9565b6103a66004803603602081101561083d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611cc5565b610862611cd7565b6040805163ffffffff9092168252519081900360200190f35b6103a66004803603602081101561089157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611ce1565b6103a6600480360360408110156108c457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611cf3565b6108f1611fe0565b6040805165ffffffffffff9092168252519081900360200190f35b6104766004803603604081101561092257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135611ff8565b6105376004803603602081101561095b57600080fd5b5035612005565b6103a66004803603602081101561097857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661211f565b6103c0612343565b610537600480360360e08110156109b357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c001356123bb565b6103a66123ff565b61053761240a565b61047660048036036040811015610a2157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135612649565b610632612656565b6103a661266c565b61053760048036036020811015610a6a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612672565b61086261269a565b6103a66126c6565b61053760048036036020811015610aad57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166126cc565b6103a661284f565b610698612855565b6103a6612871565b6108f161287d565b610537600480360360e0811015610b0057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c0013561288b565b6106986128c6565b6103a660048036036040811015610b6657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166128e7565b6103a6612904565b61086261290c565b61053760048036036020811015610bb157600080fd5b5035612928565b610537612a3b565b7ff6d86ed606f871fa1a557ac0ba607adce07767acf53f492fb215a1a4db4aea6f81565b6000805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f81018490048402820184019092528181529291830182828015610c885780601f10610c5d57610100808354040283529160200191610c88565b820191906000526020600020905b815481529060010190602001808311610c6b57829003601f168201915b505050505081565b640d7957c4d081565b6000610ca6338484612b11565b5060015b92915050565b60035481565b60125481565b600b5460ff16610d2d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055610d5d61240a565b600a5480841115610dcf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496d7065726d61783a20494e53554646494349454e545f434153480000000000604482015290519081900360640190fd5b610dda863386612b80565b8315610dea57610dea8585612c97565b8115610ec2576040517f876d9d9e000000000000000000000000000000000000000000000000000000008152336004820181815273ffffffffffffffffffffffffffffffffffffffff898116602485015260448401889052608060648501908152608485018790529089169363876d9d9e93928b928a928a928a92909160a401848480828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b158015610ea957600080fd5b505af1158015610ebd573d6000803e3d6000fd5b505050505b600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015610f3357600080fd5b505afa158015610f47573d6000803e3d6000fd5b505050506040513d6020811015610f5d57600080fd5b505190506000610f92670de0b6b3a7640000610f868866038d7ea4c6800063ffffffff612e9d16565b9063ffffffff612f1716565b90506000610fa6878363ffffffff612f5916565b90506000610fca85610fbe868b63ffffffff612f5916565b9063ffffffff612fcd16565b90506000806000610fdc8d868661300f565b9250925092508385111561115e57600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639aac2c538e30856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d60208110156110f157600080fd5b505161115e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f496d7065726d61783a20494e53554646494349454e545f4c4951554944495459604482015290519081900360640190fd5b8b73ffffffffffffffffffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f33f3048bd4e6af45e53afb722adfd57dbde82da7e93e44db921fb4b8c6a70c4b8e88888888604051808681526020018581526020018481526020018381526020018281526020019550505050505060405180910390a4505050505050505061120a61332b565b5050600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055505050565b6706f05b59d3b2000081565b73ffffffffffffffffffffffffffffffffffffffff831660009081526005602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461134757604080518082018252601e81527f496d7065726d61783a205452414e534645525f4e4f545f414c4c4f574544000060208083019190915273ffffffffffffffffffffffffffffffffffffffff8716600090815260058252838120338252909152919091205461131591849063ffffffff61333b16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526005602090815260408083203384529091529020555b6113528484846133ec565b5060019392505050565b6534a1fed8cc8081565b600b5460ff166113d757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905561141581640d7957c4d06534a1fed8cc80613505565b60138190556040805182815290517f1396dfcdb64fb7eb77fb84966f27b81afe14aa70b6e966c68d74af3302a9fe909181900360200190a150600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60135481565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60025460ff1681565b600b5460ff1661151f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905561154f6135f0565b6014805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f468b6598e7e810c65c9858b5f23a2d5b8692fb753b78a032232de4c6ed3cabbf9181900360200190a150600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60065481565b600061160361240a565b600354600e54600a5460009161163b91906e01000000000000000000000000000090046dffffffffffffffffffffffffffff16612f59565b9050811580611648575080155b1561165f57670de0b6b3a76400009250505061168f565b600061167d83610f8684670de0b6b3a764000063ffffffff612e9d16565b90506116898184613707565b93505050505b90565b60115481565b6449d482460081565b600e546e01000000000000000000000000000090046dffffffffffffffffffffffffffff1681565b60095473ffffffffffffffffffffffffffffffffffffffff161561174e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f496d7065726d61783a20464143544f52595f414c52454144595f534554000000604482015290519081900360640190fd5b600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055565b600061178461434d565b5073ffffffffffffffffffffffffffffffffffffffff82166000908152600d60209081526040918290208251808401909352546dffffffffffffffffffffffffffff80821684526e010000000000000000000000000000909104169082018190526117f357600091505061182b565b6020810151600e548251611827926dffffffffffffffffffffffffffff90811692610f86928216911663ffffffff612e9d16565b9150505b919050565b60145473ffffffffffffffffffffffffffffffffffffffff1681565b600581565b670dbd2fc137a3000081565b60095473ffffffffffffffffffffffffffffffffffffffff1633146118e357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496d7065726d61783a20554e415554484f52495a454400000000000000000000604482015290519081900360640190fd5b61195686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a01819004810282018101909252888152925088915087908190840183828082843760009201919091525061384292505050565b6008805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055600b805491909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff9091161790555050670de0b6b3a7640000600f555050565b600b5460009060ff16611a5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611aeb57600080fd5b505afa158015611aff573d6000803e3d6000fd5b505050506040513d6020811015611b1557600080fd5b5051600a54909150600090611b3190839063ffffffff612fcd16565b9050611b56611b3e6115f9565b610f8683670de0b6b3a764000063ffffffff612e9d16565b925060035460001415611b8457611b75836103e863ffffffff612fcd16565b9250611b8460006103e8613926565b60008311611bf357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f496d7065726d61783a204d494e545f414d4f554e545f5a45524f000000000000604482015290519081900360640190fd5b611bfd8484613926565b6040805182815260208101859052815173ffffffffffffffffffffffffffffffffffffffff87169233927f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee929081900390910190a35050611c5c61332b565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055919050565b600c60209081526000928352604080842090915290825290205481565b60085473ffffffffffffffffffffffffffffffffffffffff1681565b60046020526000908152604090205481565b63ffffffff421690565b60076020526000908152604090205481565b600b5460009060ff16611d6757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055611d9761240a565b600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611e0857600080fd5b505afa158015611e1c573d6000803e3d6000fd5b505050506040513d6020811015611e3257600080fd5b5051600a54909150600090611e4e90839063ffffffff612fcd16565b90506000611e64611e5e8761177a565b836139d7565b600b54604080517fb2a02ff100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89811660048301528a81166024830152604482018590529151939450610100909204169163b2a02ff1916064808201926020929091908290030181600087803b158015611eef57600080fd5b505af1158015611f03573d6000803e3d6000fd5b505050506040513d6020811015611f1957600080fd5b5051935060008080611f2c89828761300f565b604080518b8152602081018a905280820185905260608101849052608081018390529051939650919450925073ffffffffffffffffffffffffffffffffffffffff808b1692908c169133917fb0dbe18c6ffdf0da655dd690e77211d379205c497be44c64447c3f5f021b51679181900360a00190a4505050505050611faf61332b565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905592915050565b6010546601000000000000900465ffffffffffff1681565b6000610ca63384846139ed565b600b5460ff1661207657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556120b9816706f05b59d3b20000670dbd2fc137a30000613505565b60128190556040805182815290517f7a550b1995ff63260fb313f12024e66e73bad425372e5af6b1e04cb3799ef38c9181900360200190a150600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600b5460009060ff1661219357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055306000908152600460205260409020546121ef670de0b6b3a7640000610f866121e26115f9565b849063ffffffff612e9d16565b91506000821161226057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f496d7065726d61783a2052454445454d5f414d4f554e545f5a45524f00000000604482015290519081900360640190fd5b600a548211156122d157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496d7065726d61783a20494e53554646494349454e545f434153480000000000604482015290519081900360640190fd5b6122db3082613a5c565b6122e58383612c97565b6040805183815260208101839052815173ffffffffffffffffffffffffffffffffffffffff86169233927f3f693fff038bb8a046aa76d9516190ac7444f7d69cf952c4cbdc086fdef2d6fc929081900390910190a350611c5c61332b565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f81018490048402820184019092528181529291830182828015610c885780601f10610c5d57610100808354040283529160200191610c88565b6123eb878787878787877ff6d86ed606f871fa1a557ac0ba607adce07767acf53f492fb215a1a4db4aea6f613b20565b6123f68787876139ed565b50505050505050565b66038d7ea4c6800081565b600e546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000008104909116907c0100000000000000000000000000000000000000000000000000000000900463ffffffff166000612466611cd7565b90508063ffffffff168263ffffffff1614156124855750505050612647565b600e805463ffffffff8084167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117909155601054838303916000916124fa9165ffffffffffff9091169080851690612e9d16565b9050600061251a670de0b6b3a7640000610f86848963ffffffff612e9d16565b905061252c868263ffffffff612f5916565b955061255a61254d670de0b6b3a7640000610f86858b63ffffffff612e9d16565b889063ffffffff612f5916565b965061256587613dc3565b600e80547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff929092169190911790556125ad86613dc3565b600e80546dffffffffffffffffffffffffffff929092166e010000000000000000000000000000027fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff909216919091179055604080518281526020810189905280820188905290517f875352fb3fadeb8c0be7cbbe8ff761b308fa7033470cd0287f02f3436fd76cb99181900360600190a1505050505050505b565b6000610ca63384846133ec565b600e546dffffffffffffffffffffffffffff1681565b600a5481565b6126978161267f8361177a565b600e546dffffffffffffffffffffffffffff16613e46565b50565b600e547c0100000000000000000000000000000000000000000000000000000000900463ffffffff1681565b6103e881565b600b5460ff1661273d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055600a54600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905161282193859361281c93919273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b1580156127e457600080fd5b505afa1580156127f8573d6000803e3d6000fd5b505050506040513d602081101561280e57600080fd5b50519063ffffffff612fcd16565b612c97565b50600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600f5481565b60095473ffffffffffffffffffffffffffffffffffffffff1681565b6702c68af0bb14000081565b60105465ffffffffffff1681565b6128bb878787878787877f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9613b20565b6123f6878787612b11565b600b54610100900473ffffffffffffffffffffffffffffffffffffffff1681565b600560209081526000928352604080842090915290825290205481565b6312e687c081565b6010546c01000000000000000000000000900463ffffffff1681565b600b5460ff1661299957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556129d58160006702c68af0bb140000613505565b60118190556040805182815290517f9d9cd27245b4e6b06dcf523ac57b6e851b934e199eee376313f906e94bfbfd559181900360200190a150600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600b5460ff16612aac57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496d7065726d61783a205245454e544552454400000000000000000000000000604482015290519081900360640190fd5b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055612adc61240a565b612ae461332b565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8084166000818152600c60209081526040808320948716808452949091529020549114801590612be557507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114155b15612c915781811015612c5957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f496d7065726d61783a20424f52524f575f4e4f545f414c4c4f57454400000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600c6020908152604080832093871683529290522082820390555b50505050565b600854604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff86811660248301526044808301879052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009560609594169382918083835b60208310612d9d57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612d60565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612dff576040519150601f19603f3d011682016040523d82523d6000602084013e612e04565b606091505b5091509150818015612e32575080511580612e325750808060200190516020811015612e2f57600080fd5b50515b612c9157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496d7065726d61783a205452414e534645525f4641494c454400000000000000604482015290519081900360640190fd5b600082612eac57506000610caa565b82820282848281612eb957fe5b0414612f10576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806144456021913960400191505060405180910390fd5b9392505050565b6000612f1083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613f07565b600082820183811015612f1057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000612f1083836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f770081525061333b565b600080600061301d8661177a565b925083851415613055575050600e5481906e01000000000000000000000000000090046dffffffffffffffffffffffffffff16613322565b600e546dffffffffffffffffffffffffffff168486111561317d5773ffffffffffffffffffffffffffffffffffffffff87166000908152600d602052604090208587036130a8868263ffffffff612f5916565b94506130b385613dc3565b82547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff918216177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008583168102919091178455600e54613138929190041682612f59565b935061314384613dc3565b600e806101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff1602179055505050613305565b73ffffffffffffffffffffffffffffffffffffffff87166000908152600d602052604090208686038086116131b35760006131b7565b8086035b94506131c285613dc3565b82547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff919091161782558461322c5781547fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff168255613276565b81547fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000006dffffffffffffffffffffffffffff8516021782555b6000613288878763ffffffff612fcd16565b600e546e01000000000000000000000000000090046dffffffffffffffffffffffffffff16955090508085116132bf5760006132c3565b8085035b94506132ce85613dc3565b600e806101000a8154816dffffffffffffffffffffffffffff02191690836dffffffffffffffffffffffffffff1602179055505050505b6133208784836dffffffffffffffffffffffffffff16613e46565b505b93509350939050565b613333613f86565b61264761405c565b600081848411156133e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156133a9578181015183820152602001613391565b50505050905090810190601f1680156133d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b604080518082018252601b81527f496d7065726d61783a205452414e534645525f544f4f5f48494748000000000060208083019190915273ffffffffffffffffffffffffffffffffffffffff861660009081526004909152919091205461345a91839063ffffffff61333b16565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260046020526040808220939093559084168152205461349c908263ffffffff612f5916565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526004602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b61350d6135f0565b8183101561357c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496d7065726d61783a20494e56414c49445f53455454494e4700000000000000604482015290519081900360640190fd5b808311156135eb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496d7065726d61783a20494e56414c49445f53455454494e4700000000000000604482015290519081900360640190fd5b505050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f851a4406040518163ffffffff1660e01b815260040160206040518083038186803b15801561365857600080fd5b505afa15801561366c573d6000803e3d6000fd5b505050506040513d602081101561368257600080fd5b505173ffffffffffffffffffffffffffffffffffffffff16331461264757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496d7065726d61783a20554e415554484f52495a454400000000000000000000604482015290519081900360640190fd5b600f546000908084111561383957600061375861374b670de0b6b3a7640000610f8660115461373f878b612fcd90919063ffffffff16565b9063ffffffff612e9d16565b869063ffffffff612fcd16565b9050600061377485610fbe84610f86838b63ffffffff612e9d16565b90508061378657859350505050610caa565b600954604080517f345ef941000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163345ef941916004808301926020929190829003018186803b1580156137f157600080fd5b505afa158015613805573d6000803e3d6000fd5b505050506040513d602081101561381b57600080fd5b505190506138298183613926565b5050600f8190559150610caa9050565b83915050610caa565b8151613855906000906020850190614364565b508051613869906001906020840190614364565b5060405146908060526143f382396040805191829003605201822086516020978801208383018352600184527f310000000000000000000000000000000000000000000000000000000000000093880193909352815180880191909152808201929092527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606083015260808201939093523060a0808301919091528351808303909101815260c090910190925250805192019190912060065550565b600354613939908263ffffffff612f5916565b60035573ffffffffffffffffffffffffffffffffffffffff8216600090815260046020526040902054613972908263ffffffff612f5916565b73ffffffffffffffffffffffffffffffffffffffff831660008181526004602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b60008183106139e65781612f10565b5090919050565b73ffffffffffffffffffffffffffffffffffffffff8084166000818152600c6020908152604080832094871680845294825291829020859055815185815291517fc3c1215b41d54142382d54a05fb991007165ae91bcb1879bac8b290d9111aaf49281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260046020526040902054613a92908263ffffffff612fcd16565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260046020526040902055600354613acb908263ffffffff612fcd16565b60035560408051828152905160009173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b42851015613b8f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496d7065726d61783a2045585049524544000000000000000000000000000000604482015290519081900360640190fd5b60065473ffffffffffffffffffffffffffffffffffffffff808a1660008181526007602090815260408083208054600180820190925582518085018a905280840196909652958e166060860152608085018d905260a085019590955260c08085018c90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff8a166101828501526101a284018990526101c28401889052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015613cd1573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590613d4c57508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b613db757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496d7065726d61783a20494e56414c49445f5349474e41545552450000000000604482015290519081900360640190fd5b50505050505050505050565b60006e0100000000000000000000000000008210613e4257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496d7065726d61783a2053414645313132000000000000000000000000000000604482015290519081900360640190fd5b5090565b60145473ffffffffffffffffffffffffffffffffffffffff1680613e6a57506135eb565b604080517f05285d7f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015260248201869052604482018590529151918316916305285d7f9160648082019260009290919082900301818387803b158015613ee957600080fd5b505af1158015613efd573d6000803e3d6000fd5b5050505050505050565b60008183613f70576040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528351602484015283519092839260449091019190850190808383600083156133a9578181015183820152602001613391565b506000838581613f7c57fe5b0495945050505050565b600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015613ff757600080fd5b505afa15801561400b573d6000803e3d6000fd5b505050506040513d602081101561402157600080fd5b5051600a81905560408051918252517f8a0df8ef054fae2c3d2d19a7b322e864870cc9fd3cb07fb9526309c596244bf49181900360200190a1565b60125460135460105465ffffffffffff8082169166010000000000008104909116906c01000000000000000000000000900463ffffffff1660008161409f611cd7565b03905063ffffffff81161561422a576140b6611cd7565b6010600c6101000a81548163ffffffff021916908363ffffffff16021790555060008385101561413f576000670de0b6b3a76400008363ffffffff168887898903670de0b6b3a7640000028161410857fe5b0402028161411257fe5b049050670de0b6b3a764000081116141345780670de0b6b3a764000003614137565b60005b915050614180565b6000670de0b6b3a76400008363ffffffff168887888a03670de0b6b3a7640000028161416757fe5b0402028161417157fe5b04670de0b6b3a7640000019150505b670de0b6b3a76400008482020493506449d48246008411156141a5576449d482460093505b6312e687c08410156141b9576312e687c093505b601080547fffffffffffffffffffffffffffffffffffffffff000000000000ffffffffffff16660100000000000065ffffffffffff8716021790556040805185815290517f713a98ffb7d769b8e33e2ee945ebb6acb7f397532688164d3ce1081f903c77bc916020908290030190a1505b600e54600a546000916e01000000000000000000000000000090046dffffffffffffffffffffffffffff169082906142629083612f59565b90508015614283578082670de0b6b3a7640000028161427d57fe5b04614286565b60005b925050508681116142a457868185028161429c57fe5b0494506142de565b600087670de0b6b3a764000003888303670de0b6b3a764000002816142c557fe5b049050670de0b6b3a76400006004820281018602049550505b601080547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff87161790556040805186815290517f338541dc9083f6af6715482fb419e1483c1ae9097764fd68a5dc98109bd5a788916020908290030190a150505050505050565b604080518082019091526000808252602082015290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106143a557805160ff19168380011785556143d2565b828001600101855582156143d2579182015b828111156143d25782518255916020019190600101906143b7565b50613e429261168f9250905b80821115613e4257600081556001016143de56fe454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a72315820f11329f32e70b5a85ee62cd531914f65f993dcde86d7d2233ddf4c861bab315464736f6c63430005100032a265627a7a7231582043796eb9ce07516736d28322e0b387add4a46a13365857112d38afc435851d9764736f6c63430005100032

Deployed ByteCode Sourcemap

44724:404:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;44724:404:0;;;;;;;;;;;;;;;;;;;44791:334;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;44791:334:0;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;44871:18;44896:21;44920:29;;;;;;;;:::i;:::-;21:26:-1;;;;;;;7:41;;87:2;69:12;;;65:26;61:2;54:38;;;44996:10:0;44979:50;;;;41:4:-1;44979:50:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;6:49;;44979:50:0;;;;;;;44969:61;;;;;;;;;45094:15;;21:26:-1;;-1:-1;44969:61:0;;;30:16:-1;;-1:-1;45064:52:0;45050:66;45044:77;-1:-1:-1;;;;;45044:77:0:o;44724:404::-;;;;;;;;:::o

Metadata Hash

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