pragma solidity ^0.5.16; // Inheritance import "./Synth.sol"; // Internal references import "./interfaces/ICollateralManager.sol"; import "./interfaces/IEtherWrapper.sol"; import "./interfaces/IWrapperFactory.sol"; // https://docs.synthetix.io/contracts/source/contracts/multicollateralsynth contract MultiCollateralSynth is Synth { bytes32 public constant CONTRACT_NAME = "MultiCollateralSynth"; /* ========== ADDRESS RESOLVER CONFIGURATION ========== */ bytes32 private constant CONTRACT_COLLATERALMANAGER = "CollateralManager"; bytes32 private constant CONTRACT_ETHER_WRAPPER = "EtherWrapper"; bytes32 private constant CONTRACT_WRAPPER_FACTORY = "WrapperFactory"; /* ========== CONSTRUCTOR ========== */ constructor( address payable _proxy, TokenState _tokenState, string memory _tokenName, string memory _tokenSymbol, address _owner, bytes32 _currencyKey, uint _totalSupply, address _resolver ) public Synth(_proxy, _tokenState, _tokenName, _tokenSymbol, _owner, _currencyKey, _totalSupply, _resolver) {} /* ========== VIEWS ======================= */ function collateralManager() internal view returns (ICollateralManager) { return ICollateralManager(requireAndGetAddress(CONTRACT_COLLATERALMANAGER)); } function etherWrapper() internal view returns (IEtherWrapper) { return IEtherWrapper(requireAndGetAddress(CONTRACT_ETHER_WRAPPER)); } function wrapperFactory() internal view returns (IWrapperFactory) { return IWrapperFactory(requireAndGetAddress(CONTRACT_WRAPPER_FACTORY)); } function resolverAddressesRequired() public view returns (bytes32[] memory addresses) { bytes32[] memory existingAddresses = Synth.resolverAddressesRequired(); bytes32[] memory newAddresses = new bytes32[](3); newAddresses[0] = CONTRACT_COLLATERALMANAGER; newAddresses[1] = CONTRACT_ETHER_WRAPPER; newAddresses[2] = CONTRACT_WRAPPER_FACTORY; addresses = combineArrays(existingAddresses, newAddresses); } /* ========== MUTATIVE FUNCTIONS ========== */ /** * @notice Function that allows multi Collateral to issue a certain number of synths from an account. * @param account Account to issue synths to * @param amount Number of synths */ function issue(address account, uint amount) external onlyInternalContracts { super._internalIssue(account, amount); } /** * @notice Function that allows multi Collateral to burn a certain number of synths from an account. * @param account Account to burn synths from * @param amount Number of synths */ function burn(address account, uint amount) external onlyInternalContracts { super._internalBurn(account, amount); } /* ========== MODIFIERS ========== */ // overriding modifier from super to add more internal contracts and checks function _isInternalContract(address account) internal view returns (bool) { return super._isInternalContract(account) || collateralManager().hasCollateral(account) || wrapperFactory().isWrapper(account) || (account == address(etherWrapper())); } }