Contract 0x68765cba5b4269d22036b33e5da65a68f719da7a

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x3cdba7de8f343df654713a49d3f40b438b82bfc3294a0d9eb2e6d65a9342b3f50x60806040297228232022-06-18 17:28:5752 days 18 hrs ago0xc36142c497053c42bdaa14737bf80e71daa984c5 IN  Create: ConnectV2AaveV3Polygon0 MATIC0.121339150
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ConnectV2AaveV3Polygon

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 9 : main.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

/**
 * @title Aave v3.
 * @dev Lending & Borrowing.
 */

import { TokenInterface } from "../../../common/interfaces.sol";
import { Stores } from "../../../common/stores.sol";
import { Helpers } from "./helpers.sol";
import { Events } from "./events.sol";
import { AaveInterface, DTokenInterface } from "./interface.sol";

abstract contract AaveResolver is Events, Helpers {
	/**
	 * @dev Deposit Matic/ERC20_Token.
	 * @notice Deposit a token to Aave v3 for lending / collaterization.
	 * @param token The address of the token to deposit.(For Matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens deposited.
	 */
	function deposit(
		address token,
		uint256 amt,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		if (isMatic) {
			_amt = _amt == uint256(-1) ? address(this).balance : _amt;
			convertMaticToWmatic(isMatic, tokenContract, _amt);
		} else {
			_amt = _amt == uint256(-1)
				? tokenContract.balanceOf(address(this))
				: _amt;
		}

		approve(tokenContract, address(aave), _amt);

		aave.supply(_token, _amt, address(this), referralCode);

		if (!getIsColl(_token)) {
			aave.setUserUseReserveAsCollateral(_token, true);
		}

		setUint(setId, _amt);

		_eventName = "LogDeposit(address,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, getId, setId);
	}

	/**
	 ** @dev Deposit Matic/ERC20_Token without collateral
	 * @notice Deposit a token to Aave v3 without enabling it as collateral.
	 * @param token The address of the token to deposit.(For Matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens deposited.
	 */
	function depositWithoutCollateral(
		address token,
		uint256 amt,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		if (isMatic) {
			_amt = _amt == uint256(-1) ? address(this).balance : _amt;
			convertMaticToWmatic(isMatic, tokenContract, _amt);
		} else {
			_amt = _amt == uint256(-1)
				? tokenContract.balanceOf(address(this))
				: _amt;
		}

		approve(tokenContract, address(aave), _amt);

		aave.supply(_token, _amt, address(this), referralCode);

		if (getCollateralBalance(_token) > 0 && getIsColl(_token)) {
			aave.setUserUseReserveAsCollateral(_token, false);
		}

		setUint(setId, _amt);

		_eventName = "LogDepositWithoutCollateral(address,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, getId, setId);
	}

	/**
	 * @dev Withdraw matic/ERC20_Token.
	 * @notice Withdraw deposited token from Aave v3
	 * @param token The address of the token to withdraw.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to withdraw. (For max: `uint256(-1)`)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens withdrawn.
	 */
	function withdraw(
		address token,
		uint256 amt,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());
		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		uint256 initialBal = tokenContract.balanceOf(address(this));
		aave.withdraw(_token, _amt, address(this));
		uint256 finalBal = tokenContract.balanceOf(address(this));

		_amt = sub(finalBal, initialBal);

		convertWmaticToMatic(isMatic, tokenContract, _amt);

		setUint(setId, _amt);

		_eventName = "LogWithdraw(address,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, getId, setId);
	}

	/**
	 * @dev Borrow matic/ERC20_Token.
	 * @notice Borrow a token using Aave v3
	 * @param token The address of the token to borrow.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to borrow.
	 * @param rateMode The type of borrow debt. (For Stable: 1, Variable: 2)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens borrowed.
	 */
	function borrow(
		address token,
		uint256 amt,
		uint256 rateMode,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		aave.borrow(_token, _amt, rateMode, referralCode, address(this));
		convertWmaticToMatic(isMatic, TokenInterface(_token), _amt);

		setUint(setId, _amt);

		_eventName = "LogBorrow(address,uint256,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
	}

	/**
	 * @dev Borrow matic/ERC20_Token on behalf of a user.
	 * @notice Borrow a token using Aave v3 on behalf of a user
	 * @param token The address of the token to borrow.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to borrow.
	 * @param rateMode The type of borrow debt. (For Stable: 1, Variable: 2)
	 * @param onBehalfOf The user who will incur the debt
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens borrowed.
	 */
	function borrowOnBehalfOf(
		address token,
		uint256 amt,
		uint256 rateMode,
		address onBehalfOf,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		aave.borrow(_token, _amt, rateMode, referralCode, onBehalfOf);
		convertWmaticToMatic(isMatic, TokenInterface(_token), _amt);

		setUint(setId, _amt);

		_eventName = "LogBorrowOnBehalfOf(address,uint256,uint256,address,uint256,uint256)";
		_eventParam = abi.encode(
			token,
			_amt,
			rateMode,
			onBehalfOf,
			getId,
			setId
		);
	}

	/**
	 * @dev Payback borrowed matic/ERC20_Token.
	 * @notice Payback debt owed.
	 * @param token The address of the token to payback.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to payback. (For max: `uint256(-1)`)
	 * @param rateMode The type of debt paying back. (For Stable: 1, Variable: 2)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens paid back.
	 */
	function payback(
		address token,
		uint256 amt,
		uint256 rateMode,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		_amt = _amt == uint256(-1) ? getPaybackBalance(_token, rateMode) : _amt;

		if (isMatic) convertMaticToWmatic(isMatic, tokenContract, _amt);

		approve(tokenContract, address(aave), _amt);

		aave.repay(_token, _amt, rateMode, address(this));

		setUint(setId, _amt);

		_eventName = "LogPayback(address,uint256,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
	}

	/**
	 * @dev Payback borrowed matic/ERC20_Token using aTokens.
	 * @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the equivalent debt tokens.
	 * @param token The address of the token to payback.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to payback. (For max: `uint256(-1)`)
	 * @param rateMode The type of debt paying back. (For Stable: 1, Variable: 2)
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens paid back.
	 */
	function paybackWithATokens(
		address token,
		uint256 amt,
		uint256 rateMode,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		_amt = _amt == uint256(-1) ? getPaybackBalance(_token, rateMode) : _amt;

		if (isMatic) convertMaticToWmatic(isMatic, tokenContract, _amt);

		approve(tokenContract, address(aave), _amt);

		aave.repayWithATokens(_token, _amt, rateMode);

		setUint(setId, _amt);

		_eventName = "LogPayback(address,uint256,uint256,uint256,uint256)";
		_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
	}

	/**
	 * @dev Payback borrowed matic/ERC20_Token on behalf of a user.
	 * @notice Payback debt owed on behalf os a user.
	 * @param token The address of the token to payback.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param amt The amount of the token to payback. (For max: `uint256(-1)`)
	 * @param rateMode The type of debt paying back. (For Stable: 1, Variable: 2)
	 * @param onBehalfOf Address of user who's debt to repay.
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens paid back.
	 */
	function paybackOnBehalfOf(
		address token,
		uint256 amt,
		uint256 rateMode,
		address onBehalfOf,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _amt = getUint(getId, amt);

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		TokenInterface tokenContract = TokenInterface(_token);

		_amt = _amt == uint256(-1)
			? getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf)
			: _amt;

		if (isMatic) convertMaticToWmatic(isMatic, tokenContract, _amt);

		approve(tokenContract, address(aave), _amt);

		aave.repay(_token, _amt, rateMode, onBehalfOf);

		setUint(setId, _amt);

		_eventName = "LogPaybackOnBehalfOf(address,uint256,uint256,address,uint256,uint256)";
		_eventParam = abi.encode(
			token,
			_amt,
			rateMode,
			onBehalfOf,
			getId,
			setId
		);
	}

	/**
	 * @dev Enable collateral
	 * @notice Enable an array of tokens as collateral
	 * @param tokens Array of tokens to enable collateral
	 */
	function enableCollateral(address[] calldata tokens)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _length = tokens.length;
		require(_length > 0, "0-tokens-not-allowed");

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		for (uint256 i = 0; i < _length; i++) {
			bool isMatic = tokens[i] == maticAddr;
			address _token = isMatic ? wmaticAddr : tokens[i];

			if (getCollateralBalance(_token) > 0 && !getIsColl(_token)) {
				aave.setUserUseReserveAsCollateral(_token, true);
			}
		}

		_eventName = "LogEnableCollateral(address[])";
		_eventParam = abi.encode(tokens);
	}

	/**
	 * @dev Disable collateral
	 * @notice Disable an array of tokens as collateral
	 * @param tokens Array of tokens to disable as collateral
	 */
	function disableCollateral(address[] calldata tokens)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		uint256 _length = tokens.length;
		require(_length > 0, "0-tokens-not-allowed");

		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		for (uint256 i = 0; i < _length; i++) {
			bool isMatic = tokens[i] == maticAddr;
			address _token = isMatic ? wmaticAddr : tokens[i];

			if (getCollateralBalance(_token) > 0 && getIsColl(_token)) {
				aave.setUserUseReserveAsCollateral(_token, false);
			}
		}

		_eventName = "LogDisableCollateral(address[])";
		_eventParam = abi.encode(tokens);
	}

	/**
	 * @dev Swap borrow rate mode
	 * @notice Swaps user borrow rate mode between variable and stable
	 * @param token The address of the token to swap borrow rate.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param rateMode Current borrow rate s(Stable = 1, Variable = 2)
	 */
	function swapBorrowRateMode(address token, uint256 rateMode)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		if (getPaybackBalance(_token, rateMode) > 0) {
			aave.swapBorrowRateMode(_token, rateMode);
		}

		_eventName = "LogSwapRateMode(address,uint256)";
		_eventParam = abi.encode(token, rateMode);
	}

	/**
	 * @dev Set user e-mode
	 * @notice Updates the user's e-mode category
	 * @param categoryId The category Id of the e-mode user want to set
	 */
	function setUserEMode(uint8 categoryId)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		AaveInterface aave = AaveInterface(aaveProvider.getPool());

		aave.setUserEMode(categoryId);

		_eventName = "LogSetUserEMode(uint8)";
		_eventParam = abi.encode(categoryId);
	}

	/**
	 * @dev Approve Delegation
	 * @notice Gives approval to delegate debt tokens
	 * @param token The address of token
	 * @param amount The amount
	 * @param rateMode The type of borrow debt
	 * @param delegateTo The address to whom the user is delegating
	 * @param getId ID to retrieve amt.
	 * @param setId ID stores the amount of tokens deposited.
	 */
	function delegateBorrow(
		address token,
		uint256 amount,
		uint256 rateMode,
		address delegateTo,
		uint256 getId,
		uint256 setId
	)
		external
		payable
		returns (string memory _eventName, bytes memory _eventParam)
	{
		require(rateMode == 1 || rateMode == 2, "Invalid debt type");
		uint256 _amt = getUint(getId, amount);

		bool isMatic = token == maticAddr;
		address _token = isMatic ? wmaticAddr : token;

		address _dToken = getDTokenAddr(_token, rateMode);
		DTokenInterface(_dToken).approveDelegation(delegateTo, _amt);

		setUint(setId, _amt);

		_eventName = "LogDelegateBorrow(address,uint256,uint256,address,uint256,uint256)";
		_eventParam = abi.encode(
			token,
			_amt,
			rateMode,
			delegateTo,
			getId,
			setId
		);
	}
}

