MATIC Price: $0.722003 (-0.50%)
Gas: 30 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Token Holdings

Sponsored

Transaction Hash
Method
Block
From
To
Value
Transfer Ownersh...173889612021-07-29 10:53:131028 days ago1627555993IN
0x206CbDa3...89555A588
0 MATIC0.000086433
Set Contract Gua...173444302021-07-28 2:19:031029 days ago1627438743IN
0x206CbDa3...89555A588
0 MATIC0.000052111.08
Set Contract Gua...173444262021-07-28 2:18:551029 days ago1627438735IN
0x206CbDa3...89555A588
0 MATIC0.000052111.08
Set Asset Guard173444212021-07-28 2:18:451029 days ago1627438725IN
0x206CbDa3...89555A588
0 MATIC0.00005181.08
Set Asset Guard173444172021-07-28 2:18:371029 days ago1627438717IN
0x206CbDa3...89555A588
0 MATIC0.000051791.08
0x60806040173438422021-07-28 1:58:511029 days ago1627437531IN
 Create: Governance
0 MATIC0.000628151.08

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Governance

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 4 : Governance.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.7.6;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IGovernance.sol";

/// @title Governance
/// @dev A contract with storage managed by governance
contract Governance is IGovernance, Ownable {
  event ContractGuardSet(address extContract, address guardAddress);
  event AssetGuardSet(uint16 assetType, address guardAddress);
  event AddressSet(bytes32 name, address destination);

  struct ContractName {
    bytes32 name;
    address destination;
  }

  // Transaction Guards
  mapping(address => address) public override contractGuards;
  mapping(uint16 => address) public override assetGuards;

  // Addresses

  // "aaveProtocolDataProvider": aave protocol data provider
  // "swapRouter": swapRouter with uniswap v2 interface.
  // "weth": weth address which is used token swap
  mapping(bytes32 => address) public override nameToDestination;

  /* ========== RESTRICTED FUNCTIONS ========== */

  // Transaction Guards

  /// @notice Maps an exernal contract to a guard which enables managers to use the contract
  /// @param extContract The third party contract to integrate
  /// @param guardAddress The protections for manager third party contract interaction
  function setContractGuard(address extContract, address guardAddress) external onlyOwner {
    _setContractGuard(extContract, guardAddress);
  }

  function _setContractGuard(address extContract, address guardAddress) internal {
    require(extContract != address(0), "Invalid extContract address");
    require(guardAddress != address(0), "Invalid guardAddress");

    contractGuards[extContract] = guardAddress;

    emit ContractGuardSet(extContract, guardAddress);
  }

  /// @notice Maps an asset type to an asset guard which allows managers to enable the asset
  /// @dev Asset types are defined in AssetHandler.sol
  /// @param assetType Asset type as defined in Asset Handler
  /// @param guardAddress The asset guard address that allows manager interaction
  function setAssetGuard(uint16 assetType, address guardAddress) external onlyOwner {
    _setAssetGuard(assetType, guardAddress);
  }

  function _setAssetGuard(uint16 assetType, address guardAddress) internal {
    require(guardAddress != address(0), "Invalid guardAddress");

    assetGuards[assetType] = guardAddress;

    emit AssetGuardSet(assetType, guardAddress);
  }

  // Addresses

  /// @notice Maps multiple contract names to destination addresses
  /// @dev This is a central source that can be used to reference third party contracts
  /// @param contractNames The contract names and addresses struct
  function setAddresses(ContractName[] calldata contractNames) external onlyOwner {
    for (uint256 i = 0; i < contractNames.length; i++) {
      bytes32 name = contractNames[i].name;
      address destination = contractNames[i].destination;
      nameToDestination[name] = destination;
      emit AddressSet(name, destination);
    }
  }
}

File 2 of 4 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 2 of 4 : IGovernance.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IGovernance {
  function contractGuards(address target) external view returns (address guard);

  function assetGuards(uint16 assetType) external view returns (address guard);

  function nameToDestination(bytes32 name) external view returns (address);
}

