POL Price: $0.643198 (+3.31%)
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Renounce Role363694252022-12-03 9:30:43740 days ago1670059843IN
0x9fB2fbae...06F71167B
0 POL0.00136530.40902027
Renounce Role363694142022-12-03 9:30:21740 days ago1670059821IN
0x9fB2fbae...06F71167B
0 POL0.0013565730.43012657
Grant Role363694052022-12-03 9:29:59740 days ago1670059799IN
0x9fB2fbae...06F71167B
0 POL0.0030647630.40503629
Grant Role355094462022-11-12 8:50:59761 days ago1668243059IN
0x9fB2fbae...06F71167B
0 POL0.03806641376.2172337
Withdraw347369302022-10-24 9:44:04780 days ago1666604644IN
0x9fB2fbae...06F71167B
0 POL0.02760736117.39173595
Withdraw347368322022-10-24 9:40:44780 days ago1666604444IN
0x9fB2fbae...06F71167B
0 POL0.03567331150.1857337
Withdraw339323902022-10-04 19:36:09799 days ago1664912169IN
0x9fB2fbae...06F71167B
0 POL0.0081197934.86610617
Withdraw339322452022-10-04 19:31:11799 days ago1664911871IN
0x9fB2fbae...06F71167B
0 POL0.0081706634.74602669
Withdraw333833732022-09-21 12:33:46813 days ago1663763626IN
0x9fB2fbae...06F71167B
0 POL0.012820854.52321561
Withdraw333832962022-09-21 12:31:08813 days ago1663763468IN
0x9fB2fbae...06F71167B
0 POL0.0092180339.20000002
Withdraw333832382022-09-21 12:29:08813 days ago1663763348IN
0x9fB2fbae...06F71167B
0 POL0.007382731.39266666
Withdraw333831462022-09-21 12:25:56813 days ago1663763156IN
0x9fB2fbae...06F71167B
0 POL0.0077297533.1926
Withdraw333830682022-09-21 12:23:16813 days ago1663762996IN
0x9fB2fbae...06F71167B
0 POL0.0071439730.37999999
Withdraw333803782022-09-21 10:44:16813 days ago1663757056IN
0x9fB2fbae...06F71167B
0 POL0.0092176439.2
Deposit324474432022-08-29 11:52:49836 days ago1661773969IN
0x9fB2fbae...06F71167B
0 POL0.0147431538.02399999
Deposit324473132022-08-29 11:48:21836 days ago1661773701IN
0x9fB2fbae...06F71167B
0 POL0.0119693130.87000001
Deposit324472672022-08-29 11:46:45836 days ago1661773605IN
0x9fB2fbae...06F71167B
0 POL0.0148186938.22
Deposit324471012022-08-29 11:41:01836 days ago1661773261IN
0x9fB2fbae...06F71167B
0 POL0.0119862732.34000001
Deposit324470772022-08-29 11:40:13836 days ago1661773213IN
0x9fB2fbae...06F71167B
0 POL0.0089675932.34000001
Deposit324463002022-08-29 11:09:15836 days ago1661771355IN
0x9fB2fbae...06F71167B
0 POL0.0123494933.32000001
Deposit324462712022-08-29 11:08:13836 days ago1661771293IN
0x9fB2fbae...06F71167B
0 POL0.0109819139.2
Deposit324461442022-08-29 11:03:55836 days ago1661771035IN
0x9fB2fbae...06F71167B
0 POL0.011877332.04600001
Deposit324461162022-08-29 11:02:55836 days ago1661770975IN
0x9fB2fbae...06F71167B
0 POL0.0115723341.30927369
Deposit324460012022-08-29 10:58:29836 days ago1661770709IN
0x9fB2fbae...06F71167B
0 POL0.0127773734.4755934
Deposit324459822022-08-29 10:57:13836 days ago1661770633IN
0x9fB2fbae...06F71167B
0 POL0.0095863934.22160006
View all transactions

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

Contract Source Code Verified (Exact Match)

Contract Name:
MoneyMarketManager

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : MoneyMarketManager.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.9;

import {IERC20} from '../../@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {ISynthereumFinder} from '../core/interfaces/IFinder.sol';
import {IJarvisBrrrrr} from './interfaces/IJarvisBrrrrr.sol';
import {IJarvisBrrMoneyMarket} from './interfaces/IJarvisBrrMoneyMarket.sol';
import {IMoneyMarketManager} from './interfaces/IMoneyMarketManager.sol';
import {
  IMintableBurnableERC20
} from '../tokens/interfaces/IMintableBurnableERC20.sol';
import {SynthereumInterfaces} from '../core/Constants.sol';
import {
  SafeERC20
} from '../../@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {
  AccessControlEnumerable
} from '../../@openzeppelin/contracts/access/AccessControlEnumerable.sol';
import {
  ReentrancyGuard
} from '../../@openzeppelin/contracts/security/ReentrancyGuard.sol';
import {Address} from '../../@openzeppelin/contracts/utils/Address.sol';

contract MoneyMarketManager is
  IMoneyMarketManager,
  ReentrancyGuard,
  AccessControlEnumerable
{
  using SafeERC20 for IERC20;
  using SafeERC20 for IMintableBurnableERC20;
  using Address for address;

  // Describe role structure
  struct Roles {
    address admin;
    address maintainer;
  }

  string private constant DEPOSIT_SIG = 'deposit(address,uint256,bytes,bytes)';
  string private constant WITHDRAW_SIG =
    'withdraw(address,uint256,bytes,bytes)';
  bytes32 public constant MAINTAINER_ROLE = keccak256('Maintainer');

  ISynthereumFinder public immutable synthereumFinder;

  mapping(bytes32 => Implementation) private idToImplementation;
  mapping(bytes32 => mapping(address => uint256)) private moneyMarketBalances;

  event RegisteredImplementation(
    string indexed id,
    address implementation,
    bytes args
  );
  event MintAndDeposit(
    address indexed token,
    string indexed moneyMarketId,
    uint256 amount
  );
  event RedeemAndBurn(
    address indexed token,
    string indexed moneyMarketId,
    uint256 amount
  );
  event WithdrawRevenues(
    address indexed token,
    string indexed moneyMarketId,
    uint256 amount,
    address receiver
  );

  modifier onlyMaintainer() {
    require(
      hasRole(MAINTAINER_ROLE, msg.sender),
      'Sender must be the maintainer'
    );
    _;
  }

  constructor(address _synthereumFinder, Roles memory _roles) {
    synthereumFinder = ISynthereumFinder(_synthereumFinder);

    _setRoleAdmin(DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
    _setRoleAdmin(MAINTAINER_ROLE, DEFAULT_ADMIN_ROLE);
    _setupRole(DEFAULT_ADMIN_ROLE, _roles.admin);
    _setupRole(MAINTAINER_ROLE, _roles.maintainer);
  }

  function registerMoneyMarketImplementation(
    string calldata _id,
    address _implementation,
    bytes calldata _extraArgs
  ) external override onlyMaintainer nonReentrant {
    bytes32 implementationId = keccak256(abi.encode(_id));
    require(implementationId != 0x00, 'Wrong module identifier');

    idToImplementation[implementationId] = Implementation(
      _implementation,
      _extraArgs
    );

    emit RegisteredImplementation(_id, _implementation, _extraArgs);
  }

  function deposit(
    IMintableBurnableERC20 _token,
    uint256 _amount,
    string calldata _moneyMarketId,
    bytes calldata _implementationCallArgs
  ) external override onlyMaintainer nonReentrant returns (uint256 tokensOut) {
    // trigger minting of synths from the printer contract
    address jarvisBrr =
      synthereumFinder.getImplementationAddress(
        SynthereumInterfaces.JarvisBrrrrr
      );
    IJarvisBrrrrr(jarvisBrr).mint(_token, _amount);

    // deposit into money market through delegate-call
    bytes32 hashId = keccak256(abi.encode(_moneyMarketId));
    Implementation memory implementation = idToImplementation[hashId];

    moneyMarketBalances[hashId][address(_token)] += _amount;

    bytes memory result =
      implementation.implementationAddr.functionDelegateCall(
        abi.encodeWithSignature(
          DEPOSIT_SIG,
          address(_token),
          _amount,
          implementation.moneyMarketArgs,
          _implementationCallArgs
        )
      );
    tokensOut = abi.decode(result, (uint256));

    emit MintAndDeposit(address(_token), _moneyMarketId, _amount);
  }

  function withdraw(
    IMintableBurnableERC20 _token,
    uint256 _amount,
    string calldata _moneyMarketId,
    bytes calldata _implementationCallArgs
  )
    external
    override
    onlyMaintainer
    nonReentrant
    returns (uint256 burningAmount)
  {
    // withdraw from money market through delegate call
    bytes32 hashId = keccak256(abi.encode(_moneyMarketId));
    Implementation memory implementation = idToImplementation[hashId];
    require(
      _amount <= moneyMarketBalances[hashId][address(_token)],
      'Max amount limit'
    );

    bytes memory result =
      implementation.implementationAddr.functionDelegateCall(
        abi.encodeWithSignature(
          WITHDRAW_SIG,
          address(_token),
          _amount,
          implementation.moneyMarketArgs,
          _implementationCallArgs
        )
      );

    burningAmount = abi.decode(result, (uint256));
    moneyMarketBalances[hashId][address(_token)] -= burningAmount;

    // trigger burning of tokens on the printer contract
    address jarvisBrr =
      synthereumFinder.getImplementationAddress(
        SynthereumInterfaces.JarvisBrrrrr
      );
    _token.safeIncreaseAllowance(jarvisBrr, burningAmount);
    IJarvisBrrrrr(jarvisBrr).redeem(_token, burningAmount);

    emit RedeemAndBurn(address(_token), _moneyMarketId, burningAmount);
  }

  function withdrawRevenue(
    IMintableBurnableERC20 _jSynthAsset,
    address _recipient,
    string memory _moneyMarketId,
    bytes memory _implementationCallArgs
  ) external override onlyMaintainer nonReentrant returns (uint256 jSynthOut) {
    bytes32 hashId = keccak256(abi.encode(_moneyMarketId));
    Implementation memory implementation = idToImplementation[hashId];

    // get total balance from money market implementation (deposit + interest)
    uint256 totalBalance =
      IJarvisBrrMoneyMarket(implementation.implementationAddr).getTotalBalance(
        address(_jSynthAsset),
        implementation.moneyMarketArgs,
        _implementationCallArgs
      );

    uint256 revenues =
      totalBalance - moneyMarketBalances[hashId][address(_jSynthAsset)];
    require(revenues > 0, 'No revenues');

    // withdraw revenues
    bytes memory result =
      implementation.implementationAddr.functionDelegateCall(
        abi.encodeWithSignature(
          WITHDRAW_SIG,
          address(_jSynthAsset),
          revenues,
          implementation.moneyMarketArgs,
          _implementationCallArgs
        )
      );

    // send them to dao
    jSynthOut = abi.decode(result, (uint256));

    // burn eventual withdrawn excess
    if (jSynthOut > revenues) {
      address jarvisBrr =
        synthereumFinder.getImplementationAddress(
          SynthereumInterfaces.JarvisBrrrrr
        );
      uint256 burningAmount = jSynthOut - revenues;

      _jSynthAsset.safeIncreaseAllowance(jarvisBrr, burningAmount);
      IJarvisBrrrrr(jarvisBrr).redeem(_jSynthAsset, burningAmount);
      moneyMarketBalances[hashId][address(_jSynthAsset)] -= burningAmount;
    }

    _jSynthAsset.transfer(_recipient, revenues);

    emit WithdrawRevenues(
      address(_jSynthAsset),
      _moneyMarketId,
      revenues,
      _recipient
    );
  }

  function getMoneyMarketDeposited(
    string calldata _moneyMarketId,
    address _jSynthAsset
  ) external view override returns (uint256 amount) {
    bytes32 hashId = keccak256(abi.encode(_moneyMarketId));
    amount = moneyMarketBalances[hashId][_jSynthAsset];
  }

  function getMoneyMarketImplementation(string calldata _moneyMarketId)
    external
    view
    override
    returns (Implementation memory implementation)
  {
    bytes32 hashId = keccak256(abi.encode(_moneyMarketId));
    implementation = idToImplementation[hashId];
    require(
      implementation.implementationAddr != address(0),
      'Implementation not supported'
    );
  }
}

File 2 of 27 : AccessControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 27 : IAccessControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

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

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 5 of 27 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 6 of 27 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 7 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 8 of 27 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
}

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

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 10 of 27 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 11 of 27 : Finder.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.9;