contract ConnectV2AaveV3Polygon is AaveResolver {
	string public constant name = "AaveV3-v1.2";
}

File 2 of 9 : interfaces.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma abicoder v2;

interface TokenInterface {
    function approve(address, uint256) external;
    function transfer(address, uint) external;
    function transferFrom(address, address, uint) external;
    function deposit() external payable;
    function withdraw(uint) external;
    function balanceOf(address) external view returns (uint);
    function decimals() external view returns (uint);
}

interface MemoryInterface {
    function getUint(uint id) external returns (uint num);
    function setUint(uint id, uint val) external;
}

interface InstaMapping {
    function cTokenMapping(address) external view returns (address);
    function gemJoinMapping(bytes32) external view returns (address);
}

interface AccountInterface {
    function enable(address) external;
    function disable(address) external;
    function isAuth(address) external view returns (bool);
}

interface InstaConnectors {
    function isConnectors(string[] calldata) external returns (bool, address[] memory);
}

File 3 of 9 : stores.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import { MemoryInterface, InstaMapping } from "./interfaces.sol";


abstract contract Stores {

  /**
   * @dev Return ethereum address
   */
  address constant internal maticAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  /**
   * @dev Return Wrapped ETH address
   */
  address constant internal wmaticAddr = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270;

  /**
   * @dev Return memory variable address
   */
  MemoryInterface constant internal instaMemory = MemoryInterface(0x6C7256cf7C003dD85683339F75DdE9971f98f2FD);

  /**
   * @dev Get Uint value from InstaMemory Contract.
   */
  function getUint(uint getId, uint val) internal returns (uint returnVal) {
    returnVal = getId == 0 ? val : instaMemory.getUint(getId);
  }

  /**
  * @dev Set Uint value in InstaMemory Contract.
  */
  function setUint(uint setId, uint val) virtual internal {
    if (setId != 0) instaMemory.setUint(setId, val);
  }

}