File 2 of 4 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

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

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":false,"internalType":"address","name":"destination","type":"address"}],"name":"AddressSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"assetType","type":"uint16"},{"indexed":false,"internalType":"address","name":"guardAddress","type":"address"}],"name":"AssetGuardSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"extContract","type":"address"},{"indexed":false,"internalType":"address","name":"guardAddress","type":"address"}],"name":"ContractGuardSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"assetGuards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"contractGuards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nameToDestination","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"address","name":"destination","type":"address"}],"internalType":"struct Governance.ContractName[]","name":"contractNames","type":"tuple[]"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"assetType","type":"uint16"},{"internalType":"address","name":"guardAddress","type":"address"}],"name":"setAssetGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"extContract","type":"address"},{"internalType":"address","name":"guardAddress","type":"address"}],"name":"setContractGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50600061001b61006a565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35061006e565b3390565b61091a8061007d6000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063a950c30011610066578063a950c300146100e6578063c2a9ffb1146100f9578063cca5b2131461010c578063d6695d901461011f578063f2fde38b1461013257610093565b80635d36ffc414610098578063715018a6146100c15780638da5cb5b146100cb578063a76a5a5a146100d3575b600080fd5b6100ab6100a63660046106c7565b610145565b6040516100b891906107d7565b60405180910390f35b6100c9610160565b005b6100ab61020c565b6100c96100e13660046107bc565b61021b565b6100ab6100f43660046107a2565b61028b565b6100ab61010736600461078a565b6102a6565b6100c961011a36600461071a565b6102c1565b6100c961012d3660046106e8565b6103e1565b6100c96101403660046106c7565b61044d565b6001602052600090815260409020546001600160a01b031681565b61016861054f565b6001600160a01b031661017961020c565b6001600160a01b0316146101c2576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b61022361054f565b6001600160a01b031661023461020c565b6001600160a01b03161461027d576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b6102878282610553565b5050565b6002602052600090815260409020546001600160a01b031681565b6003602052600090815260409020546001600160a01b031681565b6102c961054f565b6001600160a01b03166102da61020c565b6001600160a01b031614610323576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b60005b818110156103dc57600083838381811061033c57fe5b905060400201600001359050600084848481811061035657fe5b905060400201602001602081019061036e91906106c7565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507fb37614c7d254ea8d16eb81fa11dddaeb266aa8ba4917980859c7740aff30c691906103ca9084908490610805565b60405180910390a15050600101610326565b505050565b6103e961054f565b6001600160a01b03166103fa61020c565b6001600160a01b031614610443576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b61028782826105ec565b61045561054f565b6001600160a01b031661046661020c565b6001600160a01b0316146104af576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b6001600160a01b0381166104f45760405162461bcd60e51b815260040180806020018281038252602681526020018061089f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0381166105825760405162461bcd60e51b81526004016105799061081c565b60405180910390fd5b61ffff82166000908152600260205260409081902080546001600160a01b0319166001600160a01b038416179055517f1bb7f0c97ae318d0567480b41c67984f80046809b5fc8cf1c4743b720da46853906105e09084908490610881565b60405180910390a15050565b6001600160a01b0382166106125760405162461bcd60e51b81526004016105799061084a565b6001600160a01b0381166106385760405162461bcd60e51b81526004016105799061081c565b6001600160a01b038281166000908152600160205260409081902080546001600160a01b03191692841692909217909155517fab3c7146960e2efaf23cc0fe9e1e5d37d3e7807b12bf77b970066efe5f3e7760906105e090849084906107eb565b80356001600160a01b03811681146106b057600080fd5b919050565b803561ffff811681146106b057600080fd5b6000602082840312156106d8578081fd5b6106e182610699565b9392505050565b600080604083850312156106fa578081fd5b61070383610699565b915061071160208401610699565b90509250929050565b6000806020838503121561072c578182fd5b823567ffffffffffffffff80821115610743578384fd5b818501915085601f830112610756578384fd5b813581811115610764578485fd5b866020604083028501011115610778578485fd5b60209290920196919550909350505050565b60006020828403121561079b578081fd5b5035919050565b6000602082840312156107b3578081fd5b6106e1826106b5565b600080604083850312156107ce578182fd5b610703836106b5565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b9182526001600160a01b0316602082015260400190565b602080825260149082015273496e76616c69642067756172644164647265737360601b604082015260600190565b6020808252601b908201527f496e76616c696420657874436f6e747261637420616464726573730000000000604082015260600190565b61ffff9290921682526001600160a01b031660208201526040019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a264697066735822122019c496d973e5b5c1358dc1fe2350b48507878430cb01e7dddb7f783b9de21c3464736f6c63430007060033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063a950c30011610066578063a950c300146100e6578063c2a9ffb1146100f9578063cca5b2131461010c578063d6695d901461011f578063f2fde38b1461013257610093565b80635d36ffc414610098578063715018a6146100c15780638da5cb5b146100cb578063a76a5a5a146100d3575b600080fd5b6100ab6100a63660046106c7565b610145565b6040516100b891906107d7565b60405180910390f35b6100c9610160565b005b6100ab61020c565b6100c96100e13660046107bc565b61021b565b6100ab6100f43660046107a2565b61028b565b6100ab61010736600461078a565b6102a6565b6100c961011a36600461071a565b6102c1565b6100c961012d3660046106e8565b6103e1565b6100c96101403660046106c7565b61044d565b6001602052600090815260409020546001600160a01b031681565b61016861054f565b6001600160a01b031661017961020c565b6001600160a01b0316146101c2576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b61022361054f565b6001600160a01b031661023461020c565b6001600160a01b03161461027d576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b6102878282610553565b5050565b6002602052600090815260409020546001600160a01b031681565b6003602052600090815260409020546001600160a01b031681565b6102c961054f565b6001600160a01b03166102da61020c565b6001600160a01b031614610323576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b60005b818110156103dc57600083838381811061033c57fe5b905060400201600001359050600084848481811061035657fe5b905060400201602001602081019061036e91906106c7565b6000838152600360205260409081902080546001600160a01b0319166001600160a01b038416179055519091507fb37614c7d254ea8d16eb81fa11dddaeb266aa8ba4917980859c7740aff30c691906103ca9084908490610805565b60405180910390a15050600101610326565b505050565b6103e961054f565b6001600160a01b03166103fa61020c565b6001600160a01b031614610443576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b61028782826105ec565b61045561054f565b6001600160a01b031661046661020c565b6001600160a01b0316146104af576040805162461bcd60e51b815260206004820181905260248201526000805160206108c5833981519152604482015290519081900360640190fd5b6001600160a01b0381166104f45760405162461bcd60e51b815260040180806020018281038252602681526020018061089f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0381166105825760405162461bcd60e51b81526004016105799061081c565b60405180910390fd5b61ffff82166000908152600260205260409081902080546001600160a01b0319166001600160a01b038416179055517f1bb7f0c97ae318d0567480b41c67984f80046809b5fc8cf1c4743b720da46853906105e09084908490610881565b60405180910390a15050565b6001600160a01b0382166106125760405162461bcd60e51b81526004016105799061084a565b6001600160a01b0381166106385760405162461bcd60e51b81526004016105799061081c565b6001600160a01b038281166000908152600160205260409081902080546001600160a01b03191692841692909217909155517fab3c7146960e2efaf23cc0fe9e1e5d37d3e7807b12bf77b970066efe5f3e7760906105e090849084906107eb565b80356001600160a01b03811681146106b057600080fd5b919050565b803561ffff811681146106b057600080fd5b6000602082840312156106d8578081fd5b6106e182610699565b9392505050565b600080604083850312156106fa578081fd5b61070383610699565b915061071160208401610699565b90509250929050565b6000806020838503121561072c578182fd5b823567ffffffffffffffff80821115610743578384fd5b818501915085601f830112610756578384fd5b813581811115610764578485fd5b866020604083028501011115610778578485fd5b60209290920196919550909350505050565b60006020828403121561079b578081fd5b5035919050565b6000602082840312156107b3578081fd5b6106e1826106b5565b600080604083850312156107ce578182fd5b610703836106b5565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b9182526001600160a01b0316602082015260400190565b602080825260149082015273496e76616c69642067756172644164647265737360601b604082015260600190565b6020808252601b908201527f496e76616c696420657874436f6e747261637420616464726573730000000000604082015260600190565b61ffff9290921682526001600160a01b031660208201526040019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a264697066735822122019c496d973e5b5c1358dc1fe2350b48507878430cb01e7dddb7f783b9de21c3464736f6c63430007060033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.