ETH Price: $2,172.64 (+9.81%)

Transaction Decoder

Block:
14355126 at Mar-09-2022 09:54:49 PM +UTC
Transaction Fee:
0.006371209608387834 ETH $13.84
Gas Used:
229,646 Gas / 27.743612379 Gwei

Emitted Events:

56 AppProxyUpgradeable.0x5b2c6f4cb53711ae51d600df17fa68f8239b4a704f766c99642f667d1d7bd40e( 0x5b2c6f4cb53711ae51d600df17fa68f8239b4a704f766c99642f667d1d7bd40e, 0x00000000000000000000000000000000000000000000000000000000000000ce, 0x0000000000000000000000002c8553fa44bcd556e5f7c8482f78ee634d88a509, 0000000000000000000000000000000000000000000000000000000000000001, 00000000000000000000000000000000000000000000000000000002540be400, 0000000000000000000000000000000000000000000000000000000000000060, 000000000000000000000000000000000000000000000000000000000000000e, 636d6472202d7469786661697279000000000000000000000000000000000000 )
57 FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x0000000000000000000000002c8553fa44bcd556e5f7c8482f78ee634d88a509, 0x000000000000000000000000d5d5b901bb2abae30c33b65f7714b1c11e977013, 00000000000000000000000000000000000000000000000000000002540be400 )
58 FiatTokenProxy.0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925( 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925, 0x000000000000000000000000d5d5b901bb2abae30c33b65f7714b1c11e977013, 0x0000000000000000000000003f433647318b3f704bc4a4125c9c59d69fa12bfc, 00000000000000000000000000000000000000000000000000000002540be400 )
59 FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x000000000000000000000000d5d5b901bb2abae30c33b65f7714b1c11e977013, 0x0000000000000000000000003f433647318b3f704bc4a4125c9c59d69fa12bfc, 00000000000000000000000000000000000000000000000000000002540be400 )
60 AppProxyUpgradeable.0x2790b90165fd3973ad7edde4eca71b4f8808dd4857a2a3a3e8ae5642a5cb196e( 0x2790b90165fd3973ad7edde4eca71b4f8808dd4857a2a3a3e8ae5642a5cb196e, 0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0x000000000000000000000000d5d5b901bb2abae30c33b65f7714b1c11e977013, 00000000000000000000000000000000000000000000000000000002540be400 )

Account State Difference:

  Address   Before After State Difference Code
0x2C8553fa...34d88A509
0.182255115095446668 Eth
Nonce: 391
0.175883905487058834 Eth
Nonce: 392
0.006371209608387834
0xA0b86991...E3606eB48
0xd5D5B901...11e977013
(Ethermine)
668.560107468282435867 Eth668.560681583282435867 Eth0.000574115

Execution Trace