File 4 of 9 : helpers.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import { DSMath } from "../../../common/math.sol";
import { Basic } from "../../../common/basic.sol";
import { AavePoolProviderInterface, AaveDataProviderInterface } from "./interface.sol";

abstract contract Helpers is DSMath, Basic {
	/**
	 * @dev Aave Pool Provider
	 */
	AavePoolProviderInterface internal constant aaveProvider =
		AavePoolProviderInterface(0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb); // Polygon address - PoolAddressesProvider

	/**
	 * @dev Aave Pool Data Provider
	 */
	AaveDataProviderInterface internal constant aaveData =
		AaveDataProviderInterface(0x69FA688f1Dc47d4B5d8029D5a35FB7a548310654); // Polygon address - PoolDataProvider

	/**
	 * @dev Aave Referral Code
	 */
	uint16 internal constant referralCode = 3228;

	/**
	 * @dev Checks if collateral is enabled for an asset
	 * @param token token address of the asset.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 */

	function getIsColl(address token) internal view returns (bool isCol) {
		(, , , , , , , , isCol) = aaveData.getUserReserveData(
			token,
			address(this)
		);
	}

	/**
	 * @dev Get total debt balance & fee for an asset
	 * @param token token address of the debt.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param rateMode Borrow rate mode (Stable = 1, Variable = 2)
	 */
	function getPaybackBalance(address token, uint256 rateMode)
		internal
		view
		returns (uint256)
	{
		(, uint256 stableDebt, uint256 variableDebt, , , , , , ) = aaveData
			.getUserReserveData(token, address(this));
		return rateMode == 1 ? stableDebt : variableDebt;
	}

	/**
	 * @dev Get OnBehalfOf user's total debt balance & fee for an asset
	 * @param token token address of the debt.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 * @param rateMode Borrow rate mode (Stable = 1, Variable = 2)
	 */
	function getOnBehalfOfPaybackBalance(address token, uint256 rateMode, address onBehalfOf)
		internal
		view
		returns (uint256)
	{
		(, uint256 stableDebt, uint256 variableDebt, , , , , , ) = aaveData
			.getUserReserveData(token, onBehalfOf);
		return rateMode == 1 ? stableDebt : variableDebt;
	}

	/**
	 * @dev Get total collateral balance for an asset
	 * @param token token address of the collateral.(For matic: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
	 */
	function getCollateralBalance(address token)
		internal
		view
		returns (uint256 bal)
	{
		(bal, , , , , , , , ) = aaveData.getUserReserveData(
			token,
			address(this)
		);
	}

	/**
	 * @dev Get debt token address for an asset
	 * @param token token address of the asset
	 * @param rateMode Debt type: stable-1, variable-2
	 */
	function getDTokenAddr(address token, uint256 rateMode)
		internal
		view
		returns(address dToken)
	{
		if (rateMode == 1) {
			(, dToken, ) = aaveData.getReserveTokensAddresses(token);
		} else {
			(, , dToken) = aaveData.getReserveTokensAddresses(token);
		}
	}
}