import {ISynthereumFinder} from './interfaces/IFinder.sol';
import {
  AccessControlEnumerable
} from '../../@openzeppelin/contracts/access/AccessControlEnumerable.sol';

/**
 * @title Provides addresses of contracts implementing certain interfaces.
 */
contract SynthereumFinder is ISynthereumFinder, AccessControlEnumerable {
  bytes32 public constant MAINTAINER_ROLE = keccak256('Maintainer');

  //Describe role structure
  struct Roles {
    address admin;
    address maintainer;
  }

  //----------------------------------------
  // Storage
  //----------------------------------------

  mapping(bytes32 => address) public interfacesImplemented;

  //----------------------------------------
  // Events
  //----------------------------------------

  event InterfaceImplementationChanged(
    bytes32 indexed interfaceName,
    address indexed newImplementationAddress
  );

  //----------------------------------------
  // Modifiers
  //----------------------------------------

  modifier onlyMaintainer() {
    require(
      hasRole(MAINTAINER_ROLE, msg.sender),
      'Sender must be the maintainer'
    );
    _;
  }

  //----------------------------------------
  // Constructors
  //----------------------------------------

  constructor(Roles memory roles) {
    _setRoleAdmin(DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
    _setRoleAdmin(MAINTAINER_ROLE, DEFAULT_ADMIN_ROLE);
    _setupRole(DEFAULT_ADMIN_ROLE, roles.admin);
    _setupRole(MAINTAINER_ROLE, roles.maintainer);
  }

  //----------------------------------------
  // External view
  //----------------------------------------

  /**
   * @notice Updates the address of the contract that implements `interfaceName`.
   * @param interfaceName bytes32 of the interface name that is either changed or registered.
   * @param implementationAddress address of the implementation contract.
   */
  function changeImplementationAddress(
    bytes32 interfaceName,
    address implementationAddress
  ) external override onlyMaintainer {
    interfacesImplemented[interfaceName] = implementationAddress;

    emit InterfaceImplementationChanged(interfaceName, implementationAddress);
  }

  /**
   * @notice Gets the address of the contract that implements the given `interfaceName`.
   * @param interfaceName queried interface.
   * @return implementationAddress Address of the defined interface.
   */
  function getImplementationAddress(bytes32 interfaceName)
    external
    view
    override
    returns (address)
  {
    address implementationAddress = interfacesImplemented[interfaceName];
    require(implementationAddress != address(0x0), 'Implementation not found');
    return implementationAddress;
  }
}

File 12 of 27 : IFinder.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/**
 * @title Provides addresses of the contracts implementing certain interfaces.
 */
interface ISynthereumFinder {
  /**
   * @notice Updates the address of the contract that implements `interfaceName`.
   * @param interfaceName bytes32 encoding of the interface name that is either changed or registered.
   * @param implementationAddress address of the deployed contract that implements the interface.
   */
  function changeImplementationAddress(
    bytes32 interfaceName,
    address implementationAddress
  ) external;

  /**
   * @notice Gets the address of the contract that implements the given `interfaceName`.
   * @param interfaceName queried interface.
   * @return implementationAddress Address of the deployed contract that implements the interface.
   */
  function getImplementationAddress(bytes32 interfaceName)
    external
    view
    returns (address);
}

File 13 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.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 14 of 27 : IJarvisBrrrrr.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >0.8.0;
import {
  IMintableBurnableERC20
} from '../../tokens/interfaces/IMintableBurnableERC20.sol';

interface IJarvisBrrrrr {
  struct AccessContract {
    string contractName;
    address contractAddress;
  }

  /**
   * @notice Add a contract to the withelist containing names of the contracts that have access to this contract
   * @notice Only maintainer can call this function
   * @param _contractName Name of the contract to add
   */
  function addAccessContract(string calldata _contractName) external;

  /**
   * @notice Remove a contract from the withelist containing names of the contracts that have access to this contract
   * @notice Only maintainer can call this function
   * @param _contractName Name of the contract to remove
   */
  function removeAccessContract(string calldata _contractName) external;

  /**
   * @notice Sets the max circulating supply that can be minted for a specific token - only manager can set this
   * @notice Only maintainer can call this function
   * @param _token Synthetic token address to set
   * @param _newMaxSupply New Max supply value of the token
   */
  function setMaxSupply(IMintableBurnableERC20 _token, uint256 _newMaxSupply)
    external;

  /**
   * @notice Mints synthetic token without collateral to a pre-defined address (SynthereumMoneyMarketManager)
   * @param _token Synthetic token address to mint
   * @param _amount Amount of tokens to mint
   * @return newCirculatingSupply New circulating supply in Money Market
   */
  function mint(IMintableBurnableERC20 _token, uint256 _amount)
    external
    returns (uint256 newCirculatingSupply);

  /**
   * @notice Burns synthetic token without releasing collateral from the pre-defined address (SynthereumMoneyMarketManager)
   * @param _token Synthetic token address to burn
   * @param _amount Amount of tokens to burn
   * @return newCirculatingSupply New circulating supply in Money Market
   */
  function redeem(IMintableBurnableERC20 _token, uint256 _amount)
    external
    returns (uint256 newCirculatingSupply);

  /**
   * @notice Returns the max circulating supply of a synthetic token
   * @param _token Synthetic token address
   * @return maxCircSupply Max supply of the token
   */
  function maxSupply(IMintableBurnableERC20 _token)
    external
    view
    returns (uint256 maxCircSupply);

  /**
   * @notice Returns the circulating supply of a synthetic token
   * @param _token Synthetic token address
   * @return circSupply Circulating supply of the token
   */
  function supply(IMintableBurnableERC20 _token)
    external
    view
    returns (uint256 circSupply);

  /**
   * @notice Returns the list of contracts that has access to this contract
   * @return List of contracts (name and address from the finder)
   */
  function accessContractWhitelist()
    external
    view
    returns (AccessContract[] memory);

  /**
   * @notice Returns if a contract name has access to this contract
   * @return hasAccess True if has access otherwise false
   */
  function hasContractAccess(string calldata _contractName)
    external
    view
    returns (bool hasAccess);
}

File 15 of 27 : IJarvisBrrMoneyMarket.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {
  IMintableBurnableERC20
} from '../../tokens/interfaces/IMintableBurnableERC20.sol';
import {IERC20} from '../../../@openzeppelin/contracts/token/ERC20/IERC20.sol';

interface IJarvisBrrMoneyMarket {
  /**
   * @notice deposits printed jSynth into the money market
   * @param _jSynthAsset address of the jSynth token to deposit
   * @param _amount of jSynth to deposit
   * @param _extraArgs bytes Encoded args for the implementation
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return tokensOut amount of eventual tokens received from money market
   */
  function deposit(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _amount,
    bytes calldata _extraArgs,
    bytes calldata _implementationCallArgs
  ) external returns (uint256 tokensOut);

  /**
   * @notice withdraw jSynth from the money market
   * @dev the same amount must be burned in the same tx
   * @param _jSynthAsset address of the jSynth token to withdraw
   * @param _interestTokenAmount of interest tokens to withdraw
   * @param _extraArgs bytes Encoded args for the implementation
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return jSynthOut amount of j Synth in output
   */
  function withdraw(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _interestTokenAmount,
    bytes calldata _extraArgs,
    bytes calldata _implementationCallArgs
  ) external returns (uint256 jSynthOut);

  /**
   * @notice returns the total deposited + interest generated in the money market
   * @param _jSynthAsset address of the jSynth token to get corresponding balance
   * @param _args general bytes Encoded args for the implementation
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return totalJSynth total amount of jSynth
   */
  function getTotalBalance(
    address _jSynthAsset,
    bytes calldata _args,
    bytes calldata _implementationCallArgs
  ) external returns (uint256 totalJSynth);
}

File 16 of 27 : IMoneyMarketManager.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {
  IMintableBurnableERC20
} from '../../tokens/interfaces/IMintableBurnableERC20.sol';
import {IERC20} from '../../../@openzeppelin/contracts/token/ERC20/IERC20.sol';

interface IMoneyMarketManager {
  // implementation variables
  struct Implementation {
    address implementationAddr;
    bytes moneyMarketArgs;
  }

  /**
   * @notice Registers an address implementing the IJarvisBrrMoneyMarket interface
   * @param _id Identifier of the implementation
   * @param _implementation Address of the implementation
   * @param _extraArgs bytes Encoded args for the implementation
   */
  function registerMoneyMarketImplementation(
    string calldata _id,
    address _implementation,
    bytes calldata _extraArgs
  ) external;

  /**
   * @notice deposits printed jSynth into the money market
   * @param _jSynthAsset address of the jSynth token to deposit
   * @param _amount of jSynth to deposit
   * @param _moneyMarketId identifier of the money market implementation contract to withdraw the tokens from money market
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return tokensOut amount of eventual tokens received from money market
   */
  function deposit(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _amount,
    string calldata _moneyMarketId,
    bytes calldata _implementationCallArgs
  ) external returns (uint256 tokensOut);

  /**
   * @notice withdraw jSynth from the money market
   * @dev the same amount must be burned in the same tx
   * @param _jSynthAsset address of the jSynth token to withdraw
   * @param _interestTokenAmount of interest tokens to withdraw
   * @param _moneyMarketId identifier of the money market implementation contract to withdraw the tokens from money market
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return jSynthOut amount of j Synth in output
   */
  function withdraw(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _interestTokenAmount,
    string calldata _moneyMarketId,
    bytes calldata _implementationCallArgs
  ) external returns (uint256 jSynthOut);

  /**
   * @notice withdraw generated interest from deposits in money market and sends them to dao
   * @param _jSynthAsset address of the jSynth token to get revenues of
   * @param _recipient address of recipient of revenues
   * @param _moneyMarketId identifier of the money market implementation contract
   * @param _implementationCallArgs bytes encoded arguments necessary for this specific implementation call (ie cToken)
   * @return jSynthOut amount of jSynth sent to the DAO
   */
  function withdrawRevenue(
    IMintableBurnableERC20 _jSynthAsset,
    address _recipient,
    string memory _moneyMarketId,
    bytes memory _implementationCallArgs
  ) external returns (uint256 jSynthOut);

  /**
   * @notice reads the amount of jSynth currently minted + deposited into a money market
   * @param _moneyMarketId identifier of the money market implementation contract
   * @param _jSynthAsset address of the jSynth token to get amount
   * @return amount amount of jSynth currently minted + deposited into moneyMarketId
   */
  function getMoneyMarketDeposited(
    string calldata _moneyMarketId,
    address _jSynthAsset
  ) external view returns (uint256 amount);

  /**
   * @notice reads implementation data of a supported money market
   * @param _moneyMarketId identifier of the money market implementation contract
   * @return implementation Address of the implementation and global data bytes
   */
  function getMoneyMarketImplementation(string calldata _moneyMarketId)
    external
    view
    returns (Implementation memory implementation);
}

File 17 of 27 : IMintableBurnableERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {IERC20} from '../../../@openzeppelin/contracts/token/ERC20/IERC20.sol';

/**
 * @title ERC20 interface that includes burn mint and roles methods.
 */
interface IMintableBurnableERC20 is IERC20 {
  /**
   * @notice Burns a specific amount of the caller's tokens.
   * @dev This method should be permissioned to only allow designated parties to burn tokens.
   */
  function burn(uint256 value) external;

  /**
   * @notice Mints tokens and adds them to the balance of the `to` address.
   * @dev This method should be permissioned to only allow designated parties to mint tokens.
   */
  function mint(address to, uint256 value) external returns (bool);

  /**
   * @notice Returns the number of decimals used to get its user representation.
   */
  function decimals() external view returns (uint8);
}

File 18 of 27 : Constants.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.9;

/**
 * @title Stores common interface names used throughout Synthereum.
 */
library SynthereumInterfaces {
  bytes32 public constant Deployer = 'Deployer';
  bytes32 public constant FactoryVersioning = 'FactoryVersioning';
  bytes32 public constant TokenFactory = 'TokenFactory';
  bytes32 public constant PoolRegistry = 'PoolRegistry';
  bytes32 public constant SelfMintingRegistry = 'SelfMintingRegistry';
  bytes32 public constant FixedRateRegistry = 'FixedRateRegistry';
  bytes32 public constant PriceFeed = 'PriceFeed';
  bytes32 public constant Manager = 'Manager';
  bytes32 public constant CreditLineController = 'CreditLineController';
  bytes32 public constant CollateralWhitelist = 'CollateralWhitelist';
  bytes32 public constant IdentifierWhitelist = 'IdentifierWhitelist';
  bytes32 public constant TrustedForwarder = 'TrustedForwarder';
  bytes32 public constant MoneyMarketManager = 'MoneyMarketManager';
  bytes32 public constant JarvisBrrrrr = 'JarvisBrrrrr';
  bytes32 public constant PrinterProxy = 'PrinterProxy';
  bytes32 public constant LendingManager = 'LendingManager';
  bytes32 public constant LendingStorageManager = 'LendingStorageManager';
  bytes32 public constant CommissionReceiver = 'CommissionReceiver';
  bytes32 public constant BuybackProgramReceiver = 'BuybackProgramReceiver';
  bytes32 public constant JarvisToken = 'JarvisToken';
}

library FactoryInterfaces {
  bytes32 public constant PoolFactory = 'PoolFactory';
  bytes32 public constant SelfMintingFactory = 'SelfMintingFactory';
  bytes32 public constant FixedRateFactory = 'FixedRateFactory';
}

File 19 of 27 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @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 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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 20 of 27 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 21 of 27 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

        (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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 22 of 27 : JarvisBrrCompound.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.9;

import {IJarvisBrrMoneyMarket} from '../interfaces/IJarvisBrrMoneyMarket.sol';
import {
  IMintableBurnableERC20
} from '../../tokens/interfaces/IMintableBurnableERC20.sol';
import {ICErc20} from '../interfaces/ICErc20.sol';
import {
  SafeERC20
} from '../../../@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {IERC20} from '../../../@openzeppelin/contracts/token/ERC20/IERC20.sol';

// storageless contract to be used as delegate call by JarvisBRR to deposit the minted jSynth into a money market
contract JarvisBrrCompound is IJarvisBrrMoneyMarket {
  using SafeERC20 for IMintableBurnableERC20;
  using SafeERC20 for IERC20;

  function deposit(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _amount,
    bytes calldata _extraArgs,
    bytes calldata _implementationArgs
  ) external override returns (uint256 tokensOut) {
    require(_jSynthAsset.balanceOf(address(this)) >= _amount, 'Wrong balance');

    // initialise compound interest token
    address cTokenAddress = abi.decode(_implementationArgs, (address));
    ICErc20 cToken = ICErc20(cTokenAddress);
    uint256 cTokenBalanceBefore = cToken.balanceOf(address(this));

    // approve and deposit underlying
    _jSynthAsset.safeIncreaseAllowance(cTokenAddress, _amount);
    uint256 success = cToken.mint(_amount);
    require(success == 0, 'Failed mint');

    // calculate the cTokens out
    uint256 cTokenBalanceAfter = cToken.balanceOf(address(this));
    tokensOut = cTokenBalanceAfter - cTokenBalanceBefore;
  }

  function withdraw(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _jSynthAmount,
    bytes calldata _extraArgs,
    bytes calldata _implementationArgs
  ) external override returns (uint256 jSynthOut) {
    address cTokenAddr = abi.decode(_implementationArgs, (address));
    // initialise compound interest token
    ICErc20 cToken = ICErc20(cTokenAddr);

    // redeem underlying - internally fails with an invalid amount
    cToken.redeemUnderlying(_jSynthAmount);

    jSynthOut = _jSynthAmount;
  }

  function getTotalBalance(
    address _jSynth,
    bytes calldata _args,
    bytes calldata _implementationArgs
  ) external override returns (uint256 totalJSynth) {
    ICErc20 cToken = ICErc20(abi.decode(_implementationArgs, (address)));
    totalJSynth = cToken.balanceOfUnderlying(msg.sender);
  }
}

File 23 of 27 : ICErc20.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity ^0.8.9;

interface ICErc20 {
  function mint(uint256) external returns (uint256);

  function exchangeRateCurrent() external returns (uint256);

  function supplyRatePerBlock() external returns (uint256);

  function redeem(uint256) external returns (uint256);

  function redeemUnderlying(uint256) external returns (uint256);

  function balanceOfUnderlying(address owner) external returns (uint256);

  function balanceOf(address owner) external view returns (uint256);

  function name() external view returns (string memory);
}

File 24 of 27 : JarvisBrrAave.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.9;

import {IJarvisBrrMoneyMarket} from '../interfaces/IJarvisBrrMoneyMarket.sol';
import {IPool} from '../../lending-module/interfaces/IAaveV3.sol';
import {
  IMintableBurnableERC20
} from '../../tokens/interfaces/IMintableBurnableERC20.sol';
import {
  SafeERC20
} from '../../../@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {IERC20} from '../../../@openzeppelin/contracts/token/ERC20/IERC20.sol';

// storageless contract to be used as delegate call by JarvisBRR to deposit the minted jSynth into a money market
contract JarvisBrrAave is IJarvisBrrMoneyMarket {
  using SafeERC20 for IMintableBurnableERC20;
  using SafeERC20 for IERC20;

  function deposit(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _amount,
    bytes calldata _extraArgs,
    bytes calldata _implementationArgs
  ) external override returns (uint256 tokensOut) {
    require(_jSynthAsset.balanceOf(address(this)) >= _amount, 'Wrong balance');
    (address moneyMarket, IERC20 interestToken) =
      interestBearingToken(address(_jSynthAsset), _extraArgs);

    uint256 aTokenBalanceBefore = interestToken.balanceOf(address(this));

    _jSynthAsset.safeIncreaseAllowance(moneyMarket, _amount);
    IPool(moneyMarket).supply(
      address(_jSynthAsset),
      _amount,
      address(this),
      uint16(0)
    );

    uint256 aTokenBalanceAfter = interestToken.balanceOf(address(this));

    tokensOut = aTokenBalanceAfter - aTokenBalanceBefore;
  }

  function withdraw(
    IMintableBurnableERC20 _jSynthAsset,
    uint256 _aTokensAmount,
    bytes calldata _extraArgs,
    bytes calldata _implementationArgs
  ) external override returns (uint256 jSynthOut) {
    (address moneyMarket, IERC20 interestToken) =
      interestBearingToken(address(_jSynthAsset), _extraArgs);

    require(
      interestToken.balanceOf(address(this)) >= _aTokensAmount,
      'Wrong balance'
    );

    uint256 jSynthBalanceBefore = _jSynthAsset.balanceOf(address(this));

    interestToken.safeIncreaseAllowance(moneyMarket, _aTokensAmount);
    IPool(moneyMarket).withdraw(
      address(_jSynthAsset),
      _aTokensAmount,
      address(this)
    );

    uint256 jSynthBalanceAfter = _jSynthAsset.balanceOf(address(this));

    jSynthOut = jSynthBalanceAfter - jSynthBalanceBefore;
  }

  function getTotalBalance(
    address _jSynth,
    bytes calldata _args,
    bytes calldata _implementationArgs
  ) external view override returns (uint256 totalJSynth) {
    (, IERC20 interestToken) = interestBearingToken(_jSynth, _args);
    totalJSynth = interestToken.balanceOf(msg.sender);
  }

  function interestBearingToken(address _jSynth, bytes memory _args)
    internal
    view
    returns (address moneyMarket, IERC20 token)
  {
    moneyMarket = abi.decode(_args, (address));
    token = IERC20(IPool(moneyMarket).getReserveData(_jSynth).aTokenAddress);
  }
}

File 25 of 27 : IAaveV3.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

interface IPool {
  struct ReserveConfigurationMap {
    uint256 data;
  }

  struct ReserveData {
    //stores the reserve configuration
    ReserveConfigurationMap configuration;
    //the liquidity index. Expressed in ray
    uint128 liquidityIndex;
    //the current supply rate. Expressed in ray
    uint128 currentLiquidityRate;
    //variable borrow index. Expressed in ray
    uint128 variableBorrowIndex;
    //the current variable borrow rate. Expressed in ray
    uint128 currentVariableBorrowRate;
    //the current stable borrow rate. Expressed in ray
    uint128 currentStableBorrowRate;
    //timestamp of last update
    uint40 lastUpdateTimestamp;
    //the id of the reserve. Represents the position in the list of the active reserves
    uint16 id;
    //aToken address
    address aTokenAddress;
    //stableDebtToken address
    address stableDebtTokenAddress;
    //variableDebtToken address
    address variableDebtTokenAddress;
    //address of the interest rate strategy
    address interestRateStrategyAddress;
    //the current treasury balance, scaled
    uint128 accruedToTreasury;
    //the outstanding unbacked aTokens minted through the bridging feature
    uint128 unbacked;
    //the outstanding debt borrowed against this asset in isolation mode
    uint128 isolationModeTotalDebt;
  }

  /**
   * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
   * - E.g. User supplies 100 USDC and gets in return 100 aUSDC
   * @param _asset The address of the underlying asset to supply
   * @param _amount The amount to be supplied
   * @param _onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
   *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
   *   is a different wallet
   * @param _referralCode Code used to register the integrator originating the operation, for potential rewards.
   *   0 if the action is executed directly by the user, without any middle-man
   **/
  function supply(
    address _asset,
    uint256 _amount,
    address _onBehalfOf,
    uint16 _referralCode
  ) external;

  /**
   * @notice Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
   * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
   * @param _asset The address of the underlying asset to withdraw
   * @param _amount The underlying amount to be withdrawn
   *   - Send the value type(uint256).max in order to withdraw the whole aToken balance
   * @param _to The address that will receive the underlying, same as msg.sender if the user
   *   wants to receive it on his own wallet, or a different address if the beneficiary is a
   *   different wallet
   * @return The final amount withdrawn
   **/
  function withdraw(
    address _asset,
    uint256 _amount,
    address _to
  ) external returns (uint256);

  /**
   * @notice Returns the state and configuration of the reserve
   * @param _asset The address of the underlying asset of the reserve
   * @return The state and configuration data of the reserve
   **/
  function getReserveData(address _asset)
    external
    view
    returns (ReserveData memory);
}

File 26 of 27 : JarvisBrrrrr.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.9;

import {IERC20} from '../../@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {ISynthereumFinder} from '../core/interfaces/IFinder.sol';
import {IJarvisBrrrrr} from './interfaces/IJarvisBrrrrr.sol';
import {
  IMintableBurnableERC20
} from '../tokens/interfaces/IMintableBurnableERC20.sol';
import {SynthereumInterfaces} from '../core/Constants.sol';
import {
  SafeERC20
} from '../../@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import {
  EnumerableSet
} from '../../@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import {StringUtils} from '../base/utils/StringUtils.sol';
import {
  AccessControlEnumerable
} from '../../@openzeppelin/contracts/access/AccessControlEnumerable.sol';
import {
  ReentrancyGuard
} from '../../@openzeppelin/contracts/security/ReentrancyGuard.sol';

contract JarvisBrrrrr is
  IJarvisBrrrrr,
  ReentrancyGuard,
  AccessControlEnumerable
{
  using SafeERC20 for IERC20;
  using EnumerableSet for EnumerableSet.Bytes32Set;
  using StringUtils for string;
  using StringUtils for bytes32;

  bytes32 public constant MAINTAINER_ROLE = keccak256('Maintainer');

  ISynthereumFinder public immutable synthereumFinder;

  EnumerableSet.Bytes32Set private accessWhitelist;

  mapping(IMintableBurnableERC20 => uint256) private maxCirculatingSupply;
  mapping(IMintableBurnableERC20 => uint256) private circulatingSupply;

  // Describe role structure
  struct Roles {
    address admin;
    address maintainer;
  }

  event Minted(address indexed token, address recipient, uint256 amount);
  event Redeemed(address indexed token, address recipient, uint256 amount);
  event NewMaxSupply(address indexed token, uint256 newMaxSupply);
  event AccessContractAdded(string contractName);
  event AccessContractRemoved(string contractName);

  modifier onlyMaintainer() {
    require(
      hasRole(MAINTAINER_ROLE, msg.sender),
      'Sender must be the maintainer'
    );
    _;
  }

  modifier onlyAccessWhitelist() {
    for (uint256 j = 0; j < accessWhitelist.length(); j++) {
      if (
        msg.sender ==
        synthereumFinder.getImplementationAddress(accessWhitelist.at(j))
      ) {
        _;
        return;
      }
    }
    revert('Only withelisted contracts can perform this operation');
  }

  constructor(ISynthereumFinder _synthereumFinder, Roles memory _roles) {
    synthereumFinder = _synthereumFinder;

    _setRoleAdmin(DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_ROLE);
    _setRoleAdmin(MAINTAINER_ROLE, DEFAULT_ADMIN_ROLE);
    _setupRole(DEFAULT_ADMIN_ROLE, _roles.admin);
    _setupRole(MAINTAINER_ROLE, _roles.maintainer);
  }

  /**
   * @notice Add a contract to the withelist containing names of the contracts that have access to this contract
   * @notice Only maintainer can call this function
   * @param _contractName Name of the contract to add
   */
  function addAccessContract(string calldata _contractName)
    external
    override
    onlyMaintainer
  {
    bytes32 contractNameHex = _contractName.stringToBytes32();
    require(contractNameHex != 0x00, 'No name passed');
    try synthereumFinder.getImplementationAddress(contractNameHex) returns (
      address contractAddress
    ) {
      require(
        accessWhitelist.add(contractNameHex),
        'Contract already whitelisted'
      );
      emit AccessContractAdded(_contractName);
    } catch {
      revert('Contract not supported by the finder');
    }
  }

  /**
   * @notice Remove a contract from the withelist containing names of the contracts that have access to this contract
   * @notice Only maintainer can call this function
   * @param _contractName Name of the contract to remove
   */
  function removeAccessContract(string calldata _contractName)
    external
    override
    onlyMaintainer
  {
    require(
      accessWhitelist.remove(_contractName.stringToBytes32()),
      'Contract not whitelisted'
    );
    emit AccessContractRemoved(_contractName);
  }

  /**
   * @notice Sets the max circulating supply that can be minted for a specific token
   * @notice Only maintainer can call this function
   * @param _token Synthetic token address to set
   * @param _newMaxSupply New Max supply value of the token
   */
  function setMaxSupply(IMintableBurnableERC20 _token, uint256 _newMaxSupply)
    external
    override
    onlyMaintainer
    nonReentrant
  {
    maxCirculatingSupply[_token] = _newMaxSupply;
    emit NewMaxSupply(address(_token), _newMaxSupply);
  }

  /**
   * @notice Mints synthetic token without collateral to a pre-defined address (SynthereumMoneyMarketManager)
   * @param _token Synthetic token address to mint
   * @param _amount Amount of tokens to mint
   * @return newCirculatingSupply New circulating supply in Money Market
   */
  function mint(IMintableBurnableERC20 _token, uint256 _amount)
    external
    override
    onlyAccessWhitelist
    nonReentrant
    returns (uint256 newCirculatingSupply)
  {
    newCirculatingSupply = _amount + circulatingSupply[_token];
    require(
      newCirculatingSupply <= maxCirculatingSupply[_token],
      'Minting over max limit'
    );
    circulatingSupply[_token] = newCirculatingSupply;
    _token.mint(msg.sender, _amount);
    emit Minted(address(_token), msg.sender, _amount);
  }

  /**
   * @notice Burns synthetic token without releasing collateral from the pre-defined address (SynthereumMoneyMarketManager)
   * @param _token Synthetic token address to burn
   * @param _amount Amount of tokens to burn
   * @return newCirculatingSupply New circulating supply in Money Market
   */
  function redeem(IMintableBurnableERC20 _token, uint256 _amount)
    external
    override
    onlyAccessWhitelist
    nonReentrant
    returns (uint256 newCirculatingSupply)
  {
    uint256 actualSupply = circulatingSupply[_token];
    IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
    newCirculatingSupply = actualSupply - _amount;
    circulatingSupply[_token] = newCirculatingSupply;
    _token.burn(_amount);
    emit Redeemed(address(_token), msg.sender, _amount);
  }

  /**
   * @notice Returns the max circulating supply of a synthetic token
   * @param _token Synthetic token address
   * @return maxCircSupply Max supply of the token
   */
  function maxSupply(IMintableBurnableERC20 _token)
    external
    view
    override
    returns (uint256 maxCircSupply)
  {
    maxCircSupply = maxCirculatingSupply[_token];
  }

  /**
   * @notice Returns the circulating supply of a synthetic token
   * @param _token Synthetic token address
   * @return circSupply Circulating supply of the token
   */
  function supply(IMintableBurnableERC20 _token)
    external
    view
    override
    returns (uint256 circSupply)
  {
    circSupply = circulatingSupply[_token];
  }

  /**
   * @notice Returns the list of contracts that has access to this contract
   * @return List of contracts (name and address from the finder)
   */
  function accessContractWhitelist()
    external
    view
    override
    returns (AccessContract[] memory)
  {
    uint256 contractsNumber = accessWhitelist.length();
    AccessContract[] memory withelist = new AccessContract[](contractsNumber);
    for (uint256 j = 0; j < contractsNumber; j++) {
      bytes32 contractHex = accessWhitelist.at(j);
      withelist[j] = AccessContract(
        contractHex.bytes32ToString(),
        synthereumFinder.getImplementationAddress(contractHex)
      );
    }
    return withelist;
  }

  /**
   * @notice Returns if a contract name has access to this contract
   * @return hasAccess True if has access otherwise false
   */
  function hasContractAccess(string calldata _contractName)
    external
    view
    override
    returns (bool hasAccess)
  {
    hasAccess = accessWhitelist.contains(_contractName.stringToBytes32());
  }
}

File 27 of 27 : StringUtils.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.9;

/**
 * @title Library for strings
 */
library StringUtils {
  /**
   * @notice Convert string in 32bytes
   * @param _string string to convert
   * @return result string converted in 32bytes
   */
  function stringToBytes32(string memory _string)
    internal
    pure
    returns (bytes32 result)
  {
    bytes memory source = bytes(_string);
    if (source.length == 0) {
      return 0x0;
    } else if (source.length > 32) {
      revert('Bytes length bigger than 32');
    } else {
      assembly {
        result := mload(add(source, 32))
      }
    }
  }

  /**
   * @notice Conevert bytes32 in string
   * @param _bytes32 32bytes to convert
   * @return 32bytes converted in string
   */
  function bytes32ToString(bytes32 _bytes32)
    internal
    pure
    returns (string memory)
  {
    uint8 i = 0;
    while (i < 32 && _bytes32[i] != 0) {
      i++;
    }
    bytes memory bytesArray = new bytes(i);
    for (i = 0; i < 32 && _bytes32[i] != 0; i++) {
      bytesArray[i] = _bytes32[i];
    }
    return string(bytesArray);
  }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_synthereumFinder","type":"address"},{"components":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"maintainer","type":"address"}],"internalType":"struct MoneyMarketManager.Roles","name":"_roles","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"string","name":"moneyMarketId","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MintAndDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"string","name":"moneyMarketId","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RedeemAndBurn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"id","type":"string"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"bytes","name":"args","type":"bytes"}],"name":"RegisteredImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"string","name":"moneyMarketId","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"}],"name":"WithdrawRevenues","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAINTAINER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IMintableBurnableERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"string","name":"_moneyMarketId","type":"string"},{"internalType":"bytes","name":"_implementationCallArgs","type":"bytes"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"tokensOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_moneyMarketId","type":"string"},{"internalType":"address","name":"_jSynthAsset","type":"address"}],"name":"getMoneyMarketDeposited","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_moneyMarketId","type":"string"}],"name":"getMoneyMarketImplementation","outputs":[{"components":[{"internalType":"address","name":"implementationAddr","type":"address"},{"internalType":"bytes","name":"moneyMarketArgs","type":"bytes"}],"internalType":"struct IMoneyMarketManager.Implementation","name":"implementation","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_id","type":"string"},{"internalType":"address","name":"_implementation","type":"address"},{"internalType":"bytes","name":"_extraArgs","type":"bytes"}],"name":"registerMoneyMarketImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"synthereumFinder","outputs":[{"internalType":"contract ISynthereumFinder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IMintableBurnableERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"string","name":"_moneyMarketId","type":"string"},{"internalType":"bytes","name":"_implementationCallArgs","type":"bytes"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"burningAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMintableBurnableERC20","name":"_jSynthAsset","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"string","name":"_moneyMarketId","type":"string"},{"internalType":"bytes","name":"_implementationCallArgs","type":"bytes"}],"name":"withdrawRevenue","outputs":[{"internalType":"uint256","name":"jSynthOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b5060405162002a8338038062002a83833981016040819052620000349162000264565b600160009081556001600160a01b038316608052620000549080620000ad565b6200007060008051602062002a638339815191526000620000ad565b80516200008090600090620000fa565b620000a560008051602062002a638339815191528260200151620000fa60201b60201c565b5050620002fc565b6000828152600160208190526040808320909101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6200011182826200013d60201b620014411760201c565b6000828152600260209081526040909120620001389183906200144f6200014d821b17901c565b505050565b6200014982826200016d565b5050565b600062000164836001600160a01b038416620001f5565b90505b92915050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16620001495760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60008181526001830160205260408120546200023e5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000167565b50600062000167565b80516001600160a01b03811681146200025f57600080fd5b919050565b60008082840360608112156200027957600080fd5b620002848462000247565b92506040601f19820112156200029957600080fd5b50604080519081016001600160401b0381118282101715620002cb57634e487b7160e01b600052604160045260246000fd5b604052620002dc6020850162000247565b8152620002ec6040850162000247565b6020820152809150509250929050565b6080516127366200032d600039600081816102810152818161057901528181610a2401526111ce01526127366000f3fe608060405234801561001057600080fd5b506004361061010a5760003560e01c80639010d07c116100a2578063ca15c87311610071578063ca15c87314610243578063d2817e2b14610256578063d547741f14610269578063f6bf3ef61461027c578063f8742254146102a357600080fd5b80639010d07c146101dd57806391d1485414610208578063a217fddf1461021b578063b7e03db81461022357600080fd5b80632eb1c5e3116100de5780632eb1c5e31461018f5780632f2ff15d146101a457806336568abe146101b757806345664141146101ca57600080fd5b8062a1dd111461010f57806301ffc9a714610135578063234a537514610158578063248a9ca31461016b575b600080fd5b61012261011d366004611ef0565b6102b8565b6040519081526020015b60405180910390f35b610148610143366004611f7c565b610703565b604051901515815260200161012c565b610122610166366004611fa6565b61072e565b610122610179366004611ffd565b6000908152600160208190526040909120015490565b6101a261019d366004612016565b610785565b005b6101a26101b236600461209b565b610957565b6101a26101c536600461209b565b61097e565b6101226101d8366004611ef0565b6109a0565b6101f06101eb3660046120cb565b610cf9565b6040516001600160a01b03909116815260200161012c565b61014861021636600461209b565b610d18565b610122600081565b6102366102313660046120ed565b610d43565b60405161012c9190612187565b610122610251366004611ffd565b610e9f565b610122610264366004612240565b610eb6565b6101a261027736600461209b565b611437565b6101f07f000000000000000000000000000000000000000000000000000000000000000081565b6101226000805160206126e183398151915281565b60006102d26000805160206126e183398151915233610d18565b6102f75760405162461bcd60e51b81526004016102ee906122f4565b60405180910390fd5b6002600054141561031a5760405162461bcd60e51b81526004016102ee9061232b565b60026000908155604051610334908790879060200161238b565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b03168552600184018054929650909493928401916103849061239f565b80601f01602080910402602001604051908101604052809291908181526020018280546103b09061239f565b80156103fd5780601f106103d2576101008083540402835291602001916103fd565b820191906000526020600020905b8154815290600101906020018083116103e057829003601f168201915b5050509190925250505060008381526004602090815260408083206001600160a01b038e16845290915290205490915088111561046f5760405162461bcd60e51b815260206004820152601060248201526f13585e08185b5bdd5b9d081b1a5b5a5d60821b60448201526064016102ee565b6000610500604051806060016040528060258152602001612695602591398b8b85602001518a8a6040516024016104aa9594939291906123da565b60408051601f1981840301815290829052916104c591612420565b6040519081900390206020820180516001600160e01b03166001600160e01b031990921691909117905283516001600160a01b031690611464565b905080806020019051810190610516919061243c565b60008481526004602090815260408083206001600160a01b038f16845290915281208054929650869290919061054d90849061246b565b90915550506040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063aafd5e409060240160206040518083038186803b1580156105c357600080fd5b505afa1580156105d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fb9190612482565b90506106116001600160a01b038c168287611489565b6040516301e9a69560e41b81526001600160a01b038c8116600483015260248201879052821690631e9a695090604401602060405180830381600087803b15801561065b57600080fd5b505af115801561066f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610693919061243c565b5088886040516106a492919061249f565b60405180910390208b6001600160a01b03167f45242116afbb9c9318883f2d32649ea4f5445504a538f09de7e5f4862506ae51876040516106e791815260200190565b60405180910390a3505060016000555090979650505050505050565b60006001600160e01b03198216635a05180f60e01b1480610728575061072882611572565b92915050565b600080848460405160200161074492919061238b565b60408051601f1981840301815291815281516020928301206000908152600483528181206001600160a01b0390961681529490915290922054949350505050565b61079d6000805160206126e183398151915233610d18565b6107b95760405162461bcd60e51b81526004016102ee906122f4565b600260005414156107dc5760405162461bcd60e51b81526004016102ee9061232b565b600260009081556040516107f6908790879060200161238b565b60408051601f19818403018152919052805160209091012090508061085d5760405162461bcd60e51b815260206004820152601760248201527f57726f6e67206d6f64756c65206964656e74696669657200000000000000000060448201526064016102ee565b6040518060400160405280856001600160a01b0316815260200184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152600360209081526040909120835181546001600160a01b0319166001600160a01b039091161781558382015180519193506108f4926001850192910190611df6565b505060405161090791508790879061249f565b60405180910390207fb9769fb388a71a251bdb55c941a3f45a85d39bd60235ba86f936601cc2a429a3858585604051610942939291906124af565b60405180910390a25050600160005550505050565b61096182826115a7565b6000828152600260205260409020610979908261144f565b505050565b61098882826115ce565b60008281526002602052604090206109799082611648565b60006109ba6000805160206126e183398151915233610d18565b6109d65760405162461bcd60e51b81526004016102ee906122f4565b600260005414156109f95760405162461bcd60e51b81526004016102ee9061232b565b600260009081556040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063aafd5e409060240160206040518083038186803b158015610a6e57600080fd5b505afa158015610a82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa69190612482565b6040516340c10f1960e01b81526001600160a01b038a81166004830152602482018a9052919250908216906340c10f1990604401602060405180830381600087803b158015610af457600080fd5b505af1158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2c919061243c565b5060008686604051602001610b4292919061238b565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b0316855260018401805492965090949392840191610b929061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbe9061239f565b8015610c0b5780601f10610be057610100808354040283529160200191610c0b565b820191906000526020600020905b815481529060010190602001808311610bee57829003601f168201915b5050509190925250505060008381526004602090815260408083206001600160a01b038f168452909152812080549293508b92909190610c4c9084906124dd565b925050819055506000610c8e604051806060016040528060248152602001612671602491398c8c85602001518b8b6040516024016104aa9594939291906123da565b905080806020019051810190610ca4919061243c565b94508888604051610cb692919061249f565b60405180910390208b6001600160a01b03167f4c1ebee5d7af094d8de743fe7cf4dbbb2ca9cb68dd7524dd9aa540cbbeaeb8cb8c6040516106e791815260200190565b6000828152600260205260408120610d11908361165d565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60408051808201909152600081526060602082015260008383604051602001610d6d92919061238b565b60408051601f19818403018152828252805160209182012060008181526003835283902084840190935282546001600160a01b031684526001830180549195509184019190610dbb9061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610de79061239f565b8015610e345780601f10610e0957610100808354040283529160200191610e34565b820191906000526020600020905b815481529060010190602001808311610e1757829003601f168201915b5050509190925250508151919350506001600160a01b0316610e985760405162461bcd60e51b815260206004820152601c60248201527f496d706c656d656e746174696f6e206e6f7420737570706f727465640000000060448201526064016102ee565b5092915050565b600081815260026020526040812061072890611669565b6000610ed06000805160206126e183398151915233610d18565b610eec5760405162461bcd60e51b81526004016102ee906122f4565b60026000541415610f0f5760405162461bcd60e51b81526004016102ee9061232b565b60026000908155604051610f279085906020016124f5565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b0316855260018401805492965090949392840191610f779061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa39061239f565b8015610ff05780601f10610fc557610100808354040283529160200191610ff0565b820191906000526020600020905b815481529060010190602001808311610fd357829003601f168201915b5050505050815250509050600081600001516001600160a01b031663ac2dbce6898460200151886040518463ffffffff1660e01b815260040161103593929190612508565b602060405180830381600087803b15801561104f57600080fd5b505af1158015611063573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611087919061243c565b60008481526004602090815260408083206001600160a01b038d168452909152812054919250906110b8908361246b565b9050600081116110f85760405162461bcd60e51b815260206004820152600b60248201526a4e6f20726576656e75657360a81b60448201526064016102ee565b6000611187604051806060016040528060258152602001612695602591398b8487602001518b604051602401611131949392919061253e565b60408051601f19818403018152908290529161114c91612420565b6040519081900390206020820180516001600160e01b03166001600160e01b031990921691909117905285516001600160a01b031690611464565b90508080602001905181019061119d919061243c565b955081861115611345576040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063aafd5e409060240160206040518083038186803b15801561121857600080fd5b505afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190612482565b9050600061125e848961246b565b90506112746001600160a01b038d168383611489565b6040516301e9a69560e41b81526001600160a01b038d8116600483015260248201839052831690631e9a695090604401602060405180830381600087803b1580156112be57600080fd5b505af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f6919061243c565b50806004600089815260200190815260200160002060008e6001600160a01b03166001600160a01b03168152602001908152602001600020600082825461133d919061246b565b909155505050505b60405163a9059cbb60e01b81526001600160a01b038a81166004830152602482018490528b169063a9059cbb90604401602060405180830381600087803b15801561138f57600080fd5b505af11580156113a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c79190612577565b50876040516113d69190612420565b604080519182900382208483526001600160a01b038c811660208501529092908d16917f2d9cbf32901b6bf5cbf86f48eb2be9ad070b6661b7f67a865a8419e355768d1b910160405180910390a35050600160005550919695505050505050565b6109888282611673565b61144b828261169a565b5050565b6000610d11836001600160a01b038416611705565b6060610d1183836040518060600160405280602781526020016126ba60279139611754565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b1580156114d557600080fd5b505afa1580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150d919061243c565b61151791906124dd565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905290915061156c908590611828565b50505050565b60006001600160e01b03198216637965db0b60e01b148061072857506301ffc9a760e01b6001600160e01b0319831614610728565b600082815260016020819052604090912001546115c481336118fa565b610979838361169a565b6001600160a01b038116331461163e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016102ee565b61144b828261195e565b6000610d11836001600160a01b0384166119c5565b6000610d118383611ab8565b6000610728825490565b6000828152600160208190526040909120015461169081336118fa565b610979838361195e565b6116a48282610d18565b61144b5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600081815260018301602052604081205461174c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610728565b506000610728565b6060833b6117b35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016102ee565b600080856001600160a01b0316856040516117ce9190612420565b600060405180830381855af49150503d8060008114611809576040519150601f19603f3d011682016040523d82523d6000602084013e61180e565b606091505b509150915061181e828286611ae2565b9695505050505050565b600061187d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b1b9092919063ffffffff16565b805190915015610979578080602001905181019061189b9190612577565b6109795760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102ee565b6119048282610d18565b61144b5761191c816001600160a01b03166014611b32565b611927836020611b32565b604051602001611938929190612599565b60408051601f198184030181529082905262461bcd60e51b82526102ee916004016124f5565b6119688282610d18565b1561144b5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015611aae5760006119e960018361246b565b85549091506000906119fd9060019061246b565b9050818114611a62576000866000018281548110611a1d57611a1d61260e565b9060005260206000200154905080876000018481548110611a4057611a4061260e565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a7357611a73612624565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610728565b6000915050610728565b6000826000018281548110611acf57611acf61260e565b9060005260206000200154905092915050565b60608315611af1575081610d11565b825115611b015782518084602001fd5b8160405162461bcd60e51b81526004016102ee91906124f5565b6060611b2a8484600085611cce565b949350505050565b60606000611b4183600261263a565b611b4c9060026124dd565b67ffffffffffffffff811115611b6457611b646121b4565b6040519080825280601f01601f191660200182016040528015611b8e576020820181803683370190505b509050600360fc1b81600081518110611ba957611ba961260e565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611bd857611bd861260e565b60200101906001600160f81b031916908160001a9053506000611bfc84600261263a565b611c079060016124dd565b90505b6001811115611c7f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611c3b57611c3b61260e565b1a60f81b828281518110611c5157611c5161260e565b60200101906001600160f81b031916908160001a90535060049490941c93611c7881612659565b9050611c0a565b508315610d115760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016102ee565b606082471015611d2f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102ee565b843b611d7d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102ee565b600080866001600160a01b03168587604051611d999190612420565b60006040518083038185875af1925050503d8060008114611dd6576040519150601f19603f3d011682016040523d82523d6000602084013e611ddb565b606091505b5091509150611deb828286611ae2565b979650505050505050565b828054611e029061239f565b90600052602060002090601f016020900481019282611e245760008555611e6a565b82601f10611e3d57805160ff1916838001178555611e6a565b82800160010185558215611e6a579182015b82811115611e6a578251825591602001919060010190611e4f565b50611e76929150611e7a565b5090565b5b80821115611e765760008155600101611e7b565b6001600160a01b0381168114611ea457600080fd5b50565b60008083601f840112611eb957600080fd5b50813567ffffffffffffffff811115611ed157600080fd5b602083019150836020828501011115611ee957600080fd5b9250929050565b60008060008060008060808789031215611f0957600080fd5b8635611f1481611e8f565b955060208701359450604087013567ffffffffffffffff80821115611f3857600080fd5b611f448a838b01611ea7565b90965094506060890135915080821115611f5d57600080fd5b50611f6a89828a01611ea7565b979a9699509497509295939492505050565b600060208284031215611f8e57600080fd5b81356001600160e01b031981168114610d1157600080fd5b600080600060408486031215611fbb57600080fd5b833567ffffffffffffffff811115611fd257600080fd5b611fde86828701611ea7565b9094509250506020840135611ff281611e8f565b809150509250925092565b60006020828403121561200f57600080fd5b5035919050565b60008060008060006060868803121561202e57600080fd5b853567ffffffffffffffff8082111561204657600080fd5b61205289838a01611ea7565b90975095506020880135915061206782611e8f565b9093506040870135908082111561207d57600080fd5b5061208a88828901611ea7565b969995985093965092949392505050565b600080604083850312156120ae57600080fd5b8235915060208301356120c081611e8f565b809150509250929050565b600080604083850312156120de57600080fd5b50508035926020909101359150565b6000806020838503121561210057600080fd5b823567ffffffffffffffff81111561211757600080fd5b61212385828601611ea7565b90969095509350505050565b60005b8381101561214a578181015183820152602001612132565b8381111561156c5750506000910152565b6000815180845261217381602086016020860161212f565b601f01601f19169290920160200192915050565b602080825282516001600160a01b031682820152820151604080830152600090611b2a606084018261215b565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156121e5576121e56121b4565b604051601f8501601f19908116603f0116810190828211818310171561220d5761220d6121b4565b8160405280935085815286868601111561222657600080fd5b858560208301376000602087830101525050509392505050565b6000806000806080858703121561225657600080fd5b843561226181611e8f565b9350602085013561227181611e8f565b9250604085013567ffffffffffffffff8082111561228e57600080fd5b818701915087601f8301126122a257600080fd5b6122b1888335602085016121ca565b935060608701359150808211156122c757600080fd5b508501601f810187136122d957600080fd5b6122e8878235602084016121ca565b91505092959194509250565b6020808252601d908201527f53656e646572206d75737420626520746865206d61696e7461696e6572000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000611b2a602083018486612362565b600181811c908216806123b357607f821691505b602082108114156123d457634e487b7160e01b600052602260045260246000fd5b50919050565b60018060a01b0386168152846020820152608060408201526000612401608083018661215b565b8281036060840152612414818587612362565b98975050505050505050565b6000825161243281846020870161212f565b9190910192915050565b60006020828403121561244e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008282101561247d5761247d612455565b500390565b60006020828403121561249457600080fd5b8151610d1181611e8f565b8183823760009101908152919050565b6001600160a01b03841681526040602082018190526000906124d49083018486612362565b95945050505050565b600082198211156124f0576124f0612455565b500190565b602081526000610d11602083018461215b565b6001600160a01b038416815260606020820181905260009061252c9083018561215b565b828103604084015261181e818561215b565b60018060a01b0385168152836020820152608060408201526000612565608083018561215b565b8281036060840152611deb818561215b565b60006020828403121561258957600080fd5b81518015158114610d1157600080fd5b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516125d181601785016020880161212f565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161260281602884016020880161212f565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600081600019048311821515161561265457612654612455565b500290565b60008161266857612668612455565b50600019019056fe6465706f73697428616464726573732c75696e743235362c62797465732c627974657329776974686472617728616464726573732c75696e743235362c62797465732c627974657329416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564126303c860ea810f85e857ad8768056e2eebc24b7796655ff3107e4af18e3f1ea26469706673582212201cf6e469eebd3897123f943fcfaaff13fd4d16914be257da093a637fd4ad1b3a64736f6c63430008090033126303c860ea810f85e857ad8768056e2eebc24b7796655ff3107e4af18e3f1e00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061010a5760003560e01c80639010d07c116100a2578063ca15c87311610071578063ca15c87314610243578063d2817e2b14610256578063d547741f14610269578063f6bf3ef61461027c578063f8742254146102a357600080fd5b80639010d07c146101dd57806391d1485414610208578063a217fddf1461021b578063b7e03db81461022357600080fd5b80632eb1c5e3116100de5780632eb1c5e31461018f5780632f2ff15d146101a457806336568abe146101b757806345664141146101ca57600080fd5b8062a1dd111461010f57806301ffc9a714610135578063234a537514610158578063248a9ca31461016b575b600080fd5b61012261011d366004611ef0565b6102b8565b6040519081526020015b60405180910390f35b610148610143366004611f7c565b610703565b604051901515815260200161012c565b610122610166366004611fa6565b61072e565b610122610179366004611ffd565b6000908152600160208190526040909120015490565b6101a261019d366004612016565b610785565b005b6101a26101b236600461209b565b610957565b6101a26101c536600461209b565b61097e565b6101226101d8366004611ef0565b6109a0565b6101f06101eb3660046120cb565b610cf9565b6040516001600160a01b03909116815260200161012c565b61014861021636600461209b565b610d18565b610122600081565b6102366102313660046120ed565b610d43565b60405161012c9190612187565b610122610251366004611ffd565b610e9f565b610122610264366004612240565b610eb6565b6101a261027736600461209b565b611437565b6101f07f00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e81565b6101226000805160206126e183398151915281565b60006102d26000805160206126e183398151915233610d18565b6102f75760405162461bcd60e51b81526004016102ee906122f4565b60405180910390fd5b6002600054141561031a5760405162461bcd60e51b81526004016102ee9061232b565b60026000908155604051610334908790879060200161238b565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b03168552600184018054929650909493928401916103849061239f565b80601f01602080910402602001604051908101604052809291908181526020018280546103b09061239f565b80156103fd5780601f106103d2576101008083540402835291602001916103fd565b820191906000526020600020905b8154815290600101906020018083116103e057829003601f168201915b5050509190925250505060008381526004602090815260408083206001600160a01b038e16845290915290205490915088111561046f5760405162461bcd60e51b815260206004820152601060248201526f13585e08185b5bdd5b9d081b1a5b5a5d60821b60448201526064016102ee565b6000610500604051806060016040528060258152602001612695602591398b8b85602001518a8a6040516024016104aa9594939291906123da565b60408051601f1981840301815290829052916104c591612420565b6040519081900390206020820180516001600160e01b03166001600160e01b031990921691909117905283516001600160a01b031690611464565b905080806020019051810190610516919061243c565b60008481526004602090815260408083206001600160a01b038f16845290915281208054929650869290919061054d90849061246b565b90915550506040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201526000907f00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e6001600160a01b03169063aafd5e409060240160206040518083038186803b1580156105c357600080fd5b505afa1580156105d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fb9190612482565b90506106116001600160a01b038c168287611489565b6040516301e9a69560e41b81526001600160a01b038c8116600483015260248201879052821690631e9a695090604401602060405180830381600087803b15801561065b57600080fd5b505af115801561066f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610693919061243c565b5088886040516106a492919061249f565b60405180910390208b6001600160a01b03167f45242116afbb9c9318883f2d32649ea4f5445504a538f09de7e5f4862506ae51876040516106e791815260200190565b60405180910390a3505060016000555090979650505050505050565b60006001600160e01b03198216635a05180f60e01b1480610728575061072882611572565b92915050565b600080848460405160200161074492919061238b565b60408051601f1981840301815291815281516020928301206000908152600483528181206001600160a01b0390961681529490915290922054949350505050565b61079d6000805160206126e183398151915233610d18565b6107b95760405162461bcd60e51b81526004016102ee906122f4565b600260005414156107dc5760405162461bcd60e51b81526004016102ee9061232b565b600260009081556040516107f6908790879060200161238b565b60408051601f19818403018152919052805160209091012090508061085d5760405162461bcd60e51b815260206004820152601760248201527f57726f6e67206d6f64756c65206964656e74696669657200000000000000000060448201526064016102ee565b6040518060400160405280856001600160a01b0316815260200184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152600360209081526040909120835181546001600160a01b0319166001600160a01b039091161781558382015180519193506108f4926001850192910190611df6565b505060405161090791508790879061249f565b60405180910390207fb9769fb388a71a251bdb55c941a3f45a85d39bd60235ba86f936601cc2a429a3858585604051610942939291906124af565b60405180910390a25050600160005550505050565b61096182826115a7565b6000828152600260205260409020610979908261144f565b505050565b61098882826115ce565b60008281526002602052604090206109799082611648565b60006109ba6000805160206126e183398151915233610d18565b6109d65760405162461bcd60e51b81526004016102ee906122f4565b600260005414156109f95760405162461bcd60e51b81526004016102ee9061232b565b600260009081556040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201527f00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e6001600160a01b03169063aafd5e409060240160206040518083038186803b158015610a6e57600080fd5b505afa158015610a82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa69190612482565b6040516340c10f1960e01b81526001600160a01b038a81166004830152602482018a9052919250908216906340c10f1990604401602060405180830381600087803b158015610af457600080fd5b505af1158015610b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2c919061243c565b5060008686604051602001610b4292919061238b565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b0316855260018401805492965090949392840191610b929061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bbe9061239f565b8015610c0b5780601f10610be057610100808354040283529160200191610c0b565b820191906000526020600020905b815481529060010190602001808311610bee57829003601f168201915b5050509190925250505060008381526004602090815260408083206001600160a01b038f168452909152812080549293508b92909190610c4c9084906124dd565b925050819055506000610c8e604051806060016040528060248152602001612671602491398c8c85602001518b8b6040516024016104aa9594939291906123da565b905080806020019051810190610ca4919061243c565b94508888604051610cb692919061249f565b60405180910390208b6001600160a01b03167f4c1ebee5d7af094d8de743fe7cf4dbbb2ca9cb68dd7524dd9aa540cbbeaeb8cb8c6040516106e791815260200190565b6000828152600260205260408120610d11908361165d565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60408051808201909152600081526060602082015260008383604051602001610d6d92919061238b565b60408051601f19818403018152828252805160209182012060008181526003835283902084840190935282546001600160a01b031684526001830180549195509184019190610dbb9061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610de79061239f565b8015610e345780601f10610e0957610100808354040283529160200191610e34565b820191906000526020600020905b815481529060010190602001808311610e1757829003601f168201915b5050509190925250508151919350506001600160a01b0316610e985760405162461bcd60e51b815260206004820152601c60248201527f496d706c656d656e746174696f6e206e6f7420737570706f727465640000000060448201526064016102ee565b5092915050565b600081815260026020526040812061072890611669565b6000610ed06000805160206126e183398151915233610d18565b610eec5760405162461bcd60e51b81526004016102ee906122f4565b60026000541415610f0f5760405162461bcd60e51b81526004016102ee9061232b565b60026000908155604051610f279085906020016124f5565b60408051601f19818403018152828252805160209182012060008181526003835283812085850190945283546001600160a01b0316855260018401805492965090949392840191610f779061239f565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa39061239f565b8015610ff05780601f10610fc557610100808354040283529160200191610ff0565b820191906000526020600020905b815481529060010190602001808311610fd357829003601f168201915b5050505050815250509050600081600001516001600160a01b031663ac2dbce6898460200151886040518463ffffffff1660e01b815260040161103593929190612508565b602060405180830381600087803b15801561104f57600080fd5b505af1158015611063573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611087919061243c565b60008481526004602090815260408083206001600160a01b038d168452909152812054919250906110b8908361246b565b9050600081116110f85760405162461bcd60e51b815260206004820152600b60248201526a4e6f20726576656e75657360a81b60448201526064016102ee565b6000611187604051806060016040528060258152602001612695602591398b8487602001518b604051602401611131949392919061253e565b60408051601f19818403018152908290529161114c91612420565b6040519081900390206020820180516001600160e01b03166001600160e01b031990921691909117905285516001600160a01b031690611464565b90508080602001905181019061119d919061243c565b955081861115611345576040516302abf57960e61b81526b2530b93b34b9a1393939393960a11b60048201526000907f00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e6001600160a01b03169063aafd5e409060240160206040518083038186803b15801561121857600080fd5b505afa15801561122c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112509190612482565b9050600061125e848961246b565b90506112746001600160a01b038d168383611489565b6040516301e9a69560e41b81526001600160a01b038d8116600483015260248201839052831690631e9a695090604401602060405180830381600087803b1580156112be57600080fd5b505af11580156112d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f6919061243c565b50806004600089815260200190815260200160002060008e6001600160a01b03166001600160a01b03168152602001908152602001600020600082825461133d919061246b565b909155505050505b60405163a9059cbb60e01b81526001600160a01b038a81166004830152602482018490528b169063a9059cbb90604401602060405180830381600087803b15801561138f57600080fd5b505af11580156113a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c79190612577565b50876040516113d69190612420565b604080519182900382208483526001600160a01b038c811660208501529092908d16917f2d9cbf32901b6bf5cbf86f48eb2be9ad070b6661b7f67a865a8419e355768d1b910160405180910390a35050600160005550919695505050505050565b6109888282611673565b61144b828261169a565b5050565b6000610d11836001600160a01b038416611705565b6060610d1183836040518060600160405280602781526020016126ba60279139611754565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b1580156114d557600080fd5b505afa1580156114e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150d919061243c565b61151791906124dd565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905290915061156c908590611828565b50505050565b60006001600160e01b03198216637965db0b60e01b148061072857506301ffc9a760e01b6001600160e01b0319831614610728565b600082815260016020819052604090912001546115c481336118fa565b610979838361169a565b6001600160a01b038116331461163e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016102ee565b61144b828261195e565b6000610d11836001600160a01b0384166119c5565b6000610d118383611ab8565b6000610728825490565b6000828152600160208190526040909120015461169081336118fa565b610979838361195e565b6116a48282610d18565b61144b5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600081815260018301602052604081205461174c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610728565b506000610728565b6060833b6117b35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016102ee565b600080856001600160a01b0316856040516117ce9190612420565b600060405180830381855af49150503d8060008114611809576040519150601f19603f3d011682016040523d82523d6000602084013e61180e565b606091505b509150915061181e828286611ae2565b9695505050505050565b600061187d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b1b9092919063ffffffff16565b805190915015610979578080602001905181019061189b9190612577565b6109795760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102ee565b6119048282610d18565b61144b5761191c816001600160a01b03166014611b32565b611927836020611b32565b604051602001611938929190612599565b60408051601f198184030181529082905262461bcd60e51b82526102ee916004016124f5565b6119688282610d18565b1561144b5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015611aae5760006119e960018361246b565b85549091506000906119fd9060019061246b565b9050818114611a62576000866000018281548110611a1d57611a1d61260e565b9060005260206000200154905080876000018481548110611a4057611a4061260e565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a7357611a73612624565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610728565b6000915050610728565b6000826000018281548110611acf57611acf61260e565b9060005260206000200154905092915050565b60608315611af1575081610d11565b825115611b015782518084602001fd5b8160405162461bcd60e51b81526004016102ee91906124f5565b6060611b2a8484600085611cce565b949350505050565b60606000611b4183600261263a565b611b4c9060026124dd565b67ffffffffffffffff811115611b6457611b646121b4565b6040519080825280601f01601f191660200182016040528015611b8e576020820181803683370190505b509050600360fc1b81600081518110611ba957611ba961260e565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611bd857611bd861260e565b60200101906001600160f81b031916908160001a9053506000611bfc84600261263a565b611c079060016124dd565b90505b6001811115611c7f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611c3b57611c3b61260e565b1a60f81b828281518110611c5157611c5161260e565b60200101906001600160f81b031916908160001a90535060049490941c93611c7881612659565b9050611c0a565b508315610d115760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016102ee565b606082471015611d2f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102ee565b843b611d7d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102ee565b600080866001600160a01b03168587604051611d999190612420565b60006040518083038185875af1925050503d8060008114611dd6576040519150601f19603f3d011682016040523d82523d6000602084013e611ddb565b606091505b5091509150611deb828286611ae2565b979650505050505050565b828054611e029061239f565b90600052602060002090601f016020900481019282611e245760008555611e6a565b82601f10611e3d57805160ff1916838001178555611e6a565b82800160010185558215611e6a579182015b82811115611e6a578251825591602001919060010190611e4f565b50611e76929150611e7a565b5090565b5b80821115611e765760008155600101611e7b565b6001600160a01b0381168114611ea457600080fd5b50565b60008083601f840112611eb957600080fd5b50813567ffffffffffffffff811115611ed157600080fd5b602083019150836020828501011115611ee957600080fd5b9250929050565b60008060008060008060808789031215611f0957600080fd5b8635611f1481611e8f565b955060208701359450604087013567ffffffffffffffff80821115611f3857600080fd5b611f448a838b01611ea7565b90965094506060890135915080821115611f5d57600080fd5b50611f6a89828a01611ea7565b979a9699509497509295939492505050565b600060208284031215611f8e57600080fd5b81356001600160e01b031981168114610d1157600080fd5b600080600060408486031215611fbb57600080fd5b833567ffffffffffffffff811115611fd257600080fd5b611fde86828701611ea7565b9094509250506020840135611ff281611e8f565b809150509250925092565b60006020828403121561200f57600080fd5b5035919050565b60008060008060006060868803121561202e57600080fd5b853567ffffffffffffffff8082111561204657600080fd5b61205289838a01611ea7565b90975095506020880135915061206782611e8f565b9093506040870135908082111561207d57600080fd5b5061208a88828901611ea7565b969995985093965092949392505050565b600080604083850312156120ae57600080fd5b8235915060208301356120c081611e8f565b809150509250929050565b600080604083850312156120de57600080fd5b50508035926020909101359150565b6000806020838503121561210057600080fd5b823567ffffffffffffffff81111561211757600080fd5b61212385828601611ea7565b90969095509350505050565b60005b8381101561214a578181015183820152602001612132565b8381111561156c5750506000910152565b6000815180845261217381602086016020860161212f565b601f01601f19169290920160200192915050565b602080825282516001600160a01b031682820152820151604080830152600090611b2a606084018261215b565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156121e5576121e56121b4565b604051601f8501601f19908116603f0116810190828211818310171561220d5761220d6121b4565b8160405280935085815286868601111561222657600080fd5b858560208301376000602087830101525050509392505050565b6000806000806080858703121561225657600080fd5b843561226181611e8f565b9350602085013561227181611e8f565b9250604085013567ffffffffffffffff8082111561228e57600080fd5b818701915087601f8301126122a257600080fd5b6122b1888335602085016121ca565b935060608701359150808211156122c757600080fd5b508501601f810187136122d957600080fd5b6122e8878235602084016121ca565b91505092959194509250565b6020808252601d908201527f53656e646572206d75737420626520746865206d61696e7461696e6572000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000611b2a602083018486612362565b600181811c908216806123b357607f821691505b602082108114156123d457634e487b7160e01b600052602260045260246000fd5b50919050565b60018060a01b0386168152846020820152608060408201526000612401608083018661215b565b8281036060840152612414818587612362565b98975050505050505050565b6000825161243281846020870161212f565b9190910192915050565b60006020828403121561244e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008282101561247d5761247d612455565b500390565b60006020828403121561249457600080fd5b8151610d1181611e8f565b8183823760009101908152919050565b6001600160a01b03841681526040602082018190526000906124d49083018486612362565b95945050505050565b600082198211156124f0576124f0612455565b500190565b602081526000610d11602083018461215b565b6001600160a01b038416815260606020820181905260009061252c9083018561215b565b828103604084015261181e818561215b565b60018060a01b0385168152836020820152608060408201526000612565608083018561215b565b8281036060840152611deb818561215b565b60006020828403121561258957600080fd5b81518015158114610d1157600080fd5b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516125d181601785016020880161212f565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161260281602884016020880161212f565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600081600019048311821515161561265457612654612455565b500290565b60008161266857612668612455565b50600019019056fe6465706f73697428616464726573732c75696e743235362c62797465732c627974657329776974686472617728616464726573732c75696e743235362c62797465732c627974657329416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564126303c860ea810f85e857ad8768056e2eebc24b7796655ff3107e4af18e3f1ea26469706673582212201cf6e469eebd3897123f943fcfaaff13fd4d16914be257da093a637fd4ad1b3a64736f6c63430008090033

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

00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77

-----Decoded View---------------
Arg [0] : _synthereumFinder (address): 0x43a98e5C4A7F3B7f11080fc9D58b0B8A80cA954e
Arg [1] : _roles (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000043a98e5c4a7f3b7f11080fc9d58b0b8a80ca954e
Arg [1] : 000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77
Arg [2] : 000000000000000000000000685723b9dc89bdf28ba5f98f9a8c0ac899bd6e77


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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