AppProxyUpgradeable.bfe07da6( )
  • KernelProxy.be00bbd8( )
    • Kernel.getApp( _namespace=F1F3EB40F5BC1AD1344716CED8B8A0431D840B5783AEA1FD01786BC26F35AC0F, _appId=BF8491150DAFC5DCAEE5B861414DCA922DE09CCFFA344964AE167212E8C673AE ) => ( 0x836835289A2E81B66AE5d95b7c8dBC0480dCf9da )
    • Finance.deposit( _token=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, _amount=10000000000, _reference=cmdr -tixfairy )
      • FiatTokenProxy.23b872dd( )
        • FiatTokenV2_1.transferFrom( from=0x2C8553fa44BCD556e5F7C8482F78ee634d88A509, to=0xd5D5B901BB2ABAE30C33B65f7714b1c11e977013, value=10000000000 ) => ( True )
        • FiatTokenProxy.095ea7b3( )
          • FiatTokenV2_1.approve( spender=0x3f433647318b3f704BC4A4125c9C59d69FA12Bfc, value=10000000000 ) => ( True )
          • AppProxyUpgradeable.47e7ef24( )
            • KernelProxy.be00bbd8( )
              • Kernel.getApp( _namespace=F1F3EB40F5BC1AD1344716CED8B8A0431D840B5783AEA1FD01786BC26F35AC0F, _appId=9AC98DC5F995BF0211ED589EF022719D1487E5CB2BAB505676F0D084C07CF89A ) => ( 0x3A93C17FC82CC33420d1809dDA9Fb715cc89dd37 )
              • Agent.deposit( _token=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, _value=10000000000 )
                • FiatTokenProxy.23b872dd( )
                  • FiatTokenV2_1.transferFrom( from=0xd5D5B901BB2ABAE30C33B65f7714b1c11e977013, to=0x3f433647318b3f704BC4A4125c9C59d69FA12Bfc, value=10000000000 ) => ( True )
                    File 1 of 8: AppProxyUpgradeable
                    // File: contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: contracts/apps/AppStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract AppStorage {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel");
                        bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId");
                        */
                        bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b;
                        bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b;
                    
                        function kernel() public view returns (IKernel) {
                            return IKernel(KERNEL_POSITION.getStorageAddress());
                        }
                    
                        function appId() public view returns (bytes32) {
                            return APP_ID_POSITION.getStorageBytes32();
                        }
                    
                        function setKernel(IKernel _kernel) internal {
                            KERNEL_POSITION.setStorageAddress(address(_kernel));
                        }
                    
                        function setAppId(bytes32 _appId) internal {
                            APP_ID_POSITION.setStorageBytes32(_appId);
                        }
                    }
                    
                    // File: contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: contracts/lib/misc/ERCProxy.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ERCProxy {
                        uint256 internal constant FORWARDING = 1;
                        uint256 internal constant UPGRADEABLE = 2;
                    
                        function proxyType() public pure returns (uint256 proxyTypeId);
                        function implementation() public view returns (address codeAddr);
                    }
                    
                    // File: contracts/common/DelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DelegateProxy is ERCProxy, IsContract {
                        uint256 internal constant FWD_GAS_LIMIT = 10000;
                    
                        /**
                        * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
                        * @param _dst Destination address to perform the delegatecall
                        * @param _calldata Calldata for the delegatecall
                        */
                        function delegatedFwd(address _dst, bytes _calldata) internal {
                            require(isContract(_dst));
                            uint256 fwdGasLimit = FWD_GAS_LIMIT;
                    
                            assembly {
                                let result := delegatecall(sub(gas, fwdGasLimit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
                                let size := returndatasize
                                let ptr := mload(0x40)
                                returndatacopy(ptr, 0, size)
                    
                                // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
                                // if the call returned error data, forward it
                                switch result case 0 { revert(ptr, size) }
                                default { return(ptr, size) }
                            }
                        }
                    }
                    
                    // File: contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: contracts/common/DepositableDelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DepositableDelegateProxy is DepositableStorage, DelegateProxy {
                        event ProxyDeposit(address sender, uint256 value);
                    
                        function () external payable {
                            uint256 forwardGasThreshold = FWD_GAS_LIMIT;
                            bytes32 isDepositablePosition = DEPOSITABLE_POSITION;
                    
                            // Optimized assembly implementation to prevent EIP-1884 from breaking deposits, reference code in Solidity:
                            // https://github.com/aragon/aragonOS/blob/v4.2.1/contracts/common/DepositableDelegateProxy.sol#L10-L20
                            assembly {
                                // Continue only if the gas left is lower than the threshold for forwarding to the implementation code,
                                // otherwise continue outside of the assembly block.
                                if lt(gas, forwardGasThreshold) {
                                    // Only accept the deposit and emit an event if all of the following are true:
                                    // the proxy accepts deposits (isDepositable), msg.data.length == 0, and msg.value > 0
                                    if and(and(sload(isDepositablePosition), iszero(calldatasize)), gt(callvalue, 0)) {
                                        // Equivalent Solidity code for emitting the event:
                                        // emit ProxyDeposit(msg.sender, msg.value);
                    
                                        let logData := mload(0x40) // free memory pointer
                                        mstore(logData, caller) // add 'msg.sender' to the log data (first event param)
                                        mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
                    
                                        // Emit an event with one topic to identify the event: keccak256('ProxyDeposit(address,uint256)') = 0x15ee...dee1
                                        log1(logData, 0x40, 0x15eeaa57c7bd188c1388020bcadc2c436ec60d647d36ef5b9eb3c742217ddee1)
                    
                                        stop() // Stop. Exits execution context
                                    }
                    
                                    // If any of above checks failed, revert the execution (if ETH was sent, it is returned to the sender)
                                    revert(0, 0)
                                }
                            }
                    
                            address target = implementation();
                            delegatedFwd(target, msg.data);
                        }
                    }
                    
                    // File: contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: contracts/apps/AppProxyBase.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelNamespaceConstants {
                        /**
                        * @dev Initialize AppProxy
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
                            setKernel(_kernel);
                            setAppId(_appId);
                    
                            // Implicit check that kernel is actually a Kernel
                            // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
                            // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
                            // it.
                            address appCode = getAppBase(_appId);
                    
                            // If initialize payload is provided, it will be executed
                            if (_initializePayload.length > 0) {
                                require(isContract(appCode));
                                // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
                                // returns ending execution context and halts contract deployment
                                require(appCode.delegatecall(_initializePayload));
                            }
                        }
                    
                        function getAppBase(bytes32 _appId) internal view returns (address) {
                            return kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId);
                        }
                    }
                    
                    // File: contracts/apps/AppProxyUpgradeable.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract AppProxyUpgradeable is AppProxyBase {
                        /**
                        * @dev Initialize AppProxyUpgradeable (makes it an upgradeable Aragon app)
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
                            AppProxyBase(_kernel, _appId, _initializePayload)
                            public // solium-disable-line visibility-first
                        {
                            // solium-disable-previous-line no-empty-blocks
                        }
                    
                        /**
                         * @dev ERC897, the address the proxy would delegate calls to
                         */
                        function implementation() public view returns (address) {
                            return getAppBase(appId());
                        }
                    
                        /**
                         * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy
                         */
                        function proxyType() public pure returns (uint256 proxyTypeId) {
                            return UPGRADEABLE;
                        }
                    }

                    File 2 of 8: FiatTokenProxy
                    pragma solidity ^0.4.24;
                    
                    // File: zos-lib/contracts/upgradeability/Proxy.sol
                    
                    /**
                     * @title Proxy
                     * @dev Implements delegation of calls to other contracts, with proper
                     * forwarding of return values and bubbling of failures.
                     * It defines a fallback function that delegates all calls to the address
                     * returned by the abstract _implementation() internal function.
                     */
                    contract Proxy {
                      /**
                       * @dev Fallback function.
                       * Implemented entirely in `_fallback`.
                       */
                      function () payable external {
                        _fallback();
                      }
                    
                      /**
                       * @return The Address of the implementation.
                       */
                      function _implementation() internal view returns (address);
                    
                      /**
                       * @dev Delegates execution to an implementation contract.
                       * This is a low level function that doesn't return to its internal call site.
                       * It will return to the external caller whatever the implementation returns.
                       * @param implementation Address to delegate.
                       */
                      function _delegate(address implementation) internal {
                        assembly {
                          // Copy msg.data. We take full control of memory in this inline assembly
                          // block because it will not return to Solidity code. We overwrite the
                          // Solidity scratch pad at memory position 0.
                          calldatacopy(0, 0, calldatasize)
                    
                          // Call the implementation.
                          // out and outsize are 0 because we don't know the size yet.
                          let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
                    
                          // Copy the returned data.
                          returndatacopy(0, 0, returndatasize)
                    
                          switch result
                          // delegatecall returns 0 on error.
                          case 0 { revert(0, returndatasize) }
                          default { return(0, returndatasize) }
                        }
                      }
                    
                      /**
                       * @dev Function that is run as the first thing in the fallback function.
                       * Can be redefined in derived contracts to add functionality.
                       * Redefinitions must call super._willFallback().
                       */
                      function _willFallback() internal {
                      }
                    
                      /**
                       * @dev fallback implementation.
                       * Extracted to enable manual triggering.
                       */
                      function _fallback() internal {
                        _willFallback();
                        _delegate(_implementation());
                      }
                    }
                    
                    // File: openzeppelin-solidity/contracts/AddressUtils.sol
                    
                    /**
                     * Utility library of inline functions on addresses
                     */
                    library AddressUtils {
                    
                      /**
                       * Returns whether the target address is a contract
                       * @dev This function will return false if invoked during the constructor of a contract,
                       * as the code is not actually created until after the constructor finishes.
                       * @param addr address to check
                       * @return whether the target address is a contract
                       */
                      function isContract(address addr) internal view returns (bool) {
                        uint256 size;
                        // XXX Currently there is no better way to check if there is a contract in an address
                        // than to check the size of the code at that address.
                        // See https://ethereum.stackexchange.com/a/14016/36603
                        // for more details about how this works.
                        // TODO Check this again before the Serenity release, because all addresses will be
                        // contracts then.
                        // solium-disable-next-line security/no-inline-assembly
                        assembly { size := extcodesize(addr) }
                        return size > 0;
                      }
                    
                    }
                    
                    // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol
                    
                    /**
                     * @title UpgradeabilityProxy
                     * @dev This contract implements a proxy that allows to change the
                     * implementation address to which it will delegate.
                     * Such a change is called an implementation upgrade.
                     */
                    contract UpgradeabilityProxy is Proxy {
                      /**
                       * @dev Emitted when the implementation is upgraded.
                       * @param implementation Address of the new implementation.
                       */
                      event Upgraded(address implementation);
                    
                      /**
                       * @dev Storage slot with the address of the current implementation.
                       * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
                       * validated in the constructor.
                       */
                      bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
                    
                      /**
                       * @dev Contract constructor.
                       * @param _implementation Address of the initial implementation.
                       */
                      constructor(address _implementation) public {
                        assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
                    
                        _setImplementation(_implementation);
                      }
                    
                      /**
                       * @dev Returns the current implementation.
                       * @return Address of the current implementation
                       */
                      function _implementation() internal view returns (address impl) {
                        bytes32 slot = IMPLEMENTATION_SLOT;
                        assembly {
                          impl := sload(slot)
                        }
                      }
                    
                      /**
                       * @dev Upgrades the proxy to a new implementation.
                       * @param newImplementation Address of the new implementation.
                       */
                      function _upgradeTo(address newImplementation) internal {
                        _setImplementation(newImplementation);
                        emit Upgraded(newImplementation);
                      }
                    
                      /**
                       * @dev Sets the implementation address of the proxy.
                       * @param newImplementation Address of the new implementation.
                       */
                      function _setImplementation(address newImplementation) private {
                        require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
                    
                        bytes32 slot = IMPLEMENTATION_SLOT;
                    
                        assembly {
                          sstore(slot, newImplementation)
                        }
                      }
                    }
                    
                    // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol
                    
                    /**
                     * @title AdminUpgradeabilityProxy
                     * @dev This contract combines an upgradeability proxy with an authorization
                     * mechanism for administrative tasks.
                     * All external functions in this contract must be guarded by the
                     * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
                     * feature proposal that would enable this to be done automatically.
                     */
                    contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
                      /**
                       * @dev Emitted when the administration has been transferred.
                       * @param previousAdmin Address of the previous admin.
                       * @param newAdmin Address of the new admin.
                       */
                      event AdminChanged(address previousAdmin, address newAdmin);
                    
                      /**
                       * @dev Storage slot with the admin of the contract.
                       * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
                       * validated in the constructor.
                       */
                      bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
                    
                      /**
                       * @dev Modifier to check whether the `msg.sender` is the admin.
                       * If it is, it will run the function. Otherwise, it will delegate the call
                       * to the implementation.
                       */
                      modifier ifAdmin() {
                        if (msg.sender == _admin()) {
                          _;
                        } else {
                          _fallback();
                        }
                      }
                    
                      /**
                       * Contract constructor.
                       * It sets the `msg.sender` as the proxy administrator.
                       * @param _implementation address of the initial implementation.
                       */
                      constructor(address _implementation) UpgradeabilityProxy(_implementation) public {
                        assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
                    
                        _setAdmin(msg.sender);
                      }
                    
                      /**
                       * @return The address of the proxy admin.
                       */
                      function admin() external view ifAdmin returns (address) {
                        return _admin();
                      }
                    
                      /**
                       * @return The address of the implementation.
                       */
                      function implementation() external view ifAdmin returns (address) {
                        return _implementation();
                      }
                    
                      /**
                       * @dev Changes the admin of the proxy.
                       * Only the current admin can call this function.
                       * @param newAdmin Address to transfer proxy administration to.
                       */
                      function changeAdmin(address newAdmin) external ifAdmin {
                        require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
                        emit AdminChanged(_admin(), newAdmin);
                        _setAdmin(newAdmin);
                      }
                    
                      /**
                       * @dev Upgrade the backing implementation of the proxy.
                       * Only the admin can call this function.
                       * @param newImplementation Address of the new implementation.
                       */
                      function upgradeTo(address newImplementation) external ifAdmin {
                        _upgradeTo(newImplementation);
                      }
                    
                      /**
                       * @dev Upgrade the backing implementation of the proxy and call a function
                       * on the new implementation.
                       * This is useful to initialize the proxied contract.
                       * @param newImplementation Address of the new implementation.
                       * @param data Data to send as msg.data in the low level call.
                       * It should include the signature and the parameters of the function to be
                       * called, as described in
                       * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
                       */
                      function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin {
                        _upgradeTo(newImplementation);
                        require(address(this).call.value(msg.value)(data));
                      }
                    
                      /**
                       * @return The admin slot.
                       */
                      function _admin() internal view returns (address adm) {
                        bytes32 slot = ADMIN_SLOT;
                        assembly {
                          adm := sload(slot)
                        }
                      }
                    
                      /**
                       * @dev Sets the address of the proxy admin.
                       * @param newAdmin Address of the new proxy admin.
                       */
                      function _setAdmin(address newAdmin) internal {
                        bytes32 slot = ADMIN_SLOT;
                    
                        assembly {
                          sstore(slot, newAdmin)
                        }
                      }
                    
                      /**
                       * @dev Only fall back when the sender is not the admin.
                       */
                      function _willFallback() internal {
                        require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
                        super._willFallback();
                      }
                    }
                    
                    // File: contracts/FiatTokenProxy.sol
                    
                    /**
                    * Copyright CENTRE SECZ 2018
                    *
                    * 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 SOFTWARE.
                    */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title FiatTokenProxy
                     * @dev This contract proxies FiatToken calls and enables FiatToken upgrades
                    */ 
                    contract FiatTokenProxy is AdminUpgradeabilityProxy {
                        constructor(address _implementation) public AdminUpgradeabilityProxy(_implementation) {
                        }
                    }

                    File 3 of 8: AppProxyUpgradeable
                    // File: contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: contracts/apps/AppStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract AppStorage {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel");
                        bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId");
                        */
                        bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b;
                        bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b;
                    
                        function kernel() public view returns (IKernel) {
                            return IKernel(KERNEL_POSITION.getStorageAddress());
                        }
                    
                        function appId() public view returns (bytes32) {
                            return APP_ID_POSITION.getStorageBytes32();
                        }
                    
                        function setKernel(IKernel _kernel) internal {
                            KERNEL_POSITION.setStorageAddress(address(_kernel));
                        }
                    
                        function setAppId(bytes32 _appId) internal {
                            APP_ID_POSITION.setStorageBytes32(_appId);
                        }
                    }
                    
                    // File: contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: contracts/lib/misc/ERCProxy.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ERCProxy {
                        uint256 internal constant FORWARDING = 1;
                        uint256 internal constant UPGRADEABLE = 2;
                    
                        function proxyType() public pure returns (uint256 proxyTypeId);
                        function implementation() public view returns (address codeAddr);
                    }
                    
                    // File: contracts/common/DelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DelegateProxy is ERCProxy, IsContract {
                        uint256 internal constant FWD_GAS_LIMIT = 10000;
                    
                        /**
                        * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
                        * @param _dst Destination address to perform the delegatecall
                        * @param _calldata Calldata for the delegatecall
                        */
                        function delegatedFwd(address _dst, bytes _calldata) internal {
                            require(isContract(_dst));
                            uint256 fwdGasLimit = FWD_GAS_LIMIT;
                    
                            assembly {
                                let result := delegatecall(sub(gas, fwdGasLimit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
                                let size := returndatasize
                                let ptr := mload(0x40)
                                returndatacopy(ptr, 0, size)
                    
                                // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
                                // if the call returned error data, forward it
                                switch result case 0 { revert(ptr, size) }
                                default { return(ptr, size) }
                            }
                        }
                    }
                    
                    // File: contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: contracts/common/DepositableDelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DepositableDelegateProxy is DepositableStorage, DelegateProxy {
                        event ProxyDeposit(address sender, uint256 value);
                    
                        function () external payable {
                            uint256 forwardGasThreshold = FWD_GAS_LIMIT;
                            bytes32 isDepositablePosition = DEPOSITABLE_POSITION;
                    
                            // Optimized assembly implementation to prevent EIP-1884 from breaking deposits, reference code in Solidity:
                            // https://github.com/aragon/aragonOS/blob/v4.2.1/contracts/common/DepositableDelegateProxy.sol#L10-L20
                            assembly {
                                // Continue only if the gas left is lower than the threshold for forwarding to the implementation code,
                                // otherwise continue outside of the assembly block.
                                if lt(gas, forwardGasThreshold) {
                                    // Only accept the deposit and emit an event if all of the following are true:
                                    // the proxy accepts deposits (isDepositable), msg.data.length == 0, and msg.value > 0
                                    if and(and(sload(isDepositablePosition), iszero(calldatasize)), gt(callvalue, 0)) {
                                        // Equivalent Solidity code for emitting the event:
                                        // emit ProxyDeposit(msg.sender, msg.value);
                    
                                        let logData := mload(0x40) // free memory pointer
                                        mstore(logData, caller) // add 'msg.sender' to the log data (first event param)
                                        mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
                    
                                        // Emit an event with one topic to identify the event: keccak256('ProxyDeposit(address,uint256)') = 0x15ee...dee1
                                        log1(logData, 0x40, 0x15eeaa57c7bd188c1388020bcadc2c436ec60d647d36ef5b9eb3c742217ddee1)
                    
                                        stop() // Stop. Exits execution context
                                    }
                    
                                    // If any of above checks failed, revert the execution (if ETH was sent, it is returned to the sender)
                                    revert(0, 0)
                                }
                            }
                    
                            address target = implementation();
                            delegatedFwd(target, msg.data);
                        }
                    }
                    
                    // File: contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: contracts/apps/AppProxyBase.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelNamespaceConstants {
                        /**
                        * @dev Initialize AppProxy
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
                            setKernel(_kernel);
                            setAppId(_appId);
                    
                            // Implicit check that kernel is actually a Kernel
                            // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
                            // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
                            // it.
                            address appCode = getAppBase(_appId);
                    
                            // If initialize payload is provided, it will be executed
                            if (_initializePayload.length > 0) {
                                require(isContract(appCode));
                                // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
                                // returns ending execution context and halts contract deployment
                                require(appCode.delegatecall(_initializePayload));
                            }
                        }
                    
                        function getAppBase(bytes32 _appId) internal view returns (address) {
                            return kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId);
                        }
                    }
                    
                    // File: contracts/apps/AppProxyUpgradeable.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract AppProxyUpgradeable is AppProxyBase {
                        /**
                        * @dev Initialize AppProxyUpgradeable (makes it an upgradeable Aragon app)
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
                            AppProxyBase(_kernel, _appId, _initializePayload)
                            public // solium-disable-line visibility-first
                        {
                            // solium-disable-previous-line no-empty-blocks
                        }
                    
                        /**
                         * @dev ERC897, the address the proxy would delegate calls to
                         */
                        function implementation() public view returns (address) {
                            return getAppBase(appId());
                        }
                    
                        /**
                         * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy
                         */
                        function proxyType() public pure returns (uint256 proxyTypeId) {
                            return UPGRADEABLE;
                        }
                    }

                    File 4 of 8: KernelProxy
                    // File: contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: contracts/kernel/KernelStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    contract KernelStorage {
                        // namespace => app id => address
                        mapping (bytes32 => mapping (bytes32 => address)) public apps;
                        bytes32 public recoveryVaultAppId;
                    }
                    
                    // File: contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: contracts/lib/misc/ERCProxy.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ERCProxy {
                        uint256 internal constant FORWARDING = 1;
                        uint256 internal constant UPGRADEABLE = 2;
                    
                        function proxyType() public pure returns (uint256 proxyTypeId);
                        function implementation() public view returns (address codeAddr);
                    }
                    
                    // File: contracts/common/DelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DelegateProxy is ERCProxy, IsContract {
                        uint256 internal constant FWD_GAS_LIMIT = 10000;
                    
                        /**
                        * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
                        * @param _dst Destination address to perform the delegatecall
                        * @param _calldata Calldata for the delegatecall
                        */
                        function delegatedFwd(address _dst, bytes _calldata) internal {
                            require(isContract(_dst));
                            uint256 fwdGasLimit = FWD_GAS_LIMIT;
                    
                            assembly {
                                let result := delegatecall(sub(gas, fwdGasLimit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
                                let size := returndatasize
                                let ptr := mload(0x40)
                                returndatacopy(ptr, 0, size)
                    
                                // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
                                // if the call returned error data, forward it
                                switch result case 0 { revert(ptr, size) }
                                default { return(ptr, size) }
                            }
                        }
                    }
                    
                    // File: contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: contracts/common/DepositableDelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DepositableDelegateProxy is DepositableStorage, DelegateProxy {
                        event ProxyDeposit(address sender, uint256 value);
                    
                        function () external payable {
                            uint256 forwardGasThreshold = FWD_GAS_LIMIT;
                            bytes32 isDepositablePosition = DEPOSITABLE_POSITION;
                    
                            // Optimized assembly implementation to prevent EIP-1884 from breaking deposits, reference code in Solidity:
                            // https://github.com/aragon/aragonOS/blob/v4.2.1/contracts/common/DepositableDelegateProxy.sol#L10-L20
                            assembly {
                                // Continue only if the gas left is lower than the threshold for forwarding to the implementation code,
                                // otherwise continue outside of the assembly block.
                                if lt(gas, forwardGasThreshold) {
                                    // Only accept the deposit and emit an event if all of the following are true:
                                    // the proxy accepts deposits (isDepositable), msg.data.length == 0, and msg.value > 0
                                    if and(and(sload(isDepositablePosition), iszero(calldatasize)), gt(callvalue, 0)) {
                                        // Equivalent Solidity code for emitting the event:
                                        // emit ProxyDeposit(msg.sender, msg.value);
                    
                                        let logData := mload(0x40) // free memory pointer
                                        mstore(logData, caller) // add 'msg.sender' to the log data (first event param)
                                        mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
                    
                                        // Emit an event with one topic to identify the event: keccak256('ProxyDeposit(address,uint256)') = 0x15ee...dee1
                                        log1(logData, 0x40, 0x15eeaa57c7bd188c1388020bcadc2c436ec60d647d36ef5b9eb3c742217ddee1)
                    
                                        stop() // Stop. Exits execution context
                                    }
                    
                                    // If any of above checks failed, revert the execution (if ETH was sent, it is returned to the sender)
                                    revert(0, 0)
                                }
                            }
                    
                            address target = implementation();
                            delegatedFwd(target, msg.data);
                        }
                    }
                    
                    // File: contracts/kernel/KernelProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract KernelProxy is IKernelEvents, KernelStorage, KernelAppIds, KernelNamespaceConstants, IsContract, DepositableDelegateProxy {
                        /**
                        * @dev KernelProxy is a proxy contract to a kernel implementation. The implementation
                        *      can update the reference, which effectively upgrades the contract
                        * @param _kernelImpl Address of the contract used as implementation for kernel
                        */
                        constructor(IKernel _kernelImpl) public {
                            require(isContract(address(_kernelImpl)));
                            apps[KERNEL_CORE_NAMESPACE][KERNEL_CORE_APP_ID] = _kernelImpl;
                    
                            // Note that emitting this event is important for verifying that a KernelProxy instance
                            // was never upgraded to a malicious Kernel logic contract over its lifespan.
                            // This starts the "chain of trust", that can be followed through later SetApp() events
                            // emitted during kernel upgrades.
                            emit SetApp(KERNEL_CORE_NAMESPACE, KERNEL_CORE_APP_ID, _kernelImpl);
                        }
                    
                        /**
                         * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy
                         */
                        function proxyType() public pure returns (uint256 proxyTypeId) {
                            return UPGRADEABLE;
                        }
                    
                        /**
                        * @dev ERC897, the address the proxy would delegate calls to
                        */
                        function implementation() public view returns (address) {
                            return apps[KERNEL_CORE_NAMESPACE][KERNEL_CORE_APP_ID];
                        }
                    }

                    File 5 of 8: Kernel
                    // File: contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: contracts/kernel/KernelStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    contract KernelStorage {
                        // namespace => app id => address
                        mapping (bytes32 => mapping (bytes32 => address)) public apps;
                        bytes32 public recoveryVaultAppId;
                    }
                    
                    // File: contracts/acl/ACLSyntaxSugar.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ACLSyntaxSugar {
                        function arr() internal pure returns (uint256[]) {
                            return new uint256[](0);
                        }
                    
                        function arr(bytes32 _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(address _a, address _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c);
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c, _d);
                        }
                    
                        function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), _c, _d, _e);
                        }
                    
                        function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(uint256 _a) internal pure returns (uint256[] r) {
                            r = new uint256[](1);
                            r[0] = _a;
                        }
                    
                        function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) {
                            r = new uint256[](2);
                            r[0] = _a;
                            r[1] = _b;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            r = new uint256[](3);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            r = new uint256[](4);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            r = new uint256[](5);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                            r[4] = _e;
                        }
                    }
                    
                    
                    contract ACLHelpers {
                        function decodeParamOp(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 30));
                        }
                    
                        function decodeParamId(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 31));
                        }
                    
                        function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) {
                            a = uint32(_x);
                            b = uint32(_x >> (8 * 4));
                            c = uint32(_x >> (8 * 8));
                        }
                    }
                    
                    // File: contracts/common/ConversionHelpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library ConversionHelpers {
                        string private constant ERROR_IMPROPER_LENGTH = "CONVERSION_IMPROPER_LENGTH";
                    
                        function dangerouslyCastUintArrayToBytes(uint256[] memory _input) internal pure returns (bytes memory output) {
                            // Force cast the uint256[] into a bytes array, by overwriting its length
                            // Note that the bytes array doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 byteLength = _input.length * 32;
                            assembly {
                                output := _input
                                mstore(output, byteLength)
                            }
                        }
                    
                        function dangerouslyCastBytesToUintArray(bytes memory _input) internal pure returns (uint256[] memory output) {
                            // Force cast the bytes array into a uint256[], by overwriting its length
                            // Note that the uint256[] doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 intsLength = _input.length / 32;
                            require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH);
                    
                            assembly {
                                output := _input
                                mstore(output, intsLength)
                            }
                        }
                    }
                    
                    // File: contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: contracts/common/Uint256Helpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library Uint256Helpers {
                        uint256 private constant MAX_UINT64 = uint64(-1);
                    
                        string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
                    
                        function toUint64(uint256 a) internal pure returns (uint64) {
                            require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG);
                            return uint64(a);
                        }
                    }
                    
                    // File: contracts/common/TimeHelpers.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract TimeHelpers {
                        using Uint256Helpers for uint256;
                    
                        /**
                        * @dev Returns the current block number.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber() internal view returns (uint256) {
                            return block.number;
                        }
                    
                        /**
                        * @dev Returns the current block number, converted to uint64.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber64() internal view returns (uint64) {
                            return getBlockNumber().toUint64();
                        }
                    
                        /**
                        * @dev Returns the current timestamp.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp() internal view returns (uint256) {
                            return block.timestamp; // solium-disable-line security/no-block-members
                        }
                    
                        /**
                        * @dev Returns the current timestamp, converted to uint64.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp64() internal view returns (uint64) {
                            return getTimestamp().toUint64();
                        }
                    }
                    
                    // File: contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: contracts/common/Initializable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract Initializable is TimeHelpers {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.initializable.initializationBlock")
                        bytes32 internal constant INITIALIZATION_BLOCK_POSITION = 0xebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e;
                    
                        string private constant ERROR_ALREADY_INITIALIZED = "INIT_ALREADY_INITIALIZED";
                        string private constant ERROR_NOT_INITIALIZED = "INIT_NOT_INITIALIZED";
                    
                        modifier onlyInit {
                            require(getInitializationBlock() == 0, ERROR_ALREADY_INITIALIZED);
                            _;
                        }
                    
                        modifier isInitialized {
                            require(hasInitialized(), ERROR_NOT_INITIALIZED);
                            _;
                        }
                    
                        /**
                        * @return Block number in which the contract was initialized
                        */
                        function getInitializationBlock() public view returns (uint256) {
                            return INITIALIZATION_BLOCK_POSITION.getStorageUint256();
                        }
                    
                        /**
                        * @return Whether the contract has been initialized by the time of the current block
                        */
                        function hasInitialized() public view returns (bool) {
                            uint256 initializationBlock = getInitializationBlock();
                            return initializationBlock != 0 && getBlockNumber() >= initializationBlock;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization has finished.
                        */
                        function initialized() internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(getBlockNumber());
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization to enable the contract
                        *      at a future block number rather than immediately.
                        */
                        function initializedAt(uint256 _blockNumber) internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber);
                        }
                    }
                    
                    // File: contracts/common/Petrifiable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract Petrifiable is Initializable {
                        // Use block UINT256_MAX (which should be never) as the initializable date
                        uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
                    
                        function isPetrified() public view returns (bool) {
                            return getInitializationBlock() == PETRIFIED_BLOCK;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract to prevent being initialized.
                        *      Useful for freezing base contracts when they're used behind proxies.
                        */
                        function petrify() internal onlyInit {
                            initializedAt(PETRIFIED_BLOCK);
                        }
                    }
                    
                    // File: contracts/lib/token/ERC20.sol
                    
                    // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title ERC20 interface
                     * @dev see https://github.com/ethereum/EIPs/issues/20
                     */
                    contract ERC20 {
                        function totalSupply() public view returns (uint256);
                    
                        function balanceOf(address _who) public view returns (uint256);
                    
                        function allowance(address _owner, address _spender)
                            public view returns (uint256);
                    
                        function transfer(address _to, uint256 _value) public returns (bool);
                    
                        function approve(address _spender, uint256 _value)
                            public returns (bool);
                    
                        function transferFrom(address _from, address _to, uint256 _value)
                            public returns (bool);
                    
                        event Transfer(
                            address indexed from,
                            address indexed to,
                            uint256 value
                        );
                    
                        event Approval(
                            address indexed owner,
                            address indexed spender,
                            uint256 value
                        );
                    }
                    
                    // File: contracts/common/EtherTokenConstant.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    // aragonOS and aragon-apps rely on address(0) to denote native ETH, in
                    // contracts where both tokens and ETH are accepted
                    contract EtherTokenConstant {
                        address internal constant ETH = address(0);
                    }
                    
                    // File: contracts/common/SafeERC20.sol
                    
                    // Inspired by AdEx (https://github.com/AdExNetwork/adex-protocol-eth/blob/b9df617829661a7518ee10f4cb6c4108659dd6d5/contracts/libs/SafeERC20.sol)
                    // and 0x (https://github.com/0xProject/0x-monorepo/blob/737d1dc54d72872e24abce5a1dbe1b66d35fa21a/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol#L143)
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    library SafeERC20 {
                        // Before 0.5, solidity has a mismatch between `address.transfer()` and `token.transfer()`:
                        // https://github.com/ethereum/solidity/issues/3544
                        bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb;
                    
                        string private constant ERROR_TOKEN_BALANCE_REVERTED = "SAFE_ERC_20_BALANCE_REVERTED";
                        string private constant ERROR_TOKEN_ALLOWANCE_REVERTED = "SAFE_ERC_20_ALLOWANCE_REVERTED";
                    
                        function invokeAndCheckSuccess(address _addr, bytes memory _calldata)
                            private
                            returns (bool)
                        {
                            bool ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                let success := call(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    0,                    // no value
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    // Check number of bytes returned from last function call
                                    switch returndatasize
                    
                                    // No bytes returned: assume success
                                    case 0 {
                                        ret := 1
                                    }
                    
                                    // 32 bytes returned: check if non-zero
                                    case 0x20 {
                                        // Only return success if returned data was true
                                        // Already have output in ptr
                                        ret := eq(mload(ptr), 1)
                                    }
                    
                                    // Not sure what was returned: don't mark as success
                                    default { }
                                }
                            }
                            return ret;
                        }
                    
                        function staticInvoke(address _addr, bytes memory _calldata)
                            private
                            view
                            returns (bool, uint256)
                        {
                            bool success;
                            uint256 ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                success := staticcall(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    ret := mload(ptr)
                                }
                            }
                            return (success, ret);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transfer() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransfer(ERC20 _token, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferCallData = abi.encodeWithSelector(
                                TRANSFER_SELECTOR,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transferFrom() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransferFrom(ERC20 _token, address _from, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferFromCallData = abi.encodeWithSelector(
                                _token.transferFrom.selector,
                                _from,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferFromCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.approve() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeApprove(ERC20 _token, address _spender, uint256 _amount) internal returns (bool) {
                            bytes memory approveCallData = abi.encodeWithSelector(
                                _token.approve.selector,
                                _spender,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, approveCallData);
                        }
                    
                        /**
                        * @dev Static call into ERC20.balanceOf().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticBalanceOf(ERC20 _token, address _owner) internal view returns (uint256) {
                            bytes memory balanceOfCallData = abi.encodeWithSelector(
                                _token.balanceOf.selector,
                                _owner
                            );
                    
                            (bool success, uint256 tokenBalance) = staticInvoke(_token, balanceOfCallData);
                            require(success, ERROR_TOKEN_BALANCE_REVERTED);
                    
                            return tokenBalance;
                        }
                    
                        /**
                        * @dev Static call into ERC20.allowance().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) {
                            bytes memory allowanceCallData = abi.encodeWithSelector(
                                _token.allowance.selector,
                                _owner,
                                _spender
                            );
                    
                            (bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData);
                            require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
                    
                            return allowance;
                        }
                    
                        /**
                        * @dev Static call into ERC20.totalSupply().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticTotalSupply(ERC20 _token) internal view returns (uint256) {
                            bytes memory totalSupplyCallData = abi.encodeWithSelector(_token.totalSupply.selector);
                    
                            (bool success, uint256 totalSupply) = staticInvoke(_token, totalSupplyCallData);
                            require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
                    
                            return totalSupply;
                        }
                    }
                    
                    // File: contracts/common/VaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract {
                        using SafeERC20 for ERC20;
                    
                        string private constant ERROR_DISALLOWED = "RECOVER_DISALLOWED";
                        string private constant ERROR_VAULT_NOT_CONTRACT = "RECOVER_VAULT_NOT_CONTRACT";
                        string private constant ERROR_TOKEN_TRANSFER_FAILED = "RECOVER_TOKEN_TRANSFER_FAILED";
                    
                        /**
                         * @notice Send funds to recovery Vault. This contract should never receive funds,
                         *         but in case it does, this function allows one to recover them.
                         * @param _token Token balance to be sent to recovery vault.
                         */
                        function transferToVault(address _token) external {
                            require(allowRecoverability(_token), ERROR_DISALLOWED);
                            address vault = getRecoveryVault();
                            require(isContract(vault), ERROR_VAULT_NOT_CONTRACT);
                    
                            uint256 balance;
                            if (_token == ETH) {
                                balance = address(this).balance;
                                vault.transfer(balance);
                            } else {
                                ERC20 token = ERC20(_token);
                                balance = token.staticBalanceOf(this);
                                require(token.safeTransfer(vault, balance), ERROR_TOKEN_TRANSFER_FAILED);
                            }
                    
                            emit RecoverToVault(vault, _token, balance);
                        }
                    
                        /**
                        * @dev By default deriving from AragonApp makes it recoverable
                        * @param token Token address that would be recovered
                        * @return bool whether the app allows the recovery
                        */
                        function allowRecoverability(address token) public view returns (bool) {
                            return true;
                        }
                    
                        // Cast non-implemented interface to be public so we can use it internally
                        function getRecoveryVault() public view returns (address);
                    }
                    
                    // File: contracts/apps/AppStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract AppStorage {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel");
                        bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId");
                        */
                        bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b;
                        bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b;
                    
                        function kernel() public view returns (IKernel) {
                            return IKernel(KERNEL_POSITION.getStorageAddress());
                        }
                    
                        function appId() public view returns (bytes32) {
                            return APP_ID_POSITION.getStorageBytes32();
                        }
                    
                        function setKernel(IKernel _kernel) internal {
                            KERNEL_POSITION.setStorageAddress(address(_kernel));
                        }
                    
                        function setAppId(bytes32 _appId) internal {
                            APP_ID_POSITION.setStorageBytes32(_appId);
                        }
                    }
                    
                    // File: contracts/lib/misc/ERCProxy.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ERCProxy {
                        uint256 internal constant FORWARDING = 1;
                        uint256 internal constant UPGRADEABLE = 2;
                    
                        function proxyType() public pure returns (uint256 proxyTypeId);
                        function implementation() public view returns (address codeAddr);
                    }
                    
                    // File: contracts/common/DelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DelegateProxy is ERCProxy, IsContract {
                        uint256 internal constant FWD_GAS_LIMIT = 10000;
                    
                        /**
                        * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
                        * @param _dst Destination address to perform the delegatecall
                        * @param _calldata Calldata for the delegatecall
                        */
                        function delegatedFwd(address _dst, bytes _calldata) internal {
                            require(isContract(_dst));
                            uint256 fwdGasLimit = FWD_GAS_LIMIT;
                    
                            assembly {
                                let result := delegatecall(sub(gas, fwdGasLimit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
                                let size := returndatasize
                                let ptr := mload(0x40)
                                returndatacopy(ptr, 0, size)
                    
                                // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
                                // if the call returned error data, forward it
                                switch result case 0 { revert(ptr, size) }
                                default { return(ptr, size) }
                            }
                        }
                    }
                    
                    // File: contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: contracts/common/DepositableDelegateProxy.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract DepositableDelegateProxy is DepositableStorage, DelegateProxy {
                        event ProxyDeposit(address sender, uint256 value);
                    
                        function () external payable {
                            uint256 forwardGasThreshold = FWD_GAS_LIMIT;
                            bytes32 isDepositablePosition = DEPOSITABLE_POSITION;
                    
                            // Optimized assembly implementation to prevent EIP-1884 from breaking deposits, reference code in Solidity:
                            // https://github.com/aragon/aragonOS/blob/v4.2.1/contracts/common/DepositableDelegateProxy.sol#L10-L20
                            assembly {
                                // Continue only if the gas left is lower than the threshold for forwarding to the implementation code,
                                // otherwise continue outside of the assembly block.
                                if lt(gas, forwardGasThreshold) {
                                    // Only accept the deposit and emit an event if all of the following are true:
                                    // the proxy accepts deposits (isDepositable), msg.data.length == 0, and msg.value > 0
                                    if and(and(sload(isDepositablePosition), iszero(calldatasize)), gt(callvalue, 0)) {
                                        // Equivalent Solidity code for emitting the event:
                                        // emit ProxyDeposit(msg.sender, msg.value);
                    
                                        let logData := mload(0x40) // free memory pointer
                                        mstore(logData, caller) // add 'msg.sender' to the log data (first event param)
                                        mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
                    
                                        // Emit an event with one topic to identify the event: keccak256('ProxyDeposit(address,uint256)') = 0x15ee...dee1
                                        log1(logData, 0x40, 0x15eeaa57c7bd188c1388020bcadc2c436ec60d647d36ef5b9eb3c742217ddee1)
                    
                                        stop() // Stop. Exits execution context
                                    }
                    
                                    // If any of above checks failed, revert the execution (if ETH was sent, it is returned to the sender)
                                    revert(0, 0)
                                }
                            }
                    
                            address target = implementation();
                            delegatedFwd(target, msg.data);
                        }
                    }
                    
                    // File: contracts/apps/AppProxyBase.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelNamespaceConstants {
                        /**
                        * @dev Initialize AppProxy
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
                            setKernel(_kernel);
                            setAppId(_appId);
                    
                            // Implicit check that kernel is actually a Kernel
                            // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
                            // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
                            // it.
                            address appCode = getAppBase(_appId);
                    
                            // If initialize payload is provided, it will be executed
                            if (_initializePayload.length > 0) {
                                require(isContract(appCode));
                                // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
                                // returns ending execution context and halts contract deployment
                                require(appCode.delegatecall(_initializePayload));
                            }
                        }
                    
                        function getAppBase(bytes32 _appId) internal view returns (address) {
                            return kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId);
                        }
                    }
                    
                    // File: contracts/apps/AppProxyUpgradeable.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract AppProxyUpgradeable is AppProxyBase {
                        /**
                        * @dev Initialize AppProxyUpgradeable (makes it an upgradeable Aragon app)
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
                            AppProxyBase(_kernel, _appId, _initializePayload)
                            public // solium-disable-line visibility-first
                        {
                            // solium-disable-previous-line no-empty-blocks
                        }
                    
                        /**
                         * @dev ERC897, the address the proxy would delegate calls to
                         */
                        function implementation() public view returns (address) {
                            return getAppBase(appId());
                        }
                    
                        /**
                         * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy
                         */
                        function proxyType() public pure returns (uint256 proxyTypeId) {
                            return UPGRADEABLE;
                        }
                    }
                    
                    // File: contracts/apps/AppProxyPinned.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    contract AppProxyPinned is IsContract, AppProxyBase {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.appStorage.pinnedCode")
                        bytes32 internal constant PINNED_CODE_POSITION = 0xdee64df20d65e53d7f51cb6ab6d921a0a6a638a91e942e1d8d02df28e31c038e;
                    
                        /**
                        * @dev Initialize AppProxyPinned (makes it an un-upgradeable Aragon app)
                        * @param _kernel Reference to organization kernel for the app
                        * @param _appId Identifier for app
                        * @param _initializePayload Payload for call to be made after setup to initialize
                        */
                        constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload)
                            AppProxyBase(_kernel, _appId, _initializePayload)
                            public // solium-disable-line visibility-first
                        {
                            setPinnedCode(getAppBase(_appId));
                            require(isContract(pinnedCode()));
                        }
                    
                        /**
                         * @dev ERC897, the address the proxy would delegate calls to
                         */
                        function implementation() public view returns (address) {
                            return pinnedCode();
                        }
                    
                        /**
                         * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy
                         */
                        function proxyType() public pure returns (uint256 proxyTypeId) {
                            return FORWARDING;
                        }
                    
                        function setPinnedCode(address _pinnedCode) internal {
                            PINNED_CODE_POSITION.setStorageAddress(_pinnedCode);
                        }
                    
                        function pinnedCode() internal view returns (address) {
                            return PINNED_CODE_POSITION.getStorageAddress();
                        }
                    }
                    
                    // File: contracts/factory/AppProxyFactory.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    contract AppProxyFactory {
                        event NewAppProxy(address proxy, bool isUpgradeable, bytes32 appId);
                    
                        /**
                        * @notice Create a new upgradeable app instance on `_kernel` with identifier `_appId`
                        * @param _kernel App's Kernel reference
                        * @param _appId Identifier for app
                        * @return AppProxyUpgradeable
                        */
                        function newAppProxy(IKernel _kernel, bytes32 _appId) public returns (AppProxyUpgradeable) {
                            return newAppProxy(_kernel, _appId, new bytes(0));
                        }
                    
                        /**
                        * @notice Create a new upgradeable app instance on `_kernel` with identifier `_appId` and initialization payload `_initializePayload`
                        * @param _kernel App's Kernel reference
                        * @param _appId Identifier for app
                        * @return AppProxyUpgradeable
                        */
                        function newAppProxy(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyUpgradeable) {
                            AppProxyUpgradeable proxy = new AppProxyUpgradeable(_kernel, _appId, _initializePayload);
                            emit NewAppProxy(address(proxy), true, _appId);
                            return proxy;
                        }
                    
                        /**
                        * @notice Create a new pinned app instance on `_kernel` with identifier `_appId`
                        * @param _kernel App's Kernel reference
                        * @param _appId Identifier for app
                        * @return AppProxyPinned
                        */
                        function newAppProxyPinned(IKernel _kernel, bytes32 _appId) public returns (AppProxyPinned) {
                            return newAppProxyPinned(_kernel, _appId, new bytes(0));
                        }
                    
                        /**
                        * @notice Create a new pinned app instance on `_kernel` with identifier `_appId` and initialization payload `_initializePayload`
                        * @param _kernel App's Kernel reference
                        * @param _appId Identifier for app
                        * @param _initializePayload Proxy initialization payload
                        * @return AppProxyPinned
                        */
                        function newAppProxyPinned(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyPinned) {
                            AppProxyPinned proxy = new AppProxyPinned(_kernel, _appId, _initializePayload);
                            emit NewAppProxy(address(proxy), false, _appId);
                            return proxy;
                        }
                    }
                    
                    // File: contracts/kernel/Kernel.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    // solium-disable-next-line max-len
                    contract Kernel is IKernel, KernelStorage, KernelAppIds, KernelNamespaceConstants, Petrifiable, IsContract, VaultRecoverable, AppProxyFactory, ACLSyntaxSugar {
                        /* Hardcoded constants to save gas
                        bytes32 public constant APP_MANAGER_ROLE = keccak256("APP_MANAGER_ROLE");
                        */
                        bytes32 public constant APP_MANAGER_ROLE = 0xb6d92708f3d4817afc106147d969e229ced5c46e65e0a5002a0d391287762bd0;
                    
                        string private constant ERROR_APP_NOT_CONTRACT = "KERNEL_APP_NOT_CONTRACT";
                        string private constant ERROR_INVALID_APP_CHANGE = "KERNEL_INVALID_APP_CHANGE";
                        string private constant ERROR_AUTH_FAILED = "KERNEL_AUTH_FAILED";
                    
                        /**
                        * @dev Constructor that allows the deployer to choose if the base instance should be petrified immediately.
                        * @param _shouldPetrify Immediately petrify this instance so that it can never be initialized
                        */
                        constructor(bool _shouldPetrify) public {
                            if (_shouldPetrify) {
                                petrify();
                            }
                        }
                    
                        /**
                        * @dev Initialize can only be called once. It saves the block number in which it was initialized.
                        * @notice Initialize this kernel instance along with its ACL and set `_permissionsCreator` as the entity that can create other permissions
                        * @param _baseAcl Address of base ACL app
                        * @param _permissionsCreator Entity that will be given permission over createPermission
                        */
                        function initialize(IACL _baseAcl, address _permissionsCreator) public onlyInit {
                            initialized();
                    
                            // Set ACL base
                            _setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl);
                    
                            // Create ACL instance and attach it as the default ACL app
                            IACL acl = IACL(newAppProxy(this, KERNEL_DEFAULT_ACL_APP_ID));
                            acl.initialize(_permissionsCreator);
                            _setApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, acl);
                    
                            recoveryVaultAppId = KERNEL_DEFAULT_VAULT_APP_ID;
                        }
                    
                        /**
                        * @dev Create a new instance of an app linked to this kernel
                        * @notice Create a new upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`
                        * @param _appId Identifier for app
                        * @param _appBase Address of the app's base implementation
                        * @return AppProxy instance
                        */
                        function newAppInstance(bytes32 _appId, address _appBase)
                            public
                            auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId))
                            returns (ERCProxy appProxy)
                        {
                            return newAppInstance(_appId, _appBase, new bytes(0), false);
                        }
                    
                        /**
                        * @dev Create a new instance of an app linked to this kernel and set its base
                        *      implementation if it was not already set
                        * @notice Create a new upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`. `_setDefault ? 'Also sets it as the default app instance.':''`
                        * @param _appId Identifier for app
                        * @param _appBase Address of the app's base implementation
                        * @param _initializePayload Payload for call made by the proxy during its construction to initialize
                        * @param _setDefault Whether the app proxy app is the default one.
                        *        Useful when the Kernel needs to know of an instance of a particular app,
                        *        like Vault for escape hatch mechanism.
                        * @return AppProxy instance
                        */
                        function newAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault)
                            public
                            auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId))
                            returns (ERCProxy appProxy)
                        {
                            _setAppIfNew(KERNEL_APP_BASES_NAMESPACE, _appId, _appBase);
                            appProxy = newAppProxy(this, _appId, _initializePayload);
                            // By calling setApp directly and not the internal functions, we make sure the params are checked
                            // and it will only succeed if sender has permissions to set something to the namespace.
                            if (_setDefault) {
                                setApp(KERNEL_APP_ADDR_NAMESPACE, _appId, appProxy);
                            }
                        }
                    
                        /**
                        * @dev Create a new pinned instance of an app linked to this kernel
                        * @notice Create a new non-upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`.
                        * @param _appId Identifier for app
                        * @param _appBase Address of the app's base implementation
                        * @return AppProxy instance
                        */
                        function newPinnedAppInstance(bytes32 _appId, address _appBase)
                            public
                            auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId))
                            returns (ERCProxy appProxy)
                        {
                            return newPinnedAppInstance(_appId, _appBase, new bytes(0), false);
                        }
                    
                        /**
                        * @dev Create a new pinned instance of an app linked to this kernel and set
                        *      its base implementation if it was not already set
                        * @notice Create a new non-upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`. `_setDefault ? 'Also sets it as the default app instance.':''`
                        * @param _appId Identifier for app
                        * @param _appBase Address of the app's base implementation
                        * @param _initializePayload Payload for call made by the proxy during its construction to initialize
                        * @param _setDefault Whether the app proxy app is the default one.
                        *        Useful when the Kernel needs to know of an instance of a particular app,
                        *        like Vault for escape hatch mechanism.
                        * @return AppProxy instance
                        */
                        function newPinnedAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault)
                            public
                            auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId))
                            returns (ERCProxy appProxy)
                        {
                            _setAppIfNew(KERNEL_APP_BASES_NAMESPACE, _appId, _appBase);
                            appProxy = newAppProxyPinned(this, _appId, _initializePayload);
                            // By calling setApp directly and not the internal functions, we make sure the params are checked
                            // and it will only succeed if sender has permissions to set something to the namespace.
                            if (_setDefault) {
                                setApp(KERNEL_APP_ADDR_NAMESPACE, _appId, appProxy);
                            }
                        }
                    
                        /**
                        * @dev Set the resolving address of an app instance or base implementation
                        * @notice Set the resolving address of `_appId` in namespace `_namespace` to `_app`
                        * @param _namespace App namespace to use
                        * @param _appId Identifier for app
                        * @param _app Address of the app instance or base implementation
                        * @return ID of app
                        */
                        function setApp(bytes32 _namespace, bytes32 _appId, address _app)
                            public
                            auth(APP_MANAGER_ROLE, arr(_namespace, _appId))
                        {
                            _setApp(_namespace, _appId, _app);
                        }
                    
                        /**
                        * @dev Set the default vault id for the escape hatch mechanism
                        * @param _recoveryVaultAppId Identifier of the recovery vault app
                        */
                        function setRecoveryVaultAppId(bytes32 _recoveryVaultAppId)
                            public
                            auth(APP_MANAGER_ROLE, arr(KERNEL_APP_ADDR_NAMESPACE, _recoveryVaultAppId))
                        {
                            recoveryVaultAppId = _recoveryVaultAppId;
                        }
                    
                        // External access to default app id and namespace constants to mimic default getters for constants
                        /* solium-disable function-order, mixedcase */
                        function CORE_NAMESPACE() external pure returns (bytes32) { return KERNEL_CORE_NAMESPACE; }
                        function APP_BASES_NAMESPACE() external pure returns (bytes32) { return KERNEL_APP_BASES_NAMESPACE; }
                        function APP_ADDR_NAMESPACE() external pure returns (bytes32) { return KERNEL_APP_ADDR_NAMESPACE; }
                        function KERNEL_APP_ID() external pure returns (bytes32) { return KERNEL_CORE_APP_ID; }
                        function DEFAULT_ACL_APP_ID() external pure returns (bytes32) { return KERNEL_DEFAULT_ACL_APP_ID; }
                        /* solium-enable function-order, mixedcase */
                    
                        /**
                        * @dev Get the address of an app instance or base implementation
                        * @param _namespace App namespace to use
                        * @param _appId Identifier for app
                        * @return Address of the app
                        */
                        function getApp(bytes32 _namespace, bytes32 _appId) public view returns (address) {
                            return apps[_namespace][_appId];
                        }
                    
                        /**
                        * @dev Get the address of the recovery Vault instance (to recover funds)
                        * @return Address of the Vault
                        */
                        function getRecoveryVault() public view returns (address) {
                            return apps[KERNEL_APP_ADDR_NAMESPACE][recoveryVaultAppId];
                        }
                    
                        /**
                        * @dev Get the installed ACL app
                        * @return ACL app
                        */
                        function acl() public view returns (IACL) {
                            return IACL(getApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID));
                        }
                    
                        /**
                        * @dev Function called by apps to check ACL on kernel or to check permission status
                        * @param _who Sender of the original call
                        * @param _where Address of the app
                        * @param _what Identifier for a group of actions in app
                        * @param _how Extra data for ACL auth
                        * @return Boolean indicating whether the ACL allows the role or not.
                        *         Always returns false if the kernel hasn't been initialized yet.
                        */
                        function hasPermission(address _who, address _where, bytes32 _what, bytes _how) public view returns (bool) {
                            IACL defaultAcl = acl();
                            return address(defaultAcl) != address(0) && // Poor man's initialization check (saves gas)
                                defaultAcl.hasPermission(_who, _where, _what, _how);
                        }
                    
                        function _setApp(bytes32 _namespace, bytes32 _appId, address _app) internal {
                            require(isContract(_app), ERROR_APP_NOT_CONTRACT);
                            apps[_namespace][_appId] = _app;
                            emit SetApp(_namespace, _appId, _app);
                        }
                    
                        function _setAppIfNew(bytes32 _namespace, bytes32 _appId, address _app) internal {
                            address app = getApp(_namespace, _appId);
                            if (app != address(0)) {
                                // The only way to set an app is if it passes the isContract check, so no need to check it again
                                require(app == _app, ERROR_INVALID_APP_CHANGE);
                            } else {
                                _setApp(_namespace, _appId, _app);
                            }
                        }
                    
                        modifier auth(bytes32 _role, uint256[] memory _params) {
                            require(
                                hasPermission(msg.sender, address(this), _role, ConversionHelpers.dangerouslyCastUintArrayToBytes(_params)),
                                ERROR_AUTH_FAILED
                            );
                            _;
                        }
                    }

                    File 6 of 8: Finance
                    // File: @aragon/os/contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: @aragon/os/contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: @aragon/os/contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/apps/AppStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract AppStorage {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel");
                        bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId");
                        */
                        bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b;
                        bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b;
                    
                        function kernel() public view returns (IKernel) {
                            return IKernel(KERNEL_POSITION.getStorageAddress());
                        }
                    
                        function appId() public view returns (bytes32) {
                            return APP_ID_POSITION.getStorageBytes32();
                        }
                    
                        function setKernel(IKernel _kernel) internal {
                            KERNEL_POSITION.setStorageAddress(address(_kernel));
                        }
                    
                        function setAppId(bytes32 _appId) internal {
                            APP_ID_POSITION.setStorageBytes32(_appId);
                        }
                    }
                    
                    // File: @aragon/os/contracts/acl/ACLSyntaxSugar.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ACLSyntaxSugar {
                        function arr() internal pure returns (uint256[]) {
                            return new uint256[](0);
                        }
                    
                        function arr(bytes32 _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(address _a, address _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c);
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c, _d);
                        }
                    
                        function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), _c, _d, _e);
                        }
                    
                        function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(uint256 _a) internal pure returns (uint256[] r) {
                            r = new uint256[](1);
                            r[0] = _a;
                        }
                    
                        function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) {
                            r = new uint256[](2);
                            r[0] = _a;
                            r[1] = _b;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            r = new uint256[](3);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            r = new uint256[](4);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            r = new uint256[](5);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                            r[4] = _e;
                        }
                    }
                    
                    
                    contract ACLHelpers {
                        function decodeParamOp(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 30));
                        }
                    
                        function decodeParamId(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 31));
                        }
                    
                        function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) {
                            a = uint32(_x);
                            b = uint32(_x >> (8 * 4));
                            c = uint32(_x >> (8 * 8));
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Uint256Helpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library Uint256Helpers {
                        uint256 private constant MAX_UINT64 = uint64(-1);
                    
                        string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
                    
                        function toUint64(uint256 a) internal pure returns (uint64) {
                            require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG);
                            return uint64(a);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/TimeHelpers.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract TimeHelpers {
                        using Uint256Helpers for uint256;
                    
                        /**
                        * @dev Returns the current block number.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber() internal view returns (uint256) {
                            return block.number;
                        }
                    
                        /**
                        * @dev Returns the current block number, converted to uint64.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber64() internal view returns (uint64) {
                            return getBlockNumber().toUint64();
                        }
                    
                        /**
                        * @dev Returns the current timestamp.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp() internal view returns (uint256) {
                            return block.timestamp; // solium-disable-line security/no-block-members
                        }
                    
                        /**
                        * @dev Returns the current timestamp, converted to uint64.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp64() internal view returns (uint64) {
                            return getTimestamp().toUint64();
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Initializable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract Initializable is TimeHelpers {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.initializable.initializationBlock")
                        bytes32 internal constant INITIALIZATION_BLOCK_POSITION = 0xebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e;
                    
                        string private constant ERROR_ALREADY_INITIALIZED = "INIT_ALREADY_INITIALIZED";
                        string private constant ERROR_NOT_INITIALIZED = "INIT_NOT_INITIALIZED";
                    
                        modifier onlyInit {
                            require(getInitializationBlock() == 0, ERROR_ALREADY_INITIALIZED);
                            _;
                        }
                    
                        modifier isInitialized {
                            require(hasInitialized(), ERROR_NOT_INITIALIZED);
                            _;
                        }
                    
                        /**
                        * @return Block number in which the contract was initialized
                        */
                        function getInitializationBlock() public view returns (uint256) {
                            return INITIALIZATION_BLOCK_POSITION.getStorageUint256();
                        }
                    
                        /**
                        * @return Whether the contract has been initialized by the time of the current block
                        */
                        function hasInitialized() public view returns (bool) {
                            uint256 initializationBlock = getInitializationBlock();
                            return initializationBlock != 0 && getBlockNumber() >= initializationBlock;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization has finished.
                        */
                        function initialized() internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(getBlockNumber());
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization to enable the contract
                        *      at a future block number rather than immediately.
                        */
                        function initializedAt(uint256 _blockNumber) internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Petrifiable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract Petrifiable is Initializable {
                        // Use block UINT256_MAX (which should be never) as the initializable date
                        uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
                    
                        function isPetrified() public view returns (bool) {
                            return getInitializationBlock() == PETRIFIED_BLOCK;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract to prevent being initialized.
                        *      Useful for freezing base contracts when they're used behind proxies.
                        */
                        function petrify() internal onlyInit {
                            initializedAt(PETRIFIED_BLOCK);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Autopetrified.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract Autopetrified is Petrifiable {
                        constructor() public {
                            // Immediately petrify base (non-proxy) instances of inherited contracts on deploy.
                            // This renders them uninitializable (and unusable without a proxy).
                            petrify();
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/ConversionHelpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library ConversionHelpers {
                        string private constant ERROR_IMPROPER_LENGTH = "CONVERSION_IMPROPER_LENGTH";
                    
                        function dangerouslyCastUintArrayToBytes(uint256[] memory _input) internal pure returns (bytes memory output) {
                            // Force cast the uint256[] into a bytes array, by overwriting its length
                            // Note that the bytes array doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 byteLength = _input.length * 32;
                            assembly {
                                output := _input
                                mstore(output, byteLength)
                            }
                        }
                    
                        function dangerouslyCastBytesToUintArray(bytes memory _input) internal pure returns (uint256[] memory output) {
                            // Force cast the bytes array into a uint256[], by overwriting its length
                            // Note that the uint256[] doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 intsLength = _input.length / 32;
                            require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH);
                    
                            assembly {
                                output := _input
                                mstore(output, intsLength)
                            }
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/ReentrancyGuard.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract ReentrancyGuard {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant REENTRANCY_MUTEX_POSITION = keccak256("aragonOS.reentrancyGuard.mutex");
                        */
                        bytes32 private constant REENTRANCY_MUTEX_POSITION = 0xe855346402235fdd185c890e68d2c4ecad599b88587635ee285bce2fda58dacb;
                    
                        string private constant ERROR_REENTRANT = "REENTRANCY_REENTRANT_CALL";
                    
                        modifier nonReentrant() {
                            // Ensure mutex is unlocked
                            require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT);
                    
                            // Lock mutex before function call
                            REENTRANCY_MUTEX_POSITION.setStorageBool(true);
                    
                            // Perform function call
                            _;
                    
                            // Unlock mutex after function call
                            REENTRANCY_MUTEX_POSITION.setStorageBool(false);
                        }
                    }
                    
                    // File: @aragon/os/contracts/lib/token/ERC20.sol
                    
                    // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title ERC20 interface
                     * @dev see https://github.com/ethereum/EIPs/issues/20
                     */
                    contract ERC20 {
                        function totalSupply() public view returns (uint256);
                    
                        function balanceOf(address _who) public view returns (uint256);
                    
                        function allowance(address _owner, address _spender)
                            public view returns (uint256);
                    
                        function transfer(address _to, uint256 _value) public returns (bool);
                    
                        function approve(address _spender, uint256 _value)
                            public returns (bool);
                    
                        function transferFrom(address _from, address _to, uint256 _value)
                            public returns (bool);
                    
                        event Transfer(
                            address indexed from,
                            address indexed to,
                            uint256 value
                        );
                    
                        event Approval(
                            address indexed owner,
                            address indexed spender,
                            uint256 value
                        );
                    }
                    
                    // File: @aragon/os/contracts/common/EtherTokenConstant.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    // aragonOS and aragon-apps rely on address(0) to denote native ETH, in
                    // contracts where both tokens and ETH are accepted
                    contract EtherTokenConstant {
                        address internal constant ETH = address(0);
                    }
                    
                    // File: @aragon/os/contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/SafeERC20.sol
                    
                    // Inspired by AdEx (https://github.com/AdExNetwork/adex-protocol-eth/blob/b9df617829661a7518ee10f4cb6c4108659dd6d5/contracts/libs/SafeERC20.sol)
                    // and 0x (https://github.com/0xProject/0x-monorepo/blob/737d1dc54d72872e24abce5a1dbe1b66d35fa21a/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol#L143)
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    library SafeERC20 {
                        // Before 0.5, solidity has a mismatch between `address.transfer()` and `token.transfer()`:
                        // https://github.com/ethereum/solidity/issues/3544
                        bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb;
                    
                        string private constant ERROR_TOKEN_BALANCE_REVERTED = "SAFE_ERC_20_BALANCE_REVERTED";
                        string private constant ERROR_TOKEN_ALLOWANCE_REVERTED = "SAFE_ERC_20_ALLOWANCE_REVERTED";
                    
                        function invokeAndCheckSuccess(address _addr, bytes memory _calldata)
                            private
                            returns (bool)
                        {
                            bool ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                let success := call(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    0,                    // no value
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    // Check number of bytes returned from last function call
                                    switch returndatasize
                    
                                    // No bytes returned: assume success
                                    case 0 {
                                        ret := 1
                                    }
                    
                                    // 32 bytes returned: check if non-zero
                                    case 0x20 {
                                        // Only return success if returned data was true
                                        // Already have output in ptr
                                        ret := eq(mload(ptr), 1)
                                    }
                    
                                    // Not sure what was returned: don't mark as success
                                    default { }
                                }
                            }
                            return ret;
                        }
                    
                        function staticInvoke(address _addr, bytes memory _calldata)
                            private
                            view
                            returns (bool, uint256)
                        {
                            bool success;
                            uint256 ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                success := staticcall(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    ret := mload(ptr)
                                }
                            }
                            return (success, ret);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transfer() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransfer(ERC20 _token, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferCallData = abi.encodeWithSelector(
                                TRANSFER_SELECTOR,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transferFrom() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransferFrom(ERC20 _token, address _from, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferFromCallData = abi.encodeWithSelector(
                                _token.transferFrom.selector,
                                _from,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferFromCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.approve() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeApprove(ERC20 _token, address _spender, uint256 _amount) internal returns (bool) {
                            bytes memory approveCallData = abi.encodeWithSelector(
                                _token.approve.selector,
                                _spender,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, approveCallData);
                        }
                    
                        /**
                        * @dev Static call into ERC20.balanceOf().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticBalanceOf(ERC20 _token, address _owner) internal view returns (uint256) {
                            bytes memory balanceOfCallData = abi.encodeWithSelector(
                                _token.balanceOf.selector,
                                _owner
                            );
                    
                            (bool success, uint256 tokenBalance) = staticInvoke(_token, balanceOfCallData);
                            require(success, ERROR_TOKEN_BALANCE_REVERTED);
                    
                            return tokenBalance;
                        }
                    
                        /**
                        * @dev Static call into ERC20.allowance().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) {
                            bytes memory allowanceCallData = abi.encodeWithSelector(
                                _token.allowance.selector,
                                _owner,
                                _spender
                            );
                    
                            (bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData);
                            require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
                    
                            return allowance;
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/VaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract {
                        using SafeERC20 for ERC20;
                    
                        string private constant ERROR_DISALLOWED = "RECOVER_DISALLOWED";
                        string private constant ERROR_VAULT_NOT_CONTRACT = "RECOVER_VAULT_NOT_CONTRACT";
                        string private constant ERROR_TOKEN_TRANSFER_FAILED = "RECOVER_TOKEN_TRANSFER_FAILED";
                    
                        /**
                         * @notice Send funds to recovery Vault. This contract should never receive funds,
                         *         but in case it does, this function allows one to recover them.
                         * @param _token Token balance to be sent to recovery vault.
                         */
                        function transferToVault(address _token) external {
                            require(allowRecoverability(_token), ERROR_DISALLOWED);
                            address vault = getRecoveryVault();
                            require(isContract(vault), ERROR_VAULT_NOT_CONTRACT);
                    
                            uint256 balance;
                            if (_token == ETH) {
                                balance = address(this).balance;
                                vault.transfer(balance);
                            } else {
                                ERC20 token = ERC20(_token);
                                balance = token.staticBalanceOf(this);
                                require(token.safeTransfer(vault, balance), ERROR_TOKEN_TRANSFER_FAILED);
                            }
                    
                            emit RecoverToVault(vault, _token, balance);
                        }
                    
                        /**
                        * @dev By default deriving from AragonApp makes it recoverable
                        * @param token Token address that would be recovered
                        * @return bool whether the app allows the recovery
                        */
                        function allowRecoverability(address token) public view returns (bool) {
                            return true;
                        }
                    
                        // Cast non-implemented interface to be public so we can use it internally
                        function getRecoveryVault() public view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/evmscript/IEVMScriptExecutor.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IEVMScriptExecutor {
                        function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes);
                        function executorType() external pure returns (bytes32);
                    }
                    
                    // File: @aragon/os/contracts/evmscript/IEVMScriptRegistry.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract EVMScriptRegistryConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = apmNamehash("evmreg");
                        */
                        bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = 0xddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd61;
                    }
                    
                    
                    interface IEVMScriptRegistry {
                        function addScriptExecutor(IEVMScriptExecutor executor) external returns (uint id);
                        function disableScriptExecutor(uint256 executorId) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function getScriptExecutor(bytes script) public view returns (IEVMScriptExecutor);
                    }
                    
                    // File: @aragon/os/contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: @aragon/os/contracts/evmscript/EVMScriptRunner.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract EVMScriptRunner is AppStorage, Initializable, EVMScriptRegistryConstants, KernelNamespaceConstants {
                        string private constant ERROR_EXECUTOR_UNAVAILABLE = "EVMRUN_EXECUTOR_UNAVAILABLE";
                        string private constant ERROR_PROTECTED_STATE_MODIFIED = "EVMRUN_PROTECTED_STATE_MODIFIED";
                    
                        /* This is manually crafted in assembly
                        string private constant ERROR_EXECUTOR_INVALID_RETURN = "EVMRUN_EXECUTOR_INVALID_RETURN";
                        */
                    
                        event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData);
                    
                        function getEVMScriptExecutor(bytes _script) public view returns (IEVMScriptExecutor) {
                            return IEVMScriptExecutor(getEVMScriptRegistry().getScriptExecutor(_script));
                        }
                    
                        function getEVMScriptRegistry() public view returns (IEVMScriptRegistry) {
                            address registryAddr = kernel().getApp(KERNEL_APP_ADDR_NAMESPACE, EVMSCRIPT_REGISTRY_APP_ID);
                            return IEVMScriptRegistry(registryAddr);
                        }
                    
                        function runScript(bytes _script, bytes _input, address[] _blacklist)
                            internal
                            isInitialized
                            protectState
                            returns (bytes)
                        {
                            IEVMScriptExecutor executor = getEVMScriptExecutor(_script);
                            require(address(executor) != address(0), ERROR_EXECUTOR_UNAVAILABLE);
                    
                            bytes4 sig = executor.execScript.selector;
                            bytes memory data = abi.encodeWithSelector(sig, _script, _input, _blacklist);
                    
                            bytes memory output;
                            assembly {
                                let success := delegatecall(
                                    gas,                // forward all gas
                                    executor,           // address
                                    add(data, 0x20),    // calldata start
                                    mload(data),        // calldata length
                                    0,                  // don't write output (we'll handle this ourselves)
                                    0                   // don't write output
                                )
                    
                                output := mload(0x40) // free mem ptr get
                    
                                switch success
                                case 0 {
                                    // If the call errored, forward its full error data
                                    returndatacopy(output, 0, returndatasize)
                                    revert(output, returndatasize)
                                }
                                default {
                                    switch gt(returndatasize, 0x3f)
                                    case 0 {
                                        // Need at least 0x40 bytes returned for properly ABI-encoded bytes values,
                                        // revert with "EVMRUN_EXECUTOR_INVALID_RETURN"
                                        // See remix: doing a `revert("EVMRUN_EXECUTOR_INVALID_RETURN")` always results in
                                        // this memory layout
                                        mstore(output, 0x08c379a000000000000000000000000000000000000000000000000000000000)         // error identifier
                                        mstore(add(output, 0x04), 0x0000000000000000000000000000000000000000000000000000000000000020) // starting offset
                                        mstore(add(output, 0x24), 0x000000000000000000000000000000000000000000000000000000000000001e) // reason length
                                        mstore(add(output, 0x44), 0x45564d52554e5f4558454355544f525f494e56414c49445f52455455524e0000) // reason
                    
                                        revert(output, 100) // 100 = 4 + 3 * 32 (error identifier + 3 words for the ABI encoded error)
                                    }
                                    default {
                                        // Copy result
                                        //
                                        // Needs to perform an ABI decode for the expected `bytes` return type of
                                        // `executor.execScript()` as solidity will automatically ABI encode the returned bytes as:
                                        //    [ position of the first dynamic length return value = 0x20 (32 bytes) ]
                                        //    [ output length (32 bytes) ]
                                        //    [ output content (N bytes) ]
                                        //
                                        // Perform the ABI decode by ignoring the first 32 bytes of the return data
                                        let copysize := sub(returndatasize, 0x20)
                                        returndatacopy(output, 0x20, copysize)
                    
                                        mstore(0x40, add(output, copysize)) // free mem ptr set
                                    }
                                }
                            }
                    
                            emit ScriptResult(address(executor), _script, _input, output);
                    
                            return output;
                        }
                    
                        modifier protectState {
                            address preKernel = address(kernel());
                            bytes32 preAppId = appId();
                            _; // exec
                            require(address(kernel()) == preKernel, ERROR_PROTECTED_STATE_MODIFIED);
                            require(appId() == preAppId, ERROR_PROTECTED_STATE_MODIFIED);
                        }
                    }
                    
                    // File: @aragon/os/contracts/apps/AragonApp.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    // Contracts inheriting from AragonApp are, by default, immediately petrified upon deployment so
                    // that they can never be initialized.
                    // Unless overriden, this behaviour enforces those contracts to be usable only behind an AppProxy.
                    // ReentrancyGuard, EVMScriptRunner, and ACLSyntaxSugar are not directly used by this contract, but
                    // are included so that they are automatically usable by subclassing contracts
                    contract AragonApp is AppStorage, Autopetrified, VaultRecoverable, ReentrancyGuard, EVMScriptRunner, ACLSyntaxSugar {
                        string private constant ERROR_AUTH_FAILED = "APP_AUTH_FAILED";
                    
                        modifier auth(bytes32 _role) {
                            require(canPerform(msg.sender, _role, new uint256[](0)), ERROR_AUTH_FAILED);
                            _;
                        }
                    
                        modifier authP(bytes32 _role, uint256[] _params) {
                            require(canPerform(msg.sender, _role, _params), ERROR_AUTH_FAILED);
                            _;
                        }
                    
                        /**
                        * @dev Check whether an action can be performed by a sender for a particular role on this app
                        * @param _sender Sender of the call
                        * @param _role Role on this app
                        * @param _params Permission params for the role
                        * @return Boolean indicating whether the sender has the permissions to perform the action.
                        *         Always returns false if the app hasn't been initialized yet.
                        */
                        function canPerform(address _sender, bytes32 _role, uint256[] _params) public view returns (bool) {
                            if (!hasInitialized()) {
                                return false;
                            }
                    
                            IKernel linkedKernel = kernel();
                            if (address(linkedKernel) == address(0)) {
                                return false;
                            }
                    
                            return linkedKernel.hasPermission(
                                _sender,
                                address(this),
                                _role,
                                ConversionHelpers.dangerouslyCastUintArrayToBytes(_params)
                            );
                        }
                    
                        /**
                        * @dev Get the recovery vault for the app
                        * @return Recovery vault address for the app
                        */
                        function getRecoveryVault() public view returns (address) {
                            // Funds recovery via a vault is only available when used with a kernel
                            return kernel().getRecoveryVault(); // if kernel is not set, it will revert
                        }
                    }
                    
                    // File: @aragon/os/contracts/lib/math/SafeMath.sol
                    
                    // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol
                    // Adapted to use pragma ^0.4.24 and satisfy our linter rules
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title SafeMath
                     * @dev Math operations with safety checks that revert on error
                     */
                    library SafeMath {
                        string private constant ERROR_ADD_OVERFLOW = "MATH_ADD_OVERFLOW";
                        string private constant ERROR_SUB_UNDERFLOW = "MATH_SUB_UNDERFLOW";
                        string private constant ERROR_MUL_OVERFLOW = "MATH_MUL_OVERFLOW";
                        string private constant ERROR_DIV_ZERO = "MATH_DIV_ZERO";
                    
                        /**
                        * @dev Multiplies two numbers, reverts on 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-solidity/pull/522
                            if (_a == 0) {
                                return 0;
                            }
                    
                            uint256 c = _a * _b;
                            require(c / _a == _b, ERROR_MUL_OVERFLOW);
                    
                            return c;
                        }
                    
                        /**
                        * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
                        */
                        function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
                            require(_b > 0, ERROR_DIV_ZERO); // Solidity only automatically asserts when dividing by 0
                            uint256 c = _a / _b;
                            // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
                    
                            return c;
                        }
                    
                        /**
                        * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
                        */
                        function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
                            require(_b <= _a, ERROR_SUB_UNDERFLOW);
                            uint256 c = _a - _b;
                    
                            return c;
                        }
                    
                        /**
                        * @dev Adds two numbers, reverts on overflow.
                        */
                        function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
                            uint256 c = _a + _b;
                            require(c >= _a, ERROR_ADD_OVERFLOW);
                    
                            return c;
                        }
                    
                        /**
                        * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
                        * reverts when dividing by zero.
                        */
                        function mod(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b != 0, ERROR_DIV_ZERO);
                            return a % b;
                        }
                    }
                    
                    // File: @aragon/os/contracts/lib/math/SafeMath64.sol
                    
                    // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol
                    // Adapted for uint64, pragma ^0.4.24, and satisfying our linter rules
                    // Also optimized the mul() implementation, see https://github.com/aragon/aragonOS/pull/417
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title SafeMath64
                     * @dev Math operations for uint64 with safety checks that revert on error
                     */
                    library SafeMath64 {
                        string private constant ERROR_ADD_OVERFLOW = "MATH64_ADD_OVERFLOW";
                        string private constant ERROR_SUB_UNDERFLOW = "MATH64_SUB_UNDERFLOW";
                        string private constant ERROR_MUL_OVERFLOW = "MATH64_MUL_OVERFLOW";
                        string private constant ERROR_DIV_ZERO = "MATH64_DIV_ZERO";
                    
                        /**
                        * @dev Multiplies two numbers, reverts on overflow.
                        */
                        function mul(uint64 _a, uint64 _b) internal pure returns (uint64) {
                            uint256 c = uint256(_a) * uint256(_b);
                            require(c < 0x010000000000000000, ERROR_MUL_OVERFLOW); // 2**64 (less gas this way)
                    
                            return uint64(c);
                        }
                    
                        /**
                        * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
                        */
                        function div(uint64 _a, uint64 _b) internal pure returns (uint64) {
                            require(_b > 0, ERROR_DIV_ZERO); // Solidity only automatically asserts when dividing by 0
                            uint64 c = _a / _b;
                            // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
                    
                            return c;
                        }
                    
                        /**
                        * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
                        */
                        function sub(uint64 _a, uint64 _b) internal pure returns (uint64) {
                            require(_b <= _a, ERROR_SUB_UNDERFLOW);
                            uint64 c = _a - _b;
                    
                            return c;
                        }
                    
                        /**
                        * @dev Adds two numbers, reverts on overflow.
                        */
                        function add(uint64 _a, uint64 _b) internal pure returns (uint64) {
                            uint64 c = _a + _b;
                            require(c >= _a, ERROR_ADD_OVERFLOW);
                    
                            return c;
                        }
                    
                        /**
                        * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
                        * reverts when dividing by zero.
                        */
                        function mod(uint64 a, uint64 b) internal pure returns (uint64) {
                            require(b != 0, ERROR_DIV_ZERO);
                            return a % b;
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: @aragon/apps-vault/contracts/Vault.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
                        using SafeERC20 for ERC20;
                    
                        bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");
                    
                        string private constant ERROR_DATA_NON_ZERO = "VAULT_DATA_NON_ZERO";
                        string private constant ERROR_NOT_DEPOSITABLE = "VAULT_NOT_DEPOSITABLE";
                        string private constant ERROR_DEPOSIT_VALUE_ZERO = "VAULT_DEPOSIT_VALUE_ZERO";
                        string private constant ERROR_TRANSFER_VALUE_ZERO = "VAULT_TRANSFER_VALUE_ZERO";
                        string private constant ERROR_SEND_REVERTED = "VAULT_SEND_REVERTED";
                        string private constant ERROR_VALUE_MISMATCH = "VAULT_VALUE_MISMATCH";
                        string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "VAULT_TOKEN_TRANSFER_FROM_REVERT";
                        string private constant ERROR_TOKEN_TRANSFER_REVERTED = "VAULT_TOKEN_TRANSFER_REVERTED";
                    
                        event VaultTransfer(address indexed token, address indexed to, uint256 amount);
                        event VaultDeposit(address indexed token, address indexed sender, uint256 amount);
                    
                        /**
                        * @dev On a normal send() or transfer() this fallback is never executed as it will be
                        *      intercepted by the Proxy (see aragonOS#281)
                        */
                        function () external payable isInitialized {
                            require(msg.data.length == 0, ERROR_DATA_NON_ZERO);
                            _deposit(ETH, msg.value);
                        }
                    
                        /**
                        * @notice Initialize Vault app
                        * @dev As an AragonApp it needs to be initialized in order for roles (`auth` and `authP`) to work
                        */
                        function initialize() external onlyInit {
                            initialized();
                            setDepositable(true);
                        }
                    
                        /**
                        * @notice Deposit `_value` `_token` to the vault
                        * @param _token Address of the token being transferred
                        * @param _value Amount of tokens being transferred
                        */
                        function deposit(address _token, uint256 _value) external payable isInitialized {
                            _deposit(_token, _value);
                        }
                    
                        /**
                        * @notice Transfer `_value` `_token` from the Vault to `_to`
                        * @param _token Address of the token being transferred
                        * @param _to Address of the recipient of tokens
                        * @param _value Amount of tokens being transferred
                        */
                        /* solium-disable-next-line function-order */
                        function transfer(address _token, address _to, uint256 _value)
                            external
                            authP(TRANSFER_ROLE, arr(_token, _to, _value))
                        {
                            require(_value > 0, ERROR_TRANSFER_VALUE_ZERO);
                    
                            if (_token == ETH) {
                                require(_to.send(_value), ERROR_SEND_REVERTED);
                            } else {
                                require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED);
                            }
                    
                            emit VaultTransfer(_token, _to, _value);
                        }
                    
                        function balance(address _token) public view returns (uint256) {
                            if (_token == ETH) {
                                return address(this).balance;
                            } else {
                                return ERC20(_token).staticBalanceOf(address(this));
                            }
                        }
                    
                        /**
                        * @dev Disable recovery escape hatch, as it could be used
                        *      maliciously to transfer funds away from the vault
                        */
                        function allowRecoverability(address) public view returns (bool) {
                            return false;
                        }
                    
                        function _deposit(address _token, uint256 _value) internal {
                            require(isDepositable(), ERROR_NOT_DEPOSITABLE);
                            require(_value > 0, ERROR_DEPOSIT_VALUE_ZERO);
                    
                            if (_token == ETH) {
                                // Deposit is implicit in this case
                                require(msg.value == _value, ERROR_VALUE_MISMATCH);
                            } else {
                                require(
                                    ERC20(_token).safeTransferFrom(msg.sender, address(this), _value),
                                    ERROR_TOKEN_TRANSFER_FROM_REVERTED
                                );
                            }
                    
                            emit VaultDeposit(_token, msg.sender, _value);
                        }
                    }
                    
                    // File: contracts/Finance.sol
                    
                    /*
                     * SPDX-License-Identitifer:    GPL-3.0-or-later
                     */
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    contract Finance is EtherTokenConstant, IsContract, AragonApp {
                        using SafeMath for uint256;
                        using SafeMath64 for uint64;
                        using SafeERC20 for ERC20;
                    
                        bytes32 public constant CREATE_PAYMENTS_ROLE = keccak256("CREATE_PAYMENTS_ROLE");
                        bytes32 public constant CHANGE_PERIOD_ROLE = keccak256("CHANGE_PERIOD_ROLE");
                        bytes32 public constant CHANGE_BUDGETS_ROLE = keccak256("CHANGE_BUDGETS_ROLE");
                        bytes32 public constant EXECUTE_PAYMENTS_ROLE = keccak256("EXECUTE_PAYMENTS_ROLE");
                        bytes32 public constant MANAGE_PAYMENTS_ROLE = keccak256("MANAGE_PAYMENTS_ROLE");
                    
                        uint256 internal constant NO_SCHEDULED_PAYMENT = 0;
                        uint256 internal constant NO_TRANSACTION = 0;
                        uint256 internal constant MAX_SCHEDULED_PAYMENTS_PER_TX = 20;
                        uint256 internal constant MAX_UINT256 = uint256(-1);
                        uint64 internal constant MAX_UINT64 = uint64(-1);
                        uint64 internal constant MINIMUM_PERIOD = uint64(1 days);
                    
                        string private constant ERROR_COMPLETE_TRANSITION = "FINANCE_COMPLETE_TRANSITION";
                        string private constant ERROR_NO_SCHEDULED_PAYMENT = "FINANCE_NO_SCHEDULED_PAYMENT";
                        string private constant ERROR_NO_TRANSACTION = "FINANCE_NO_TRANSACTION";
                        string private constant ERROR_NO_PERIOD = "FINANCE_NO_PERIOD";
                        string private constant ERROR_VAULT_NOT_CONTRACT = "FINANCE_VAULT_NOT_CONTRACT";
                        string private constant ERROR_SET_PERIOD_TOO_SHORT = "FINANCE_SET_PERIOD_TOO_SHORT";
                        string private constant ERROR_NEW_PAYMENT_AMOUNT_ZERO = "FINANCE_NEW_PAYMENT_AMOUNT_ZERO";
                        string private constant ERROR_NEW_PAYMENT_INTERVAL_ZERO = "FINANCE_NEW_PAYMENT_INTRVL_ZERO";
                        string private constant ERROR_NEW_PAYMENT_EXECS_ZERO = "FINANCE_NEW_PAYMENT_EXECS_ZERO";
                        string private constant ERROR_NEW_PAYMENT_IMMEDIATE = "FINANCE_NEW_PAYMENT_IMMEDIATE";
                        string private constant ERROR_RECOVER_AMOUNT_ZERO = "FINANCE_RECOVER_AMOUNT_ZERO";
                        string private constant ERROR_DEPOSIT_AMOUNT_ZERO = "FINANCE_DEPOSIT_AMOUNT_ZERO";
                        string private constant ERROR_ETH_VALUE_MISMATCH = "FINANCE_ETH_VALUE_MISMATCH";
                        string private constant ERROR_BUDGET = "FINANCE_BUDGET";
                        string private constant ERROR_EXECUTE_PAYMENT_NUM = "FINANCE_EXECUTE_PAYMENT_NUM";
                        string private constant ERROR_EXECUTE_PAYMENT_TIME = "FINANCE_EXECUTE_PAYMENT_TIME";
                        string private constant ERROR_PAYMENT_RECEIVER = "FINANCE_PAYMENT_RECEIVER";
                        string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "FINANCE_TKN_TRANSFER_FROM_REVERT";
                        string private constant ERROR_TOKEN_APPROVE_FAILED = "FINANCE_TKN_APPROVE_FAILED";
                        string private constant ERROR_PAYMENT_INACTIVE = "FINANCE_PAYMENT_INACTIVE";
                        string private constant ERROR_REMAINING_BUDGET = "FINANCE_REMAINING_BUDGET";
                    
                        // Order optimized for storage
                        struct ScheduledPayment {
                            address token;
                            address receiver;
                            address createdBy;
                            bool inactive;
                            uint256 amount;
                            uint64 initialPaymentTime;
                            uint64 interval;
                            uint64 maxExecutions;
                            uint64 executions;
                        }
                    
                        // Order optimized for storage
                        struct Transaction {
                            address token;
                            address entity;
                            bool isIncoming;
                            uint256 amount;
                            uint256 paymentId;
                            uint64 paymentExecutionNumber;
                            uint64 date;
                            uint64 periodId;
                        }
                    
                        struct TokenStatement {
                            uint256 expenses;
                            uint256 income;
                        }
                    
                        struct Period {
                            uint64 startTime;
                            uint64 endTime;
                            uint256 firstTransactionId;
                            uint256 lastTransactionId;
                            mapping (address => TokenStatement) tokenStatement;
                        }
                    
                        struct Settings {
                            uint64 periodDuration;
                            mapping (address => uint256) budgets;
                            mapping (address => bool) hasBudget;
                        }
                    
                        Vault public vault;
                        Settings internal settings;
                    
                        // We are mimicing arrays, we use mappings instead to make app upgrade more graceful
                        mapping (uint256 => ScheduledPayment) internal scheduledPayments;
                        // Payments start at index 1, to allow us to use scheduledPayments[0] for transactions that are not
                        // linked to a scheduled payment
                        uint256 public paymentsNextIndex;
                    
                        mapping (uint256 => Transaction) internal transactions;
                        uint256 public transactionsNextIndex;
                    
                        mapping (uint64 => Period) internal periods;
                        uint64 public periodsLength;
                    
                        event NewPeriod(uint64 indexed periodId, uint64 periodStarts, uint64 periodEnds);
                        event SetBudget(address indexed token, uint256 amount, bool hasBudget);
                        event NewPayment(uint256 indexed paymentId, address indexed recipient, uint64 maxExecutions, string reference);
                        event NewTransaction(uint256 indexed transactionId, bool incoming, address indexed entity, uint256 amount, string reference);
                        event ChangePaymentState(uint256 indexed paymentId, bool active);
                        event ChangePeriodDuration(uint64 newDuration);
                        event PaymentFailure(uint256 paymentId);
                    
                        // Modifier used by all methods that impact accounting to make sure accounting period
                        // is changed before the operation if needed
                        // NOTE: its use **MUST** be accompanied by an initialization check
                        modifier transitionsPeriod {
                            bool completeTransition = _tryTransitionAccountingPeriod(getMaxPeriodTransitions());
                            require(completeTransition, ERROR_COMPLETE_TRANSITION);
                            _;
                        }
                    
                        modifier scheduledPaymentExists(uint256 _paymentId) {
                            require(_paymentId > 0 && _paymentId < paymentsNextIndex, ERROR_NO_SCHEDULED_PAYMENT);
                            _;
                        }
                    
                        modifier transactionExists(uint256 _transactionId) {
                            require(_transactionId > 0 && _transactionId < transactionsNextIndex, ERROR_NO_TRANSACTION);
                            _;
                        }
                    
                        modifier periodExists(uint64 _periodId) {
                            require(_periodId < periodsLength, ERROR_NO_PERIOD);
                            _;
                        }
                    
                        /**
                         * @notice Deposit ETH to the Vault, to avoid locking them in this Finance app forever
                         * @dev Send ETH to Vault. Send all the available balance.
                         */
                        function () external payable isInitialized transitionsPeriod {
                            require(msg.value > 0, ERROR_DEPOSIT_AMOUNT_ZERO);
                            _deposit(
                                ETH,
                                msg.value,
                                "Ether transfer to Finance app",
                                msg.sender,
                                true
                            );
                        }
                    
                        /**
                        * @notice Initialize Finance app for Vault at `_vault` with period length of `@transformTime(_periodDuration)`
                        * @param _vault Address of the vault Finance will rely on (non changeable)
                        * @param _periodDuration Duration in seconds of each period
                        */
                        function initialize(Vault _vault, uint64 _periodDuration) external onlyInit {
                            initialized();
                    
                            require(isContract(_vault), ERROR_VAULT_NOT_CONTRACT);
                            vault = _vault;
                    
                            require(_periodDuration >= MINIMUM_PERIOD, ERROR_SET_PERIOD_TOO_SHORT);
                            settings.periodDuration = _periodDuration;
                    
                            // Reserve the first scheduled payment index as an unused index for transactions not linked
                            // to a scheduled payment
                            scheduledPayments[0].inactive = true;
                            paymentsNextIndex = 1;
                    
                            // Reserve the first transaction index as an unused index for periods with no transactions
                            transactionsNextIndex = 1;
                    
                            // Start the first period
                            _newPeriod(getTimestamp64());
                        }
                    
                        /**
                        * @notice Deposit `@tokenAmount(_token, _amount)`
                        * @dev Deposit for approved ERC20 tokens or ETH
                        * @param _token Address of deposited token
                        * @param _amount Amount of tokens sent
                        * @param _reference Reason for payment
                        */
                        function deposit(address _token, uint256 _amount, string _reference) external payable isInitialized transitionsPeriod {
                            require(_amount > 0, ERROR_DEPOSIT_AMOUNT_ZERO);
                            if (_token == ETH) {
                                // Ensure that the ETH sent with the transaction equals the amount in the deposit
                                require(msg.value == _amount, ERROR_ETH_VALUE_MISMATCH);
                            }
                    
                            _deposit(
                                _token,
                                _amount,
                                _reference,
                                msg.sender,
                                true
                            );
                        }
                    
                        /**
                        * @notice Create a new payment of `@tokenAmount(_token, _amount)` to `_receiver` for '`_reference`'
                        * @dev Note that this function is protected by the `CREATE_PAYMENTS_ROLE` but uses `MAX_UINT256`
                        *      as its interval auth parameter (as a sentinel value for "never repeating").
                        *      While this protects against most cases (you typically want to set a baseline requirement
                        *      for interval time), it does mean users will have to explicitly check for this case when
                        *      granting a permission that includes a upperbound requirement on the interval time.
                        * @param _token Address of token for payment
                        * @param _receiver Address that will receive payment
                        * @param _amount Tokens that are paid every time the payment is due
                        * @param _reference String detailing payment reason
                        */
                        function newImmediatePayment(address _token, address _receiver, uint256 _amount, string _reference)
                            external
                            // Use MAX_UINT256 as the interval parameter, as this payment will never repeat
                            // Payment time parameter is left as the last param as it was added later
                            authP(CREATE_PAYMENTS_ROLE, _arr(_token, _receiver, _amount, MAX_UINT256, uint256(1), getTimestamp()))
                            transitionsPeriod
                        {
                            require(_amount > 0, ERROR_NEW_PAYMENT_AMOUNT_ZERO);
                    
                            _makePaymentTransaction(
                                _token,
                                _receiver,
                                _amount,
                                NO_SCHEDULED_PAYMENT,   // unrelated to any payment id; it isn't created
                                0,   // also unrelated to any payment executions
                                _reference
                            );
                        }
                    
                        /**
                        * @notice Create a new payment of `@tokenAmount(_token, _amount)` to `_receiver` for `_reference`, executing `_maxExecutions` times at intervals of `@transformTime(_interval)`
                        * @dev See `newImmediatePayment()` for limitations on how the interval auth parameter can be used
                        * @param _token Address of token for payment
                        * @param _receiver Address that will receive payment
                        * @param _amount Tokens that are paid every time the payment is due
                        * @param _initialPaymentTime Timestamp for when the first payment is done
                        * @param _interval Number of seconds that need to pass between payment transactions
                        * @param _maxExecutions Maximum instances a payment can be executed
                        * @param _reference String detailing payment reason
                        */
                        function newScheduledPayment(
                            address _token,
                            address _receiver,
                            uint256 _amount,
                            uint64 _initialPaymentTime,
                            uint64 _interval,
                            uint64 _maxExecutions,
                            string _reference
                        )
                            external
                            // Payment time parameter is left as the last param as it was added later
                            authP(CREATE_PAYMENTS_ROLE, _arr(_token, _receiver, _amount, uint256(_interval), uint256(_maxExecutions), uint256(_initialPaymentTime)))
                            transitionsPeriod
                            returns (uint256 paymentId)
                        {
                            require(_amount > 0, ERROR_NEW_PAYMENT_AMOUNT_ZERO);
                            require(_interval > 0, ERROR_NEW_PAYMENT_INTERVAL_ZERO);
                            require(_maxExecutions > 0, ERROR_NEW_PAYMENT_EXECS_ZERO);
                    
                            // Token budget must not be set at all or allow at least one instance of this payment each period
                            require(!settings.hasBudget[_token] || settings.budgets[_token] >= _amount, ERROR_BUDGET);
                    
                            // Don't allow creating single payments that are immediately executable, use `newImmediatePayment()` instead
                            if (_maxExecutions == 1) {
                                require(_initialPaymentTime > getTimestamp64(), ERROR_NEW_PAYMENT_IMMEDIATE);
                            }
                    
                            paymentId = paymentsNextIndex++;
                            emit NewPayment(paymentId, _receiver, _maxExecutions, _reference);
                    
                            ScheduledPayment storage payment = scheduledPayments[paymentId];
                            payment.token = _token;
                            payment.receiver = _receiver;
                            payment.amount = _amount;
                            payment.initialPaymentTime = _initialPaymentTime;
                            payment.interval = _interval;
                            payment.maxExecutions = _maxExecutions;
                            payment.createdBy = msg.sender;
                    
                            // We skip checking how many times the new payment was executed to allow creating new
                            // scheduled payments before having enough vault balance
                            _executePayment(paymentId);
                        }
                    
                        /**
                        * @notice Change period duration to `@transformTime(_periodDuration)`, effective for next accounting period
                        * @param _periodDuration Duration in seconds for accounting periods
                        */
                        function setPeriodDuration(uint64 _periodDuration)
                            external
                            authP(CHANGE_PERIOD_ROLE, arr(uint256(_periodDuration), uint256(settings.periodDuration)))
                            transitionsPeriod
                        {
                            require(_periodDuration >= MINIMUM_PERIOD, ERROR_SET_PERIOD_TOO_SHORT);
                            settings.periodDuration = _periodDuration;
                            emit ChangePeriodDuration(_periodDuration);
                        }
                    
                        /**
                        * @notice Set budget for `_token.symbol(): string` to `@tokenAmount(_token, _amount, false)`, effective immediately
                        * @param _token Address for token
                        * @param _amount New budget amount
                        */
                        function setBudget(
                            address _token,
                            uint256 _amount
                        )
                            external
                            authP(CHANGE_BUDGETS_ROLE, arr(_token, _amount, settings.budgets[_token], uint256(settings.hasBudget[_token] ? 1 : 0)))
                            transitionsPeriod
                        {
                            settings.budgets[_token] = _amount;
                            if (!settings.hasBudget[_token]) {
                                settings.hasBudget[_token] = true;
                            }
                            emit SetBudget(_token, _amount, true);
                        }
                    
                        /**
                        * @notice Remove spending limit for `_token.symbol(): string`, effective immediately
                        * @param _token Address for token
                        */
                        function removeBudget(address _token)
                            external
                            authP(CHANGE_BUDGETS_ROLE, arr(_token, uint256(0), settings.budgets[_token], uint256(settings.hasBudget[_token] ? 1 : 0)))
                            transitionsPeriod
                        {
                            settings.budgets[_token] = 0;
                            settings.hasBudget[_token] = false;
                            emit SetBudget(_token, 0, false);
                        }
                    
                        /**
                        * @notice Execute pending payment #`_paymentId`
                        * @dev Executes any payment (requires role)
                        * @param _paymentId Identifier for payment
                        */
                        function executePayment(uint256 _paymentId)
                            external
                            authP(EXECUTE_PAYMENTS_ROLE, arr(_paymentId, scheduledPayments[_paymentId].amount))
                            scheduledPaymentExists(_paymentId)
                            transitionsPeriod
                        {
                            _executePaymentAtLeastOnce(_paymentId);
                        }
                    
                        /**
                        * @notice Execute pending payment #`_paymentId`
                        * @dev Always allow receiver of a payment to trigger execution
                        *      Initialization check is implicitly provided by `scheduledPaymentExists()` as new
                        *      scheduled payments can only be created via `newScheduledPayment(),` which requires initialization
                        * @param _paymentId Identifier for payment
                        */
                        function receiverExecutePayment(uint256 _paymentId) external scheduledPaymentExists(_paymentId) transitionsPeriod {
                            require(scheduledPayments[_paymentId].receiver == msg.sender, ERROR_PAYMENT_RECEIVER);
                            _executePaymentAtLeastOnce(_paymentId);
                        }
                    
                        /**
                        * @notice `_active ? 'Activate' : 'Disable'` payment #`_paymentId`
                        * @dev Note that we do not require this action to transition periods, as it doesn't directly
                        *      impact any accounting periods.
                        *      Not having to transition periods also makes disabling payments easier to prevent funds
                        *      from being pulled out in the event of a breach.
                        * @param _paymentId Identifier for payment
                        * @param _active Whether it will be active or inactive
                        */
                        function setPaymentStatus(uint256 _paymentId, bool _active)
                            external
                            authP(MANAGE_PAYMENTS_ROLE, arr(_paymentId, uint256(_active ? 1 : 0)))
                            scheduledPaymentExists(_paymentId)
                        {
                            scheduledPayments[_paymentId].inactive = !_active;
                            emit ChangePaymentState(_paymentId, _active);
                        }
                    
                        /**
                         * @notice Send tokens held in this contract to the Vault
                         * @dev Allows making a simple payment from this contract to the Vault, to avoid locked tokens.
                         *      This contract should never receive tokens with a simple transfer call, but in case it
                         *      happens, this function allows for their recovery.
                         * @param _token Token whose balance is going to be transferred.
                         */
                        function recoverToVault(address _token) external isInitialized transitionsPeriod {
                            uint256 amount = _token == ETH ? address(this).balance : ERC20(_token).staticBalanceOf(address(this));
                            require(amount > 0, ERROR_RECOVER_AMOUNT_ZERO);
                    
                            _deposit(
                                _token,
                                amount,
                                "Recover to Vault",
                                address(this),
                                false
                            );
                        }
                    
                        /**
                        * @notice Transition accounting period if needed
                        * @dev Transitions accounting periods if needed. For preventing OOG attacks, a maxTransitions
                        *      param is provided. If more than the specified number of periods need to be transitioned,
                        *      it will return false.
                        * @param _maxTransitions Maximum periods that can be transitioned
                        * @return success Boolean indicating whether the accounting period is the correct one (if false,
                        *                 maxTransitions was surpased and another call is needed)
                        */
                        function tryTransitionAccountingPeriod(uint64 _maxTransitions) external isInitialized returns (bool success) {
                            return _tryTransitionAccountingPeriod(_maxTransitions);
                        }
                    
                        // Getter fns
                    
                        /**
                        * @dev Disable recovery escape hatch if the app has been initialized, as it could be used
                        *      maliciously to transfer funds in the Finance app to another Vault
                        *      finance#recoverToVault() should be used to recover funds to the Finance's vault
                        */
                        function allowRecoverability(address) public view returns (bool) {
                            return !hasInitialized();
                        }
                    
                        function getPayment(uint256 _paymentId)
                            public
                            view
                            scheduledPaymentExists(_paymentId)
                            returns (
                                address token,
                                address receiver,
                                uint256 amount,
                                uint64 initialPaymentTime,
                                uint64 interval,
                                uint64 maxExecutions,
                                bool inactive,
                                uint64 executions,
                                address createdBy
                            )
                        {
                            ScheduledPayment storage payment = scheduledPayments[_paymentId];
                    
                            token = payment.token;
                            receiver = payment.receiver;
                            amount = payment.amount;
                            initialPaymentTime = payment.initialPaymentTime;
                            interval = payment.interval;
                            maxExecutions = payment.maxExecutions;
                            executions = payment.executions;
                            inactive = payment.inactive;
                            createdBy = payment.createdBy;
                        }
                    
                        function getTransaction(uint256 _transactionId)
                            public
                            view
                            transactionExists(_transactionId)
                            returns (
                                uint64 periodId,
                                uint256 amount,
                                uint256 paymentId,
                                uint64 paymentExecutionNumber,
                                address token,
                                address entity,
                                bool isIncoming,
                                uint64 date
                            )
                        {
                            Transaction storage transaction = transactions[_transactionId];
                    
                            token = transaction.token;
                            entity = transaction.entity;
                            isIncoming = transaction.isIncoming;
                            date = transaction.date;
                            periodId = transaction.periodId;
                            amount = transaction.amount;
                            paymentId = transaction.paymentId;
                            paymentExecutionNumber = transaction.paymentExecutionNumber;
                        }
                    
                        function getPeriod(uint64 _periodId)
                            public
                            view
                            periodExists(_periodId)
                            returns (
                                bool isCurrent,
                                uint64 startTime,
                                uint64 endTime,
                                uint256 firstTransactionId,
                                uint256 lastTransactionId
                            )
                        {
                            Period storage period = periods[_periodId];
                    
                            isCurrent = _currentPeriodId() == _periodId;
                    
                            startTime = period.startTime;
                            endTime = period.endTime;
                            firstTransactionId = period.firstTransactionId;
                            lastTransactionId = period.lastTransactionId;
                        }
                    
                        function getPeriodTokenStatement(uint64 _periodId, address _token)
                            public
                            view
                            periodExists(_periodId)
                            returns (uint256 expenses, uint256 income)
                        {
                            TokenStatement storage tokenStatement = periods[_periodId].tokenStatement[_token];
                            expenses = tokenStatement.expenses;
                            income = tokenStatement.income;
                        }
                    
                        /**
                        * @dev We have to check for initialization as periods are only valid after initializing
                        */
                        function currentPeriodId() public view isInitialized returns (uint64) {
                            return _currentPeriodId();
                        }
                    
                        /**
                        * @dev We have to check for initialization as periods are only valid after initializing
                        */
                        function getPeriodDuration() public view isInitialized returns (uint64) {
                            return settings.periodDuration;
                        }
                    
                        /**
                        * @dev We have to check for initialization as budgets are only valid after initializing
                        */
                        function getBudget(address _token) public view isInitialized returns (uint256 budget, bool hasBudget) {
                            budget = settings.budgets[_token];
                            hasBudget = settings.hasBudget[_token];
                        }
                    
                        /**
                        * @dev We have to check for initialization as budgets are only valid after initializing
                        */
                        function getRemainingBudget(address _token) public view isInitialized returns (uint256) {
                            return _getRemainingBudget(_token);
                        }
                    
                        /**
                        * @dev We have to check for initialization as budgets are only valid after initializing
                        */
                        function canMakePayment(address _token, uint256 _amount) public view isInitialized returns (bool) {
                            return _canMakePayment(_token, _amount);
                        }
                    
                        /**
                        * @dev Initialization check is implicitly provided by `scheduledPaymentExists()` as new
                        *      scheduled payments can only be created via `newScheduledPayment(),` which requires initialization
                        */
                        function nextPaymentTime(uint256 _paymentId) public view scheduledPaymentExists(_paymentId) returns (uint64) {
                            return _nextPaymentTime(_paymentId);
                        }
                    
                        // Internal fns
                    
                        function _deposit(address _token, uint256 _amount, string _reference, address _sender, bool _isExternalDeposit) internal {
                            _recordIncomingTransaction(
                                _token,
                                _sender,
                                _amount,
                                _reference
                            );
                    
                            if (_token == ETH) {
                                vault.deposit.value(_amount)(ETH, _amount);
                            } else {
                                // First, transfer the tokens to Finance if necessary
                                // External deposit will be false when the assets were already in the Finance app
                                // and just need to be transferred to the Vault
                                if (_isExternalDeposit) {
                                    // This assumes the sender has approved the tokens for Finance
                                    require(
                                        ERC20(_token).safeTransferFrom(msg.sender, address(this), _amount),
                                        ERROR_TOKEN_TRANSFER_FROM_REVERTED
                                    );
                                }
                                // Approve the tokens for the Vault (it does the actual transferring)
                                require(ERC20(_token).safeApprove(vault, _amount), ERROR_TOKEN_APPROVE_FAILED);
                                // Finally, initiate the deposit
                                vault.deposit(_token, _amount);
                            }
                        }
                    
                        function _executePayment(uint256 _paymentId) internal returns (uint256) {
                            ScheduledPayment storage payment = scheduledPayments[_paymentId];
                            require(!payment.inactive, ERROR_PAYMENT_INACTIVE);
                    
                            uint64 paid = 0;
                            while (_nextPaymentTime(_paymentId) <= getTimestamp64() && paid < MAX_SCHEDULED_PAYMENTS_PER_TX) {
                                if (!_canMakePayment(payment.token, payment.amount)) {
                                    emit PaymentFailure(_paymentId);
                                    break;
                                }
                    
                                // The while() predicate prevents these two from ever overflowing
                                payment.executions += 1;
                                paid += 1;
                    
                                // We've already checked the remaining budget with `_canMakePayment()`
                                _unsafeMakePaymentTransaction(
                                    payment.token,
                                    payment.receiver,
                                    payment.amount,
                                    _paymentId,
                                    payment.executions,
                                    ""
                                );
                            }
                    
                            return paid;
                        }
                    
                        function _executePaymentAtLeastOnce(uint256 _paymentId) internal {
                            uint256 paid = _executePayment(_paymentId);
                            if (paid == 0) {
                                if (_nextPaymentTime(_paymentId) <= getTimestamp64()) {
                                    revert(ERROR_EXECUTE_PAYMENT_NUM);
                                } else {
                                    revert(ERROR_EXECUTE_PAYMENT_TIME);
                                }
                            }
                        }
                    
                        function _makePaymentTransaction(
                            address _token,
                            address _receiver,
                            uint256 _amount,
                            uint256 _paymentId,
                            uint64 _paymentExecutionNumber,
                            string _reference
                        )
                            internal
                        {
                            require(_getRemainingBudget(_token) >= _amount, ERROR_REMAINING_BUDGET);
                            _unsafeMakePaymentTransaction(_token, _receiver, _amount, _paymentId, _paymentExecutionNumber, _reference);
                        }
                    
                        /**
                        * @dev Unsafe version of _makePaymentTransaction that assumes you have already checked the
                        *      remaining budget
                        */
                        function _unsafeMakePaymentTransaction(
                            address _token,
                            address _receiver,
                            uint256 _amount,
                            uint256 _paymentId,
                            uint64 _paymentExecutionNumber,
                            string _reference
                        )
                            internal
                        {
                            _recordTransaction(
                                false,
                                _token,
                                _receiver,
                                _amount,
                                _paymentId,
                                _paymentExecutionNumber,
                                _reference
                            );
                    
                            vault.transfer(_token, _receiver, _amount);
                        }
                    
                        function _newPeriod(uint64 _startTime) internal returns (Period storage) {
                            // There should be no way for this to overflow since each period is at least one day
                            uint64 newPeriodId = periodsLength++;
                    
                            Period storage period = periods[newPeriodId];
                            period.startTime = _startTime;
                    
                            // Be careful here to not overflow; if startTime + periodDuration overflows, we set endTime
                            // to MAX_UINT64 (let's assume that's the end of time for now).
                            uint64 endTime = _startTime + settings.periodDuration - 1;
                            if (endTime < _startTime) { // overflowed
                                endTime = MAX_UINT64;
                            }
                            period.endTime = endTime;
                    
                            emit NewPeriod(newPeriodId, period.startTime, period.endTime);
                    
                            return period;
                        }
                    
                        function _recordIncomingTransaction(
                            address _token,
                            address _sender,
                            uint256 _amount,
                            string _reference
                        )
                            internal
                        {
                            _recordTransaction(
                                true, // incoming transaction
                                _token,
                                _sender,
                                _amount,
                                NO_SCHEDULED_PAYMENT, // unrelated to any existing payment
                                0, // and no payment executions
                                _reference
                            );
                        }
                    
                        function _recordTransaction(
                            bool _incoming,
                            address _token,
                            address _entity,
                            uint256 _amount,
                            uint256 _paymentId,
                            uint64 _paymentExecutionNumber,
                            string _reference
                        )
                            internal
                        {
                            uint64 periodId = _currentPeriodId();
                            TokenStatement storage tokenStatement = periods[periodId].tokenStatement[_token];
                            if (_incoming) {
                                tokenStatement.income = tokenStatement.income.add(_amount);
                            } else {
                                tokenStatement.expenses = tokenStatement.expenses.add(_amount);
                            }
                    
                            uint256 transactionId = transactionsNextIndex++;
                    
                            Transaction storage transaction = transactions[transactionId];
                            transaction.token = _token;
                            transaction.entity = _entity;
                            transaction.isIncoming = _incoming;
                            transaction.amount = _amount;
                            transaction.paymentId = _paymentId;
                            transaction.paymentExecutionNumber = _paymentExecutionNumber;
                            transaction.date = getTimestamp64();
                            transaction.periodId = periodId;
                    
                            Period storage period = periods[periodId];
                            if (period.firstTransactionId == NO_TRANSACTION) {
                                period.firstTransactionId = transactionId;
                            }
                    
                            emit NewTransaction(transactionId, _incoming, _entity, _amount, _reference);
                        }
                    
                        function _tryTransitionAccountingPeriod(uint64 _maxTransitions) internal returns (bool success) {
                            Period storage currentPeriod = periods[_currentPeriodId()];
                            uint64 timestamp = getTimestamp64();
                    
                            // Transition periods if necessary
                            while (timestamp > currentPeriod.endTime) {
                                if (_maxTransitions == 0) {
                                    // Required number of transitions is over allowed number, return false indicating
                                    // it didn't fully transition
                                    return false;
                                }
                                // We're already protected from underflowing above
                                _maxTransitions -= 1;
                    
                                // If there were any transactions in period, record which was the last
                                // In case 0 transactions occured, first and last tx id will be 0
                                if (currentPeriod.firstTransactionId != NO_TRANSACTION) {
                                    currentPeriod.lastTransactionId = transactionsNextIndex.sub(1);
                                }
                    
                                // New period starts at end time + 1
                                currentPeriod = _newPeriod(currentPeriod.endTime.add(1));
                            }
                    
                            return true;
                        }
                    
                        function _canMakePayment(address _token, uint256 _amount) internal view returns (bool) {
                            return _getRemainingBudget(_token) >= _amount && vault.balance(_token) >= _amount;
                        }
                    
                        function _currentPeriodId() internal view returns (uint64) {
                            // There is no way for this to overflow if protected by an initialization check
                            return periodsLength - 1;
                        }
                    
                        function _getRemainingBudget(address _token) internal view returns (uint256) {
                            if (!settings.hasBudget[_token]) {
                                return MAX_UINT256;
                            }
                    
                            uint256 budget = settings.budgets[_token];
                            uint256 spent = periods[_currentPeriodId()].tokenStatement[_token].expenses;
                    
                            // A budget decrease can cause the spent amount to be greater than period budget
                            // If so, return 0 to not allow more spending during period
                            if (spent >= budget) {
                                return 0;
                            }
                    
                            // We're already protected from the overflow above
                            return budget - spent;
                        }
                    
                        function _nextPaymentTime(uint256 _paymentId) internal view returns (uint64) {
                            ScheduledPayment storage payment = scheduledPayments[_paymentId];
                    
                            if (payment.executions >= payment.maxExecutions) {
                                return MAX_UINT64; // re-executes in some billions of years time... should not need to worry
                            }
                    
                            // Split in multiple lines to circumvent linter warning
                            uint64 increase = payment.executions.mul(payment.interval);
                            uint64 nextPayment = payment.initialPaymentTime.add(increase);
                            return nextPayment;
                        }
                    
                        // Syntax sugar
                    
                        function _arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e, uint256 _f) internal pure returns (uint256[] r) {
                            r = new uint256[](6);
                            r[0] = uint256(_a);
                            r[1] = uint256(_b);
                            r[2] = _c;
                            r[3] = _d;
                            r[4] = _e;
                            r[5] = _f;
                        }
                    
                        // Mocked fns (overrided during testing)
                        // Must be view for mocking purposes
                    
                        function getMaxPeriodTransitions() internal view returns (uint64) { return MAX_UINT64; }
                    }

                    File 7 of 8: FiatTokenV2_1
                    // File: @openzeppelin/contracts/math/SafeMath.sol
                    
                    // SPDX-License-Identifier: MIT
                    
                    pragma solidity ^0.6.0;
                    
                    /**
                     * @dev Wrappers over Solidity's arithmetic operations with added overflow
                     * checks.
                     *
                     * Arithmetic operations in Solidity wrap on overflow. This can easily result
                     * in bugs, because programmers usually assume that an overflow raises an
                     * error, which is the standard behavior in high level programming languages.
                     * `SafeMath` restores this intuition by reverting the transaction when an
                     * operation overflows.
                     *
                     * Using this library instead of the unchecked operations eliminates an entire
                     * class of bugs, so it's recommended to use it always.
                     */
                    library SafeMath {
                        /**
                         * @dev Returns the addition of two unsigned integers, reverting on
                         * overflow.
                         *
                         * Counterpart to Solidity's `+` operator.
                         *
                         * Requirements:
                         *
                         * - Addition cannot overflow.
                         */
                        function add(uint256 a, uint256 b) internal pure returns (uint256) {
                            uint256 c = a + b;
                            require(c >= a, "SafeMath: addition overflow");
                    
                            return c;
                        }
                    
                        /**
                         * @dev Returns the subtraction of two unsigned integers, reverting on
                         * overflow (when the result is negative).
                         *
                         * Counterpart to Solidity's `-` operator.
                         *
                         * Requirements:
                         *
                         * - Subtraction cannot overflow.
                         */
                        function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                            return sub(a, b, "SafeMath: subtraction overflow");
                        }
                    
                        /**
                         * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
                         * overflow (when the result is negative).
                         *
                         * Counterpart to Solidity's `-` operator.
                         *
                         * Requirements:
                         *
                         * - Subtraction cannot overflow.
                         */
                        function sub(
                            uint256 a,
                            uint256 b,
                            string memory errorMessage
                        ) internal pure returns (uint256) {
                            require(b <= a, errorMessage);
                            uint256 c = a - b;
                    
                            return c;
                        }
                    
                        /**
                         * @dev Returns the multiplication of two unsigned integers, reverting on
                         * overflow.
                         *
                         * Counterpart to Solidity's `*` operator.
                         *
                         * Requirements:
                         *
                         * - Multiplication cannot overflow.
                         */
                        function mul(uint256 a, uint256 b) internal pure returns (uint256) {
                            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
                            // benefit is lost if 'b' is also tested.
                            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
                            if (a == 0) {
                                return 0;
                            }
                    
                            uint256 c = a * b;
                            require(c / a == b, "SafeMath: multiplication overflow");
                    
                            return c;
                        }
                    
                        /**
                         * @dev Returns the integer division of two unsigned integers. Reverts on
                         * division by zero. The result is rounded towards zero.
                         *
                         * Counterpart to Solidity's `/` operator. Note: this function uses a
                         * `revert` opcode (which leaves remaining gas untouched) while Solidity
                         * uses an invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function div(uint256 a, uint256 b) internal pure returns (uint256) {
                            return div(a, b, "SafeMath: division by zero");
                        }
                    
                        /**
                         * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
                         * division by zero. The result is rounded towards zero.
                         *
                         * Counterpart to Solidity's `/` operator. Note: this function uses a
                         * `revert` opcode (which leaves remaining gas untouched) while Solidity
                         * uses an invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function div(
                            uint256 a,
                            uint256 b,
                            string memory errorMessage
                        ) internal pure returns (uint256) {
                            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: @openzeppelin/contracts/token/ERC20/IERC20.sol
                    
                    pragma solidity ^0.6.0;
                    
                    /**
                     * @dev Interface of the ERC20 standard as defined in the EIP.
                     */
                    interface IERC20 {
                        /**
                         * @dev Returns the amount of tokens in existence.
                         */
                        function totalSupply() external view returns (uint256);
                    
                        /**
                         * @dev Returns the amount of tokens owned by `account`.
                         */
                        function balanceOf(address account) external view returns (uint256);
                    
                        /**
                         * @dev Moves `amount` tokens from the caller's account to `recipient`.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * Emits a {Transfer} event.
                         */
                        function transfer(address recipient, uint256 amount)
                            external
                            returns (bool);
                    
                        /**
                         * @dev Returns the remaining number of tokens that `spender` will be
                         * allowed to spend on behalf of `owner` through {transferFrom}. This is
                         * zero by default.
                         *
                         * This value changes when {approve} or {transferFrom} are called.
                         */
                        function allowance(address owner, address spender)
                            external
                            view
                            returns (uint256);
                    
                        /**
                         * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * IMPORTANT: Beware that changing an allowance with this method brings the risk
                         * that someone may use both the old and the new allowance by unfortunate
                         * transaction ordering. One possible solution to mitigate this race
                         * condition is to first reduce the spender's allowance to 0 and set the
                         * desired value afterwards:
                         * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
                         *
                         * Emits an {Approval} event.
                         */
                        function approve(address spender, uint256 amount) external returns (bool);
                    
                        /**
                         * @dev Moves `amount` tokens from `sender` to `recipient` using the
                         * allowance mechanism. `amount` is then deducted from the caller's
                         * allowance.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * Emits a {Transfer} event.
                         */
                        function transferFrom(
                            address sender,
                            address recipient,
                            uint256 amount
                        ) external returns (bool);
                    
                        /**
                         * @dev Emitted when `value` tokens are moved from one account (`from`) to
                         * another (`to`).
                         *
                         * Note that `value` may be zero.
                         */
                        event Transfer(address indexed from, address indexed to, uint256 value);
                    
                        /**
                         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                         * a call to {approve}. `value` is the new allowance.
                         */
                        event Approval(
                            address indexed owner,
                            address indexed spender,
                            uint256 value
                        );
                    }
                    
                    // File: contracts/v1/AbstractFiatTokenV1.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    abstract contract AbstractFiatTokenV1 is IERC20 {
                        function _approve(
                            address owner,
                            address spender,
                            uint256 value
                        ) internal virtual;
                    
                        function _transfer(
                            address from,
                            address to,
                            uint256 value
                        ) internal virtual;
                    }
                    
                    // File: contracts/v1/Ownable.sol
                    
                    /**
                     * Copyright (c) 2018 zOS Global Limited.
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    pragma solidity 0.6.12;
                    
                    /**
                     * @notice The Ownable contract has an owner address, and provides basic
                     * authorization control functions
                     * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-labs/blob/3887ab77b8adafba4a26ace002f3a684c1a3388b/upgradeability_ownership/contracts/ownership/Ownable.sol
                     * Modifications:
                     * 1. Consolidate OwnableStorage into this contract (7/13/18)
                     * 2. Reformat, conform to Solidity 0.6 syntax, and add error messages (5/13/20)
                     * 3. Make public functions external (5/27/20)
                     */
                    contract Ownable {
                        // Owner of the contract
                        address private _owner;
                    
                        /**
                         * @dev Event to show ownership has been transferred
                         * @param previousOwner representing the address of the previous owner
                         * @param newOwner representing the address of the new owner
                         */
                        event OwnershipTransferred(address previousOwner, address newOwner);
                    
                        /**
                         * @dev The constructor sets the original owner of the contract to the sender account.
                         */
                        constructor() public {
                            setOwner(msg.sender);
                        }
                    
                        /**
                         * @dev Tells the address of the owner
                         * @return the address of the owner
                         */
                        function owner() external view returns (address) {
                            return _owner;
                        }
                    
                        /**
                         * @dev Sets a new owner address
                         */
                        function setOwner(address newOwner) internal {
                            _owner = newOwner;
                        }
                    
                        /**
                         * @dev Throws if called by any account other than the owner.
                         */
                        modifier onlyOwner() {
                            require(msg.sender == _owner, "Ownable: caller is not the owner");
                            _;
                        }
                    
                        /**
                         * @dev Allows the current owner to transfer control of the contract to a newOwner.
                         * @param newOwner The address to transfer ownership to.
                         */
                        function transferOwnership(address newOwner) external onlyOwner {
                            require(
                                newOwner != address(0),
                                "Ownable: new owner is the zero address"
                            );
                            emit OwnershipTransferred(_owner, newOwner);
                            setOwner(newOwner);
                        }
                    }
                    
                    // File: contracts/v1/Pausable.sol
                    
                    /**
                     * Copyright (c) 2016 Smart Contract Solutions, Inc.
                     * Copyright (c) 2018-2020 CENTRE SECZ0
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @notice Base contract which allows children to implement an emergency stop
                     * mechanism
                     * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/feb665136c0dae9912e08397c1a21c4af3651ef3/contracts/lifecycle/Pausable.sol
                     * Modifications:
                     * 1. Added pauser role, switched pause/unpause to be onlyPauser (6/14/2018)
                     * 2. Removed whenNotPause/whenPaused from pause/unpause (6/14/2018)
                     * 3. Removed whenPaused (6/14/2018)
                     * 4. Switches ownable library to use ZeppelinOS (7/12/18)
                     * 5. Remove constructor (7/13/18)
                     * 6. Reformat, conform to Solidity 0.6 syntax and add error messages (5/13/20)
                     * 7. Make public functions external (5/27/20)
                     */
                    contract Pausable is Ownable {
                        event Pause();
                        event Unpause();
                        event PauserChanged(address indexed newAddress);
                    
                        address public pauser;
                        bool public paused = false;
                    
                        /**
                         * @dev Modifier to make a function callable only when the contract is not paused.
                         */
                        modifier whenNotPaused() {
                            require(!paused, "Pausable: paused");
                            _;
                        }
                    
                        /**
                         * @dev throws if called by any account other than the pauser
                         */
                        modifier onlyPauser() {
                            require(msg.sender == pauser, "Pausable: caller is not the pauser");
                            _;
                        }
                    
                        /**
                         * @dev called by the owner to pause, triggers stopped state
                         */
                        function pause() external onlyPauser {
                            paused = true;
                            emit Pause();
                        }
                    
                        /**
                         * @dev called by the owner to unpause, returns to normal state
                         */
                        function unpause() external onlyPauser {
                            paused = false;
                            emit Unpause();
                        }
                    
                        /**
                         * @dev update the pauser role
                         */
                        function updatePauser(address _newPauser) external onlyOwner {
                            require(
                                _newPauser != address(0),
                                "Pausable: new pauser is the zero address"
                            );
                            pauser = _newPauser;
                            emit PauserChanged(pauser);
                        }
                    }
                    
                    // File: contracts/v1/Blacklistable.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title Blacklistable Token
                     * @dev Allows accounts to be blacklisted by a "blacklister" role
                     */
                    contract Blacklistable is Ownable {
                        address public blacklister;
                        mapping(address => bool) internal blacklisted;
                    
                        event Blacklisted(address indexed _account);
                        event UnBlacklisted(address indexed _account);
                        event BlacklisterChanged(address indexed newBlacklister);
                    
                        /**
                         * @dev Throws if called by any account other than the blacklister
                         */
                        modifier onlyBlacklister() {
                            require(
                                msg.sender == blacklister,
                                "Blacklistable: caller is not the blacklister"
                            );
                            _;
                        }
                    
                        /**
                         * @dev Throws if argument account is blacklisted
                         * @param _account The address to check
                         */
                        modifier notBlacklisted(address _account) {
                            require(
                                !blacklisted[_account],
                                "Blacklistable: account is blacklisted"
                            );
                            _;
                        }
                    
                        /**
                         * @dev Checks if account is blacklisted
                         * @param _account The address to check
                         */
                        function isBlacklisted(address _account) external view returns (bool) {
                            return blacklisted[_account];
                        }
                    
                        /**
                         * @dev Adds account to blacklist
                         * @param _account The address to blacklist
                         */
                        function blacklist(address _account) external onlyBlacklister {
                            blacklisted[_account] = true;
                            emit Blacklisted(_account);
                        }
                    
                        /**
                         * @dev Removes account from blacklist
                         * @param _account The address to remove from the blacklist
                         */
                        function unBlacklist(address _account) external onlyBlacklister {
                            blacklisted[_account] = false;
                            emit UnBlacklisted(_account);
                        }
                    
                        function updateBlacklister(address _newBlacklister) external onlyOwner {
                            require(
                                _newBlacklister != address(0),
                                "Blacklistable: new blacklister is the zero address"
                            );
                            blacklister = _newBlacklister;
                            emit BlacklisterChanged(blacklister);
                        }
                    }
                    
                    // File: contracts/v1/FiatTokenV1.sol
                    
                    /**
                     *
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title FiatToken
                     * @dev ERC20 Token backed by fiat reserves
                     */
                    contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable {
                        using SafeMath for uint256;
                    
                        string public name;
                        string public symbol;
                        uint8 public decimals;
                        string public currency;
                        address public masterMinter;
                        bool internal initialized;
                    
                        mapping(address => uint256) internal balances;
                        mapping(address => mapping(address => uint256)) internal allowed;
                        uint256 internal totalSupply_ = 0;
                        mapping(address => bool) internal minters;
                        mapping(address => uint256) internal minterAllowed;
                    
                        event Mint(address indexed minter, address indexed to, uint256 amount);
                        event Burn(address indexed burner, uint256 amount);
                        event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
                        event MinterRemoved(address indexed oldMinter);
                        event MasterMinterChanged(address indexed newMasterMinter);
                    
                        function initialize(
                            string memory tokenName,
                            string memory tokenSymbol,
                            string memory tokenCurrency,
                            uint8 tokenDecimals,
                            address newMasterMinter,
                            address newPauser,
                            address newBlacklister,
                            address newOwner
                        ) public {
                            require(!initialized, "FiatToken: contract is already initialized");
                            require(
                                newMasterMinter != address(0),
                                "FiatToken: new masterMinter is the zero address"
                            );
                            require(
                                newPauser != address(0),
                                "FiatToken: new pauser is the zero address"
                            );
                            require(
                                newBlacklister != address(0),
                                "FiatToken: new blacklister is the zero address"
                            );
                            require(
                                newOwner != address(0),
                                "FiatToken: new owner is the zero address"
                            );
                    
                            name = tokenName;
                            symbol = tokenSymbol;
                            currency = tokenCurrency;
                            decimals = tokenDecimals;
                            masterMinter = newMasterMinter;
                            pauser = newPauser;
                            blacklister = newBlacklister;
                            setOwner(newOwner);
                            initialized = true;
                        }
                    
                        /**
                         * @dev Throws if called by any account other than a minter
                         */
                        modifier onlyMinters() {
                            require(minters[msg.sender], "FiatToken: caller is not a minter");
                            _;
                        }
                    
                        /**
                         * @dev Function to mint tokens
                         * @param _to The address that will receive the minted tokens.
                         * @param _amount The amount of tokens to mint. Must be less than or equal
                         * to the minterAllowance of the caller.
                         * @return A boolean that indicates if the operation was successful.
                         */
                        function mint(address _to, uint256 _amount)
                            external
                            whenNotPaused
                            onlyMinters
                            notBlacklisted(msg.sender)
                            notBlacklisted(_to)
                            returns (bool)
                        {
                            require(_to != address(0), "FiatToken: mint to the zero address");
                            require(_amount > 0, "FiatToken: mint amount not greater than 0");
                    
                            uint256 mintingAllowedAmount = minterAllowed[msg.sender];
                            require(
                                _amount <= mintingAllowedAmount,
                                "FiatToken: mint amount exceeds minterAllowance"
                            );
                    
                            totalSupply_ = totalSupply_.add(_amount);
                            balances[_to] = balances[_to].add(_amount);
                            minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
                            emit Mint(msg.sender, _to, _amount);
                            emit Transfer(address(0), _to, _amount);
                            return true;
                        }
                    
                        /**
                         * @dev Throws if called by any account other than the masterMinter
                         */
                        modifier onlyMasterMinter() {
                            require(
                                msg.sender == masterMinter,
                                "FiatToken: caller is not the masterMinter"
                            );
                            _;
                        }
                    
                        /**
                         * @dev Get minter allowance for an account
                         * @param minter The address of the minter
                         */
                        function minterAllowance(address minter) external view returns (uint256) {
                            return minterAllowed[minter];
                        }
                    
                        /**
                         * @dev Checks if account is a minter
                         * @param account The address to check
                         */
                        function isMinter(address account) external view returns (bool) {
                            return minters[account];
                        }
                    
                        /**
                         * @notice Amount of remaining tokens spender is allowed to transfer on
                         * behalf of the token owner
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @return Allowance amount
                         */
                        function allowance(address owner, address spender)
                            external
                            override
                            view
                            returns (uint256)
                        {
                            return allowed[owner][spender];
                        }
                    
                        /**
                         * @dev Get totalSupply of token
                         */
                        function totalSupply() external override view returns (uint256) {
                            return totalSupply_;
                        }
                    
                        /**
                         * @dev Get token balance of an account
                         * @param account address The account
                         */
                        function balanceOf(address account)
                            external
                            override
                            view
                            returns (uint256)
                        {
                            return balances[account];
                        }
                    
                        /**
                         * @notice Set spender's allowance over the caller's tokens to be a given
                         * value.
                         * @param spender   Spender's address
                         * @param value     Allowance amount
                         * @return True if successful
                         */
                        function approve(address spender, uint256 value)
                            external
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _approve(msg.sender, spender, value);
                            return true;
                        }
                    
                        /**
                         * @dev Internal function to set allowance
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @param value     Allowance amount
                         */
                        function _approve(
                            address owner,
                            address spender,
                            uint256 value
                        ) internal override {
                            require(owner != address(0), "ERC20: approve from the zero address");
                            require(spender != address(0), "ERC20: approve to the zero address");
                            allowed[owner][spender] = value;
                            emit Approval(owner, spender, value);
                        }
                    
                        /**
                         * @notice Transfer tokens by spending allowance
                         * @param from  Payer's address
                         * @param to    Payee's address
                         * @param value Transfer amount
                         * @return True if successful
                         */
                        function transferFrom(
                            address from,
                            address to,
                            uint256 value
                        )
                            external
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(from)
                            notBlacklisted(to)
                            returns (bool)
                        {
                            require(
                                value <= allowed[from][msg.sender],
                                "ERC20: transfer amount exceeds allowance"
                            );
                            _transfer(from, to, value);
                            allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
                            return true;
                        }
                    
                        /**
                         * @notice Transfer tokens from the caller
                         * @param to    Payee's address
                         * @param value Transfer amount
                         * @return True if successful
                         */
                        function transfer(address to, uint256 value)
                            external
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(to)
                            returns (bool)
                        {
                            _transfer(msg.sender, to, value);
                            return true;
                        }
                    
                        /**
                         * @notice Internal function to process transfers
                         * @param from  Payer's address
                         * @param to    Payee's address
                         * @param value Transfer amount
                         */
                        function _transfer(
                            address from,
                            address to,
                            uint256 value
                        ) internal override {
                            require(from != address(0), "ERC20: transfer from the zero address");
                            require(to != address(0), "ERC20: transfer to the zero address");
                            require(
                                value <= balances[from],
                                "ERC20: transfer amount exceeds balance"
                            );
                    
                            balances[from] = balances[from].sub(value);
                            balances[to] = balances[to].add(value);
                            emit Transfer(from, to, value);
                        }
                    
                        /**
                         * @dev Function to add/update a new minter
                         * @param minter The address of the minter
                         * @param minterAllowedAmount The minting amount allowed for the minter
                         * @return True if the operation was successful.
                         */
                        function configureMinter(address minter, uint256 minterAllowedAmount)
                            external
                            whenNotPaused
                            onlyMasterMinter
                            returns (bool)
                        {
                            minters[minter] = true;
                            minterAllowed[minter] = minterAllowedAmount;
                            emit MinterConfigured(minter, minterAllowedAmount);
                            return true;
                        }
                    
                        /**
                         * @dev Function to remove a minter
                         * @param minter The address of the minter to remove
                         * @return True if the operation was successful.
                         */
                        function removeMinter(address minter)
                            external
                            onlyMasterMinter
                            returns (bool)
                        {
                            minters[minter] = false;
                            minterAllowed[minter] = 0;
                            emit MinterRemoved(minter);
                            return true;
                        }
                    
                        /**
                         * @dev allows a minter to burn some of its own tokens
                         * Validates that caller is a minter and that sender is not blacklisted
                         * amount is less than or equal to the minter's account balance
                         * @param _amount uint256 the amount of tokens to be burned
                         */
                        function burn(uint256 _amount)
                            external
                            whenNotPaused
                            onlyMinters
                            notBlacklisted(msg.sender)
                        {
                            uint256 balance = balances[msg.sender];
                            require(_amount > 0, "FiatToken: burn amount not greater than 0");
                            require(balance >= _amount, "FiatToken: burn amount exceeds balance");
                    
                            totalSupply_ = totalSupply_.sub(_amount);
                            balances[msg.sender] = balance.sub(_amount);
                            emit Burn(msg.sender, _amount);
                            emit Transfer(msg.sender, address(0), _amount);
                        }
                    
                        function updateMasterMinter(address _newMasterMinter) external onlyOwner {
                            require(
                                _newMasterMinter != address(0),
                                "FiatToken: new masterMinter is the zero address"
                            );
                            masterMinter = _newMasterMinter;
                            emit MasterMinterChanged(masterMinter);
                        }
                    }
                    
                    // File: @openzeppelin/contracts/utils/Address.sol
                    
                    pragma solidity ^0.6.2;
                    
                    /**
                     * @dev Collection of functions related to the address type
                     */
                    library Address {
                        /**
                         * @dev Returns true if `account` is a contract.
                         *
                         * [IMPORTANT]
                         * ====
                         * It is unsafe to assume that an address for which this function returns
                         * false is an externally-owned account (EOA) and not a contract.
                         *
                         * Among others, `isContract` will return false for the following
                         * types of addresses:
                         *
                         *  - an externally-owned account
                         *  - a contract in construction
                         *  - an address where a contract will be created
                         *  - an address where a contract lived, but was destroyed
                         * ====
                         */
                        function isContract(address account) internal view returns (bool) {
                            // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
                            // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
                            // for accounts without code, i.e. `keccak256('')`
                            bytes32 codehash;
                    
                                bytes32 accountHash
                             = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
                            // solhint-disable-next-line no-inline-assembly
                            assembly {
                                codehash := extcodehash(account)
                            }
                            return (codehash != accountHash && codehash != 0x0);
                        }
                    
                        /**
                         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                         * `recipient`, forwarding all available gas and reverting on errors.
                         *
                         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                         * of certain opcodes, possibly making contracts go over the 2300 gas limit
                         * imposed by `transfer`, making them unable to receive funds via
                         * `transfer`. {sendValue} removes this limitation.
                         *
                         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                         *
                         * IMPORTANT: because control is transferred to `recipient`, care must be
                         * taken to not create reentrancy vulnerabilities. Consider using
                         * {ReentrancyGuard} or the
                         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                         */
                        function sendValue(address payable recipient, uint256 amount) internal {
                            require(
                                address(this).balance >= amount,
                                "Address: insufficient balance"
                            );
                    
                            // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                            (bool success, ) = recipient.call{ value: amount }("");
                            require(
                                success,
                                "Address: unable to send value, recipient may have reverted"
                            );
                        }
                    
                        /**
                         * @dev Performs a Solidity function call using a low level `call`. A
                         * plain`call` is an unsafe replacement for a function call: use this
                         * function instead.
                         *
                         * If `target` reverts with a revert reason, it is bubbled up by this
                         * function (like regular Solidity function calls).
                         *
                         * Returns the raw returned data. To convert to the expected return value,
                         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                         *
                         * Requirements:
                         *
                         * - `target` must be a contract.
                         * - calling `target` with `data` must not revert.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data)
                            internal
                            returns (bytes memory)
                        {
                            return functionCall(target, data, "Address: low-level call failed");
                        }
                    
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                         * `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            return _functionCallWithValue(target, data, 0, errorMessage);
                        }
                    
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but also transferring `value` wei to `target`.
                         *
                         * Requirements:
                         *
                         * - the calling contract must have an ETH balance of at least `value`.
                         * - the called Solidity function must be `payable`.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value
                        ) internal returns (bytes memory) {
                            return
                                functionCallWithValue(
                                    target,
                                    data,
                                    value,
                                    "Address: low-level call with value failed"
                                );
                        }
                    
                        /**
                         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                         * with `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(
                                address(this).balance >= value,
                                "Address: insufficient balance for call"
                            );
                            return _functionCallWithValue(target, data, value, errorMessage);
                        }
                    
                        function _functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 weiValue,
                            string memory errorMessage
                        ) private returns (bytes memory) {
                            require(isContract(target), "Address: call to non-contract");
                    
                            // solhint-disable-next-line avoid-low-level-calls
                            (bool success, bytes memory returndata) = target.call{
                                value: weiValue
                            }(data);
                            if (success) {
                                return returndata;
                            } else {
                                // Look for revert reason and bubble it up if present
                                if (returndata.length > 0) {
                                    // The easiest way to bubble the revert reason is using memory via assembly
                    
                                    // solhint-disable-next-line no-inline-assembly
                                    assembly {
                                        let returndata_size := mload(returndata)
                                        revert(add(32, returndata), returndata_size)
                                    }
                                } else {
                                    revert(errorMessage);
                                }
                            }
                        }
                    }
                    
                    // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
                    
                    pragma solidity ^0.6.0;
                    
                    /**
                     * @title SafeERC20
                     * @dev Wrappers around ERC20 operations that throw on failure (when the token
                     * contract returns false). Tokens that return no value (and instead revert or
                     * throw on failure) are also supported, non-reverting calls are assumed to be
                     * successful.
                     * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
                     * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
                     */
                    library SafeERC20 {
                        using SafeMath for uint256;
                        using Address for address;
                    
                        function safeTransfer(
                            IERC20 token,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(
                                token,
                                abi.encodeWithSelector(token.transfer.selector, to, value)
                            );
                        }
                    
                        function safeTransferFrom(
                            IERC20 token,
                            address from,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(
                                token,
                                abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
                            );
                        }
                    
                        /**
                         * @dev Deprecated. This function has issues similar to the ones found in
                         * {IERC20-approve}, and its usage is discouraged.
                         *
                         * Whenever possible, use {safeIncreaseAllowance} and
                         * {safeDecreaseAllowance} instead.
                         */
                        function safeApprove(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            // safeApprove should only be called when setting an initial allowance,
                            // or when resetting it to zero. To increase and decrease it, use
                            // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                            // solhint-disable-next-line max-line-length
                            require(
                                (value == 0) || (token.allowance(address(this), spender) == 0),
                                "SafeERC20: approve from non-zero to non-zero allowance"
                            );
                            _callOptionalReturn(
                                token,
                                abi.encodeWithSelector(token.approve.selector, spender, value)
                            );
                        }
                    
                        function safeIncreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            uint256 newAllowance = token.allowance(address(this), spender).add(
                                value
                            );
                            _callOptionalReturn(
                                token,
                                abi.encodeWithSelector(
                                    token.approve.selector,
                                    spender,
                                    newAllowance
                                )
                            );
                        }
                    
                        function safeDecreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            uint256 newAllowance = token.allowance(address(this), spender).sub(
                                value,
                                "SafeERC20: decreased allowance below zero"
                            );
                            _callOptionalReturn(
                                token,
                                abi.encodeWithSelector(
                                    token.approve.selector,
                                    spender,
                                    newAllowance
                                )
                            );
                        }
                    
                        /**
                         * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                         * on the return value: the return value is optional (but if data is returned, it must not be false).
                         * @param token The token targeted by the call.
                         * @param data The call data (encoded using abi.encode or one of its variants).
                         */
                        function _callOptionalReturn(IERC20 token, bytes memory data) private {
                            // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                            // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                            // the target address contains contract code and also asserts for success in the low-level call.
                    
                            bytes memory returndata = address(token).functionCall(
                                data,
                                "SafeERC20: low-level call failed"
                            );
                            if (returndata.length > 0) {
                                // Return data is optional
                                // solhint-disable-next-line max-line-length
                                require(
                                    abi.decode(returndata, (bool)),
                                    "SafeERC20: ERC20 operation did not succeed"
                                );
                            }
                        }
                    }
                    
                    // File: contracts/v1.1/Rescuable.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    contract Rescuable is Ownable {
                        using SafeERC20 for IERC20;
                    
                        address private _rescuer;
                    
                        event RescuerChanged(address indexed newRescuer);
                    
                        /**
                         * @notice Returns current rescuer
                         * @return Rescuer's address
                         */
                        function rescuer() external view returns (address) {
                            return _rescuer;
                        }
                    
                        /**
                         * @notice Revert if called by any account other than the rescuer.
                         */
                        modifier onlyRescuer() {
                            require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
                            _;
                        }
                    
                        /**
                         * @notice Rescue ERC20 tokens locked up in this contract.
                         * @param tokenContract ERC20 token contract address
                         * @param to        Recipient address
                         * @param amount    Amount to withdraw
                         */
                        function rescueERC20(
                            IERC20 tokenContract,
                            address to,
                            uint256 amount
                        ) external onlyRescuer {
                            tokenContract.safeTransfer(to, amount);
                        }
                    
                        /**
                         * @notice Assign the rescuer role to a given address.
                         * @param newRescuer New rescuer's address
                         */
                        function updateRescuer(address newRescuer) external onlyOwner {
                            require(
                                newRescuer != address(0),
                                "Rescuable: new rescuer is the zero address"
                            );
                            _rescuer = newRescuer;
                            emit RescuerChanged(newRescuer);
                        }
                    }
                    
                    // File: contracts/v1.1/FiatTokenV1_1.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title FiatTokenV1_1
                     * @dev ERC20 Token backed by fiat reserves
                     */
                    contract FiatTokenV1_1 is FiatTokenV1, Rescuable {
                    
                    }
                    
                    // File: contracts/v2/AbstractFiatTokenV2.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    abstract contract AbstractFiatTokenV2 is AbstractFiatTokenV1 {
                        function _increaseAllowance(
                            address owner,
                            address spender,
                            uint256 increment
                        ) internal virtual;
                    
                        function _decreaseAllowance(
                            address owner,
                            address spender,
                            uint256 decrement
                        ) internal virtual;
                    }
                    
                    // File: contracts/util/ECRecover.sol
                    
                    /**
                     * Copyright (c) 2016-2019 zOS Global Limited
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title ECRecover
                     * @notice A library that provides a safe ECDSA recovery function
                     */
                    library ECRecover {
                        /**
                         * @notice Recover signer's address from a signed message
                         * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/65e4ffde586ec89af3b7e9140bdc9235d1254853/contracts/cryptography/ECDSA.sol
                         * Modifications: Accept v, r, and s as separate arguments
                         * @param digest    Keccak-256 hash digest of the signed message
                         * @param v         v of the signature
                         * @param r         r of the signature
                         * @param s         s of the signature
                         * @return Signer address
                         */
                        function recover(
                            bytes32 digest,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal pure returns (address) {
                            // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
                            // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
                            // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
                            // signatures from current libraries generate a unique signature with an s-value in the lower half order.
                            //
                            // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
                            // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
                            // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
                            // these malleable signatures as well.
                            if (
                                uint256(s) >
                                0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
                            ) {
                                revert("ECRecover: invalid signature 's' value");
                            }
                    
                            if (v != 27 && v != 28) {
                                revert("ECRecover: invalid signature 'v' value");
                            }
                    
                            // If the signature is valid (and not malleable), return the signer address
                            address signer = ecrecover(digest, v, r, s);
                            require(signer != address(0), "ECRecover: invalid signature");
                    
                            return signer;
                        }
                    }
                    
                    // File: contracts/util/EIP712.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title EIP712
                     * @notice A library that provides EIP712 helper functions
                     */
                    library EIP712 {
                        /**
                         * @notice Make EIP712 domain separator
                         * @param name      Contract name
                         * @param version   Contract version
                         * @return Domain separator
                         */
                        function makeDomainSeparator(string memory name, string memory version)
                            internal
                            view
                            returns (bytes32)
                        {
                            uint256 chainId;
                            assembly {
                                chainId := chainid()
                            }
                            return
                                keccak256(
                                    abi.encode(
                                        // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                                        0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                                        keccak256(bytes(name)),
                                        keccak256(bytes(version)),
                                        chainId,
                                        address(this)
                                    )
                                );
                        }
                    
                        /**
                         * @notice Recover signer's address from a EIP712 signature
                         * @param domainSeparator   Domain separator
                         * @param v                 v of the signature
                         * @param r                 r of the signature
                         * @param s                 s of the signature
                         * @param typeHashAndData   Type hash concatenated with data
                         * @return Signer's address
                         */
                        function recover(
                            bytes32 domainSeparator,
                            uint8 v,
                            bytes32 r,
                            bytes32 s,
                            bytes memory typeHashAndData
                        ) internal pure returns (address) {
                            bytes32 digest = keccak256(
                                abi.encodePacked(
                                    "\x19\x01",
                                    domainSeparator,
                                    keccak256(typeHashAndData)
                                )
                            );
                            return ECRecover.recover(digest, v, r, s);
                        }
                    }
                    
                    // File: contracts/v2/EIP712Domain.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title EIP712 Domain
                     */
                    contract EIP712Domain {
                        /**
                         * @dev EIP712 Domain Separator
                         */
                        bytes32 public DOMAIN_SEPARATOR;
                    }
                    
                    // File: contracts/v2/EIP3009.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title EIP-3009
                     * @notice Provide internal implementation for gas-abstracted transfers
                     * @dev Contracts that inherit from this must wrap these with publicly
                     * accessible functions, optionally adding modifiers where necessary
                     */
                    abstract contract EIP3009 is AbstractFiatTokenV2, EIP712Domain {
                        // keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                        bytes32
                            public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH = 0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267;
                    
                        // keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                        bytes32
                            public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
                    
                        // keccak256("CancelAuthorization(address authorizer,bytes32 nonce)")
                        bytes32
                            public constant CANCEL_AUTHORIZATION_TYPEHASH = 0x158b0a9edf7a828aad02f63cd515c68ef2f50ba807396f6d12842833a1597429;
                    
                        /**
                         * @dev authorizer address => nonce => bool (true if nonce is used)
                         */
                        mapping(address => mapping(bytes32 => bool)) private _authorizationStates;
                    
                        event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
                        event AuthorizationCanceled(
                            address indexed authorizer,
                            bytes32 indexed nonce
                        );
                    
                        /**
                         * @notice Returns the state of an authorization
                         * @dev Nonces are randomly generated 32-byte data unique to the
                         * authorizer's address
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @return True if the nonce is used
                         */
                        function authorizationState(address authorizer, bytes32 nonce)
                            external
                            view
                            returns (bool)
                        {
                            return _authorizationStates[authorizer][nonce];
                        }
                    
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _requireValidAuthorization(from, nonce, validAfter, validBefore);
                    
                            bytes memory data = abi.encode(
                                TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce
                            );
                            require(
                                EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == from,
                                "FiatTokenV2: invalid signature"
                            );
                    
                            _markAuthorizationAsUsed(from, nonce);
                            _transfer(from, to, value);
                        }
                    
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            require(to == msg.sender, "FiatTokenV2: caller must be the payee");
                            _requireValidAuthorization(from, nonce, validAfter, validBefore);
                    
                            bytes memory data = abi.encode(
                                RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce
                            );
                            require(
                                EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == from,
                                "FiatTokenV2: invalid signature"
                            );
                    
                            _markAuthorizationAsUsed(from, nonce);
                            _transfer(from, to, value);
                        }
                    
                        /**
                         * @notice Attempt to cancel an authorization
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _requireUnusedAuthorization(authorizer, nonce);
                    
                            bytes memory data = abi.encode(
                                CANCEL_AUTHORIZATION_TYPEHASH,
                                authorizer,
                                nonce
                            );
                            require(
                                EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == authorizer,
                                "FiatTokenV2: invalid signature"
                            );
                    
                            _authorizationStates[authorizer][nonce] = true;
                            emit AuthorizationCanceled(authorizer, nonce);
                        }
                    
                        /**
                         * @notice Check that an authorization is unused
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         */
                        function _requireUnusedAuthorization(address authorizer, bytes32 nonce)
                            private
                            view
                        {
                            require(
                                !_authorizationStates[authorizer][nonce],
                                "FiatTokenV2: authorization is used or canceled"
                            );
                        }
                    
                        /**
                         * @notice Check that authorization is valid
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         */
                        function _requireValidAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint256 validAfter,
                            uint256 validBefore
                        ) private view {
                            require(
                                now > validAfter,
                                "FiatTokenV2: authorization is not yet valid"
                            );
                            require(now < validBefore, "FiatTokenV2: authorization is expired");
                            _requireUnusedAuthorization(authorizer, nonce);
                        }
                    
                        /**
                         * @notice Mark an authorization as used
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         */
                        function _markAuthorizationAsUsed(address authorizer, bytes32 nonce)
                            private
                        {
                            _authorizationStates[authorizer][nonce] = true;
                            emit AuthorizationUsed(authorizer, nonce);
                        }
                    }
                    
                    // File: contracts/v2/EIP2612.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title EIP-2612
                     * @notice Provide internal implementation for gas-abstracted approvals
                     */
                    abstract contract EIP2612 is AbstractFiatTokenV2, EIP712Domain {
                        // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
                        bytes32
                            public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
                    
                        mapping(address => uint256) private _permitNonces;
                    
                        /**
                         * @notice Nonces for permit
                         * @param owner Token owner's address (Authorizer)
                         * @return Next nonce
                         */
                        function nonces(address owner) external view returns (uint256) {
                            return _permitNonces[owner];
                        }
                    
                        /**
                         * @notice Verify a signed approval permit and execute if valid
                         * @param owner     Token owner's address (Authorizer)
                         * @param spender   Spender's address
                         * @param value     Amount of allowance
                         * @param deadline  The time at which this expires (unix time)
                         * @param v         v of the signature
                         * @param r         r of the signature
                         * @param s         s of the signature
                         */
                        function _permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            require(deadline >= now, "FiatTokenV2: permit is expired");
                    
                            bytes memory data = abi.encode(
                                PERMIT_TYPEHASH,
                                owner,
                                spender,
                                value,
                                _permitNonces[owner]++,
                                deadline
                            );
                            require(
                                EIP712.recover(DOMAIN_SEPARATOR, v, r, s, data) == owner,
                                "EIP2612: invalid signature"
                            );
                    
                            _approve(owner, spender, value);
                        }
                    }
                    
                    // File: contracts/v2/FiatTokenV2.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    /**
                     * @title FiatToken V2
                     * @notice ERC20 Token backed by fiat reserves, version 2
                     */
                    contract FiatTokenV2 is FiatTokenV1_1, EIP3009, EIP2612 {
                        uint8 internal _initializedVersion;
                    
                        /**
                         * @notice Initialize v2
                         * @param newName   New token name
                         */
                        function initializeV2(string calldata newName) external {
                            // solhint-disable-next-line reason-string
                            require(initialized && _initializedVersion == 0);
                            name = newName;
                            DOMAIN_SEPARATOR = EIP712.makeDomainSeparator(newName, "2");
                            _initializedVersion = 1;
                        }
                    
                        /**
                         * @notice Increase the allowance by a given increment
                         * @param spender   Spender's address
                         * @param increment Amount of increase in allowance
                         * @return True if successful
                         */
                        function increaseAllowance(address spender, uint256 increment)
                            external
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _increaseAllowance(msg.sender, spender, increment);
                            return true;
                        }
                    
                        /**
                         * @notice Decrease the allowance by a given decrement
                         * @param spender   Spender's address
                         * @param decrement Amount of decrease in allowance
                         * @return True if successful
                         */
                        function decreaseAllowance(address spender, uint256 decrement)
                            external
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _decreaseAllowance(msg.sender, spender, decrement);
                            return true;
                        }
                    
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _transferWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                v,
                                r,
                                s
                            );
                        }
                    
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _receiveWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                v,
                                r,
                                s
                            );
                        }
                    
                        /**
                         * @notice Attempt to cancel an authorization
                         * @dev Works only if the authorization is not yet used.
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused {
                            _cancelAuthorization(authorizer, nonce, v, r, s);
                        }
                    
                        /**
                         * @notice Update allowance with a signed permit
                         * @param owner       Token owner's address (Authorizer)
                         * @param spender     Spender's address
                         * @param value       Amount of allowance
                         * @param deadline    Expiration time, seconds since the epoch
                         * @param v           v of the signature
                         * @param r           r of the signature
                         * @param s           s of the signature
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused notBlacklisted(owner) notBlacklisted(spender) {
                            _permit(owner, spender, value, deadline, v, r, s);
                        }
                    
                        /**
                         * @notice Internal function to increase the allowance by a given increment
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @param increment Amount of increase
                         */
                        function _increaseAllowance(
                            address owner,
                            address spender,
                            uint256 increment
                        ) internal override {
                            _approve(owner, spender, allowed[owner][spender].add(increment));
                        }
                    
                        /**
                         * @notice Internal function to decrease the allowance by a given decrement
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @param decrement Amount of decrease
                         */
                        function _decreaseAllowance(
                            address owner,
                            address spender,
                            uint256 decrement
                        ) internal override {
                            _approve(
                                owner,
                                spender,
                                allowed[owner][spender].sub(
                                    decrement,
                                    "ERC20: decreased allowance below zero"
                                )
                            );
                        }
                    }
                    
                    // File: contracts/v2/FiatTokenV2_1.sol
                    
                    /**
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * 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
                     * 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
                     * SOFTWARE.
                     */
                    
                    pragma solidity 0.6.12;
                    
                    // solhint-disable func-name-mixedcase
                    
                    /**
                     * @title FiatToken V2.1
                     * @notice ERC20 Token backed by fiat reserves, version 2.1
                     */
                    contract FiatTokenV2_1 is FiatTokenV2 {
                        /**
                         * @notice Initialize v2.1
                         * @param lostAndFound  The address to which the locked funds are sent
                         */
                        function initializeV2_1(address lostAndFound) external {
                            // solhint-disable-next-line reason-string
                            require(_initializedVersion == 1);
                    
                            uint256 lockedAmount = balances[address(this)];
                            if (lockedAmount > 0) {
                                _transfer(address(this), lostAndFound, lockedAmount);
                            }
                            blacklisted[address(this)] = true;
                    
                            _initializedVersion = 2;
                        }
                    
                        /**
                         * @notice Version string for the EIP712 domain separator
                         * @return Version string
                         */
                        function version() external view returns (string memory) {
                            return "2";
                        }
                    }

                    File 8 of 8: Agent
                    // File: contracts/standards/ERC1271.sol
                    
                    pragma solidity 0.4.24;
                    
                    // ERC1271 on Feb 12th, 2019: https://github.com/ethereum/EIPs/blob/a97dc434930d0ccc4461c97d8c7a920dc585adf2/EIPS/eip-1271.md
                    // Using `isValidSignature(bytes32,bytes)` even though the standard still hasn't been modified
                    // Rationale: https://github.com/ethereum/EIPs/issues/1271#issuecomment-462719728
                    
                    
                    contract ERC1271 {
                        bytes4 constant public ERC1271_INTERFACE_ID = 0xfb855dc9; // this.isValidSignature.selector
                    
                        bytes4 constant public ERC1271_RETURN_VALID_SIGNATURE =   0x20c13b0b; // TODO: Likely needs to be updated
                        bytes4 constant public ERC1271_RETURN_INVALID_SIGNATURE = 0x00000000;
                    
                        /**
                        * @dev Function must be implemented by deriving contract
                        * @param _hash Arbitrary length data signed on the behalf of address(this)
                        * @param _signature Signature byte array associated with _data
                        * @return A bytes4 magic value 0x20c13b0b if the signature check passes, 0x00000000 if not
                        *
                        * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
                        * MUST allow external calls
                        */
                        function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4);
                    
                        function returnIsValidSignatureMagicNumber(bool isValid) internal pure returns (bytes4) {
                            return isValid ? ERC1271_RETURN_VALID_SIGNATURE : ERC1271_RETURN_INVALID_SIGNATURE;
                        }
                    }
                    
                    
                    contract ERC1271Bytes is ERC1271 {
                        /**
                        * @dev Default behavior of `isValidSignature(bytes,bytes)`, can be overloaded for custom validation
                        * @param _data Arbitrary length data signed on the behalf of address(this)
                        * @param _signature Signature byte array associated with _data
                        * @return A bytes4 magic value 0x20c13b0b if the signature check passes, 0x00000000 if not
                        *
                        * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
                        * MUST allow external calls
                        */
                        function isValidSignature(bytes _data, bytes _signature) public view returns (bytes4) {
                            return isValidSignature(keccak256(_data), _signature);
                        }
                    }
                    
                    // File: contracts/SignatureValidator.sol
                    
                    pragma solidity 0.4.24;
                    
                    // Inspired by https://github.com/horizon-games/multi-token-standard/blob/319740cf2a78b8816269ae49a09c537b3fd7303b/contracts/utils/SignatureValidator.sol
                    // This should probably be moved into aOS: https://github.com/aragon/aragonOS/pull/442
                    
                    
                    
                    library SignatureValidator {
                        enum SignatureMode {
                            Invalid, // 0x00
                            EIP712,  // 0x01
                            EthSign, // 0x02
                            ERC1271, // 0x03
                            NMode    // 0x04, to check if mode is specified, leave at the end
                        }
                    
                        // bytes4(keccak256("isValidSignature(bytes,bytes)")
                        bytes4 public constant ERC1271_RETURN_VALID_SIGNATURE = 0x20c13b0b;
                        uint256 internal constant ERC1271_ISVALIDSIG_MAX_GAS = 250000;
                    
                        string private constant ERROR_INVALID_LENGTH_POP_BYTE = "SIGVAL_INVALID_LENGTH_POP_BYTE";
                    
                        /// @dev Validates that a hash was signed by a specified signer.
                        /// @param hash Hash which was signed.
                        /// @param signer Address of the signer.
                        /// @param signature ECDSA signature along with the mode (0 = Invalid, 1 = EIP712, 2 = EthSign, 3 = ERC1271) {mode}{r}{s}{v}.
                        /// @return Returns whether signature is from a specified user.
                        function isValidSignature(bytes32 hash, address signer, bytes signature) internal view returns (bool) {
                            if (signature.length == 0) {
                                return false;
                            }
                    
                            uint8 modeByte = uint8(signature[0]);
                            if (modeByte >= uint8(SignatureMode.NMode)) {
                                return false;
                            }
                            SignatureMode mode = SignatureMode(modeByte);
                    
                            if (mode == SignatureMode.EIP712) {
                                return ecVerify(hash, signer, signature);
                            } else if (mode == SignatureMode.EthSign) {
                                return ecVerify(
                                    keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
                                    signer,
                                    signature
                                );
                            } else if (mode == SignatureMode.ERC1271) {
                                // Pop the mode byte before sending it down the validation chain
                                return safeIsValidSignature(signer, hash, popFirstByte(signature));
                            } else {
                                return false;
                            }
                        }
                    
                        function ecVerify(bytes32 hash, address signer, bytes memory signature) private pure returns (bool) {
                            (bool badSig, bytes32 r, bytes32 s, uint8 v) = unpackEcSig(signature);
                    
                            if (badSig) {
                                return false;
                            }
                    
                            return signer == ecrecover(hash, v, r, s);
                        }
                    
                        function unpackEcSig(bytes memory signature) private pure returns (bool badSig, bytes32 r, bytes32 s, uint8 v) {
                            if (signature.length != 66) {
                                badSig = true;
                                return;
                            }
                    
                            v = uint8(signature[65]);
                            assembly {
                                r := mload(add(signature, 33))
                                s := mload(add(signature, 65))
                            }
                    
                            // Allow signature version to be 0 or 1
                            if (v < 27) {
                                v += 27;
                            }
                    
                            if (v != 27 && v != 28) {
                                badSig = true;
                            }
                        }
                    
                        function popFirstByte(bytes memory input) private pure returns (bytes memory output) {
                            uint256 inputLength = input.length;
                            require(inputLength > 0, ERROR_INVALID_LENGTH_POP_BYTE);
                    
                            output = new bytes(inputLength - 1);
                    
                            if (output.length == 0) {
                                return output;
                            }
                    
                            uint256 inputPointer;
                            uint256 outputPointer;
                            assembly {
                                inputPointer := add(input, 0x21)
                                outputPointer := add(output, 0x20)
                            }
                            memcpy(outputPointer, inputPointer, output.length);
                        }
                    
                        function safeIsValidSignature(address validator, bytes32 hash, bytes memory signature) private view returns (bool) {
                            bytes memory data = abi.encodeWithSelector(ERC1271(validator).isValidSignature.selector, hash, signature);
                            bytes4 erc1271Return = safeBytes4StaticCall(validator, data, ERC1271_ISVALIDSIG_MAX_GAS);
                            return erc1271Return == ERC1271_RETURN_VALID_SIGNATURE;
                        }
                    
                        function safeBytes4StaticCall(address target, bytes data, uint256 maxGas) private view returns (bytes4 ret) {
                            uint256 gasLeft = gasleft();
                    
                            uint256 callGas = gasLeft > maxGas ? maxGas : gasLeft;
                            bool ok;
                            assembly {
                                ok := staticcall(callGas, target, add(data, 0x20), mload(data), 0, 0)
                            }
                    
                            if (!ok) {
                                return;
                            }
                    
                            uint256 size;
                            assembly { size := returndatasize }
                            if (size != 32) {
                                return;
                            }
                    
                            assembly {
                                let ptr := mload(0x40)       // get next free memory ptr
                                returndatacopy(ptr, 0, size) // copy return from above `staticcall`
                                ret := mload(ptr)            // read data at ptr and set it to be returned
                            }
                    
                            return ret;
                        }
                    
                        // From: https://github.com/Arachnid/solidity-stringutils/blob/01e955c1d6/src/strings.sol
                        function memcpy(uint256 dest, uint256 src, uint256 len) private pure {
                            // Copy word-length chunks while possible
                            for (; len >= 32; len -= 32) {
                                assembly {
                                    mstore(dest, mload(src))
                                }
                                dest += 32;
                                src += 32;
                            }
                    
                            // Copy remaining bytes
                            uint mask = 256 ** (32 - len) - 1;
                            assembly {
                                let srcpart := and(mload(src), not(mask))
                                let destpart := and(mload(dest), mask)
                                mstore(dest, or(destpart, srcpart))
                            }
                        }
                    }
                    
                    // File: contracts/standards/IERC165.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    interface IERC165 {
                        function supportsInterface(bytes4 interfaceId) external pure returns (bool);
                    }
                    
                    // File: contracts/standards/IERC721Receiver.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    interface IERC721Receiver {
                        /**
                         * @notice Handle the receipt of an NFT
                         * @dev The ERC721 smart contract calls this function on the recipient
                         * after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
                         * otherwise the caller will revert the transaction. The selector to be
                         * returned can be obtained as `this.onERC721Received.selector`. This
                         * function MAY throw to revert and reject the transfer.
                         * Note: the ERC721 contract address is always the message sender.
                         * @param operator The address which called `safeTransferFrom` function
                         * @param from The address which previously owned the token
                         * @param tokenId The NFT identifier which is being transferred
                         * @param data Additional data with no specified format
                         * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
                         */
                        function onERC721Received(address operator, address from, uint256 tokenId, bytes data) external returns (bytes4);
                    }
                    
                    // File: @aragon/os/contracts/common/UnstructuredStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library UnstructuredStorage {
                        function getStorageBool(bytes32 position) internal view returns (bool data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageAddress(bytes32 position) internal view returns (address data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
                            assembly { data := sload(position) }
                        }
                    
                        function setStorageBool(bytes32 position, bool data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageAddress(bytes32 position, address data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageBytes32(bytes32 position, bytes32 data) internal {
                            assembly { sstore(position, data) }
                        }
                    
                        function setStorageUint256(bytes32 position, uint256 data) internal {
                            assembly { sstore(position, data) }
                        }
                    }
                    
                    // File: @aragon/os/contracts/acl/IACL.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IACL {
                        function initialize(address permissionsCreator) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    }
                    
                    // File: @aragon/os/contracts/common/IVaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IVaultRecoverable {
                        event RecoverToVault(address indexed vault, address indexed token, uint256 amount);
                    
                        function transferToVault(address token) external;
                    
                        function allowRecoverability(address token) external view returns (bool);
                        function getRecoveryVault() external view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/kernel/IKernel.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    interface IKernelEvents {
                        event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app);
                    }
                    
                    
                    // This should be an interface, but interfaces can't inherit yet :(
                    contract IKernel is IKernelEvents, IVaultRecoverable {
                        function acl() public view returns (IACL);
                        function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);
                    
                        function setApp(bytes32 namespace, bytes32 appId, address app) public;
                        function getApp(bytes32 namespace, bytes32 appId) public view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/apps/AppStorage.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract AppStorage {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_POSITION = keccak256("aragonOS.appStorage.kernel");
                        bytes32 internal constant APP_ID_POSITION = keccak256("aragonOS.appStorage.appId");
                        */
                        bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b;
                        bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b;
                    
                        function kernel() public view returns (IKernel) {
                            return IKernel(KERNEL_POSITION.getStorageAddress());
                        }
                    
                        function appId() public view returns (bytes32) {
                            return APP_ID_POSITION.getStorageBytes32();
                        }
                    
                        function setKernel(IKernel _kernel) internal {
                            KERNEL_POSITION.setStorageAddress(address(_kernel));
                        }
                    
                        function setAppId(bytes32 _appId) internal {
                            APP_ID_POSITION.setStorageBytes32(_appId);
                        }
                    }
                    
                    // File: @aragon/os/contracts/acl/ACLSyntaxSugar.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract ACLSyntaxSugar {
                        function arr() internal pure returns (uint256[]) {
                            return new uint256[](0);
                        }
                    
                        function arr(bytes32 _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a) internal pure returns (uint256[] r) {
                            return arr(uint256(_a));
                        }
                    
                        function arr(address _a, address _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c);
                        }
                    
                        function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), _b, _c, _d);
                        }
                    
                        function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b));
                        }
                    
                        function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), _c, _d, _e);
                        }
                    
                        function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) {
                            return arr(uint256(_a), uint256(_b), uint256(_c));
                        }
                    
                        function arr(uint256 _a) internal pure returns (uint256[] r) {
                            r = new uint256[](1);
                            r[0] = _a;
                        }
                    
                        function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) {
                            r = new uint256[](2);
                            r[0] = _a;
                            r[1] = _b;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {
                            r = new uint256[](3);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {
                            r = new uint256[](4);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                        }
                    
                        function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {
                            r = new uint256[](5);
                            r[0] = _a;
                            r[1] = _b;
                            r[2] = _c;
                            r[3] = _d;
                            r[4] = _e;
                        }
                    }
                    
                    
                    contract ACLHelpers {
                        function decodeParamOp(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 30));
                        }
                    
                        function decodeParamId(uint256 _x) internal pure returns (uint8 b) {
                            return uint8(_x >> (8 * 31));
                        }
                    
                        function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) {
                            a = uint32(_x);
                            b = uint32(_x >> (8 * 4));
                            c = uint32(_x >> (8 * 8));
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Uint256Helpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library Uint256Helpers {
                        uint256 private constant MAX_UINT64 = uint64(-1);
                    
                        string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
                    
                        function toUint64(uint256 a) internal pure returns (uint64) {
                            require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG);
                            return uint64(a);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/TimeHelpers.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract TimeHelpers {
                        using Uint256Helpers for uint256;
                    
                        /**
                        * @dev Returns the current block number.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber() internal view returns (uint256) {
                            return block.number;
                        }
                    
                        /**
                        * @dev Returns the current block number, converted to uint64.
                        *      Using a function rather than `block.number` allows us to easily mock the block number in
                        *      tests.
                        */
                        function getBlockNumber64() internal view returns (uint64) {
                            return getBlockNumber().toUint64();
                        }
                    
                        /**
                        * @dev Returns the current timestamp.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp() internal view returns (uint256) {
                            return block.timestamp; // solium-disable-line security/no-block-members
                        }
                    
                        /**
                        * @dev Returns the current timestamp, converted to uint64.
                        *      Using a function rather than `block.timestamp` allows us to easily mock it in
                        *      tests.
                        */
                        function getTimestamp64() internal view returns (uint64) {
                            return getTimestamp().toUint64();
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Initializable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    contract Initializable is TimeHelpers {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.initializable.initializationBlock")
                        bytes32 internal constant INITIALIZATION_BLOCK_POSITION = 0xebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e;
                    
                        string private constant ERROR_ALREADY_INITIALIZED = "INIT_ALREADY_INITIALIZED";
                        string private constant ERROR_NOT_INITIALIZED = "INIT_NOT_INITIALIZED";
                    
                        modifier onlyInit {
                            require(getInitializationBlock() == 0, ERROR_ALREADY_INITIALIZED);
                            _;
                        }
                    
                        modifier isInitialized {
                            require(hasInitialized(), ERROR_NOT_INITIALIZED);
                            _;
                        }
                    
                        /**
                        * @return Block number in which the contract was initialized
                        */
                        function getInitializationBlock() public view returns (uint256) {
                            return INITIALIZATION_BLOCK_POSITION.getStorageUint256();
                        }
                    
                        /**
                        * @return Whether the contract has been initialized by the time of the current block
                        */
                        function hasInitialized() public view returns (bool) {
                            uint256 initializationBlock = getInitializationBlock();
                            return initializationBlock != 0 && getBlockNumber() >= initializationBlock;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization has finished.
                        */
                        function initialized() internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(getBlockNumber());
                        }
                    
                        /**
                        * @dev Function to be called by top level contract after initialization to enable the contract
                        *      at a future block number rather than immediately.
                        */
                        function initializedAt(uint256 _blockNumber) internal onlyInit {
                            INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Petrifiable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract Petrifiable is Initializable {
                        // Use block UINT256_MAX (which should be never) as the initializable date
                        uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
                    
                        function isPetrified() public view returns (bool) {
                            return getInitializationBlock() == PETRIFIED_BLOCK;
                        }
                    
                        /**
                        * @dev Function to be called by top level contract to prevent being initialized.
                        *      Useful for freezing base contracts when they're used behind proxies.
                        */
                        function petrify() internal onlyInit {
                            initializedAt(PETRIFIED_BLOCK);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/Autopetrified.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract Autopetrified is Petrifiable {
                        constructor() public {
                            // Immediately petrify base (non-proxy) instances of inherited contracts on deploy.
                            // This renders them uninitializable (and unusable without a proxy).
                            petrify();
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/ConversionHelpers.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    library ConversionHelpers {
                        string private constant ERROR_IMPROPER_LENGTH = "CONVERSION_IMPROPER_LENGTH";
                    
                        function dangerouslyCastUintArrayToBytes(uint256[] memory _input) internal pure returns (bytes memory output) {
                            // Force cast the uint256[] into a bytes array, by overwriting its length
                            // Note that the bytes array doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 byteLength = _input.length * 32;
                            assembly {
                                output := _input
                                mstore(output, byteLength)
                            }
                        }
                    
                        function dangerouslyCastBytesToUintArray(bytes memory _input) internal pure returns (uint256[] memory output) {
                            // Force cast the bytes array into a uint256[], by overwriting its length
                            // Note that the uint256[] doesn't need to be initialized as we immediately overwrite it
                            // with the input and a new length. The input becomes invalid from this point forward.
                            uint256 intsLength = _input.length / 32;
                            require(_input.length == intsLength * 32, ERROR_IMPROPER_LENGTH);
                    
                            assembly {
                                output := _input
                                mstore(output, intsLength)
                            }
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/ReentrancyGuard.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract ReentrancyGuard {
                        using UnstructuredStorage for bytes32;
                    
                        /* Hardcoded constants to save gas
                        bytes32 internal constant REENTRANCY_MUTEX_POSITION = keccak256("aragonOS.reentrancyGuard.mutex");
                        */
                        bytes32 private constant REENTRANCY_MUTEX_POSITION = 0xe855346402235fdd185c890e68d2c4ecad599b88587635ee285bce2fda58dacb;
                    
                        string private constant ERROR_REENTRANT = "REENTRANCY_REENTRANT_CALL";
                    
                        modifier nonReentrant() {
                            // Ensure mutex is unlocked
                            require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT);
                    
                            // Lock mutex before function call
                            REENTRANCY_MUTEX_POSITION.setStorageBool(true);
                    
                            // Perform function call
                            _;
                    
                            // Unlock mutex after function call
                            REENTRANCY_MUTEX_POSITION.setStorageBool(false);
                        }
                    }
                    
                    // File: @aragon/os/contracts/lib/token/ERC20.sol
                    
                    // See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title ERC20 interface
                     * @dev see https://github.com/ethereum/EIPs/issues/20
                     */
                    contract ERC20 {
                        function totalSupply() public view returns (uint256);
                    
                        function balanceOf(address _who) public view returns (uint256);
                    
                        function allowance(address _owner, address _spender)
                            public view returns (uint256);
                    
                        function transfer(address _to, uint256 _value) public returns (bool);
                    
                        function approve(address _spender, uint256 _value)
                            public returns (bool);
                    
                        function transferFrom(address _from, address _to, uint256 _value)
                            public returns (bool);
                    
                        event Transfer(
                            address indexed from,
                            address indexed to,
                            uint256 value
                        );
                    
                        event Approval(
                            address indexed owner,
                            address indexed spender,
                            uint256 value
                        );
                    }
                    
                    // File: @aragon/os/contracts/common/EtherTokenConstant.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    // aragonOS and aragon-apps rely on address(0) to denote native ETH, in
                    // contracts where both tokens and ETH are accepted
                    contract EtherTokenConstant {
                        address internal constant ETH = address(0);
                    }
                    
                    // File: @aragon/os/contracts/common/IsContract.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract IsContract {
                        /*
                        * NOTE: this should NEVER be used for authentication
                        * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
                        *
                        * This is only intended to be used as a sanity check that an address is actually a contract,
                        * RATHER THAN an address not being a contract.
                        */
                        function isContract(address _target) internal view returns (bool) {
                            if (_target == address(0)) {
                                return false;
                            }
                    
                            uint256 size;
                            assembly { size := extcodesize(_target) }
                            return size > 0;
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/SafeERC20.sol
                    
                    // Inspired by AdEx (https://github.com/AdExNetwork/adex-protocol-eth/blob/b9df617829661a7518ee10f4cb6c4108659dd6d5/contracts/libs/SafeERC20.sol)
                    // and 0x (https://github.com/0xProject/0x-monorepo/blob/737d1dc54d72872e24abce5a1dbe1b66d35fa21a/contracts/protocol/contracts/protocol/AssetProxy/ERC20Proxy.sol#L143)
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    library SafeERC20 {
                        // Before 0.5, solidity has a mismatch between `address.transfer()` and `token.transfer()`:
                        // https://github.com/ethereum/solidity/issues/3544
                        bytes4 private constant TRANSFER_SELECTOR = 0xa9059cbb;
                    
                        string private constant ERROR_TOKEN_BALANCE_REVERTED = "SAFE_ERC_20_BALANCE_REVERTED";
                        string private constant ERROR_TOKEN_ALLOWANCE_REVERTED = "SAFE_ERC_20_ALLOWANCE_REVERTED";
                    
                        function invokeAndCheckSuccess(address _addr, bytes memory _calldata)
                            private
                            returns (bool)
                        {
                            bool ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                let success := call(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    0,                    // no value
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    // Check number of bytes returned from last function call
                                    switch returndatasize
                    
                                    // No bytes returned: assume success
                                    case 0 {
                                        ret := 1
                                    }
                    
                                    // 32 bytes returned: check if non-zero
                                    case 0x20 {
                                        // Only return success if returned data was true
                                        // Already have output in ptr
                                        ret := eq(mload(ptr), 1)
                                    }
                    
                                    // Not sure what was returned: don't mark as success
                                    default { }
                                }
                            }
                            return ret;
                        }
                    
                        function staticInvoke(address _addr, bytes memory _calldata)
                            private
                            view
                            returns (bool, uint256)
                        {
                            bool success;
                            uint256 ret;
                            assembly {
                                let ptr := mload(0x40)    // free memory pointer
                    
                                success := staticcall(
                                    gas,                  // forward all gas
                                    _addr,                // address
                                    add(_calldata, 0x20), // calldata start
                                    mload(_calldata),     // calldata length
                                    ptr,                  // write output over free memory
                                    0x20                  // uint256 return
                                )
                    
                                if gt(success, 0) {
                                    ret := mload(ptr)
                                }
                            }
                            return (success, ret);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transfer() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransfer(ERC20 _token, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferCallData = abi.encodeWithSelector(
                                TRANSFER_SELECTOR,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.transferFrom() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeTransferFrom(ERC20 _token, address _from, address _to, uint256 _amount) internal returns (bool) {
                            bytes memory transferFromCallData = abi.encodeWithSelector(
                                _token.transferFrom.selector,
                                _from,
                                _to,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, transferFromCallData);
                        }
                    
                        /**
                        * @dev Same as a standards-compliant ERC20.approve() that never reverts (returns false).
                        *      Note that this makes an external call to the token.
                        */
                        function safeApprove(ERC20 _token, address _spender, uint256 _amount) internal returns (bool) {
                            bytes memory approveCallData = abi.encodeWithSelector(
                                _token.approve.selector,
                                _spender,
                                _amount
                            );
                            return invokeAndCheckSuccess(_token, approveCallData);
                        }
                    
                        /**
                        * @dev Static call into ERC20.balanceOf().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticBalanceOf(ERC20 _token, address _owner) internal view returns (uint256) {
                            bytes memory balanceOfCallData = abi.encodeWithSelector(
                                _token.balanceOf.selector,
                                _owner
                            );
                    
                            (bool success, uint256 tokenBalance) = staticInvoke(_token, balanceOfCallData);
                            require(success, ERROR_TOKEN_BALANCE_REVERTED);
                    
                            return tokenBalance;
                        }
                    
                        /**
                        * @dev Static call into ERC20.allowance().
                        * Reverts if the call fails for some reason (should never fail).
                        */
                        function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) {
                            bytes memory allowanceCallData = abi.encodeWithSelector(
                                _token.allowance.selector,
                                _owner,
                                _spender
                            );
                    
                            (bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData);
                            require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
                    
                            return allowance;
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/VaultRecoverable.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract {
                        using SafeERC20 for ERC20;
                    
                        string private constant ERROR_DISALLOWED = "RECOVER_DISALLOWED";
                        string private constant ERROR_VAULT_NOT_CONTRACT = "RECOVER_VAULT_NOT_CONTRACT";
                        string private constant ERROR_TOKEN_TRANSFER_FAILED = "RECOVER_TOKEN_TRANSFER_FAILED";
                    
                        /**
                         * @notice Send funds to recovery Vault. This contract should never receive funds,
                         *         but in case it does, this function allows one to recover them.
                         * @param _token Token balance to be sent to recovery vault.
                         */
                        function transferToVault(address _token) external {
                            require(allowRecoverability(_token), ERROR_DISALLOWED);
                            address vault = getRecoveryVault();
                            require(isContract(vault), ERROR_VAULT_NOT_CONTRACT);
                    
                            uint256 balance;
                            if (_token == ETH) {
                                balance = address(this).balance;
                                vault.transfer(balance);
                            } else {
                                ERC20 token = ERC20(_token);
                                balance = token.staticBalanceOf(this);
                                require(token.safeTransfer(vault, balance), ERROR_TOKEN_TRANSFER_FAILED);
                            }
                    
                            emit RecoverToVault(vault, _token, balance);
                        }
                    
                        /**
                        * @dev By default deriving from AragonApp makes it recoverable
                        * @param token Token address that would be recovered
                        * @return bool whether the app allows the recovery
                        */
                        function allowRecoverability(address token) public view returns (bool) {
                            return true;
                        }
                    
                        // Cast non-implemented interface to be public so we can use it internally
                        function getRecoveryVault() public view returns (address);
                    }
                    
                    // File: @aragon/os/contracts/evmscript/IEVMScriptExecutor.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IEVMScriptExecutor {
                        function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes);
                        function executorType() external pure returns (bytes32);
                    }
                    
                    // File: @aragon/os/contracts/evmscript/IEVMScriptRegistry.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    contract EVMScriptRegistryConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = apmNamehash("evmreg");
                        */
                        bytes32 internal constant EVMSCRIPT_REGISTRY_APP_ID = 0xddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd61;
                    }
                    
                    
                    interface IEVMScriptRegistry {
                        function addScriptExecutor(IEVMScriptExecutor executor) external returns (uint id);
                        function disableScriptExecutor(uint256 executorId) external;
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function getScriptExecutor(bytes script) public view returns (IEVMScriptExecutor);
                    }
                    
                    // File: @aragon/os/contracts/kernel/KernelConstants.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    contract KernelAppIds {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel");
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl");
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault");
                        */
                        bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c;
                        bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a;
                        bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1;
                    }
                    
                    
                    contract KernelNamespaceConstants {
                        /* Hardcoded constants to save gas
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core");
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base");
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app");
                        */
                        bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8;
                        bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f;
                        bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
                    }
                    
                    // File: @aragon/os/contracts/evmscript/EVMScriptRunner.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract EVMScriptRunner is AppStorage, Initializable, EVMScriptRegistryConstants, KernelNamespaceConstants {
                        string private constant ERROR_EXECUTOR_UNAVAILABLE = "EVMRUN_EXECUTOR_UNAVAILABLE";
                        string private constant ERROR_PROTECTED_STATE_MODIFIED = "EVMRUN_PROTECTED_STATE_MODIFIED";
                    
                        /* This is manually crafted in assembly
                        string private constant ERROR_EXECUTOR_INVALID_RETURN = "EVMRUN_EXECUTOR_INVALID_RETURN";
                        */
                    
                        event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData);
                    
                        function getEVMScriptExecutor(bytes _script) public view returns (IEVMScriptExecutor) {
                            return IEVMScriptExecutor(getEVMScriptRegistry().getScriptExecutor(_script));
                        }
                    
                        function getEVMScriptRegistry() public view returns (IEVMScriptRegistry) {
                            address registryAddr = kernel().getApp(KERNEL_APP_ADDR_NAMESPACE, EVMSCRIPT_REGISTRY_APP_ID);
                            return IEVMScriptRegistry(registryAddr);
                        }
                    
                        function runScript(bytes _script, bytes _input, address[] _blacklist)
                            internal
                            isInitialized
                            protectState
                            returns (bytes)
                        {
                            IEVMScriptExecutor executor = getEVMScriptExecutor(_script);
                            require(address(executor) != address(0), ERROR_EXECUTOR_UNAVAILABLE);
                    
                            bytes4 sig = executor.execScript.selector;
                            bytes memory data = abi.encodeWithSelector(sig, _script, _input, _blacklist);
                    
                            bytes memory output;
                            assembly {
                                let success := delegatecall(
                                    gas,                // forward all gas
                                    executor,           // address
                                    add(data, 0x20),    // calldata start
                                    mload(data),        // calldata length
                                    0,                  // don't write output (we'll handle this ourselves)
                                    0                   // don't write output
                                )
                    
                                output := mload(0x40) // free mem ptr get
                    
                                switch success
                                case 0 {
                                    // If the call errored, forward its full error data
                                    returndatacopy(output, 0, returndatasize)
                                    revert(output, returndatasize)
                                }
                                default {
                                    switch gt(returndatasize, 0x3f)
                                    case 0 {
                                        // Need at least 0x40 bytes returned for properly ABI-encoded bytes values,
                                        // revert with "EVMRUN_EXECUTOR_INVALID_RETURN"
                                        // See remix: doing a `revert("EVMRUN_EXECUTOR_INVALID_RETURN")` always results in
                                        // this memory layout
                                        mstore(output, 0x08c379a000000000000000000000000000000000000000000000000000000000)         // error identifier
                                        mstore(add(output, 0x04), 0x0000000000000000000000000000000000000000000000000000000000000020) // starting offset
                                        mstore(add(output, 0x24), 0x000000000000000000000000000000000000000000000000000000000000001e) // reason length
                                        mstore(add(output, 0x44), 0x45564d52554e5f4558454355544f525f494e56414c49445f52455455524e0000) // reason
                    
                                        revert(output, 100) // 100 = 4 + 3 * 32 (error identifier + 3 words for the ABI encoded error)
                                    }
                                    default {
                                        // Copy result
                                        //
                                        // Needs to perform an ABI decode for the expected `bytes` return type of
                                        // `executor.execScript()` as solidity will automatically ABI encode the returned bytes as:
                                        //    [ position of the first dynamic length return value = 0x20 (32 bytes) ]
                                        //    [ output length (32 bytes) ]
                                        //    [ output content (N bytes) ]
                                        //
                                        // Perform the ABI decode by ignoring the first 32 bytes of the return data
                                        let copysize := sub(returndatasize, 0x20)
                                        returndatacopy(output, 0x20, copysize)
                    
                                        mstore(0x40, add(output, copysize)) // free mem ptr set
                                    }
                                }
                            }
                    
                            emit ScriptResult(address(executor), _script, _input, output);
                    
                            return output;
                        }
                    
                        modifier protectState {
                            address preKernel = address(kernel());
                            bytes32 preAppId = appId();
                            _; // exec
                            require(address(kernel()) == preKernel, ERROR_PROTECTED_STATE_MODIFIED);
                            require(appId() == preAppId, ERROR_PROTECTED_STATE_MODIFIED);
                        }
                    }
                    
                    // File: @aragon/os/contracts/apps/AragonApp.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    // Contracts inheriting from AragonApp are, by default, immediately petrified upon deployment so
                    // that they can never be initialized.
                    // Unless overriden, this behaviour enforces those contracts to be usable only behind an AppProxy.
                    // ReentrancyGuard, EVMScriptRunner, and ACLSyntaxSugar are not directly used by this contract, but
                    // are included so that they are automatically usable by subclassing contracts
                    contract AragonApp is AppStorage, Autopetrified, VaultRecoverable, ReentrancyGuard, EVMScriptRunner, ACLSyntaxSugar {
                        string private constant ERROR_AUTH_FAILED = "APP_AUTH_FAILED";
                    
                        modifier auth(bytes32 _role) {
                            require(canPerform(msg.sender, _role, new uint256[](0)), ERROR_AUTH_FAILED);
                            _;
                        }
                    
                        modifier authP(bytes32 _role, uint256[] _params) {
                            require(canPerform(msg.sender, _role, _params), ERROR_AUTH_FAILED);
                            _;
                        }
                    
                        /**
                        * @dev Check whether an action can be performed by a sender for a particular role on this app
                        * @param _sender Sender of the call
                        * @param _role Role on this app
                        * @param _params Permission params for the role
                        * @return Boolean indicating whether the sender has the permissions to perform the action.
                        *         Always returns false if the app hasn't been initialized yet.
                        */
                        function canPerform(address _sender, bytes32 _role, uint256[] _params) public view returns (bool) {
                            if (!hasInitialized()) {
                                return false;
                            }
                    
                            IKernel linkedKernel = kernel();
                            if (address(linkedKernel) == address(0)) {
                                return false;
                            }
                    
                            return linkedKernel.hasPermission(
                                _sender,
                                address(this),
                                _role,
                                ConversionHelpers.dangerouslyCastUintArrayToBytes(_params)
                            );
                        }
                    
                        /**
                        * @dev Get the recovery vault for the app
                        * @return Recovery vault address for the app
                        */
                        function getRecoveryVault() public view returns (address) {
                            // Funds recovery via a vault is only available when used with a kernel
                            return kernel().getRecoveryVault(); // if kernel is not set, it will revert
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/DepositableStorage.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    contract DepositableStorage {
                        using UnstructuredStorage for bytes32;
                    
                        // keccak256("aragonOS.depositableStorage.depositable")
                        bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
                    
                        function isDepositable() public view returns (bool) {
                            return DEPOSITABLE_POSITION.getStorageBool();
                        }
                    
                        function setDepositable(bool _depositable) internal {
                            DEPOSITABLE_POSITION.setStorageBool(_depositable);
                        }
                    }
                    
                    // File: @aragon/apps-vault/contracts/Vault.sol
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
                        using SafeERC20 for ERC20;
                    
                        bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");
                    
                        string private constant ERROR_DATA_NON_ZERO = "VAULT_DATA_NON_ZERO";
                        string private constant ERROR_NOT_DEPOSITABLE = "VAULT_NOT_DEPOSITABLE";
                        string private constant ERROR_DEPOSIT_VALUE_ZERO = "VAULT_DEPOSIT_VALUE_ZERO";
                        string private constant ERROR_TRANSFER_VALUE_ZERO = "VAULT_TRANSFER_VALUE_ZERO";
                        string private constant ERROR_SEND_REVERTED = "VAULT_SEND_REVERTED";
                        string private constant ERROR_VALUE_MISMATCH = "VAULT_VALUE_MISMATCH";
                        string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "VAULT_TOKEN_TRANSFER_FROM_REVERT";
                        string private constant ERROR_TOKEN_TRANSFER_REVERTED = "VAULT_TOKEN_TRANSFER_REVERTED";
                    
                        event VaultTransfer(address indexed token, address indexed to, uint256 amount);
                        event VaultDeposit(address indexed token, address indexed sender, uint256 amount);
                    
                        /**
                        * @dev On a normal send() or transfer() this fallback is never executed as it will be
                        *      intercepted by the Proxy (see aragonOS#281)
                        */
                        function () external payable isInitialized {
                            require(msg.data.length == 0, ERROR_DATA_NON_ZERO);
                            _deposit(ETH, msg.value);
                        }
                    
                        /**
                        * @notice Initialize Vault app
                        * @dev As an AragonApp it needs to be initialized in order for roles (`auth` and `authP`) to work
                        */
                        function initialize() external onlyInit {
                            initialized();
                            setDepositable(true);
                        }
                    
                        /**
                        * @notice Deposit `_value` `_token` to the vault
                        * @param _token Address of the token being transferred
                        * @param _value Amount of tokens being transferred
                        */
                        function deposit(address _token, uint256 _value) external payable isInitialized {
                            _deposit(_token, _value);
                        }
                    
                        /**
                        * @notice Transfer `_value` `_token` from the Vault to `_to`
                        * @param _token Address of the token being transferred
                        * @param _to Address of the recipient of tokens
                        * @param _value Amount of tokens being transferred
                        */
                        /* solium-disable-next-line function-order */
                        function transfer(address _token, address _to, uint256 _value)
                            external
                            authP(TRANSFER_ROLE, arr(_token, _to, _value))
                        {
                            require(_value > 0, ERROR_TRANSFER_VALUE_ZERO);
                    
                            if (_token == ETH) {
                                require(_to.send(_value), ERROR_SEND_REVERTED);
                            } else {
                                require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED);
                            }
                    
                            emit VaultTransfer(_token, _to, _value);
                        }
                    
                        function balance(address _token) public view returns (uint256) {
                            if (_token == ETH) {
                                return address(this).balance;
                            } else {
                                return ERC20(_token).staticBalanceOf(address(this));
                            }
                        }
                    
                        /**
                        * @dev Disable recovery escape hatch, as it could be used
                        *      maliciously to transfer funds away from the vault
                        */
                        function allowRecoverability(address) public view returns (bool) {
                            return false;
                        }
                    
                        function _deposit(address _token, uint256 _value) internal {
                            require(isDepositable(), ERROR_NOT_DEPOSITABLE);
                            require(_value > 0, ERROR_DEPOSIT_VALUE_ZERO);
                    
                            if (_token == ETH) {
                                // Deposit is implicit in this case
                                require(msg.value == _value, ERROR_VALUE_MISMATCH);
                            } else {
                                require(
                                    ERC20(_token).safeTransferFrom(msg.sender, address(this), _value),
                                    ERROR_TOKEN_TRANSFER_FROM_REVERTED
                                );
                            }
                    
                            emit VaultDeposit(_token, msg.sender, _value);
                        }
                    }
                    
                    // File: @aragon/os/contracts/common/IForwarder.sol
                    
                    /*
                     * SPDX-License-Identitifer:    MIT
                     */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    interface IForwarder {
                        function isForwarder() external pure returns (bool);
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function canForward(address sender, bytes evmCallScript) public view returns (bool);
                    
                        // TODO: this should be external
                        // See https://github.com/ethereum/solidity/issues/4832
                        function forward(bytes evmCallScript) public;
                    }
                    
                    // File: contracts/Agent.sol
                    
                    /*
                     * SPDX-License-Identifier:    GPL-3.0-or-later
                     */
                    
                    pragma solidity 0.4.24;
                    
                    
                    
                    
                    
                    
                    
                    
                    contract Agent is IERC165, IERC721Receiver, ERC1271Bytes, IForwarder, IsContract, Vault {
                        /* Hardcoded constants to save gas
                        bytes32 public constant EXECUTE_ROLE = keccak256("EXECUTE_ROLE");
                        bytes32 public constant SAFE_EXECUTE_ROLE = keccak256("SAFE_EXECUTE_ROLE");
                        bytes32 public constant ADD_PROTECTED_TOKEN_ROLE = keccak256("ADD_PROTECTED_TOKEN_ROLE");
                        bytes32 public constant REMOVE_PROTECTED_TOKEN_ROLE = keccak256("REMOVE_PROTECTED_TOKEN_ROLE");
                        bytes32 public constant ADD_PRESIGNED_HASH_ROLE = keccak256("ADD_PRESIGNED_HASH_ROLE");
                        bytes32 public constant DESIGNATE_SIGNER_ROLE = keccak256("DESIGNATE_SIGNER_ROLE");
                        bytes32 public constant RUN_SCRIPT_ROLE = keccak256("RUN_SCRIPT_ROLE");
                        */
                    
                        bytes32 public constant EXECUTE_ROLE = 0xcebf517aa4440d1d125e0355aae64401211d0848a23c02cc5d29a14822580ba4;
                        bytes32 public constant SAFE_EXECUTE_ROLE = 0x0a1ad7b87f5846153c6d5a1f761d71c7d0cfd122384f56066cd33239b7933694;
                        bytes32 public constant ADD_PROTECTED_TOKEN_ROLE = 0x6eb2a499556bfa2872f5aa15812b956cc4a71b4d64eb3553f7073c7e41415aaa;
                        bytes32 public constant REMOVE_PROTECTED_TOKEN_ROLE = 0x71eee93d500f6f065e38b27d242a756466a00a52a1dbcd6b4260f01a8640402a;
                        bytes32 public constant ADD_PRESIGNED_HASH_ROLE = 0x0b29780bb523a130b3b01f231ef49ed2fa2781645591a0b0a44ca98f15a5994c;
                        bytes32 public constant DESIGNATE_SIGNER_ROLE = 0x23ce341656c3f14df6692eebd4757791e33662b7dcf9970c8308303da5472b7c;
                        bytes32 public constant RUN_SCRIPT_ROLE = 0xb421f7ad7646747f3051c50c0b8e2377839296cd4973e27f63821d73e390338f;
                    
                        uint256 public constant PROTECTED_TOKENS_CAP = 10;
                    
                        bytes4 private constant ERC165_INTERFACE_ID = 0x01ffc9a7;
                        bytes4 private constant ERC721_RECEIVED_INTERFACE_ID = 0x150b7a02; // bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))
                    
                        string private constant ERROR_TARGET_PROTECTED = "AGENT_TARGET_PROTECTED";
                        string private constant ERROR_PROTECTED_TOKENS_MODIFIED = "AGENT_PROTECTED_TOKENS_MODIFIED";
                        string private constant ERROR_PROTECTED_BALANCE_LOWERED = "AGENT_PROTECTED_BALANCE_LOWERED";
                        string private constant ERROR_TOKENS_CAP_REACHED = "AGENT_TOKENS_CAP_REACHED";
                        string private constant ERROR_TOKEN_NOT_ERC20 = "AGENT_TOKEN_NOT_ERC20";
                        string private constant ERROR_TOKEN_ALREADY_PROTECTED = "AGENT_TOKEN_ALREADY_PROTECTED";
                        string private constant ERROR_TOKEN_NOT_PROTECTED = "AGENT_TOKEN_NOT_PROTECTED";
                        string private constant ERROR_DESIGNATED_TO_SELF = "AGENT_DESIGNATED_TO_SELF";
                        string private constant ERROR_CAN_NOT_FORWARD = "AGENT_CAN_NOT_FORWARD";
                    
                        mapping (bytes32 => bool) public isPresigned;
                        address public designatedSigner;
                        address[] public protectedTokens;
                    
                        event SafeExecute(address indexed sender, address indexed target, bytes data);
                        event Execute(address indexed sender, address indexed target, uint256 ethValue, bytes data);
                        event AddProtectedToken(address indexed token);
                        event RemoveProtectedToken(address indexed token);
                        event PresignHash(address indexed sender, bytes32 indexed hash);
                        event SetDesignatedSigner(address indexed sender, address indexed oldSigner, address indexed newSigner);
                        event ReceiveERC721(address indexed token, address indexed operator, address indexed from, uint256 tokenId, bytes data);
                    
                        /**
                        * @notice Execute '`@radspec(_target, _data)`' on `_target``_ethValue == 0 ? '' : ' (Sending ' + @tokenAmount(0x0000000000000000000000000000000000000000, _ethValue) + ')'`
                        * @param _target Address where the action is being executed
                        * @param _ethValue Amount of ETH from the contract that is sent with the action
                        * @param _data Calldata for the action
                        * @return Exits call frame forwarding the return data of the executed call (either error or success data)
                        */
                        function execute(address _target, uint256 _ethValue, bytes _data)
                            external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context
                            authP(EXECUTE_ROLE, arr(_target, _ethValue, uint256(_getSig(_data)))) // bytes4 casted as uint256 sets the bytes as the LSBs
                        {
                            bool result = _target.call.value(_ethValue)(_data);
                    
                            if (result) {
                                emit Execute(msg.sender, _target, _ethValue, _data);
                            }
                    
                            assembly {
                                let ptr := mload(0x40)
                                returndatacopy(ptr, 0, returndatasize)
                    
                                // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
                                // if the call returned error data, forward it
                                switch result case 0 { revert(ptr, returndatasize) }
                                default { return(ptr, returndatasize) }
                            }
                        }
                    
                        /**
                        * @notice Execute '`@radspec(_target, _data)`' on `_target`, ensuring that protected tokens can't be spent
                        * @param _target Address where the action is being executed
                        * @param _data Calldata for the action
                        * @return Exits call frame forwarding the return data of the executed call (either error or success data)
                        */
                        function safeExecute(address _target, bytes _data)
                            external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context
                            authP(SAFE_EXECUTE_ROLE, arr(_target, uint256(_getSig(_data)))) // bytes4 casted as uint256 sets the bytes as the LSBs
                        {
                            uint256 protectedTokensLength = protectedTokens.length;
                            address[] memory protectedTokens_ = new address[](protectedTokensLength);
                            uint256[] memory balances = new uint256[](protectedTokensLength);
                    
                            for (uint256 i = 0; i < protectedTokensLength; i++) {
                                address token = protectedTokens[i];
                                require(_target != token, ERROR_TARGET_PROTECTED);
                                // we copy the protected tokens array to check whether the storage array has been modified during the underlying call
                                protectedTokens_[i] = token;
                                // we copy the balances to check whether they have been modified during the underlying call
                                balances[i] = balance(token);
                            }
                    
                            bool result = _target.call(_data);
                    
                            bytes32 ptr;
                            uint256 size;
                            assembly {
                                size := returndatasize
                                ptr := mload(0x40)
                                mstore(0x40, add(ptr, returndatasize))
                                returndatacopy(ptr, 0, returndatasize)
                            }
                    
                            if (result) {
                                // if the underlying call has succeeded, we check that the protected tokens
                                // and their balances have not been modified and return the call's return data
                                require(protectedTokens.length == protectedTokensLength, ERROR_PROTECTED_TOKENS_MODIFIED);
                                for (uint256 j = 0; j < protectedTokensLength; j++) {
                                    require(protectedTokens[j] == protectedTokens_[j], ERROR_PROTECTED_TOKENS_MODIFIED);
                                    require(balance(protectedTokens[j]) >= balances[j], ERROR_PROTECTED_BALANCE_LOWERED);
                                }
                    
                                emit SafeExecute(msg.sender, _target, _data);
                    
                                assembly {
                                    return(ptr, size)
                                }
                            } else {
                                // if the underlying call has failed, we revert and forward returned error data
                                assembly {
                                    revert(ptr, size)
                                }
                            }
                        }
                    
                        /**
                        * @notice Add `_token.symbol(): string` to the list of protected tokens
                        * @param _token Address of the token to be protected
                        */
                        function addProtectedToken(address _token) external authP(ADD_PROTECTED_TOKEN_ROLE, arr(_token)) {
                            require(protectedTokens.length < PROTECTED_TOKENS_CAP, ERROR_TOKENS_CAP_REACHED);
                            require(_isERC20(_token), ERROR_TOKEN_NOT_ERC20);
                            require(!_tokenIsProtected(_token), ERROR_TOKEN_ALREADY_PROTECTED);
                    
                            _addProtectedToken(_token);
                        }
                    
                        /**
                        * @notice Remove `_token.symbol(): string` from the list of protected tokens
                        * @param _token Address of the token to be unprotected
                        */
                        function removeProtectedToken(address _token) external authP(REMOVE_PROTECTED_TOKEN_ROLE, arr(_token)) {
                            require(_tokenIsProtected(_token), ERROR_TOKEN_NOT_PROTECTED);
                    
                            _removeProtectedToken(_token);
                        }
                    
                        /**
                        * @notice Pre-sign hash `_hash`
                        * @param _hash Hash that will be considered signed regardless of the signature checked with 'isValidSignature()'
                        */
                        function presignHash(bytes32 _hash)
                            external
                            authP(ADD_PRESIGNED_HASH_ROLE, arr(_hash))
                        {
                            isPresigned[_hash] = true;
                    
                            emit PresignHash(msg.sender, _hash);
                        }
                    
                        /**
                        * @notice Set `_designatedSigner` as the designated signer of the app, which will be able to sign messages on behalf of the app
                        * @param _designatedSigner Address that will be able to sign messages on behalf of the app
                        */
                        function setDesignatedSigner(address _designatedSigner)
                            external
                            authP(DESIGNATE_SIGNER_ROLE, arr(_designatedSigner))
                        {
                            // Prevent an infinite loop by setting the app itself as its designated signer.
                            // An undetectable loop can be created by setting a different contract as the
                            // designated signer which calls back into `isValidSignature`.
                            // Given that `isValidSignature` is always called with just 50k gas, the max
                            // damage of the loop is wasting 50k gas.
                            require(_designatedSigner != address(this), ERROR_DESIGNATED_TO_SELF);
                    
                            address oldDesignatedSigner = designatedSigner;
                            designatedSigner = _designatedSigner;
                    
                            emit SetDesignatedSigner(msg.sender, oldDesignatedSigner, _designatedSigner);
                        }
                    
                        function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns (bytes4) {
                            emit ReceiveERC721(msg.sender, _operator, _from, _tokenId, _data);
                    
                            return ERC721_RECEIVED_INTERFACE_ID;
                        }
                    
                        // Forwarding fns
                    
                        /**
                        * @notice Tells whether the Agent app is a forwarder or not
                        * @dev IForwarder interface conformance
                        * @return Always true
                        */
                        function isForwarder() external pure returns (bool) {
                            return true;
                        }
                    
                        /**
                         * @notice Tells whether this contract supports a given ERC-165 interface
                         * @dev Implements conformance to ERC-165
                         * @param _interfaceId Interface bytes to check
                         * @return True if this contract supports the interface
                         */
                        function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
                            return
                                _interfaceId == ERC1271_INTERFACE_ID ||
                                _interfaceId == ERC721_RECEIVED_INTERFACE_ID ||
                                _interfaceId == ERC165_INTERFACE_ID;
                        }
                    
                        /**
                        * @notice Execute the script as the Agent app
                        * @dev IForwarder interface conformance. Forwards any token holder action.
                        * @param _evmScript Script being executed
                        */
                        function forward(bytes _evmScript) public {
                            require(canForward(msg.sender, _evmScript), ERROR_CAN_NOT_FORWARD);
                    
                            bytes memory input = ""; // no input
                            address[] memory blacklist = new address[](0); // no addr blacklist, can interact with anything
                            runScript(_evmScript, input, blacklist);
                            // We don't need to emit an event here as EVMScriptRunner will emit ScriptResult if successful
                        }
                    
                        /**
                        * @notice Tells whether `_sender` can forward actions or not
                        * @dev IForwarder interface conformance
                        * @param _sender Address of the account intending to forward an action
                        * @return True if the given address can run scripts, false otherwise
                        */
                        function canForward(address _sender, bytes _evmScript) public view returns (bool) {
                            // Note that `canPerform()` implicitly does an initialization check itself
                            return canPerform(_sender, RUN_SCRIPT_ROLE, arr(_getScriptACLParam(_evmScript)));
                        }
                    
                        // ERC-1271 conformance
                    
                        /**
                         * @notice Tells whether a signature is seen as valid by this contract through ERC-1271
                         * @param _hash Arbitrary length data signed on the behalf of address (this)
                         * @param _signature Signature byte array associated with _data
                         * @return The ERC-1271 magic value if the signature is valid
                         */
                        function isValidSignature(bytes32 _hash, bytes _signature) public view returns (bytes4) {
                            // Short-circuit in case the hash was presigned. Optimization as performing calls
                            // and ecrecover is more expensive than an SLOAD.
                            if (isPresigned[_hash]) {
                                return returnIsValidSignatureMagicNumber(true);
                            }
                    
                            bool isValid;
                            if (designatedSigner == address(0)) {
                                isValid = false;
                            } else {
                                isValid = SignatureValidator.isValidSignature(_hash, designatedSigner, _signature);
                            }
                    
                            return returnIsValidSignatureMagicNumber(isValid);
                        }
                    
                        // Getters
                    
                        function getProtectedTokensLength() public view isInitialized returns (uint256) {
                            return protectedTokens.length;
                        }
                    
                        // Internal fns
                    
                        function _addProtectedToken(address _token) internal {
                            protectedTokens.push(_token);
                    
                            emit AddProtectedToken(_token);
                        }
                    
                        function _removeProtectedToken(address _token) internal {
                            protectedTokens[_protectedTokenIndex(_token)] = protectedTokens[protectedTokens.length - 1];
                            protectedTokens.length--;
                    
                            emit RemoveProtectedToken(_token);
                        }
                    
                        function _isERC20(address _token) internal view returns (bool) {
                            if (!isContract(_token)) {
                                return false;
                            }
                    
                            // Throwaway sanity check to make sure the token's `balanceOf()` does not error (for now)
                            balance(_token);
                    
                            return true;
                        }
                    
                        function _protectedTokenIndex(address _token) internal view returns (uint256) {
                            for (uint i = 0; i < protectedTokens.length; i++) {
                                if (protectedTokens[i] == _token) {
                                  return i;
                                }
                            }
                    
                            revert(ERROR_TOKEN_NOT_PROTECTED);
                        }
                    
                        function _tokenIsProtected(address _token) internal view returns (bool) {
                            for (uint256 i = 0; i < protectedTokens.length; i++) {
                                if (protectedTokens[i] == _token) {
                                    return true;
                                }
                            }
                    
                            return false;
                        }
                    
                        function _getScriptACLParam(bytes _evmScript) internal pure returns (uint256) {
                            return uint256(keccak256(abi.encodePacked(_evmScript)));
                        }
                    
                        function _getSig(bytes _data) internal pure returns (bytes4 sig) {
                            if (_data.length < 4) {
                                return;
                            }
                    
                            assembly { sig := mload(add(_data, 0x20)) }
                        }
                    }