File 5 of 9 : events.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

contract Events {
	event LogDeposit(
		address indexed token,
		uint256 tokenAmt,
		uint256 getId,
		uint256 setId
	);
	event LogWithdraw(
		address indexed token,
		uint256 tokenAmt,
		uint256 getId,
		uint256 setId
	);
	event LogBorrow(
		address indexed token,
		uint256 tokenAmt,
		uint256 indexed rateMode,
		uint256 getId,
		uint256 setId
	);
	event LogPayback(
		address indexed token,
		uint256 tokenAmt,
		uint256 indexed rateMode,
		uint256 getId,
		uint256 setId
	);
	event LogEnableCollateral(address[] tokens);
	event LogDisableCollateral(address[] tokens);
	event LogSwapRateMode(address indexed token, uint256 rateMode);
	event LogSetUserEMode(uint8 categoryId);
	event LogDelegateBorrow(
		address token,
		uint256 amount,
		uint256 rateMode,
		address delegateTo,
		uint256 getId,
		uint256 setId
	);
	event LogDepositWithoutCollateral(
		address token,
		uint256 amt,
		uint256 getId,
		uint256 setId
	);
	event LogBorrowOnBehalfOf(
		address token,
		uint256 amt,
		uint256 rateMode,
		address onBehalfOf,
		uint256 getId,
		uint256 setId
	);
	event LogPaybackOnBehalfOf(
		address token,
		uint256 amt,
		uint256 rateMode,
		address onBehalfOf,
		uint256 getId,
		uint256 setId
	);
}

File 6 of 9 : interface.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

interface AaveInterface {
	function supply(
		address asset,
		uint256 amount,
		address onBehalfOf,
		uint16 referralCode
	) external;

	function withdraw(
		address asset,
		uint256 amount,
		address to
	) external returns (uint256);

	function borrow(
		address asset,
		uint256 amount,
		uint256 interestRateMode,
		uint16 referralCode,
		address onBehalfOf
	) external;

	function repay(
		address asset,
		uint256 amount,
		uint256 interestRateMode,
		address onBehalfOf
	) external returns (uint256);

	function repayWithATokens(
		address asset,
		uint256 amount,
		uint256 interestRateMode
	) external returns (uint256);

	function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
		external;

	function swapBorrowRateMode(address asset, uint256 interestRateMode)
		external;

	function setUserEMode(uint8 categoryId) external;
}

interface AavePoolProviderInterface {
	function getPool() external view returns (address);
}

interface AaveDataProviderInterface {
	function getReserveTokensAddresses(address _asset)
		external
		view
		returns (
			address aTokenAddress,
			address stableDebtTokenAddress,
			address variableDebtTokenAddress
		);

	function getUserReserveData(address _asset, address _user)
		external
		view
		returns (
			uint256 currentATokenBalance,
			uint256 currentStableDebt,
			uint256 currentVariableDebt,
			uint256 principalStableDebt,
			uint256 scaledVariableDebt,
			uint256 stableBorrowRate,
			uint256 liquidityRate,
			uint40 stableRateLastUpdated,
			bool usageAsCollateralEnabled
		);

	function getReserveEModeCategory(address asset)
		external
		view
		returns (uint256);
}

interface AaveAddressProviderRegistryInterface {
	function getAddressesProvidersList()
		external
		view
		returns (address[] memory);
}

interface ATokenInterface {
	function balanceOf(address _user) external view returns (uint256);
}

interface DTokenInterface {
	function approveDelegation(address delegatee, uint256 amount) external;
}

File 7 of 9 : math.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";

contract DSMath {
  uint constant WAD = 10 ** 18;
  uint constant RAY = 10 ** 27;

  function add(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(x, y);
  }

  function sub(uint x, uint y) internal virtual pure returns (uint z) {
    z = SafeMath.sub(x, y);
  }

  function mul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.mul(x, y);
  }

  function div(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.div(x, y);
  }

  function wmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD;
  }

  function wdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y;
  }

  function rdiv(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y;
  }

  function rmul(uint x, uint y) internal pure returns (uint z) {
    z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY;
  }

  function toInt(uint x) internal pure returns (int y) {
    y = int(x);
    require(y >= 0, "int-overflow");
  }

  function toRad(uint wad) internal pure returns (uint rad) {
    rad = mul(wad, 10 ** 27);
  }

}

File 8 of 9 : basic.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import { TokenInterface } from "./interfaces.sol";
import { Stores } from "./stores.sol";
import { DSMath } from "./math.sol";

abstract contract Basic is DSMath, Stores {

    function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = (_amt / 10 ** (18 - _dec));
    }

    function convertTo18(uint _dec, uint256 _amt) internal pure returns (uint256 amt) {
        amt = mul(_amt, 10 ** (18 - _dec));
    }

    function getTokenBal(TokenInterface token) internal view returns(uint _amt) {
        _amt = address(token) == maticAddr ? address(this).balance : token.balanceOf(address(this));
    }

    function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {
        buyDec = address(buyAddr) == maticAddr ?  18 : buyAddr.decimals();
        sellDec = address(sellAddr) == maticAddr ?  18 : sellAddr.decimals();
    }

    function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) {
        return abi.encode(eventName, eventParam);
    }

    function changeMaticAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){
        _buy = buy == maticAddr ? TokenInterface(wmaticAddr) : TokenInterface(buy);
        _sell = sell == maticAddr ? TokenInterface(wmaticAddr) : TokenInterface(sell);
    }

    function approve(TokenInterface token, address spender, uint256 amount) internal {
        try token.approve(spender, amount) {

        } catch {
            token.approve(spender, 0);
            token.approve(spender, amount);
        }
    }

    function convertMaticToWmatic(bool isMatic, TokenInterface token, uint amount) internal {
        if(isMatic) token.deposit{value: amount}();
    }

    function convertWmaticToMatic(bool isMatic, TokenInterface token, uint amount) internal {
        if(isMatic) {
            approve(token, address(token), amount);
            token.withdraw(amount);
        }
    }
}

File 9 of 9 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @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) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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;
    }
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"rateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rateMode","type":"uint256"},{"indexed":false,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogBorrowOnBehalfOf","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rateMode","type":"uint256"},{"indexed":false,"internalType":"address","name":"delegateTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogDelegateBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogDepositWithoutCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"LogDisableCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"LogEnableCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"rateMode","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogPayback","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rateMode","type":"uint256"},{"indexed":false,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogPaybackOnBehalfOf","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"categoryId","type":"uint8"}],"name":"LogSetUserEMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"rateMode","type":"uint256"}],"name":"LogSwapRateMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"getId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"setId","type":"uint256"}],"name":"LogWithdraw","type":"event"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"borrow","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"borrowOnBehalfOf","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"address","name":"delegateTo","type":"address"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"delegateBorrow","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"depositWithoutCollateral","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"disableCollateral","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"enableCollateral","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"payback","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"paybackOnBehalfOf","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"paybackWithATokens","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint8","name":"categoryId","type":"uint8"}],"name":"setUserEMode","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"rateMode","type":"uint256"}],"name":"swapBorrowRateMode","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"string","name":"_eventName","type":"string"},{"internalType":"bytes","name":"_eventParam","type":"bytes"}],"stateMutability":"payable","type":"function"}]

608060405234801561001057600080fd5b50612af2806100206000396000f3fe6080604052600436106100dd5760003560e01c806389952fa11161007f578063ce88b43911610059578063ce88b43914610460578063da2b65c814610498578063fae4202114610508578063fe89c24814610578576100dd565b806389952fa1146103a457806394ba89a2146103ec578063bd1cde5914610418576100dd565b80634e5e60e7116100bb5780634e5e60e7146102a25780636abcd3de146102e057806377613a8a1461031e57806386b5b4451461035c576100dd565b806306fdde03146100e257806328530a471461016c5780634532d7761461026a575b600080fd5b3480156100ee57600080fd5b506100f76105b0565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61018c6004803603602081101561018257600080fd5b503560ff166105d7565b604051808060200180602001838103835285818151815260200191508051906020019080838360005b838110156101cd5781810151838201526020016101b5565b50505050905090810190601f1680156101fa5780820380516001836020036101000a031916815260200191505b50838103825284518152845160209182019186019080838360005b8381101561022d578181015183820152602001610215565b50505050905090810190601f16801561025a5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b61018c6004803603608081101561028057600080fd5b506001600160a01b03813516906020810135906040810135906060013561070d565b61018c600480360360a08110156102b857600080fd5b506001600160a01b0381351690602081013590604081013590606081013590608001356109ef565b61018c600480360360a08110156102f657600080fd5b506001600160a01b038135169060208101359060408101359060608101359060800135610bfa565b61018c600480360360a081101561033457600080fd5b506001600160a01b038135169060208101359060408101359060608101359060800135610dca565b61018c600480360360c081101561037257600080fd5b506001600160a01b03813581169160208101359160408201359160608101359091169060808101359060a00135610f34565b61018c600480360360c08110156103ba57600080fd5b506001600160a01b03813581169160208101359160408201359160608101359091169060808101359060a00135611111565b61018c6004803603604081101561040257600080fd5b506001600160a01b0381351690602001356112b5565b61018c600480360360c081101561042e57600080fd5b506001600160a01b03813581169160208101359160408201359160608101359091169060808101359060a00135611461565b61018c6004803603608081101561047657600080fd5b506001600160a01b03813516906020810135906040810135906060013561168d565b61018c600480360360208110156104ae57600080fd5b8101906020810181356401000000008111156104c957600080fd5b8201836020820111156104db57600080fd5b803590602001918460208302840111640100000000831117156104fd57600080fd5b509092509050611979565b61018c6004803603602081101561051e57600080fd5b81019060208101813564010000000081111561053957600080fd5b82018360208201111561054b57600080fd5b8035906020019184602083028401116401000000008311171561056d57600080fd5b509092509050611bf8565b61018c6004803603608081101561058e57600080fd5b506001600160a01b038135169060208101359060408101359060600135611e72565b6040518060400160405280600b81526020016a20b0bb32ab1996bb18971960a91b81525081565b606080600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561062957600080fd5b505afa15801561063d573d6000803e3d6000fd5b505050506040513d602081101561065357600080fd5b5051604080516328530a4760e01b815260ff8716600482015290519192506001600160a01b038316916328530a479160248082019260009290919082900301818387803b1580156106a357600080fd5b505af11580156106b7573d6000803e3d6000fd5b505060408051808201825260168152754c6f6753657455736572454d6f64652875696e74382960501b602080830191909152825160ff909916898201528251808a03909101815297820190915296945050505050565b606080600061071c858761216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561076d57600080fd5b505afa158015610781573d6000803e3d6000fd5b505050506040513d602081101561079757600080fd5b505190506001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146000816107c857896107de565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905060008190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561083457600080fd5b505afa158015610848573d6000803e3d6000fd5b505050506040513d602081101561085e57600080fd5b505160408051631a4ca37b60e21b81526001600160a01b038681166004830152602482018a90523060448301529151929350908716916369328dec916064808201926020929091908290030181600087803b1580156108bc57600080fd5b505af11580156108d0573d6000803e3d6000fd5b505050506040513d60208110156108e657600080fd5b5050604080516370a0823160e01b815230600482015290516000916001600160a01b038516916370a0823191602480820192602092909190829003018186803b15801561093257600080fd5b505afa158015610946573d6000803e3d6000fd5b505050506040513d602081101561095c57600080fd5b5051905061096a818361220b565b9650610977858489612217565b6109818a8861228c565b6040518060600160405280602c8152602001612993602c913998508c878c8c60405160200180856001600160a01b0316815260200184815260200183815260200182815260200194505050505060405160208183030381529060405297505050505050505094509492505050565b60608060006109fe858861216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a4f57600080fd5b505afa158015610a63573d6000803e3d6000fd5b505050506040513d6020811015610a7957600080fd5b505190506001600160a01b03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081610aaa578a610ac0565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b9050806000198514610ad25784610adc565b610adc828b612309565b94508215610aef57610aef8382876123c9565b610afa818587612428565b6040805163573ade8160e01b81526001600160a01b03848116600483015260248201889052604482018d905230606483015291519186169163573ade81916084808201926020929091908290030181600087803b158015610b5a57600080fd5b505af1158015610b6e573d6000803e3d6000fd5b505050506040513d6020811015610b8457600080fd5b50610b919050888661228c565b604051806060016040528060338152602001612a8a60339139604080516001600160a01b03909e1660208f01528d81019690965260608d019a909a52505050506080880194909452505060a0808601919091528151808603909101815260c09094019052929050565b6060806000610c09858861216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c5a57600080fd5b505afa158015610c6e573d6000803e3d6000fd5b505050506040513d6020811015610c8457600080fd5b505190506001600160a01b03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081610cb5578a610ccb565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b6040805163a415bcad60e01b81526001600160a01b03808416600483015260248201889052604482018d9052610c9c606483015230608483015291519293509085169163a415bcad9160a48082019260009290919082900301818387803b158015610d3557600080fd5b505af1158015610d49573d6000803e3d6000fd5b50505050610d58828286612217565b610d62878561228c565b60405180606001604052806032815260200161296160329139604080516001600160a01b03909d1660208e01528c81019590955260608c01999099525050506080880194909452505060a0808601919091528151808603909101815260c09094019052929050565b6060806000610dd9858861216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e2a57600080fd5b505afa158015610e3e573d6000803e3d6000fd5b505050506040513d6020811015610e5457600080fd5b505190506001600160a01b03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081610e85578a610e9b565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b9050806000198514610ead5784610eb7565b610eb7828b612309565b94508215610eca57610eca8382876123c9565b610ed5818587612428565b836001600160a01b0316632dad97d483878d6040518463ffffffff1660e01b815260040180846001600160a01b031681526020018381526020018281526020019350505050602060405180830381600087803b158015610b5a57600080fd5b6060806000610f43858961216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f9457600080fd5b505afa158015610fa8573d6000803e3d6000fd5b505050506040513d6020811015610fbe57600080fd5b505190506001600160a01b038a1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081610fef578b611005565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b6040805163a415bcad60e01b81526001600160a01b03808416600483015260248201889052604482018e9052610c9c60648301528c8116608483015291519293509085169163a415bcad9160a48082019260009290919082900301818387803b15801561107157600080fd5b505af1158015611085573d6000803e3d6000fd5b50505050611094828286612217565b61109e878561228c565b604051806080016040528060448152602001612a4660449139604080516001600160a01b039e8f16602082015280820196909652606086019b909b529b9098166080840152505060a0810194909452505060c0808301919091528351808303909101815260e09091019092525091929050565b60608085600114806111235750856002145b611168576040805162461bcd60e51b8152602060048201526011602482015270496e76616c69642064656274207479706560781b604482015290519081900360640190fd5b6000611174858961216f565b90506001600160a01b03891673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146000816111a3578a6111b9565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905060006111c7828b61256f565b9050806001600160a01b031663c04a8a108a866040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561122057600080fd5b505af1158015611234573d6000803e3d6000fd5b50505050611242878561228c565b604051806080016040528060428152602001612a0460429139604080516001600160a01b039e8f16602082015280820196909652606086019b909b529b9098166080840152505060a0810194909452505060c0808301919091528351808303909101815260e09091019092525091929050565b606080600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561130757600080fd5b505afa15801561131b573d6000803e3d6000fd5b505050506040513d602081101561133157600080fd5b505190506001600160a01b03851673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146000816113625786611378565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905060006113868288612309565b11156113fc57826001600160a01b03166394ba89a282886040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156113e357600080fd5b505af11580156113f7573d6000803e3d6000fd5b505050505b505060408051808201825260208082527f4c6f6753776170526174654d6f646528616464726573732c75696e74323536298183015282516001600160a01b03909816908801528682019590955280518087038201815260609096019052509193915050565b6060806000611470858961216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114c157600080fd5b505afa1580156114d5573d6000803e3d6000fd5b505050506040513d60208110156114eb57600080fd5b505190506001600160a01b038a1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1460008161151c578b611532565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b9050806000198514611544578461154f565b61154f828c8c61269a565b94508215611562576115628382876123c9565b61156d818587612428565b6040805163573ade8160e01b81526001600160a01b03848116600483015260248201889052604482018e90528c8116606483015291519186169163573ade81916084808201926020929091908290030181600087803b1580156115cf57600080fd5b505af11580156115e3573d6000803e3d6000fd5b505050506040513d60208110156115f957600080fd5b506116069050888661228c565b6040518060800160405280604581526020016129bf6045913996508c858c8c8c8c60405160200180876001600160a01b03168152602001868152602001858152602001846001600160a01b03168152602001838152602001828152602001965050505050505060405160208183030381529060405295505050505050965096945050505050565b606080600061169c858761216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156116ed57600080fd5b505afa158015611701573d6000803e3d6000fd5b505050506040513d602081101561171757600080fd5b505190506001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081611748578961175e565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905080821561178a5760001985146117765784611778565b475b94506117858382876123c9565b61180f565b6000198514611799578461180c565b604080516370a0823160e01b815230600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b1580156117df57600080fd5b505afa1580156117f3573d6000803e3d6000fd5b505050506040513d602081101561180957600080fd5b50515b94505b61181a818587612428565b6040805163617ba03760e01b81526001600160a01b03848116600483015260248201889052306044830152610c9c606483015291519186169163617ba0379160848082019260009290919082900301818387803b15801561187a57600080fd5b505af115801561188e573d6000803e3d6000fd5b5050505061189b82612768565b61190a5760408051635a3b74b960e01b81526001600160a01b03848116600483015260016024830152915191861691635a3b74b99160448082019260009290919082900301818387803b1580156118f157600080fd5b505af1158015611905573d6000803e3d6000fd5b505050505b611914888661228c565b6040518060600160405280602b81526020016128fa602b9139604080516001600160a01b03909d1660208e01528c81019690965260608c0199909952505050506080808801949094528051808803909401845260a09096019095525090939092509050565b60608082806119c6576040805162461bcd60e51b81526020600482015260146024820152730c0b5d1bdad95b9ccb5b9bdd0b585b1b1bddd95960621b604482015290519081900360640190fd5b600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a1557600080fd5b505afa158015611a29573d6000803e3d6000fd5b505050506040513d6020811015611a3f57600080fd5b5051905060005b82811015611b6557600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee888884818110611a7157fe5b905060200201356001600160a01b03166001600160a01b0316149050600081611ab557888884818110611aa057fe5b905060200201356001600160a01b0316611acb565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b90506000611ad882612804565b118015611aeb5750611ae981612768565b155b15611b5b5760408051635a3b74b960e01b81526001600160a01b03838116600483015260016024830152915191861691635a3b74b99160448082019260009290919082900301818387803b158015611b4257600080fd5b505af1158015611b56573d6000803e3d6000fd5b505050505b5050600101611a46565b506040518060400160405280601e81526020017f4c6f67456e61626c65436f6c6c61746572616c28616464726573735b5d2900008152509350858560405160200180806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509350505050604051602081830303815290604052925050509250929050565b6060808280611c45576040805162461bcd60e51b81526020600482015260146024820152730c0b5d1bdad95b9ccb5b9bdd0b585b1b1bddd95960621b604482015290519081900360640190fd5b600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c9457600080fd5b505afa158015611ca8573d6000803e3d6000fd5b505050506040513d6020811015611cbe57600080fd5b5051905060005b82811015611ddf57600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee888884818110611cf057fe5b905060200201356001600160a01b03166001600160a01b0316149050600081611d3457888884818110611d1f57fe5b905060200201356001600160a01b0316611d4a565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b90506000611d5782612804565b118015611d685750611d6881612768565b15611dd55760408051635a3b74b960e01b81526001600160a01b038381166004830152600060248301819052925190871692635a3b74b9926044808201939182900301818387803b158015611dbc57600080fd5b505af1158015611dd0573d6000803e3d6000fd5b505050505b5050600101611cc5565b506040518060400160405280601f81526020017f4c6f6744697361626c65436f6c6c61746572616c28616464726573735b5d29008152509350858560405160200180806020018281038252848482818152602001925060200280828437600081840152601f19601f8201169050808301925050509350505050604051602081830303815290604052925050509250929050565b6060806000611e81858761216f565b9050600073a97684ead0e402dc232d5a977953df7ecbab3cdb6001600160a01b031663026b1d5f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ed257600080fd5b505afa158015611ee6573d6000803e3d6000fd5b505050506040513d6020811015611efc57600080fd5b505190506001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600081611f2d5789611f43565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b9050808215611f6f576000198514611f5b5784611f5d565b475b9450611f6a8382876123c9565b611ff4565b6000198514611f7e5784611ff1565b604080516370a0823160e01b815230600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b158015611fc457600080fd5b505afa158015611fd8573d6000803e3d6000fd5b505050506040513d6020811015611fee57600080fd5b50515b94505b611fff818587612428565b6040805163617ba03760e01b81526001600160a01b03848116600483015260248201889052306044830152610c9c606483015291519186169163617ba0379160848082019260009290919082900301818387803b15801561205f57600080fd5b505af1158015612073573d6000803e3d6000fd5b50505050600061208283612804565b118015612093575061209382612768565b156121005760408051635a3b74b960e01b81526001600160a01b038481166004830152600060248301819052925190871692635a3b74b9926044808201939182900301818387803b1580156120e757600080fd5b505af11580156120fb573d6000803e3d6000fd5b505050505b61210a888661228c565b6040518060600160405280603c8152602001612925603c9139604080516001600160a01b03909d1660208e01528c81019690965260608c0199909952505050506080808801949094528051808803909401845260a09096019095525090939092509050565b6000821561220257736c7256cf7c003dd85683339f75dde9971f98f2fd6001600160a01b031663a9c70eaa846040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b1580156121d157600080fd5b505af11580156121e5573d6000803e3d6000fd5b505050506040513d60208110156121fb57600080fd5b5051612204565b815b9392505050565b6000612204838361289c565b821561228757612228828383612428565b816001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561226e57600080fd5b505af1158015612282573d6000803e3d6000fd5b505050505b505050565b81156123055760408051631878f25160e21b815260048101849052602481018390529051736c7256cf7c003dd85683339f75dde9971f98f2fd916361e3c94491604480830192600092919082900301818387803b1580156122ec57600080fd5b505af1158015612300573d6000803e3d6000fd5b505050505b5050565b604080516328dd2d0160e01b81526001600160a01b03841660048201523060248201529051600091829182917369fa688f1dc47d4b5d8029d5a35fb7a548310654916328dd2d019160448082019261012092909190829003018186803b15801561237257600080fd5b505afa158015612386573d6000803e3d6000fd5b505050506040513d61012081101561239d57600080fd5b5060208101516040909101519092509050600184146123bc57806123be565b815b925050505b92915050565b821561228757816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561240a57600080fd5b505af115801561241e573d6000803e3d6000fd5b5050505050505050565b826001600160a01b031663095ea7b383836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561247f57600080fd5b505af1925050508015612490575060015b612287576040805163095ea7b360e01b81526001600160a01b03848116600483015260006024830181905292519086169263095ea7b3926044808201939182900301818387803b1580156124e357600080fd5b505af11580156124f7573d6000803e3d6000fd5b50505050826001600160a01b031663095ea7b383836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561255257600080fd5b505af1158015612566573d6000803e3d6000fd5b50505050612287565b6000816001141561260a57604080516334924edb60e21b81526001600160a01b038516600482015290517369fa688f1dc47d4b5d8029d5a35fb7a5483106549163d2493b6c916024808301926060929190829003018186803b1580156125d457600080fd5b505afa1580156125e8573d6000803e3d6000fd5b505050506040513d60608110156125fe57600080fd5b506020015190506123c3565b604080516334924edb60e21b81526001600160a01b038516600482015290517369fa688f1dc47d4b5d8029d5a35fb7a5483106549163d2493b6c916024808301926060929190829003018186803b15801561266457600080fd5b505afa158015612678573d6000803e3d6000fd5b505050506040513d606081101561268e57600080fd5b50604001519392505050565b60008060007369fa688f1dc47d4b5d8029d5a35fb7a5483106546001600160a01b03166328dd2d0187866040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b03168152602001925050506101206040518083038186803b15801561271257600080fd5b505afa158015612726573d6000803e3d6000fd5b505050506040513d61012081101561273d57600080fd5b50602081015160409091015190925090506001851461275c578061275e565b815b9695505050505050565b604080516328dd2d0160e01b81526001600160a01b038316600482015230602482015290516000917369fa688f1dc47d4b5d8029d5a35fb7a548310654916328dd2d019160448082019261012092909190829003018186803b1580156127cd57600080fd5b505afa1580156127e1573d6000803e3d6000fd5b505050506040513d6101208110156127f857600080fd5b50610100015192915050565b604080516328dd2d0160e01b81526001600160a01b038316600482015230602482015290516000917369fa688f1dc47d4b5d8029d5a35fb7a548310654916328dd2d019160448082019261012092909190829003018186803b15801561286957600080fd5b505afa15801561287d573d6000803e3d6000fd5b505050506040513d61012081101561289457600080fd5b505192915050565b6000828211156128f3576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe4c6f674465706f73697428616464726573732c75696e743235362c75696e743235362c75696e74323536294c6f674465706f736974576974686f7574436f6c6c61746572616c28616464726573732c75696e743235362c75696e743235362c75696e74323536294c6f67426f72726f7728616464726573732c75696e743235362c75696e743235362c75696e743235362c75696e74323536294c6f67576974686472617728616464726573732c75696e743235362c75696e743235362c75696e74323536294c6f675061796261636b4f6e426568616c664f6628616464726573732c75696e743235362c75696e743235362c616464726573732c75696e743235362c75696e74323536294c6f6744656c6567617465426f72726f7728616464726573732c75696e743235362c75696e743235362c616464726573732c75696e743235362c75696e74323536294c6f67426f72726f774f6e426568616c664f6628616464726573732c75696e743235362c75696e743235362c616464726573732c75696e743235362c75696e74323536294c6f675061796261636b28616464726573732c75696e743235362c75696e743235362c75696e743235362c75696e7432353629a2646970667358221220f1948a60345162fae29138dc58abc0ab930cfc57ceda28e6bb3d3e2867877ac864736f6c63430007060033

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.