Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- MinterestNFTMirror
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-06-02T10:28:43.753373Z
contracts/layerZero/MinterestNFTMirror.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "../MinterestNFT.sol";
import "./MONFT1155Core.sol";
contract MinterestNFTMirror is MinterestNFT, MONFT1155Core {
function _initialize(
string memory _baseURI,
address _admin,
address _lzEndpoint
) public {
lzEndpoint = ILayerZeroEndpoint(_lzEndpoint);
initialize(_baseURI, _admin);
}
function _debitFrom(
address _from,
uint16,
bytes memory,
uint256[] memory _tokenIds,
uint256[] memory,
uint256[] memory _amounts
) internal virtual override {
address spender = _msgSender();
require(
spender == _from || isApprovedForAll(_from, spender),
"ONFT1155: send caller is not owner nor approved"
);
_burnBatch(_from, _tokenIds, _amounts);
}
function _creditTo(
uint16,
address _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _tiers,
uint256[] memory _amounts
) internal virtual override {
_mintBatch(_toAddress, _tokenIds, _amounts, "");
emissionBooster().onMintToken(_toAddress, _tokenIds, _amounts, _tiers);
}
function _getEmissionBooster() internal view override returns (IEmissionBooster) {
return emissionBooster();
}
/// @dev Returns true if this contract implements the interface defined by `interfaceId`
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ONFT1155Core, MinterestNFT)
returns (bool)
{
return
interfaceId == type(IMinterestNFT).interfaceId ||
interfaceId == type(IERC165).interfaceId ||
super.supportsInterface(interfaceId);
}
/// @dev Function with this modifier can be executed only by accounts with DEFAULT_ADMIN_ROLE.
/// Override standard `Ownable` behavior to keep original implementation of `LzApp` contract.
modifier onlyOwner() override {
_checkRole(DEFAULT_ADMIN_ROLE);
_;
}
}
contracts/layerZero/lzApp/LzApp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/utils/Context.sol";
import "@layerzerolabs/solidity-examples/contracts/util/BytesLib.sol";
import "@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroReceiver.sol";
import "@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroUserApplicationConfig.sol";
import "@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroEndpoint.sol";
import "@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroEndpoint.sol";
import "../../libraries/ErrorCodes.sol";
/*
* a generic LzReceiver implementation
*/
abstract contract LzApp is Context, ILayerZeroReceiver, ILayerZeroUserApplicationConfig {
using BytesLib for bytes;
// ua can not send payload larger than this by default, but it can be changed by the ua owner
uint256 public constant DEFAULT_PAYLOAD_SIZE_LIMIT = 10000;
//slither-disable-next-line immutable-states
ILayerZeroEndpoint public lzEndpoint;
mapping(uint16 => bytes) public trustedRemoteLookup;
mapping(uint16 => mapping(uint16 => uint256)) public minDstGasLookup;
mapping(uint16 => uint256) public payloadSizeLimitLookup;
address public precrime;
event SetPrecrime(address precrime);
event SetTrustedRemote(uint16 _remoteChainId, bytes _path);
event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress);
event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint256 _minDstGas);
event LayerZeroEndpointSet(ILayerZeroEndpoint previosLzEndpoint, ILayerZeroEndpoint newLzEndpoint);
function lzReceive(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) public virtual override {
// lzReceive must be called by the endpoint for security
require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller");
bytes memory trustedRemote = trustedRemoteLookup[_srcChainId];
// if will still block the message pathway from (srcChainId, srcAddress).
// should not receive message from untrusted remote.
require(
_srcAddress.length == trustedRemote.length &&
trustedRemote.length > 0 &&
keccak256(_srcAddress) == keccak256(trustedRemote),
"LzApp: invalid source sending contract"
);
_blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
// abstract function - the default behaviour of LayerZero is blocking.
// See: NonblockingLzApp if you dont need to enforce ordered messaging
function _blockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64 _nonce,
bytes memory _payload
) internal virtual;
function _lzSend(
uint16 _dstChainId,
bytes memory _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes memory _adapterParams,
uint256 _nativeFee
) internal virtual {
bytes memory trustedRemote = trustedRemoteLookup[_dstChainId];
require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source");
_checkPayloadSize(_dstChainId, _payload.length);
// slither-disable-next-line arbitrary-send-eth
lzEndpoint.send{value: _nativeFee}(
_dstChainId,
trustedRemote,
_payload,
_refundAddress,
_zroPaymentAddress,
_adapterParams
);
}
function _checkGasLimit(
uint16 _dstChainId,
uint16 _type,
bytes memory _adapterParams,
uint256 _extraGas
) internal view virtual {
uint256 providedGasLimit = _getGasLimit(_adapterParams);
uint256 minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas;
require(minGasLimit > 0, "LzApp: minGasLimit not set");
require(providedGasLimit >= minGasLimit, "LzApp: gas limit is too low");
}
function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint256 gasLimit) {
require(_adapterParams.length >= 34, "LzApp: invalid adapterParams");
assembly {
gasLimit := mload(add(_adapterParams, 34))
}
}
function _checkPayloadSize(uint16 _dstChainId, uint256 _payloadSize) internal view virtual {
uint256 payloadSizeLimit = payloadSizeLimitLookup[_dstChainId];
if (payloadSizeLimit == 0) {
// use default if not set
payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT;
}
require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large");
}
//---------------------------UserApplication config----------------------------------------
function getConfig(
uint16 _version,
uint16 _chainId,
address,
uint256 _configType
) external view returns (bytes memory) {
return lzEndpoint.getConfig(_version, _chainId, address(this), _configType);
}
// generic config for LayerZero user Application
function setConfig(
uint16 _version,
uint16 _chainId,
uint256 _configType,
bytes calldata _config
) external override onlyOwner {
lzEndpoint.setConfig(_version, _chainId, _configType, _config);
}
function setSendVersion(uint16 _version) external override onlyOwner {
lzEndpoint.setSendVersion(_version);
}
function setReceiveVersion(uint16 _version) external override onlyOwner {
lzEndpoint.setReceiveVersion(_version);
}
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner {
lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress);
}
// _path = abi.encodePacked(remoteAddress, localAddress)
// this function set the trusted path for the cross-chain communication
function setTrustedRemote(uint16 _remoteChainId, bytes calldata _path) external onlyOwner {
trustedRemoteLookup[_remoteChainId] = _path;
emit SetTrustedRemote(_remoteChainId, _path);
}
function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner {
trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this));
emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress);
}
function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) {
bytes memory path = trustedRemoteLookup[_remoteChainId];
require(path.length != 0, "LzApp: no trusted path record");
return path.slice(0, path.length - 20); // the last 20 bytes should be address(this)
}
function setPrecrime(address _precrime) external onlyOwner {
require(_precrime != address(0), "LzApp: precrime can not be zero address");
precrime = _precrime;
emit SetPrecrime(_precrime);
}
function setMinDstGas(
uint16 _dstChainId,
uint16 _packetType,
uint256 _minGas
) external onlyOwner {
require(_minGas > 0, "LzApp: invalid minGas");
minDstGasLookup[_dstChainId][_packetType] = _minGas;
emit SetMinDstGas(_dstChainId, _packetType, _minGas);
}
// if the size is 0, it means default size limit
function setPayloadSizeLimit(uint16 _dstChainId, uint256 _size) external onlyOwner {
payloadSizeLimitLookup[_dstChainId] = _size;
}
/**
* @notice Initializes LayerZero endpoint
* @param _lzEndpoint The address of the LayerZero endpoint
* @dev RESTRICTION: Admin only
*/
function initializeLZEndpoint(ILayerZeroEndpoint _lzEndpoint) external onlyOwner {
require(address(_lzEndpoint) != address(0), ErrorCodes.ZERO_ADDRESS);
require(address(lzEndpoint) == address(0), ErrorCodes.SECOND_INITIALIZATION);
emit LayerZeroEndpointSet(lzEndpoint, _lzEndpoint);
lzEndpoint = _lzEndpoint;
}
//--------------------------- VIEW FUNCTION ----------------------------------------
function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) {
bytes memory trustedSource = trustedRemoteLookup[_srcChainId];
return keccak256(trustedSource) == keccak256(_srcAddress);
}
modifier onlyOwner() virtual {
require(false, "UNAUTHORIZED");
_;
}
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
contracts/layerZero/lzApp/NonblockingLzApp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "./LzApp.sol";
import "@layerzerolabs/solidity-examples/contracts/util/ExcessivelySafeCall.sol";
/*
* the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel
* this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking
* NOTE: if the srcAddress is not configured properly, it will still block the message pathway
* from (srcChainId, srcAddress)
*/
abstract contract NonblockingLzApp is LzApp {
using ExcessivelySafeCall for address;
mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages;
event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason);
event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash);
// overriding the virtual function in LzReceiver
function _blockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64 _nonce,
bytes memory _payload
) internal virtual override {
(bool success, bytes memory reason) = address(this).excessivelySafeCall(
gasleft(),
150,
abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload)
);
// try-catch all errors/exceptions
if (!success) {
_storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason);
}
}
function _storeFailedMessage(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64 _nonce,
bytes memory _payload,
bytes memory _reason
) internal virtual {
failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload);
emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason);
}
function nonblockingLzReceive(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) public virtual {
// only internal transaction
require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp");
_nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
//@notice override this function
function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64 _nonce,
bytes memory _payload
) internal virtual;
function retryMessage(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) public payable virtual {
// assert there is message to retry
bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce];
require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message");
require(keccak256(_payload) == payloadHash, "NonblockingLzApp: invalid payload");
// clear the stored message
failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0);
// execute the message. revert if it fails again
_nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash);
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
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;
}
}
contracts/interfaces/IBDSystem.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
interface IBDSystem is IAccessControl, ILinkageLeaf {
event AgreementAdded(
address indexed liquidityProvider,
address indexed representative,
uint256 representativeBonus,
uint256 liquidityProviderBoost,
uint32 startBlock,
uint32 endBlock
);
event AgreementEnded(
address indexed liquidityProvider,
address indexed representative,
uint256 representativeBonus,
uint256 liquidityProviderBoost,
uint32 endBlock
);
/**
* @notice getter function to get liquidity provider agreement
*/
function providerToAgreement(address)
external
view
returns (
uint256 liquidityProviderBoost,
uint256 representativeBonus,
uint32 endBlock,
address representative
);
/**
* @notice getter function to get counts
* of liquidity providers of the representative
*/
function representativesProviderCounter(address) external view returns (uint256);
/**
* @notice Creates a new agreement between liquidity provider and representative
* @dev Admin function to create a new agreement
* @param liquidityProvider_ address of the liquidity provider
* @param representative_ address of the liquidity provider representative.
* @param representativeBonus_ percentage of the emission boost for representative
* @param liquidityProviderBoost_ percentage of the boost for liquidity provider
* @param endBlock_ The number of the first block when agreement will not be in effect
* @dev RESTRICTION: Admin only
*/
function createAgreement(
address liquidityProvider_,
address representative_,
uint256 representativeBonus_,
uint256 liquidityProviderBoost_,
uint32 endBlock_
) external;
/**
* @notice Removes a agreement between liquidity provider and representative
* @dev Admin function to remove a agreement
* @param liquidityProvider_ address of the liquidity provider
* @param representative_ address of the representative.
* @dev RESTRICTION: Admin only
*/
function removeAgreement(address liquidityProvider_, address representative_) external;
/**
* @notice checks if `account_` is liquidity provider.
* @dev account_ is liquidity provider if he has agreement.
* @param account_ address to check
* @return `true` if `account_` is liquidity provider, otherwise returns false
*/
function isAccountLiquidityProvider(address account_) external view returns (bool);
/**
* @notice checks if `account_` is business development representative.
* @dev account_ is business development representative if he has liquidity providers.
* @param account_ address to check
* @return `true` if `account_` is business development representative, otherwise returns false
*/
function isAccountRepresentative(address account_) external view returns (bool);
/**
* @notice checks if agreement is expired
* @dev reverts if the `account_` is not a valid liquidity provider
* @param account_ address of the liquidity provider
* @return `true` if agreement is expired, otherwise returns false
*/
function isAgreementExpired(address account_) external view returns (bool);
}
contracts/interfaces/ISupervisor.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IMToken.sol";
import "./IBuyback.sol";
import "./IRewardsHub.sol";
import "./ILinkageLeaf.sol";
import "./IWhitelist.sol";
/**
* @title Minterest Supervisor Contract
* @author Minterest
*/
interface ISupervisor is IAccessControl, ILinkageLeaf {
/**
* @notice Emitted when an admin supports a market
*/
event MarketListed(IMToken mToken);
/**
* @notice Emitted when an account enable a market
*/
event MarketEnabledAsCollateral(IMToken mToken, address account);
/**
* @notice Emitted when an account disable a market
*/
event MarketDisabledAsCollateral(IMToken mToken, address account);
/**
* @notice Emitted when a utilisation factor is changed by admin
*/
event NewUtilisationFactor(
IMToken mToken,
uint256 oldUtilisationFactorMantissa,
uint256 newUtilisationFactorMantissa
);
/**
* @notice Emitted when liquidation fee is changed by admin
*/
event NewLiquidationFee(IMToken marketAddress, uint256 oldLiquidationFee, uint256 newLiquidationFee);
/**
* @notice Emitted when borrow cap for a mToken is changed
*/
event NewBorrowCap(IMToken indexed mToken, uint256 newBorrowCap);
/**
* @notice Per-account mapping of "assets you are in"
*/
function accountAssets(address, uint256) external view returns (IMToken);
/**
* @notice Collection of states of supported markets
* @dev Types containing (nested) mappings could not be parameters or return of external methods
*/
function markets(IMToken)
external
view
returns (
bool isListed,
uint256 utilisationFactorMantissa,
uint256 liquidationFeeMantissa
);
/**
* @notice get A list of all markets
*/
function allMarkets(uint256) external view returns (IMToken);
/**
* @notice get Borrow caps enforced by beforeBorrow for each mToken address.
*/
function borrowCaps(IMToken) external view returns (uint256);
/**
* @notice get keccak-256 hash of gatekeeper role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice get keccak-256 hash of timelock
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Returns the assets an account has enabled as collateral
* @param account The address of the account to pull assets for
* @return A dynamic list with the assets the account has enabled as collateral
*/
function getAccountAssets(address account) external view returns (IMToken[] memory);
/**
* @notice Returns whether the given account is enabled as collateral in the given asset
* @param account The address of the account to check
* @param mToken The mToken to check
* @return True if the account is in the asset, otherwise false.
*/
function checkMembership(address account, IMToken mToken) external view returns (bool);
/**
* @notice Add assets to be included in account liquidity calculation
* @param mTokens The list of addresses of the mToken markets to be enabled as collateral
*/
function enableAsCollateral(IMToken[] memory mTokens) external;
/**
* @notice Removes asset from sender's account liquidity calculation
* @dev Sender must not have an outstanding borrow balance in the asset,
* or be providing necessary collateral for an outstanding borrow.
* @param mTokenAddress The address of the asset to be removed
*/
function disableAsCollateral(IMToken mTokenAddress) external;
/**
* @notice Makes checks if the account should be allowed to lend tokens in the given market
* @param mToken The market to verify the lend against
* @param lender The account which would get the lent tokens
*/
function beforeLend(IMToken mToken, address lender) external;
/**
* @notice Checks if the account should be allowed to redeem tokens in the given market and triggers emission system
* @param mToken The market to verify the redeem against
* @param redeemer The account which would redeem the tokens
* @param redeemTokens The number of mTokens to exchange for the underlying asset in the market
* @param isAmlProcess Do we need to check the AML system or not
*/
function beforeRedeem(
IMToken mToken,
address redeemer,
uint256 redeemTokens,
bool isAmlProcess
) external;
/**
* @notice Checks if the account should be allowed to borrow the underlying asset of the given market
* @param mToken The market to verify the borrow against
* @param borrower The account which would borrow the asset
* @param borrowAmount The amount of underlying the account would borrow
*/
function beforeBorrow(
IMToken mToken,
address borrower,
uint256 borrowAmount
) external;
/**
* @notice Checks if the account should be allowed to repay a borrow in the given market
* @param mToken The market to verify the repay against
* @param borrower The account which would borrowed the asset
*/
function beforeRepayBorrow(IMToken mToken, address borrower) external;
/**
* @notice Checks if the seizing of assets should be allowed to occur (auto liquidation process)
* @param mToken Asset which was used as collateral and will be seized
* @param liquidator_ The address of liquidator contract
* @param borrower The address of the borrower
*/
function beforeAutoLiquidationSeize(
IMToken mToken,
address liquidator_,
address borrower
) external;
/**
* @notice Checks if the sender should be allowed to repay borrow in the given market (auto liquidation process)
* @param liquidator_ The address of liquidator contract
* @param borrower_ The account which borrowed the asset
* @param mToken_ The market to verify the repay against
*/
function beforeAutoLiquidationRepay(
address liquidator_,
address borrower_,
IMToken mToken_
) external;
/**
* @notice Checks if the address is the Liquidation contract
* @dev Used in liquidation process
* @param liquidator_ Prospective address of the Liquidation contract
*/
function isLiquidator(address liquidator_) external view;
/**
* @notice Checks if the account should be allowed to transfer tokens in the given market
* @param mToken The market to verify the transfer against
* @param src The account which sources the tokens
* @param dst The account which receives the tokens
* @param transferTokens The number of mTokens to transfer
*/
function beforeTransfer(
IMToken mToken,
address src,
address dst,
uint256 transferTokens
) external;
/**
* @notice Makes checks before flash loan in MToken
* @param mToken The address of the token
* receiver - The address of the loan receiver
* amount - How much tokens to flash loan
* fee - Flash loan fee
*/
function beforeFlashLoan(
IMToken mToken,
address, /* receiver */
uint256, /* amount */
uint256 /* fee */
) external view;
/**
* @notice Calculate account liquidity in USD related to utilisation factors of underlying assets
* @return (USD value above total utilisation requirements of all assets,
* USD value below total utilisation requirements of all assets)
*/
function getAccountLiquidity(address account) external view returns (uint256, uint256);
/**
* @notice Determine what the account liquidity would be if the given amounts were redeemed/borrowed
* @param mTokenModify The market to hypothetically redeem/borrow in
* @param account The account to determine liquidity for
* @param redeemTokens The number of tokens to hypothetically redeem
* @param borrowAmount The amount of underlying to hypothetically borrow
* @return (hypothetical account liquidity in excess of collateral requirements,
* hypothetical account shortfall below collateral requirements)
*/
function getHypotheticalAccountLiquidity(
address account,
IMToken mTokenModify,
uint256 redeemTokens,
uint256 borrowAmount
) external returns (uint256, uint256);
/**
* @notice Get liquidationFeeMantissa and utilisationFactorMantissa for market
* @param market Market for which values are obtained
* @return (liquidationFeeMantissa, utilisationFactorMantissa)
*/
function getMarketData(IMToken market) external view returns (uint256, uint256);
/**
* @notice Validates redeem and reverts on rejection. May emit logs.
* @param redeemAmount The amount of the underlying asset being redeemed
* @param redeemTokens The number of tokens being redeemed
*/
function redeemVerify(uint256 redeemAmount, uint256 redeemTokens) external view;
/**
* @notice Sets the utilisationFactor for a market
* @dev Governance function to set per-market utilisationFactor
* @param mToken The market to set the factor on
* @param newUtilisationFactorMantissa The new utilisation factor, scaled by 1e18
* @dev RESTRICTION: Timelock only.
*/
function setUtilisationFactor(IMToken mToken, uint256 newUtilisationFactorMantissa) external;
/**
* @notice Sets the liquidationFee for a market
* @dev Governance function to set per-market liquidationFee
* @param mToken The market to set the fee on
* @param newLiquidationFeeMantissa The new liquidation fee, scaled by 1e18
* @dev RESTRICTION: Timelock only.
*/
function setLiquidationFee(IMToken mToken, uint256 newLiquidationFeeMantissa) external;
/**
* @notice Add the market to the markets mapping and set it as listed, also initialize MNT market state.
* @dev Admin function to set isListed and add support for the market
* @param mToken The address of the market (token) to list
* @dev RESTRICTION: Admin only.
*/
function supportMarket(IMToken mToken) external;
/**
* @notice Set the given borrow caps for the given mToken markets.
* Borrowing that brings total borrows to or above borrow cap will revert.
* @dev Admin or gateKeeper function to set the borrow caps.
* A borrow cap of 0 corresponds to unlimited borrowing.
* @param mTokens The addresses of the markets (tokens) to change the borrow caps for
* @param newBorrowCaps The new borrow cap values in underlying to be set.
* A value of 0 corresponds to unlimited borrowing.
* @dev RESTRICTION: Gatekeeper only.
*/
function setMarketBorrowCaps(IMToken[] calldata mTokens, uint256[] calldata newBorrowCaps) external;
/**
* @notice Return all of the markets
* @dev The automatic getter may be used to access an individual market.
* @return The list of market addresses
*/
function getAllMarkets() external view returns (IMToken[] memory);
/**
* @notice Returns true if market is listed in Supervisor
*/
function isMarketListed(IMToken) external view returns (bool);
/**
* @notice Check that account is not in the black list and protocol operations are available.
* @param account The address of the account to check
*/
function isNotBlacklisted(address account) external view returns (bool);
/**
* @notice Check if transfer of MNT is allowed for accounts.
* @param from The source account address to check
* @param to The destination account address to check
*/
function isMntTransferAllowed(address from, address to) external view returns (bool);
/**
* @notice Returns block number
*/
function getBlockNumber() external view returns (uint256);
}
contracts/interfaces/ILinkageRoot.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
interface ILinkageRoot {
/**
* @notice Emitted when new root contract connected to all leafs
*/
event LinkageRootSwitch(ILinkageRoot newRoot);
/**
* @notice Emitted when root interconnects its contracts
*/
event LinkageRootInterconnected();
/**
* @notice Connects new root to all leafs contracts
* @param newRoot New root contract address
*/
function switchLinkageRoot(ILinkageRoot newRoot) external;
/**
* @notice Update root for all leaf contracts
* @dev Should include only leaf contracts
*/
function interconnect() external;
}
contracts/libraries/ProtocolLinkage.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "../interfaces/ILinkageLeaf.sol";
import "../interfaces/ILinkageRoot.sol";
import "./ErrorCodes.sol";
abstract contract LinkageRoot is ILinkageRoot {
/// @notice Store self address to prevent context changing while delegateCall
ILinkageRoot internal immutable _self = this;
/// @notice Owner address
address public immutable _linkage_owner;
constructor(address owner_) {
require(owner_ != address(0), ErrorCodes.ADMIN_ADDRESS_CANNOT_BE_ZERO);
_linkage_owner = owner_;
}
/// @inheritdoc ILinkageRoot
function switchLinkageRoot(ILinkageRoot newRoot) external {
require(msg.sender == _linkage_owner, ErrorCodes.UNAUTHORIZED);
emit LinkageRootSwitch(newRoot);
Address.functionDelegateCall(
address(newRoot),
abi.encodePacked(LinkageRoot.interconnect.selector),
"LinkageRoot: low-level delegate call failed"
);
}
/// @inheritdoc ILinkageRoot
function interconnect() external {
emit LinkageRootInterconnected();
interconnectInternal();
}
function interconnectInternal() internal virtual;
}
abstract contract LinkageLeaf is ILinkageLeaf {
/// @inheritdoc ILinkageLeaf
function switchLinkageRoot(ILinkageRoot newRoot) public {
require(address(newRoot) != address(0), ErrorCodes.LL_NEW_ROOT_CANNOT_BE_ZERO);
StorageSlot.AddressSlot storage slot = getRootSlot();
address oldRoot = slot.value;
if (oldRoot == address(newRoot)) return;
require(oldRoot == address(0) || oldRoot == msg.sender, ErrorCodes.UNAUTHORIZED);
slot.value = address(newRoot);
emit LinkageRootSwitched(newRoot, LinkageRoot(oldRoot));
}
/**
* @dev Gets current root contract address
*/
function getLinkageRootAddress() internal view returns (address) {
return getRootSlot().value;
}
/**
* @dev Gets current root contract storage slot
*/
function getRootSlot() private pure returns (StorageSlot.AddressSlot storage) {
// keccak256("minterest.slot.linkageRoot")
return StorageSlot.getAddressSlot(0xc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf);
}
}
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
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:
*
* ```solidity
* 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}:
*
* ```solidity
* 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. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
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);
_;
}
/**
* @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 virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @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 virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" 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 virtual 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.
*
* May emit a {RoleGranted} event.
*/
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.
*
* May emit a {RoleRevoked} event.
*/
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 revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
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.
*
* May emit a {RoleGranted} event.
*
* [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}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
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);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
contracts/interfaces/IMnt.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "./ILinkageLeaf.sol";
interface IMnt is IERC20Upgradeable, IERC165, IAccessControlUpgradeable, ILinkageLeaf {
event MaxNonVotingPeriodChanged(uint256 oldPeriod, uint256 newPeriod);
event NewGovernor(address governor);
event VotesUpdated(address account, uint256 oldVotingWeight, uint256 newVotingWeight);
event TotalVotesUpdated(uint256 oldTotalVotes, uint256 newTotalVotes);
/**
* @notice get governor
*/
function governor() external view returns (address);
/**
* @notice returns votingWeight for user
*/
function votingWeight(address) external view returns (uint256);
/**
* @notice get total voting weight
*/
function totalVotingWeight() external view returns (uint256);
/**
* @notice Updates voting power of the account
*/
function updateVotingWeight(address account) external;
/**
* @notice Creates new total voting weight checkpoint
* @dev RESTRICTION: Governor only.
*/
function updateTotalWeightCheckpoint() external;
/**
* @notice Checks user activity for the last `maxNonVotingPeriod` blocks
* @param account_ The address of the account
* @return returns true if the user voted or his delegatee voted for the last maxNonVotingPeriod blocks,
* otherwise returns false
*/
function isParticipantActive(address account_) external view returns (bool);
/**
* @notice Updates last voting timestamp of the account
* @dev RESTRICTION: Governor only.
*/
function updateVoteTimestamp(address account) external;
/**
* @notice Gets the latest voting timestamp for account.
* @dev If the user delegated his votes, then it also checks the timestamp of the last vote of the delegatee
* @param account The address of the account
* @return latest voting timestamp for account
*/
function lastActivityTimestamp(address account) external view returns (uint256);
/**
* @notice set new governor
* @dev RESTRICTION: Admin only.
*/
function setGovernor(address newGovernor) external;
/**
* @notice Sets the maxNonVotingPeriod
* @dev Admin function to set maxNonVotingPeriod
* @param newPeriod_ The new maxNonVotingPeriod (in sec). Must be greater than 90 days and lower than 2 years.
* @dev RESTRICTION: Admin only.
*/
function setMaxNonVotingPeriod(uint256 newPeriod_) external;
}
@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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;
}
@openzeppelin/contracts/token/ERC1155/ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual override returns (uint256[] memory) {
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(address from, uint256 id, uint256 amount) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
contracts/interfaces/ILinkageLeaf.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./ILinkageRoot.sol";
interface ILinkageLeaf {
/**
* @notice Emitted when root contract address is changed
*/
event LinkageRootSwitched(ILinkageRoot newRoot, ILinkageRoot oldRoot);
/**
* @notice Connects new root contract address
* @param newRoot New root contract address
*/
function switchLinkageRoot(ILinkageRoot newRoot) external;
}
contracts/InterconnectorLeaf.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./libraries/ProtocolLinkage.sol";
import "./interfaces/IInterconnectorLeaf.sol";
abstract contract InterconnectorLeaf is IInterconnectorLeaf, LinkageLeaf {
function getInterconnector() public view returns (IInterconnector) {
return IInterconnector(getLinkageRootAddress());
}
}
@openzeppelin/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
@layerzerolabs/solidity-examples/contracts/util/BytesLib.sol
// SPDX-License-Identifier: Unlicense
/*
* @title Solidity Bytes Arrays Utils
* @author Gonçalo Sá <goncalo.sa@consensys.net>
*
* @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
* The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
*/
pragma solidity >=0.8.0 <0.9.0;
library BytesLib {
function concat(
bytes memory _preBytes,
bytes memory _postBytes
)
internal
pure
returns (bytes memory)
{
bytes memory tempBytes;
assembly {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// Store the length of the first bytes array at the beginning of
// the memory for tempBytes.
let length := mload(_preBytes)
mstore(tempBytes, length)
// Maintain a memory counter for the current write location in the
// temp bytes array by adding the 32 bytes for the array length to
// the starting location.
let mc := add(tempBytes, 0x20)
// Stop copying when the memory counter reaches the length of the
// first bytes array.
let end := add(mc, length)
for {
// Initialize a copy counter to the start of the _preBytes data,
// 32 bytes into its memory.
let cc := add(_preBytes, 0x20)
} lt(mc, end) {
// Increase both counters by 32 bytes each iteration.
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// Write the _preBytes data into the tempBytes memory 32 bytes
// at a time.
mstore(mc, mload(cc))
}
// Add the length of _postBytes to the current length of tempBytes
// and store it as the new length in the first 32 bytes of the
// tempBytes memory.
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
// Move the memory counter back from a multiple of 0x20 to the
// actual end of the _preBytes data.
mc := end
// Stop copying when the memory counter reaches the new combined
// length of the arrays.
end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
// Update the free-memory pointer by padding our last write location
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
// next 32 byte block, then round down to the nearest multiple of
// 32. If the sum of the length of the two arrays is zero then add
// one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(0x40, and(
add(add(end, iszero(add(length, mload(_preBytes)))), 31),
not(31) // Round down to the nearest 32 bytes.
))
}
return tempBytes;
}
function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
assembly {
// Read the first 32 bytes of _preBytes storage, which is the length
// of the array. (We don't need to use the offset into the slot
// because arrays use the entire slot.)
let fslot := sload(_preBytes.slot)
// Arrays of 31 bytes or less have an even value in their slot,
// while longer arrays have an odd value. The actual length is
// the slot divided by two for odd values, and the lowest order
// byte divided by two for even values.
// If the slot is even, bitwise and the slot with 255 and divide by
// two to get the length. If the slot is odd, bitwise and the slot
// with -1 and divide by two.
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
let newlength := add(slength, mlength)
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
sstore(
_preBytes.slot,
// all the modifications to the slot are inside this
// next block
add(
// we can just add to the slot contents because the
// bytes we want to change are the LSBs
fslot,
add(
mul(
div(
// load the bytes from memory
mload(add(_postBytes, 0x20)),
// zero all bytes to the right
exp(0x100, sub(32, mlength))
),
// and now shift left the number of bytes to
// leave space for the length in the slot
exp(0x100, sub(32, newlength))
),
// increase length by the double of the memory
// bytes length
mul(mlength, 2)
)
)
)
}
case 1 {
// The stored value fits in the slot, but the combined value
// will exceed it.
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// The contents of the _postBytes array start 32 bytes into
// the structure. Our first read should obtain the `submod`
// bytes that can fit into the unused space in the last word
// of the stored array. To get this, we read 32 bytes starting
// from `submod`, so the data we read overlaps with the array
// contents by `submod` bytes. Masking the lowest-order
// `submod` bytes allows us to add that value directly to the
// stored value.
let submod := sub(32, slength)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(
sc,
add(
and(
fslot,
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
),
and(mload(mc), mask)
)
)
for {
mc := add(mc, 0x20)
sc := add(sc, 1)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
default {
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
// Start copying to the last used word of the stored array.
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// Copy over the first `submod` bytes of the new data as in
// case 1 above.
let slengthmod := mod(slength, 32)
let mlengthmod := mod(mlength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
sc := add(sc, 1)
mc := add(mc, 0x20)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
}
}
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
)
internal
pure
returns (bytes memory)
{
require(_length + 31 >= _length, "slice_overflow");
require(_bytes.length >= _start + _length, "slice_outOfBounds");
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
uint16 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x2), _start))
}
return tempUint;
}
function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
uint32 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x4), _start))
}
return tempUint;
}
function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
uint64 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x8), _start))
}
return tempUint;
}
function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
uint96 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0xc), _start))
}
return tempUint;
}
function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
uint128 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x10), _start))
}
return tempUint;
}
function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
bool success = true;
assembly {
let length := mload(_preBytes)
// if lengths don't match the arrays are not equal
switch eq(length, mload(_postBytes))
case 1 {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
let mc := add(_preBytes, 0x20)
let end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
} eq(add(lt(mc, end), cb), 2) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function equalStorage(
bytes storage _preBytes,
bytes memory _postBytes
)
internal
view
returns (bool)
{
bool success = true;
assembly {
// we know _preBytes_offset is 0
let fslot := sload(_preBytes.slot)
// Decode the length of the stored array like in concatStorage().
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
// if lengths don't match the arrays are not equal
switch eq(slength, mlength)
case 1 {
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
// blank the last byte which is the length
fslot := mul(div(fslot, 0x100), 0x100)
if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
// unsuccess:
success := 0
}
}
default {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := keccak256(0x0, 0x20)
let mc := add(_postBytes, 0x20)
let end := add(mc, mlength)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
for {} eq(add(lt(mc, end), cb), 2) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
if iszero(eq(sload(sc), mload(mc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
}
contracts/interfaces/IRewardsHubLight.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IMToken.sol";
import "./ILinkageLeaf.sol";
interface IRewardsHubLight is ILinkageLeaf {
event DistributedSupplierMnt(IMToken mToken, address supplier, uint256 mntDelta, uint256 mntSupplyIndex);
event DistributedBorrowerMnt(IMToken mToken, address borrower, uint256 mntDelta, uint256 mntBorrowIndex);
event EmissionRewardAccrued(address account, uint256 amount);
event RepresentativeRewardAccrued(address account, address provider, uint256 amount);
event BuybackRewardAccrued(address account, uint256 amount);
event Withdraw(address account, uint256 amount);
event MntGranted(address recipient, uint256 amount);
event MntSupplyEmissionRateUpdated(IMToken mToken, uint256 newSupplyEmissionRate);
event MntBorrowEmissionRateUpdated(IMToken mToken, uint256 newBorrowEmissionRate);
/**
* @notice get keccak-256 hash of gatekeeper
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice get keccak-256 hash of timelock
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Gets the rate at which MNT is distributed to the corresponding supply market (per block)
*/
function mntSupplyEmissionRate(IMToken) external view returns (uint256);
/**
* @notice Gets the rate at which MNT is distributed to the corresponding borrow market (per block)
*/
function mntBorrowEmissionRate(IMToken) external view returns (uint256);
/**
* @notice Gets the MNT market supply state for each market
*/
function mntSupplyState(IMToken) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT market borrow state for each market
*/
function mntBorrowState(IMToken) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT supply index and block number for each market
*/
function mntSupplierState(IMToken, address) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets the MNT borrow index and block number for each market
*/
function mntBorrowerState(IMToken, address) external view returns (uint224 index, uint32 blockN);
/**
* @notice Gets amount of available balance of an account.
*/
function totalBalanceOf(address account) external view returns (uint256);
/**
* @notice Gets amount of MNT that can be withdrawn from an account at this block.
*/
function availableBalanceOf(address account) external view returns (uint256);
/**
* @notice Initializes market in RewardsHub. Should be called once from Supervisor.supportMarket
* @dev RESTRICTION: Supervisor only
*/
function initMarket(IMToken mToken) external;
/**
* @notice Accrues MNT to the market by updating the borrow and supply indexes
* @dev This method doesn't update MNT index history in Minterest NFT.
* @param market The market whose supply and borrow index to update
* @return (MNT supply index, MNT borrow index)
*/
function updateAndGetMntIndexes(IMToken market) external returns (uint224, uint224);
/**
* @notice Shorthand function to distribute MNT emissions from supplies of one market.
*/
function distributeSupplierMnt(IMToken mToken, address account) external;
/**
* @notice Shorthand function to distribute MNT emissions from borrows of one market.
*/
function distributeBorrowerMnt(IMToken mToken, address account) external;
/**
* @notice Updates market indexes and distributes tokens (if any) for holder
* @dev Updates indexes and distributes only for those markets where the holder have a
* non-zero supply or borrow balance.
* @param account The address to distribute MNT for
*/
function distributeAllMnt(address account) external;
/**
* @notice Distribute all MNT accrued by the accounts
* @param accounts The addresses to distribute MNT for
* @param mTokens The list of markets to distribute MNT in
* @param borrowers Whether or not to distribute MNT earned by borrowing
* @param suppliers Whether or not to distribute MNT earned by supplying
*/
function distributeMnt(
address[] memory accounts,
IMToken[] memory mTokens,
bool borrowers,
bool suppliers
) external;
/**
* @notice Accrues buyback reward
* @dev RESTRICTION: Buyback only
*/
function accrueBuybackReward(address account, uint256 amount) external;
/**
* @notice Transfers available part of MNT rewards to the sender.
* This will decrease accounts buyback and voting weights.
*/
function withdraw(uint256 amount) external;
/**
* @notice Transfers
* @dev RESTRICTION: Admin only
*/
function grant(address recipient, uint256 amount) external;
/**
* @notice Set MNT borrow and supply emission rates for a single market
* @param mToken The market whose MNT emission rate to update
* @param newMntSupplyEmissionRate New supply MNT emission rate for market
* @param newMntBorrowEmissionRate New borrow MNT emission rate for market
* @dev RESTRICTION Timelock only
*/
function setMntEmissionRates(
IMToken mToken,
uint256 newMntSupplyEmissionRate,
uint256 newMntBorrowEmissionRate
) external;
}
contracts/interfaces/IMinterestNFT.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
/**
* @title MinterestNFT
* @dev Contract module which provides functionality to mint new ERC1155 tokens
* Each token connected with image and metadata. The image and metadata saved
* on IPFS and this contract stores the CID of the folder where lying metadata.
* Also each token belongs one of the Minterest tiers, and give some emission
* boost for Minterest distribution system.
*/
interface IMinterestNFT is IAccessControl, IERC1155, ILinkageLeaf {
/**
* @notice Emitted when new base URI was installed
*/
event NewBaseUri(string newBaseUri);
/**
* @notice get name for Minterst NFT Token
*/
function name() external view returns (string memory);
/**
* @notice get symbool for Minterst NFT Token
*/
function symbol() external view returns (string memory);
/**
* @notice get keccak-256 hash of GATEKEEPER role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice Mint new 1155 standard token
* @param account_ The address of the owner of minterestNFT
* @param amount_ Instance count for minterestNFT
* @param data_ The _data argument MAY be re-purposed for the new context.
* @param tier_ tier
*/
function mint(
address account_,
uint256 amount_,
bytes memory data_,
uint256 tier_
) external;
/**
* @notice Mint new ERC1155 standard tokens in one transaction
* @param account_ The address of the owner of tokens
* @param amounts_ Array of instance counts for tokens
* @param data_ The _data argument MAY be re-purposed for the new context.
* @param tiers_ Array of tiers
* @dev RESTRICTION: Gatekeeper only
*/
function mintBatch(
address account_,
uint256[] memory amounts_,
bytes memory data_,
uint256[] memory tiers_
) external;
/**
* @notice Transfer token to another account
* @param to_ The address of the token receiver
* @param id_ token id
* @param amount_ Count of tokens
* @param data_ The _data argument MAY be re-purposed for the new context.
*/
function safeTransfer(
address to_,
uint256 id_,
uint256 amount_,
bytes memory data_
) external;
/**
* @notice Transfer tokens to another account
* @param to_ The address of the tokens receiver
* @param ids_ Array of token ids
* @param amounts_ Array of tokens count
* @param data_ The _data argument MAY be re-purposed for the new context.
*/
function safeBatchTransfer(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory data_
) external;
/**
* @notice Set new base URI
* @param newBaseUri Base URI
* @dev RESTRICTION: Admin only
*/
function setURI(string memory newBaseUri) external;
/**
* @notice Override function to return image URL, opensea requirement
* @param tokenId_ Id of token to get URL
* @return IPFS URI for token id, opensea requirement
*/
function uri(uint256 tokenId_) external view returns (string memory);
/**
* @dev Returns the next token ID to be minted
* @return the next token ID to be minted
*/
function nextIdToBeMinted() external view returns (uint256);
}
@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol)
pragma solidity ^0.8.0;
import "./IERC3156FlashBorrower.sol";
/**
* @dev Interface of the ERC3156 FlashLender, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashLender {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
contracts/interfaces/IMToken.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IInterestRateModel.sol";
interface IMToken is IAccessControl, IERC20, IERC3156FlashLender, IERC165 {
/**
* @notice Event emitted when interest is accrued
*/
event AccrueInterest(
uint256 cashPrior,
uint256 interestAccumulated,
uint256 borrowIndex,
uint256 totalBorrows,
uint256 totalProtocolInterest
);
/**
* @notice Event emitted when tokens are lended
*/
event Lend(address lender, uint256 lendAmount, uint256 lendTokens, uint256 newTotalTokenSupply);
/**
* @notice Event emitted when tokens are redeemed
*/
event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens, uint256 newTotalTokenSupply);
/**
* @notice Event emitted when underlying is borrowed
*/
event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);
/**
* @notice Event emitted when tokens are seized
*/
event Seize(
address borrower,
address receiver,
uint256 seizeTokens,
uint256 accountsTokens,
uint256 totalSupply,
uint256 seizeUnderlyingAmount
);
/**
* @notice Event emitted when a borrow is repaid
*/
event RepayBorrow(
address payer,
address borrower,
uint256 repayAmount,
uint256 accountBorrows,
uint256 totalBorrows
);
/**
* @notice Event emitted when a borrow is repaid during autoliquidation
*/
event AutoLiquidationRepayBorrow(
address borrower,
uint256 repayAmount,
uint256 accountBorrowsNew,
uint256 totalBorrowsNew,
uint256 TotalProtocolInterestNew
);
/**
* @notice Event emitted when flash loan is executed
*/
event FlashLoanExecuted(address receiver, uint256 amount, uint256 fee);
/**
* @notice Event emitted when interestRateModel is changed
*/
event NewMarketInterestRateModel(IInterestRateModel oldInterestRateModel, IInterestRateModel newInterestRateModel);
/**
* @notice Event emitted when the protocol interest factor is changed
*/
event NewProtocolInterestFactor(
uint256 oldProtocolInterestFactorMantissa,
uint256 newProtocolInterestFactorMantissa
);
/**
* @notice Event emitted when the flash loan max share is changed
*/
event NewFlashLoanMaxShare(uint256 oldMaxShare, uint256 newMaxShare);
/**
* @notice Event emitted when the flash loan fee is changed
*/
event NewFlashLoanFee(uint256 oldFee, uint256 newFee);
/**
* @notice Event emitted when the protocol interest are added
*/
event ProtocolInterestAdded(address benefactor, uint256 addAmount, uint256 newTotalProtocolInterest);
/**
* @notice Event emitted when the protocol interest reduced
*/
event ProtocolInterestReduced(address admin, uint256 reduceAmount, uint256 newTotalProtocolInterest);
/**
* @notice Value is the Keccak-256 hash of "TIMELOCK"
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Underlying asset for this MToken
*/
function underlying() external view returns (IERC20);
/**
* @notice EIP-20 token name for this token
*/
function name() external view returns (string memory);
/**
* @notice EIP-20 token symbol for this token
*/
function symbol() external view returns (string memory);
/**
* @notice EIP-20 token decimals for this token
*/
function decimals() external view returns (uint8);
/**
* @notice Model which tells what the current interest rate should be
*/
function interestRateModel() external view returns (IInterestRateModel);
/**
* @notice Initial exchange rate used when lending the first MTokens (used when totalTokenSupply = 0)
*/
function initialExchangeRateMantissa() external view returns (uint256);
/**
* @notice Fraction of interest currently set aside for protocol interest
*/
function protocolInterestFactorMantissa() external view returns (uint256);
/**
* @notice Block number that interest was last accrued at
*/
function accrualBlockNumber() external view returns (uint256);
/**
* @notice Accumulator of the total earned interest rate since the opening of the market
*/
function borrowIndex() external view returns (uint256);
/**
* @notice Total amount of outstanding borrows of the underlying in this market
*/
function totalBorrows() external view returns (uint256);
/**
* @notice Total amount of protocol interest of the underlying held in this market
*/
function totalProtocolInterest() external view returns (uint256);
/**
* @notice Share of market's current underlying token balance that can be used as flash loan (scaled by 1e18).
*/
function maxFlashLoanShare() external view returns (uint256);
/**
* @notice Share of flash loan amount that would be taken as fee (scaled by 1e18).
*/
function flashLoanFeeShare() external view returns (uint256);
/**
* @notice Returns total token supply
*/
function totalSupply() external view returns (uint256);
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint256 amount) external returns (bool);
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(
address src,
address dst,
uint256 amount
) external returns (bool);
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint256);
/**
* @notice Get the underlying balance of the `owner`
* @dev This also accrues interest in a transaction
* @param owner The address of the account to query
* @return The amount of underlying owned by `owner`
*/
function balanceOfUnderlying(address owner) external returns (uint256);
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by supervisor to more efficiently perform liquidity checks.
* @param account Address of the account to snapshot
* @return (token balance, borrow balance, exchange rate mantissa)
*/
function getAccountSnapshot(address account)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @notice Returns the current per-block borrow interest rate for this mToken
* @return The borrow interest rate per block, scaled by 1e18
*/
function borrowRatePerBlock() external view returns (uint256);
/**
* @notice Returns the current per-block supply interest rate for this mToken
* @return The supply interest rate per block, scaled by 1e18
*/
function supplyRatePerBlock() external view returns (uint256);
/**
* @notice Returns the current total borrows plus accrued interest
* @return The total borrows with interest
*/
function totalBorrowsCurrent() external returns (uint256);
/**
* @notice Accrue interest to updated borrowIndex and then calculate account's
* borrow balance using the updated borrowIndex
* @param account The address whose balance should be calculated after updating borrowIndex
* @return The calculated balance
*/
function borrowBalanceCurrent(address account) external returns (uint256);
/**
* @notice Return the borrow balance of account based on stored data
* @param account The address whose balance should be calculated
* @return The calculated balance
*/
function borrowBalanceStored(address account) external view returns (uint256);
/**
* @notice Accrue interest then return the up-to-date exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateCurrent() external returns (uint256);
/**
* @notice Calculates the exchange rate from the underlying to the MToken
* @dev This function does not accrue interest before calculating the exchange rate
* @return Calculated exchange rate scaled by 1e18
*/
function exchangeRateStored() external view returns (uint256);
/**
* @notice Get cash balance of this mToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint256);
/**
* @notice Applies accrued interest to total borrows and protocol interest
* @dev This calculates interest accrued from the last checkpointed block
* up to the current block and writes new checkpoint to storage.
*/
function accrueInterest() external;
/**
* @notice Sender supplies assets into the market and receives mTokens in exchange
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param lendAmount The amount of the underlying asset to supply
*/
function lend(uint256 lendAmount) external;
/**
* @notice Sender redeems mTokens in exchange for the underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemTokens The number of mTokens to redeem into underlying
*/
function redeem(uint256 redeemTokens) external;
/**
* @notice Redeems all mTokens for account in exchange for the underlying asset.
* Can only be called within the AML system!
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param account An account that is potentially sanctioned by the AML system
*/
function redeemByAmlDecision(address account) external;
/**
* @notice Sender redeems mTokens in exchange for a specified amount of underlying asset
* @dev Accrues interest whether or not the operation succeeds, unless reverted
* @param redeemAmount The amount of underlying to receive from redeeming mTokens
*/
function redeemUnderlying(uint256 redeemAmount) external;
/**
* @notice Sender borrows assets from the protocol to their own address
* @param borrowAmount The amount of the underlying asset to borrow
*/
function borrow(uint256 borrowAmount) external;
/**
* @notice Sender repays their own borrow
* @param repayAmount The amount to repay
*/
function repayBorrow(uint256 repayAmount) external;
/**
* @notice Sender repays a borrow belonging to borrower
* @param borrower the account with the debt being payed off
* @param repayAmount The amount to repay
*/
function repayBorrowBehalf(address borrower, uint256 repayAmount) external;
/**
* @notice Liquidator repays a borrow belonging to borrower
* @param borrower_ the account with the debt being payed off
* @param repayAmount_ the amount of underlying tokens being returned
*/
function autoLiquidationRepayBorrow(address borrower_, uint256 repayAmount_) external;
/**
* @notice A public function to sweep accidental ERC-20 transfers to this contract.
* Tokens are sent to admin (timelock)
* @param token The address of the ERC-20 token to sweep
* @dev RESTRICTION: Admin only.
*/
function sweepToken(IERC20 token, address admin_) external;
/**
* @notice Burns collateral tokens at the borrower's address, transfer underlying assets
to the Liquidator address.
* @dev Called only during an auto liquidation process, msg.sender must be the Liquidation contract.
* @param borrower_ The account having collateral seized
* @param seizeUnderlyingAmount_ The number of underlying assets to seize. The caller must ensure
that the parameter is greater than zero.
* @param isLoanInsignificant_ Marker for insignificant loan whose collateral must be credited to the
protocolInterest
* @param receiver_ Address that receives accounts collateral
*/
function autoLiquidationSeize(
address borrower_,
uint256 seizeUnderlyingAmount_,
bool isLoanInsignificant_,
address receiver_
) external;
/**
* @notice The amount of currency available to be lent.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @notice The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @notice Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrower receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
/**
* @notice accrues interest and sets a new protocol interest factor for the protocol
* @dev Admin function to accrue interest and set a new protocol interest factor
* @dev RESTRICTION: Timelock only.
*/
function setProtocolInterestFactor(uint256 newProtocolInterestFactorMantissa) external;
/**
* @notice Accrues interest and increase protocol interest by transferring from msg.sender
* @param addAmount_ Amount of addition to protocol interest
*/
function addProtocolInterest(uint256 addAmount_) external;
/**
* @notice Can only be called by liquidation contract. Increase protocol interest by transferring from payer.
* @dev Calling code should make sure that accrueInterest() was called before.
* @param payer_ The address from which the protocol interest will be transferred
* @param addAmount_ Amount of addition to protocol interest
*/
function addProtocolInterestBehalf(address payer_, uint256 addAmount_) external;
/**
* @notice Accrues interest and reduces protocol interest by transferring to admin
* @param reduceAmount Amount of reduction to protocol interest
* @dev RESTRICTION: Admin only.
*/
function reduceProtocolInterest(uint256 reduceAmount, address admin_) external;
/**
* @notice accrues interest and updates the interest rate model using setInterestRateModelFresh
* @dev Admin function to accrue interest and update the interest rate model
* @param newInterestRateModel the new interest rate model to use
* @dev RESTRICTION: Timelock only.
*/
function setInterestRateModel(IInterestRateModel newInterestRateModel) external;
/**
* @notice Updates share of markets cash that can be used as maximum amount of flash loan.
* @param newMax New max amount share
* @dev RESTRICTION: Timelock only.
*/
function setFlashLoanMaxShare(uint256 newMax) external;
/**
* @notice Updates fee of flash loan.
* @param newFee New fee share of flash loan
* @dev RESTRICTION: Timelock only.
*/
function setFlashLoanFeeShare(uint256 newFee) external;
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
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);
}
@openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}
contracts/layerZero/interfaces/onft1155/IONFT1155Core.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Interface of the ONFT Core standard
*/
interface IONFT1155Core is IERC165 {
event SendToChain(
uint16 indexed _dstChainId,
address indexed _from,
bytes indexed _toAddress,
uint256 _tokenId,
uint256 _amount
);
event SendBatchToChain(
uint16 indexed _dstChainId,
address indexed _from,
bytes indexed _toAddress,
uint256[] _tokenIds,
uint256[] _amounts
);
event ReceiveFromChain(
uint16 indexed _srcChainId,
bytes indexed _srcAddress,
address indexed _toAddress,
uint256 _tokenId,
uint256 _amount
);
event ReceiveBatchFromChain(
uint16 indexed _srcChainId,
bytes indexed _srcAddress,
address indexed _toAddress,
uint256[] _tokenIds,
uint256[] _amounts
);
// _from - address where tokens should be deducted from on behalf of
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenId - token Id to transfer
// _amount - amount of the tokens to transfer
// _refundAddress - address on src that will receive refund for any overpayment of L0 fees
// _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro
// _adapterParams - flexible bytes array to indicate messaging adapter services in L0
function sendFrom(
address _from,
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _tokenId,
uint256 _amount,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
// _from - address where tokens should be deducted from on behalf of
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenIds - token Ids to transfer
// _amounts - amounts of the tokens to transfer
// _refundAddress - address on src that will receive refund for any overpayment of L0 fees
// _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro
// _adapterParams - flexible bytes array to indicate messaging adapter services in L0
function sendBatchFrom(
address _from,
uint16 _dstChainId,
bytes calldata _toAddress,
uint256[] calldata _tokenIds,
uint256[] calldata _amounts,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenId - token Id to transfer
// _amount - amount of the tokens to transfer
// _useZro - indicates to use zro to pay L0 fees
// _adapterParams - flexible bytes array to indicate messaging adapter services in L0
function estimateSendFee(
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _tokenId,
uint256 _amount,
bool _useZro,
bytes calldata _adapterParams
) external view returns (uint256 nativeFee, uint256 zroFee);
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenIds - tokens Id to transfer
// _amounts - amounts of the tokens to transfer
// _useZro - indicates to use zro to pay L0 fees
// _adapterParams - flexible bytes array to indicate messaging adapter services in L0
function estimateSendBatchFee(
uint16 _dstChainId,
bytes calldata _toAddress,
uint256[] calldata _tokenIds,
uint256[] calldata _amounts,
bool _useZro,
bytes calldata _adapterParams
) external view returns (uint256 nativeFee, uint256 zroFee);
}
@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC3156FlashBorrower.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC3156 FlashBorrower, as defined in
* https://eips.ethereum.org/EIPS/eip-3156[ERC-3156].
*
* _Available since v4.1._
*/
interface IERC3156FlashBorrower {
/**
* @dev Receive a flash loan.
* @param initiator The initiator of the loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param fee The additional amount of tokens to repay.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
* @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan"
*/
function onFlashLoan(
address initiator,
address token,
uint256 amount,
uint256 fee,
bytes calldata data
) external returns (bytes32);
}
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
contracts/interfaces/IInterestRateModel.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title Minterest InterestRateModel Interface
* @author Minterest
*/
interface IInterestRateModel {
/**
* @notice Calculates the current borrow interest rate per block
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param protocolInterest The total amount of protocol interest the market has
* @return The borrow rate per block (as a percentage, and scaled by 1e18)
*/
function getBorrowRate(
uint256 cash,
uint256 borrows,
uint256 protocolInterest
) external view returns (uint256);
/**
* @notice Calculates the current supply interest rate per block
* @param cash The total amount of cash the market has
* @param borrows The total amount of borrows the market has outstanding
* @param protocolInterest The total amount of protocol interest the market has
* @param protocolInterestFactorMantissa The current protocol interest factor the market has
* @return The supply rate per block (as a percentage, and scaled by 1e18)
*/
function getSupplyRate(
uint256 cash,
uint256 borrows,
uint256 protocolInterest,
uint256 protocolInterestFactorMantissa
) external view returns (uint256);
}
contracts/layerZero/onft1155/ONFT1155Core.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "../interfaces/onft1155/IONFT1155Core.sol";
import "../lzApp/NonblockingLzApp.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
abstract contract ONFT1155Core is NonblockingLzApp, ERC165, IONFT1155Core {
uint256 public constant NO_EXTRA_GAS = 0;
uint16 public constant FUNCTION_TYPE_SEND = 1;
uint16 public constant FUNCTION_TYPE_SEND_BATCH = 2;
bool public useCustomAdapterParams;
event SetUseCustomAdapterParams(bool _useCustomAdapterParams);
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IONFT1155Core).interfaceId || super.supportsInterface(interfaceId);
}
function estimateSendFee(
uint16 _dstChainId,
bytes memory _toAddress,
uint256 _tokenId,
uint256 _amount,
bool _useZro,
bytes memory _adapterParams
) public view virtual override returns (uint256 nativeFee, uint256 zroFee) {
return
estimateSendBatchFee(
_dstChainId,
_toAddress,
_toSingletonArray(_tokenId),
_toSingletonArray(_amount),
_useZro,
_adapterParams
);
}
function estimateSendBatchFee(
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
bool _useZro,
bytes memory _adapterParams
) public view virtual override returns (uint256 nativeFee, uint256 zroFee) {
bytes memory payload = abi.encode(_toAddress, _tokenIds, _amounts);
return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams);
}
function sendFrom(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256 _tokenId,
uint256 _amount,
address payable _refundAddress,
address _zroPaymentAddress,
bytes memory _adapterParams
) public payable virtual override {
_sendBatch(
_from,
_dstChainId,
_toAddress,
_toSingletonArray(_tokenId),
_toSingletonArray(_amount),
_refundAddress,
_zroPaymentAddress,
_adapterParams
);
}
function sendBatchFrom(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
address payable _refundAddress,
address _zroPaymentAddress,
bytes memory _adapterParams
) public payable virtual override {
_sendBatch(
_from,
_dstChainId,
_toAddress,
_tokenIds,
_amounts,
_refundAddress,
_zroPaymentAddress,
_adapterParams
);
}
function _sendBatch(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
address payable _refundAddress,
address _zroPaymentAddress,
bytes memory _adapterParams
) internal virtual {
_debitFrom(_from, _dstChainId, _toAddress, _tokenIds, _amounts);
bytes memory payload = abi.encode(_toAddress, _tokenIds, _amounts);
if (_tokenIds.length == 1) {
if (useCustomAdapterParams) {
_checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND, _adapterParams, NO_EXTRA_GAS);
} else {
require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty.");
}
emit SendToChain(_dstChainId, _from, _toAddress, _tokenIds[0], _amounts[0]);
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value);
} else if (_tokenIds.length > 1) {
if (useCustomAdapterParams) {
_checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND_BATCH, _adapterParams, NO_EXTRA_GAS);
} else {
require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty.");
}
emit SendBatchToChain(_dstChainId, _from, _toAddress, _tokenIds, _amounts);
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value);
}
}
function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64, /*_nonce*/
bytes memory _payload
) internal virtual override {
// decode and load the toAddress
(bytes memory toAddressBytes, uint256[] memory tokenIds, uint256[] memory amounts) = abi.decode(
_payload,
(bytes, uint256[], uint256[])
);
address toAddress;
assembly {
toAddress := mload(add(toAddressBytes, 20))
}
_creditTo(_srcChainId, toAddress, tokenIds, amounts);
if (tokenIds.length == 1) {
emit ReceiveFromChain(_srcChainId, _srcAddress, toAddress, tokenIds[0], amounts[0]);
} else if (tokenIds.length > 1) {
emit ReceiveBatchFromChain(_srcChainId, _srcAddress, toAddress, tokenIds, amounts);
}
}
function setUseCustomAdapterParams(bool _useCustomAdapterParams) external onlyOwner {
useCustomAdapterParams = _useCustomAdapterParams;
emit SetUseCustomAdapterParams(_useCustomAdapterParams);
}
function _debitFrom(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts
) internal virtual;
function _creditTo(
uint16 _srcChainId,
address _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts
) internal virtual;
function _toSingletonArray(uint256 element) internal pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
contracts/interfaces/IPriceOracle.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IMToken.sol";
interface IPriceOracle {
/**
* @notice Get the underlying price of a mToken asset
* @param mToken The mToken to get the underlying price of
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
*
* @dev Price should be scaled to 1e18 for tokens with tokenDecimals = 1e18
* and for 1e30 for tokens with tokenDecimals = 1e6.
*/
function getUnderlyingPrice(IMToken mToken) external view returns (uint256);
/**
* @notice Return price for an asset
* @param asset address of token
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
* @dev Price should be scaled to 1e18 for tokens with tokenDecimals = 1e18
* and for 1e30 for tokens with tokenDecimals = 1e6.
*/
function getAssetPrice(address asset) external view returns (uint256);
}
@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
contracts/interfaces/IEmissionBooster.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ISupervisor.sol";
import "./IRewardsHub.sol";
import "./IMToken.sol";
import "./ILinkageLeaf.sol";
interface IEmissionBooster is IAccessControl, ILinkageLeaf {
/**
* @notice Emitted when new Tier was created
*/
event NewTierCreated(uint256 createdTier, uint32 endBoostBlock, uint256 emissionBoost);
/**
* @notice Emitted when Tier was enabled
*/
event TierEnabled(
IMToken market,
uint256 enabledTier,
uint32 startBoostBlock,
uint224 mntSupplyIndex,
uint224 mntBorrowIndex
);
/**
* @notice Emitted when emission boost mode was enabled
*/
event EmissionBoostEnabled(address caller);
/**
* @notice Emitted when MNT supply index of the tier ending on the market was saved to storage
*/
event SupplyIndexUpdated(address market, uint256 nextTier, uint224 newIndex, uint32 endBlock);
/**
* @notice Emitted when MNT borrow index of the tier ending on the market was saved to storage
*/
event BorrowIndexUpdated(address market, uint256 nextTier, uint224 newIndex, uint32 endBlock);
/**
* @notice get the Tier for each MinterestNFT token
*/
function tokenTier(uint256) external view returns (uint256);
/**
* @notice get a list of all created Tiers
*/
function tiers(uint256)
external
view
returns (
uint32,
uint32,
uint256
);
/**
* @notice get status of emission boost mode.
*/
function isEmissionBoostingEnabled() external view returns (bool);
/**
* @notice get Stored markets indexes per block.
*/
function marketSupplyIndexes(IMToken, uint256) external view returns (uint256);
/**
* @notice get Stored markets indexes per block.
*/
function marketBorrowIndexes(IMToken, uint256) external view returns (uint256);
/**
* @notice Mint token hook which is called from MinterestNFT.mint() and sets specific
* settings for this NFT
* @param to_ NFT ovner
* @param ids_ NFTs IDs
* @param amounts_ Amounts of minted NFTs per tier
* @param tiers_ NFT tiers
* @dev RESTRICTION: MinterestNFT only
*/
function onMintToken(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
uint256[] memory tiers_
) external;
/**
* @notice Transfer token hook which is called from MinterestNFT.transfer() and sets specific
* settings for this NFT
* @param from_ Address of the tokens previous owner. Should not be zero (minter).
* @param to_ Address of the tokens new owner.
* @param ids_ NFTs IDs
* @param amounts_ Amounts of minted NFTs per tier
* @dev RESTRICTION: MinterestNFT only
*/
function onTransferToken(
address from_,
address to_,
uint256[] memory ids_,
uint256[] memory amounts_
) external;
/**
* @notice Enables emission boost mode.
* @dev Admin function for enabling emission boosts.
* @dev RESTRICTION: Whitelist only
*/
function enableEmissionBoosting() external;
/**
* @notice Creates new Tiers for MinterestNFT tokens
* @dev Admin function for creating Tiers
* @param endBoostBlocks Emission boost end blocks for created Tiers
* @param emissionBoosts Emission boosts for created Tiers, scaled by 1e18
* Note: The arrays passed to the function must be of the same length and the order of the elements must match
* each other
* @dev RESTRICTION: Admin only
*/
function createTiers(uint32[] memory endBoostBlocks, uint256[] memory emissionBoosts) external;
/**
* @notice Enables emission boost in specified Tiers
* @param tiersForEnabling Tier for enabling emission boost
* @dev RESTRICTION: Admin only
*/
function enableTiers(uint256[] memory tiersForEnabling) external;
/**
* @notice Return the number of created Tiers
* @return The number of created Tiers
*/
function getNumberOfTiers() external view returns (uint256);
/**
* @notice Checks if the specified Tier is active
* @param tier_ The Tier that is being checked
*/
function isTierActive(uint256 tier_) external view returns (bool);
/**
* @notice Checks if the specified Tier exists
* @param tier_ The Tier that is being checked
*/
function tierExists(uint256 tier_) external view returns (bool);
/**
* @param account_ The address of the account
* @return Bitmap of all accounts tiers
*/
function getAccountTiersBitmap(address account_) external view returns (uint256);
/**
* @param account_ The address of the account to check if they have any tokens with tier
*/
function isAccountHaveTiers(address account_) external view returns (bool);
/**
* @param account_ Address of the account
* @return tier Highest tier number
* @return boost Highest boost amount
*/
function getCurrentAccountBoost(address account_) external view returns (uint256 tier, uint256 boost);
/**
* @notice Calculates emission boost for the account.
* @param market_ Market for which we are calculating emission boost
* @param account_ The address of the account for which we are calculating emission boost
* @param userLastIndex_ The account's last updated mntBorrowIndex or mntSupplyIndex
* @param userLastBlock_ The block number in which the index for the account was last updated
* @param marketIndex_ The market's current mntBorrowIndex or mntSupplyIndex
* @param isSupply_ boolean value, if true, then return calculate emission boost for suppliers
* @return boostedIndex Boost part of delta index
*/
function calculateEmissionBoost(
IMToken market_,
address account_,
uint256 userLastIndex_,
uint256 userLastBlock_,
uint256 marketIndex_,
bool isSupply_
) external view returns (uint256 boostedIndex);
/**
* @notice Update MNT supply index for market for NFT tiers that are expired but not yet updated.
* @dev This function checks if there are tiers to update and process them one by one:
* calculates the MNT supply index depending on the delta index and delta blocks between
* last MNT supply index update and the current state,
* emits SupplyIndexUpdated event and recalculates next tier to update.
* @param market Address of the market to update
* @param lastUpdatedBlock Last updated block number
* @param lastUpdatedIndex Last updated index value
* @param currentSupplyIndex Current MNT supply index value
* @dev RESTRICTION: RewardsHub only
*/
function updateSupplyIndexesHistory(
IMToken market,
uint256 lastUpdatedBlock,
uint256 lastUpdatedIndex,
uint256 currentSupplyIndex
) external;
/**
* @notice Update MNT borrow index for market for NFT tiers that are expired but not yet updated.
* @dev This function checks if there are tiers to update and process them one by one:
* calculates the MNT borrow index depending on the delta index and delta blocks between
* last MNT borrow index update and the current state,
* emits BorrowIndexUpdated event and recalculates next tier to update.
* @param market Address of the market to update
* @param lastUpdatedBlock Last updated block number
* @param lastUpdatedIndex Last updated index value
* @param currentBorrowIndex Current MNT borrow index value
* @dev RESTRICTION: RewardsHub only
*/
function updateBorrowIndexesHistory(
IMToken market,
uint256 lastUpdatedBlock,
uint256 lastUpdatedIndex,
uint256 currentBorrowIndex
) external;
/**
* @notice Get Id of NFT tier to update next on provided market MNT index, supply or borrow
* @param market Market for which should the next Tier to update be updated
* @param isSupply_ Flag that indicates whether MNT supply or borrow market should be updated
* @return Id of tier to update
*/
function getNextTierToBeUpdatedIndex(IMToken market, bool isSupply_) external view returns (uint256);
}
@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroEndpoint.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external;
// @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}
contracts/interfaces/IBuyback.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./ILinkageLeaf.sol";
interface IBuyback is IAccessControl, ILinkageLeaf {
event Stake(address who, uint256 amount);
event Unstake(address who, uint256 amount);
event NewBuyback(uint256 amount, uint256 share);
event ParticipateBuyback(address who);
event LeaveBuyback(address who, uint256 currentStaked);
event BuybackWeightChanged(address who, uint256 newWeight, uint256 oldWeight, uint256 newTotalWeight);
event LoyaltyParametersChanged(uint256 newCoreFactor, uint32 newCoreResetPenalty);
event LoyaltyStrataChanged();
event LoyaltyGroupsChanged(uint256 newGroupCount);
/**
* @notice Gets info about account membership in Buyback
*/
function getMemberInfo(address account)
external
view
returns (
bool participating,
uint256 weight,
uint256 lastIndex,
uint256 stakeAmount
);
/**
* @notice Gets info about accounts loyalty calculation
*/
function getLoyaltyInfo(address account)
external
view
returns (
uint32 loyaltyStart,
uint256 coreBalance,
uint256 lastBalance
);
/**
* @notice Gets if an account is participating in Buyback
*/
function isParticipating(address account) external view returns (bool);
/**
* @notice Gets stake of the account
*/
function getStakedAmount(address account) external view returns (uint256);
/**
* @notice Gets buyback weight of an account
*/
function getWeight(address account) external view returns (uint256);
/**
* @notice Gets loyalty factor of an account with given balance.
*/
function getLoyaltyFactorForBalance(address account, uint256 balance) external view returns (uint256);
/**
* @notice Gets total Buyback weight, which is the sum of weights of all accounts.
*/
function getTotalWeight() external view returns (uint256);
/**
* @notice Gets current Buyback index.
* Its the accumulated sum of MNTs shares that are given for each weight of an account.
*/
function getBuybackIndex() external view returns (uint256);
/**
* @notice Gets all global loyalty parameters.
*/
function getLoyaltyParameters()
external
view
returns (
uint256[24] memory loyaltyStrata,
uint256[] memory groupThresholds,
uint32[] memory groupStartStrata,
uint256 coreFactor,
uint32 coreResetPenalty
);
/**
* @notice Stakes the specified amount of MNT and transfers them to this contract.
* @notice This contract should be approved to transfer MNT from sender account
* @param amount The amount of MNT to stake
*/
function stake(uint256 amount) external;
/**
* @notice Unstakes the specified amount of MNT and transfers them back to sender if he participates
* in the Buyback system, otherwise just transfers MNT tokens to the sender.
* would not be greater than staked amount left. If `amount == MaxUint256` unstakes all staked tokens.
* @param amount The amount of MNT to unstake
*/
function unstake(uint256 amount) external;
/**
* @notice Claims buyback rewards, updates buyback weight and voting power.
* Does nothing if account is not participating. Reverts if operation is paused.
* @param account Address to update weights for
*/
function updateBuybackAndVotingWeights(address account) external;
/**
* @notice Claims buyback rewards, updates buyback weight and voting power.
* Does nothing if account is not participating or update is paused.
* @param account Address to update weights for
*/
function updateBuybackAndVotingWeightsRelaxed(address account) external;
/**
* @notice Does a buyback using the specified amount of MNT from sender's account
* @param amount The amount of MNT to take and distribute as buyback
* @dev RESTRICTION: Distributor only
*/
function buyback(uint256 amount) external;
/**
* @notice Make account participating in the buyback.
*/
function participate() external;
/**
* @notice Make accounts participate in buyback before its start.
* @param accounts Address to make participate in buyback.
* @dev RESTRICTION: Admin only
*/
function participateOnBehalf(address[] memory accounts) external;
/**
* @notice Leave buyback participation, claim any MNTs rewarded by the buyback.
* Leaving does not withdraw staked MNTs but reduces weight of the account to zero
*/
function leave() external;
/**
* @notice Leave buyback participation on behalf, claim any MNTs rewarded by the buyback and
* reduce the weight of account to zero. All staked MNTs remain on the buyback contract and available
* for their owner to be claimed
* Can only be called if (timestamp > participantLastVoteTimestamp + maxNonVotingPeriod).
* @param participant Address to leave for
* @dev RESTRICTION: GATEKEEPER only
*/
function leaveOnBehalf(address participant) external;
/**
* @notice Leave buyback participation on behalf, claim any MNTs rewarded by the buyback and
* reduce the weight of account to zero. All staked MNTs remain on the buyback contract and available
* for their owner to be claimed.
* @dev Function to leave sanctioned accounts from Buyback system
* Can only be called if the participant is sanctioned by the AML system.
* @param participant Address to leave for
*/
function leaveByAmlDecision(address participant) external;
/**
* @notice Changes loyalty core factor and core reset penalty parameters.
* @dev RESTRICTION: Admin only
*/
function setLoyaltyParameters(uint256 newCoreFactor, uint32 newCoreResetPenalty) external;
/**
* @notice Sets new loyalty factors for all strata.
* @dev RESTRICTION: Admin only
*/
function setLoyaltyStrata(uint256[24] memory newLoyaltyStrata) external;
/**
* @notice Sets new groups and their parameters
* @param newGroupThresholds New list of groups and their balance thresholds.
* @param newGroupStartStrata Indexes of starting stratum of each group. First index MUST be zero.
* Length of array must be equal to the newGroupThresholds
* @dev RESTRICTION: Admin only
*/
function setLoyaltyGroups(uint256[] memory newGroupThresholds, uint32[] memory newGroupStartStrata) external;
}
contracts/interfaces/IInterconnectorLeaf.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IInterconnector.sol";
import "./ILinkageLeaf.sol";
interface IInterconnectorLeaf is ILinkageLeaf {
function getInterconnector() external view returns (IInterconnector);
}
contracts/interfaces/IVesting.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IBuyback.sol";
/**
* @title Vesting contract provides unlocking of tokens on a schedule. It uses the *graded vesting* way,
* which unlocks a specific amount of balance every period of time, until all balance unlocked.
*
* Vesting Schedule.
*
* The schedule of a vesting is described by data structure `VestingSchedule`: starting from the start timestamp
* throughout the duration, the entire amount of totalAmount tokens will be unlocked.
*/
interface IVesting is IAccessControl {
/**
* @notice An event that's emitted when a new vesting schedule for a account is created.
*/
event VestingScheduleAdded(address target, VestingSchedule schedule);
/**
* @notice An event that's emitted when a vesting schedule revoked.
*/
event VestingScheduleRevoked(address target, uint256 unreleased, uint256 locked);
/**
* @notice An event that's emitted when the account Withdrawn the released tokens.
*/
event Withdrawn(address target, uint256 withdrawn);
/**
* @notice Emitted when an account is added to the delay list
*/
event AddedToDelayList(address account);
/**
* @notice Emitted when an account is removed from the delay list
*/
event RemovedFromDelayList(address account);
/**
* @notice The structure is used in the contract constructor for create vesting schedules
* during contract deploying.
* @param totalAmount the number of tokens to be vested during the vesting duration.
* @param target the address that will receive tokens according to schedule parameters.
* @param start offset in minutes at which vesting starts. Zero will vesting immediately.
* @param duration duration in minutes of the period in which the tokens will vest.
* @param revocable whether the vesting is revocable or not.
*/
struct ScheduleData {
uint256 totalAmount;
address target;
uint32 start;
uint32 duration;
bool revocable;
}
/**
* @notice Vesting schedules of an account.
* @param totalAmount the number of tokens to be vested during the vesting duration.
* @param released the amount of the token released. It means that the account has called withdraw() and received
* @param start the timestamp in minutes at which vesting starts. Must not be equal to zero, as it is used to
* check for the existence of a vesting schedule.
* @param duration duration in minutes of the period in which the tokens will vest.
* `released amount` of tokens to his address.
* @param revocable whether the vesting is revocable or not.
*/
struct VestingSchedule {
uint256 totalAmount;
uint256 released;
uint32 created;
uint32 start;
uint32 duration;
bool revocable;
}
/// @notice get keccak-256 hash of GATEKEEPER role
function GATEKEEPER() external view returns (bytes32);
/// @notice get keccak-256 hash of TOKEN_PROVIDER role
function TOKEN_PROVIDER() external view returns (bytes32);
/**
* @notice get vesting schedule of an account.
*/
function schedules(address)
external
view
returns (
uint256 totalAmount,
uint256 released,
uint32 created,
uint32 start,
uint32 duration,
bool revocable
);
/**
* @notice Gets the amount of MNT that was transferred to Vesting contract
* and can be transferred to other accounts via vesting process.
* Transferring rewards from Vesting via withdraw method will decrease this amount.
*/
function allocation() external view returns (uint256);
/**
* @notice Gets the amount of allocated MNT tokens that are not used in any vesting schedule yet.
* Creation of new vesting schedules will decrease this amount.
*/
function freeAllocation() external view returns (uint256);
/**
* @notice get Whether or not the account is in the delay list
*/
function delayList(address) external view returns (bool);
/**
* @notice Withdraw the specified number of tokens. For a successful transaction, the requirement
* `amount_ > 0 && amount_ <= unreleased` must be met.
* If `amount_ == MaxUint256` withdraw all unreleased tokens.
* @param amount_ The number of tokens to withdraw.
*/
function withdraw(uint256 amount_) external;
/**
* @notice Increases vesting schedule allocation and transfers MNT into Vesting.
* @dev RESTRICTION: TOKEN_PROVIDER only
*/
function refill(uint256 amount) external;
/**
* @notice Transfers MNT that were added to the contract without calling the refill and are unallocated.
* @dev RESTRICTION: Admin only
*/
function sweep(address recipient, uint256 amount) external;
/**
* @notice Allows the admin to create a new vesting schedules.
* @param schedulesData an array of vesting schedules that will be created.
* @dev RESTRICTION: Admin only.
*/
function createVestingScheduleBatch(ScheduleData[] memory schedulesData) external;
/**
* @notice Allows the admin to revoke the vesting schedule. Tokens already vested
* transfer to the account, the rest are returned to the vesting contract.
* Accounts that are in delay list have their withdraw blocked so they would not receive anything.
* @param target_ the address from which the vesting schedule is revoked.
* @dev RESTRICTION: Gatekeeper only.
*/
function revokeVestingSchedule(address target_) external;
/**
* @notice Calculates the end of the vesting.
* @param who_ account address for which the parameter is returned.
* @return the end of the vesting.
*/
function endOfVesting(address who_) external view returns (uint256);
/**
* @notice Calculates locked amount for a given `time`.
* @param who_ account address for which the parameter is returned.
* @return locked amount for a given `time`.
*/
function lockedAmount(address who_) external view returns (uint256);
/**
* @notice Calculates the amount that has already vested.
* @param who_ account address for which the parameter is returned.
* @return the amount that has already vested.
*/
function vestedAmount(address who_) external view returns (uint256);
/**
* @notice Calculates the amount that has already vested but hasn't been released yet.
* @param who_ account address for which the parameter is returned.
* @return the amount that has already vested but hasn't been released yet.
*/
function releasableAmount(address who_) external view returns (uint256);
/**
* @notice Gets the amount that has already vested but hasn't been released yet if account
* schedule had no starting delay (cliff).
*/
function getReleasableWithoutCliff(address account) external view returns (uint256);
/**
* @notice Add an account with revocable schedule to the delay list
* @param who_ The account that is being added to the delay list
* @dev RESTRICTION: Gatekeeper only.
*/
function addToDelayList(address who_) external;
/**
* @notice Remove an account from the delay list
* @param who_ The account that is being removed from the delay list
* @dev RESTRICTION: Gatekeeper only.
*/
function removeFromDelayList(address who_) external;
}
contracts/libraries/ErrorCodes.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
library ErrorCodes {
// Common
string internal constant ADMIN_ONLY = "E101";
string internal constant UNAUTHORIZED = "E102";
string internal constant OPERATION_PAUSED = "E103";
string internal constant WHITELISTED_ONLY = "E104";
string internal constant ADDRESS_IS_NOT_IN_AML_SYSTEM = "E105";
string internal constant ADDRESS_IS_BLACKLISTED = "E106";
// Invalid input
string internal constant ADMIN_ADDRESS_CANNOT_BE_ZERO = "E201";
string internal constant INVALID_REDEEM = "E202";
string internal constant REDEEM_TOO_MUCH = "E203";
string internal constant MARKET_NOT_LISTED = "E204";
string internal constant INSUFFICIENT_LIQUIDITY = "E205";
string internal constant INVALID_SENDER = "E206";
string internal constant BORROW_CAP_REACHED = "E207";
string internal constant BALANCE_OWED = "E208";
string internal constant UNRELIABLE_LIQUIDATOR = "E209";
string internal constant INVALID_DESTINATION = "E210";
string internal constant INSUFFICIENT_STAKE = "E211";
string internal constant INVALID_DURATION = "E212";
string internal constant INVALID_PERIOD_RATE = "E213";
string internal constant EB_TIER_LIMIT_REACHED = "E214";
string internal constant LQ_INCORRECT_REPAY_AMOUNT = "E215";
string internal constant LQ_INSUFFICIENT_SEIZE_AMOUNT = "E216";
string internal constant EB_TIER_DOES_NOT_EXIST = "E217";
string internal constant EB_ZERO_TIER_CANNOT_BE_ENABLED = "E218";
string internal constant EB_ALREADY_ACTIVATED_TIER = "E219";
string internal constant EB_END_BLOCK_MUST_BE_LARGER_THAN_CURRENT = "E220";
string internal constant EB_CANNOT_MINT_TOKEN_FOR_ACTIVATED_TIER = "E221";
string internal constant EB_EMISSION_BOOST_IS_NOT_IN_RANGE = "E222";
string internal constant TARGET_ADDRESS_CANNOT_BE_ZERO = "E223";
string internal constant INSUFFICIENT_TOKEN_IN_VESTING_CONTRACT = "E224";
string internal constant VESTING_SCHEDULE_ALREADY_EXISTS = "E225";
string internal constant INSUFFICIENT_TOKENS_TO_CREATE_SCHEDULE = "E226";
string internal constant NO_VESTING_SCHEDULE = "E227";
string internal constant MNT_AMOUNT_IS_ZERO = "E230";
string internal constant INCORRECT_AMOUNT = "E231";
string internal constant MEMBERSHIP_LIMIT = "E232";
string internal constant MEMBER_NOT_EXIST = "E233";
string internal constant MEMBER_ALREADY_ADDED = "E234";
string internal constant MEMBERSHIP_LIMIT_REACHED = "E235";
string internal constant REPORTED_PRICE_SHOULD_BE_GREATER_THAN_ZERO = "E236";
string internal constant MTOKEN_ADDRESS_CANNOT_BE_ZERO = "E237";
string internal constant TOKEN_ADDRESS_CANNOT_BE_ZERO = "E238";
string internal constant REDEEM_TOKENS_OR_REDEEM_AMOUNT_MUST_BE_ZERO = "E239";
string internal constant FL_TOKEN_IS_NOT_UNDERLYING = "E240";
string internal constant FL_AMOUNT_IS_TOO_LARGE = "E241";
string internal constant FL_CALLBACK_FAILED = "E242";
string internal constant EB_MARKET_INDEX_IS_LESS_THAN_USER_INDEX = "E254";
string internal constant LQ_UNSUPPORTED_FULL_REPAY = "E255";
string internal constant LQ_UNSUPPORTED_FULL_SEIZE = "E256";
string internal constant LQ_UNSUPPORTED_MARKET_RECEIVED = "E257";
string internal constant LQ_UNSUCCESSFUL_CALLBACK = "E258";
string internal constant FL_UNAUTHORIZED_CALLBACK = "E270";
string internal constant FL_INCORRECT_TOKEN_OUT_DEVIATION = "E271";
string internal constant FL_SWAP_CALL_FAILS = "E272";
string internal constant FL_INVALID_AMOUNT_TOKEN_IN_SPENT = "E273";
string internal constant FL_INVALID_AMOUNT_TOKEN_OUT_RECEIVED = "E274";
string internal constant FL_EXACT_IN_INCORRECT_ALLOWANCE_AFTER = "E275";
string internal constant FL_RECEIVER_NOT_FOUND = "E276";
// Protocol errors
string internal constant INVALID_PRICE = "E301";
string internal constant MARKET_NOT_FRESH = "E302";
string internal constant BORROW_RATE_TOO_HIGH = "E303";
string internal constant INSUFFICIENT_TOKEN_CASH = "E304";
string internal constant INSUFFICIENT_TOKENS_FOR_RELEASE = "E305";
string internal constant INSUFFICIENT_MNT_FOR_GRANT = "E306";
string internal constant TOKEN_TRANSFER_IN_UNDERFLOW = "E307";
string internal constant NOT_PARTICIPATING_IN_BUYBACK = "E308";
string internal constant NOT_ENOUGH_PARTICIPATING_ACCOUNTS = "E309";
string internal constant NOTHING_TO_DISTRIBUTE = "E310";
string internal constant ALREADY_PARTICIPATING_IN_BUYBACK = "E311";
string internal constant MNT_APPROVE_FAILS = "E312";
string internal constant TOO_EARLY_TO_DRIP = "E313";
string internal constant BB_UNSTAKE_TOO_EARLY = "E314";
string internal constant INSUFFICIENT_SHORTFALL = "E315";
string internal constant HEALTHY_FACTOR_NOT_IN_RANGE = "E316";
string internal constant BUYBACK_DRIPS_ALREADY_HAPPENED = "E317";
string internal constant EB_INDEX_SHOULD_BE_GREATER_THAN_INITIAL = "E318";
string internal constant NO_VESTING_SCHEDULES = "E319";
string internal constant INSUFFICIENT_UNRELEASED_TOKENS = "E320";
string internal constant ORACLE_PRICE_EXPIRED = "E321";
string internal constant TOKEN_NOT_FOUND = "E322";
string internal constant RECEIVED_PRICE_HAS_INVALID_ROUND = "E323";
string internal constant FL_PULL_AMOUNT_IS_TOO_LOW = "E324";
string internal constant INSUFFICIENT_TOTAL_PROTOCOL_INTEREST = "E325";
string internal constant BB_ACCOUNT_RECENTLY_VOTED = "E326";
string internal constant PRICE_FEED_ID_NOT_FOUND = "E327";
string internal constant INCORRECT_PRICE_MULTIPLIER = "E328";
string internal constant LL_NEW_ROOT_CANNOT_BE_ZERO = "E329";
string internal constant RH_PAYOUT_FROM_FUTURE = "E330";
string internal constant RH_ACCRUE_WITHOUT_UNLOCK = "E331";
string internal constant RH_LERP_DELTA_IS_GREATER_THAN_PERIOD = "E332";
string internal constant PRICE_FEED_ADDRESS_NOT_FOUND = "E333";
// Invalid input - Admin functions
string internal constant ZERO_EXCHANGE_RATE = "E401";
string internal constant SECOND_INITIALIZATION = "E402";
string internal constant MARKET_ALREADY_LISTED = "E403";
string internal constant IDENTICAL_VALUE = "E404";
string internal constant ZERO_ADDRESS = "E405";
string internal constant EC_INVALID_PROVIDER_REPRESENTATIVE = "E406";
string internal constant EC_PROVIDER_CANT_BE_REPRESENTATIVE = "E407";
string internal constant OR_ORACLE_ADDRESS_CANNOT_BE_ZERO = "E408";
string internal constant OR_UNDERLYING_TOKENS_DECIMALS_SHOULD_BE_GREATER_THAN_ZERO = "E409";
string internal constant OR_REPORTER_MULTIPLIER_SHOULD_BE_GREATER_THAN_ZERO = "E410";
string internal constant INVALID_TOKEN = "E411";
string internal constant INVALID_PROTOCOL_INTEREST_FACTOR_MANTISSA = "E412";
string internal constant INVALID_REDUCE_AMOUNT = "E413";
string internal constant LIQUIDATION_FEE_MANTISSA_SHOULD_BE_GREATER_THAN_ZERO = "E414";
string internal constant INVALID_UTILISATION_FACTOR_MANTISSA = "E415";
string internal constant INVALID_MTOKENS_OR_BORROW_CAPS = "E416";
string internal constant FL_PARAM_IS_TOO_LARGE = "E417";
string internal constant MNT_INVALID_NONVOTING_PERIOD = "E418";
string internal constant INPUT_ARRAY_LENGTHS_ARE_NOT_EQUAL = "E419";
string internal constant EC_INVALID_BOOSTS = "E420";
string internal constant EC_ACCOUNT_IS_ALREADY_LIQUIDITY_PROVIDER = "E421";
string internal constant EC_ACCOUNT_HAS_NO_AGREEMENT = "E422";
string internal constant OR_TIMESTAMP_THRESHOLD_SHOULD_BE_GREATER_THAN_ZERO = "E423";
string internal constant OR_UNDERLYING_TOKENS_DECIMALS_TOO_BIG = "E424";
string internal constant OR_REPORTER_MULTIPLIER_TOO_BIG = "E425";
string internal constant SHOULD_HAVE_REVOCABLE_SCHEDULE = "E426";
string internal constant MEMBER_NOT_IN_DELAY_LIST = "E427";
string internal constant DELAY_LIST_LIMIT = "E428";
string internal constant NUMBER_IS_NOT_IN_SCALE = "E429";
string internal constant BB_STRATUM_OF_FIRST_LOYALTY_GROUP_IS_NOT_ZERO = "E430";
string internal constant INPUT_ARRAY_IS_EMPTY = "E431";
string internal constant OR_INCORRECT_PRICE_FEED_ID = "E432";
string internal constant OR_PRICE_AGE_CAN_NOT_BE_ZERO = "E433";
string internal constant OR_INCORRECT_PRICE_FEED_ADDRESS = "E434";
string internal constant OR_INCORRECT_SECONDARY_PRICE_FEED_ADDRESS = "E435";
string internal constant RH_COOLDOWN_START_ALREADY_SET = "E436";
string internal constant RH_INCORRECT_COOLDOWN_START = "E437";
string internal constant RH_COOLDOWN_IS_FINISHED = "E438";
string internal constant RH_INCORRECT_NUMBER_OF_CHARGES = "E439";
string internal constant RH_INCORRECT_CHARGE_SHARE = "E440";
string internal constant RH_COOLDOWN_START_NOT_SET = "E441";
}
@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroReceiver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroReceiver {
// @notice LayerZero endpoint will invoke this function to deliver the message on the destination
// @param _srcChainId - the source endpoint identifier
// @param _srcAddress - the source sending contract address from the source chain
// @param _nonce - the ordered message nonce
// @param _payload - the signed payload is the UA bytes has encoded to be sent
function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;
}
contracts/MinterestNFT.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "./interfaces/IMinterestNFT.sol";
import "./libraries/ErrorCodes.sol";
import "./InterconnectorLeaf.sol";
/**
* @title MinterestNFT
* @dev Contract module which provides functionality to mint new ERC1155 tokens
* Each token connected with image and metadata. The image and metadata saved
* on IPFS and this contract stores the CID of the folder where lying metadata.
* Also each token belongs one of the Minterest tiers, and give some emission
* boost for Minterest distribution system.
*/
contract MinterestNFT is IMinterestNFT, ERC1155, Initializable, AccessControl, InterconnectorLeaf {
using Counters for Counters.Counter;
using Strings for string;
/// @notice The right part is the keccak-256 hash of variable name
bytes32 public constant GATEKEEPER = bytes32(0x20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b2);
/// Name for Minterst NFT Token
string public constant name = "Minterest NFT";
/// Symbol for Minterst NFT Token
string public constant symbol = "MNFT";
/// @dev ERC1155 id, Indicates a specific token or token type
Counters.Counter private idCounter;
constructor() ERC1155("https://") {
_disableInitializers();
}
/**
* @notice Initialize contract
* @param _baseURI Base of URI where stores images
* @param _admin The address of the Admin
*/
function initialize(string memory _baseURI, address _admin) public initializer {
require(_admin != address(0), ErrorCodes.ZERO_ADDRESS);
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(GATEKEEPER, _admin);
_setURI(_baseURI);
}
/*** External user-defined functions ***/
/// @inheritdoc IMinterestNFT
function mint(
address account_,
uint256 amount_,
bytes memory data_,
uint256 tier_
) external onlyRole(GATEKEEPER) {
idCounter.increment();
uint256 id = idCounter.current();
_mint(account_, id, amount_, data_);
if (tier_ > 0) {
emissionBooster().onMintToken(
account_,
_asSingletonArray2(id),
_asSingletonArray2(amount_),
_asSingletonArray2(tier_)
);
}
}
/// @inheritdoc IMinterestNFT
function mintBatch(
address account_,
uint256[] memory amounts_,
bytes memory data_,
uint256[] memory tiers_
) external onlyRole(GATEKEEPER) {
require(tiers_.length == amounts_.length, ErrorCodes.INPUT_ARRAY_LENGTHS_ARE_NOT_EQUAL);
uint256[] memory ids = new uint256[](amounts_.length);
for (uint256 i = 0; i < amounts_.length; i++) {
idCounter.increment();
uint256 id = idCounter.current();
ids[i] = id;
}
_mintBatch(account_, ids, amounts_, data_);
emissionBooster().onMintToken(account_, ids, amounts_, tiers_);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*/
function _beforeTokenTransfer(
address,
address from_,
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory
) internal virtual override {
// Ignore mint transfers
if (from_ != address(0)) emissionBooster().onTransferToken(from_, to_, ids_, amounts_);
}
/// @inheritdoc IMinterestNFT
function safeTransfer(
address to_,
uint256 id_,
uint256 amount_,
bytes memory data_
) external {
safeTransferFrom(msg.sender, to_, id_, amount_, data_);
}
/// @inheritdoc IMinterestNFT
function safeBatchTransfer(
address to_,
uint256[] memory ids_,
uint256[] memory amounts_,
bytes memory data_
) external {
safeBatchTransferFrom(msg.sender, to_, ids_, amounts_, data_);
}
/*** Admin Functions ***/
/// @inheritdoc IMinterestNFT
function setURI(string memory newBaseUri) external onlyRole(DEFAULT_ADMIN_ROLE) {
_setURI(newBaseUri);
emit NewBaseUri(newBaseUri);
}
/*** Helper special functions ***/
/// @inheritdoc IMinterestNFT
function uri(uint256 tokenId_) public view override(ERC1155, IMinterestNFT) returns (string memory) {
// slither-disable-next-line encode-packed-collision
return string(abi.encodePacked(super.uri(tokenId_), Strings.toString(tokenId_), ".json"));
}
/// @inheritdoc IMinterestNFT
function nextIdToBeMinted() external view returns (uint256) {
return idCounter.current() + 1;
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControl, ERC1155, IERC165)
returns (bool)
{
return interfaceId == type(IMinterestNFT).interfaceId || super.supportsInterface(interfaceId);
}
function _asSingletonArray2(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
function emissionBooster() internal view returns (IEmissionBooster) {
return getInterconnector().emissionBooster();
}
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
contracts/interfaces/IWeightAggregator.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
interface IWeightAggregator {
/**
* @notice Returns MNTs of the account that are used in buyback weight calculation.
*/
function getAccountFunds(address account) external view returns (uint256);
/**
* @notice Returns loyalty factor of the specified account.
*/
function getLoyaltyFactor(address account) external view returns (uint256);
/**
* @notice Returns Buyback weight for the user
*/
function getBuybackWeight(address account) external view returns (uint256);
/**
* @notice Return voting weight for the user
*/
function getVotingWeight(address account) external view returns (uint256);
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
contracts/interfaces/IWhitelist.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
interface IWhitelist is IAccessControl {
/**
* @notice The given member was added to the whitelist
*/
event MemberAdded(address);
/**
* @notice The given member was removed from the whitelist
*/
event MemberRemoved(address);
/**
* @notice Protocol operation mode switched
*/
event WhitelistModeWasTurnedOff();
/**
* @notice Amount of maxMembers changed
*/
event MaxMemberAmountChanged(uint256);
/**
* @notice get maximum number of members.
* When membership reaches this number, no new members may join.
*/
function maxMembers() external view returns (uint256);
/**
* @notice get the total number of members stored in the map.
*/
function memberCount() external view returns (uint256);
/**
* @notice get protocol operation mode.
*/
function whitelistModeEnabled() external view returns (bool);
/**
* @notice get is account member of whitelist
*/
function accountMembership(address) external view returns (bool);
/**
* @notice get keccak-256 hash of GATEKEEPER role
*/
function GATEKEEPER() external view returns (bytes32);
/**
* @notice Add a new member to the whitelist.
* @param newAccount The account that is being added to the whitelist.
* @dev RESTRICTION: Gatekeeper only.
*/
function addMember(address newAccount) external;
/**
* @notice Remove a member from the whitelist.
* @param accountToRemove The account that is being removed from the whitelist.
* @dev RESTRICTION: Gatekeeper only.
*/
function removeMember(address accountToRemove) external;
/**
* @notice Disables whitelist mode and enables emission boost mode.
* @dev RESTRICTION: Admin only.
*/
function turnOffWhitelistMode() external;
/**
* @notice Set a new threshold of participants.
* @param newThreshold New number of participants.
* @dev RESTRICTION: Gatekeeper only.
*/
function setMaxMembers(uint256 newThreshold) external;
/**
* @notice Check protocol operation mode. In whitelist mode, only members from whitelist and who have
* EmissionBooster can work with protocol.
* @param who The address of the account to check for participation.
*/
function isWhitelisted(address who) external view returns (bool);
}
@openzeppelin/contracts/utils/Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
@openzeppelin/contracts/token/ERC1155/IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
contracts/layerZero/MONFT1155Core.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "./onft1155/ONFT1155Core.sol";
import "./lzApp/NonblockingLzApp.sol";
import "../interfaces/IEmissionBooster.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* Custom version of ONFT1155Core contract to use with MinterestNFT
*/
abstract contract MONFT1155Core is ONFT1155Core {
function estimateSendBatchFee(
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
bool _useZro,
bytes memory _adapterParams
) public view virtual override returns (uint256 nativeFee, uint256 zroFee) {
uint256[] memory tiers = _getTiers(_tokenIds);
bytes memory payload = abi.encode(_toAddress, _tokenIds, tiers, _amounts);
return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams);
}
function _sendBatch(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
address payable _refundAddress,
address _zroPaymentAddress,
bytes memory _adapterParams
) internal virtual override {
uint256[] memory tiers = _getTiers(_tokenIds);
_debitFrom(_from, _dstChainId, _toAddress, _tokenIds, tiers, _amounts);
bytes memory payload = abi.encode(_toAddress, _tokenIds, tiers, _amounts);
if (_tokenIds.length == 1) {
if (useCustomAdapterParams) {
_checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND, _adapterParams, NO_EXTRA_GAS);
} else {
require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty.");
}
emit SendToChain(_dstChainId, _from, _toAddress, _tokenIds[0], _amounts[0]);
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value);
} else if (_tokenIds.length > 1) {
if (useCustomAdapterParams) {
_checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND_BATCH, _adapterParams, NO_EXTRA_GAS);
} else {
require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty.");
}
emit SendBatchToChain(_dstChainId, _from, _toAddress, _tokenIds, _amounts);
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value);
}
}
function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory _srcAddress,
uint64, /*_nonce*/
bytes memory _payload
) internal virtual override {
// decode and load the toAddress
(bytes memory toAddressBytes, uint256[] memory tokenIds, uint256[] memory tiers, uint256[] memory amounts) = abi
.decode(_payload, (bytes, uint256[], uint256[], uint256[]));
address toAddress;
assembly {
toAddress := mload(add(toAddressBytes, 20))
}
_creditTo(_srcChainId, toAddress, tokenIds, tiers, amounts);
if (tokenIds.length == 1) {
emit ReceiveFromChain(_srcChainId, _srcAddress, toAddress, tokenIds[0], amounts[0]);
} else if (tokenIds.length > 1) {
emit ReceiveBatchFromChain(_srcChainId, _srcAddress, toAddress, tokenIds, amounts);
}
}
function _getTiers(uint256[] memory _tokenIds) internal view returns (uint256[] memory) {
uint256[] memory tiers = new uint256[](_tokenIds.length);
for (uint256 i = 0; i < _tokenIds.length; i++) {
tiers[i] = _getEmissionBooster().tokenTier(_tokenIds[i]);
}
return tiers;
}
function _getEmissionBooster() internal view virtual returns (IEmissionBooster);
// Overriding unused function from ONFT1155Core
function _debitFrom(
address,
uint16,
bytes memory,
uint256[] memory,
uint256[] memory
) internal pure override {
require(false, "Deprecated function");
}
// Overriding unused function from ONFT1155Core
function _creditTo(
uint16,
address,
uint256[] memory,
uint256[] memory
) internal pure override {
require(false, "Deprecated function");
}
// Overload functions from ONFT1155Core, add tiers parameter
function _debitFrom(
address _from,
uint16 _dstChainId,
bytes memory _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _tiers,
uint256[] memory _amounts
) internal virtual;
// Overload functions from ONFT1155Core, add tiers parameter
function _creditTo(
uint16 _srcChainId,
address _toAddress,
uint256[] memory _tokenIds,
uint256[] memory _tiers,
uint256[] memory _amounts
) internal virtual;
}
contracts/interfaces/IRewardsHub.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./IRewardsHubLight.sol";
interface IRewardsHub is IRewardsHubLight {
event RewardUnlocked(address account, uint256 amount);
/**
* @notice Gets summary amount of available and delayed balances of an account.
*/
function totalBalanceOf(address account) external view override returns (uint256);
/**
* @notice Gets part of delayed rewards that is unlocked and have become available.
*/
function getUnlockableRewards(address account) external view returns (uint256);
}
contracts/interfaces/IInterconnector.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "./ISupervisor.sol";
import "./IRewardsHub.sol";
import "./IMnt.sol";
import "./IBuyback.sol";
import "./IVesting.sol";
import "./IMinterestNFT.sol";
import "./IPriceOracle.sol";
import "./ILiquidation.sol";
import "./IBDSystem.sol";
import "./IWeightAggregator.sol";
import "./IEmissionBooster.sol";
interface IInterconnector {
function supervisor() external view returns (ISupervisor);
function buyback() external view returns (IBuyback);
function emissionBooster() external view returns (IEmissionBooster);
function bdSystem() external view returns (IBDSystem);
function rewardsHub() external view returns (IRewardsHub);
function mnt() external view returns (IMnt);
function minterestNFT() external view returns (IMinterestNFT);
function liquidation() external view returns (ILiquidation);
function oracle() external view returns (IPriceOracle);
function vesting() external view returns (IVesting);
function whitelist() external view returns (IWhitelist);
function weightAggregator() external view returns (IWeightAggregator);
}
@layerzerolabs/solidity-examples/contracts/util/ExcessivelySafeCall.sol
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.7.6;
library ExcessivelySafeCall {
uint256 constant LOW_28_MASK =
0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
/// @notice Use when you _really_ really _really_ don't trust the called
/// contract. This prevents the called contract from causing reversion of
/// the caller in as many ways as we can.
/// @dev The main difference between this and a solidity low-level call is
/// that we limit the number of bytes that the callee can cause to be
/// copied to caller memory. This prevents stupid things like malicious
/// contracts returning 10,000,000 bytes causing a local OOG when copying
/// to memory.
/// @param _target The address to call
/// @param _gas The amount of gas to forward to the remote contract
/// @param _maxCopy The maximum number of bytes of returndata to copy
/// to memory.
/// @param _calldata The data to send to the remote contract
/// @return success and returndata, as `.call()`. Returndata is capped to
/// `_maxCopy` bytes.
function excessivelySafeCall(
address _target,
uint256 _gas,
uint16 _maxCopy,
bytes memory _calldata
) internal returns (bool, bytes memory) {
// set up for assembly call
uint256 _toCopy;
bool _success;
bytes memory _returnData = new bytes(_maxCopy);
// dispatch message to recipient
// by assembly calling "handle" function
// we call via assembly to avoid memcopying a very large returndata
// returned by a malicious contract
assembly {
_success := call(
_gas, // gas
_target, // recipient
0, // ether value
add(_calldata, 0x20), // inloc
mload(_calldata), // inlen
0, // outloc
0 // outlen
)
// limit our copy to 256 bytes
_toCopy := returndatasize()
if gt(_toCopy, _maxCopy) {
_toCopy := _maxCopy
}
// Store the length of the copied bytes
mstore(_returnData, _toCopy)
// copy the bytes from returndata[0:_toCopy]
returndatacopy(add(_returnData, 0x20), 0, _toCopy)
}
return (_success, _returnData);
}
/// @notice Use when you _really_ really _really_ don't trust the called
/// contract. This prevents the called contract from causing reversion of
/// the caller in as many ways as we can.
/// @dev The main difference between this and a solidity low-level call is
/// that we limit the number of bytes that the callee can cause to be
/// copied to caller memory. This prevents stupid things like malicious
/// contracts returning 10,000,000 bytes causing a local OOG when copying
/// to memory.
/// @param _target The address to call
/// @param _gas The amount of gas to forward to the remote contract
/// @param _maxCopy The maximum number of bytes of returndata to copy
/// to memory.
/// @param _calldata The data to send to the remote contract
/// @return success and returndata, as `.call()`. Returndata is capped to
/// `_maxCopy` bytes.
function excessivelySafeStaticCall(
address _target,
uint256 _gas,
uint16 _maxCopy,
bytes memory _calldata
) internal view returns (bool, bytes memory) {
// set up for assembly call
uint256 _toCopy;
bool _success;
bytes memory _returnData = new bytes(_maxCopy);
// dispatch message to recipient
// by assembly calling "handle" function
// we call via assembly to avoid memcopying a very large returndata
// returned by a malicious contract
assembly {
_success := staticcall(
_gas, // gas
_target, // recipient
add(_calldata, 0x20), // inloc
mload(_calldata), // inlen
0, // outloc
0 // outlen
)
// limit our copy to 256 bytes
_toCopy := returndatasize()
if gt(_toCopy, _maxCopy) {
_toCopy := _maxCopy
}
// Store the length of the copied bytes
mstore(_returnData, _toCopy)
// copy the bytes from returndata[0:_toCopy]
returndatacopy(add(_returnData, 0x20), 0, _toCopy)
}
return (_success, _returnData);
}
/**
* @notice Swaps function selectors in encoded contract calls
* @dev Allows reuse of encoded calldata for functions with identical
* argument types but different names. It simply swaps out the first 4 bytes
* for the new selector. This function modifies memory in place, and should
* only be used with caution.
* @param _newSelector The new 4-byte selector
* @param _buf The encoded contract args
*/
function swapSelector(bytes4 _newSelector, bytes memory _buf)
internal
pure
{
require(_buf.length >= 4);
uint256 _mask = LOW_28_MASK;
assembly {
// load the first word of
let _word := mload(add(_buf, 0x20))
// mask out the top 4 bytes
// /x
_word := and(_word, _mask)
_word := or(_newSelector, _word)
mstore(add(_buf, 0x20), _word)
}
}
}
@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
@layerzerolabs/solidity-examples/contracts/interfaces/ILayerZeroUserApplicationConfig.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
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;
}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
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;
}
contracts/interfaces/ILiquidation.sol
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.17;
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "./IMToken.sol";
import "./ILinkageLeaf.sol";
import "./IPriceOracle.sol";
/**
* This contract provides the liquidation functionality.
*/
interface ILiquidation is IAccessControl, ILinkageLeaf {
event HealthyFactorLimitChanged(uint256 oldValue, uint256 newValue);
event ReliableLiquidation(
bool isDebtHealthy,
address liquidator,
address borrower,
IMToken seizeMarket,
IMToken repayMarket,
uint256 seizeAmountUnderlying,
uint256 repayAmountUnderlying
);
/**
* @dev Local accountState for avoiding stack-depth limits in calculating liquidation amounts.
*/
struct AccountLiquidationAmounts {
uint256 accountTotalSupplyUsd;
uint256 accountTotalCollateralUsd;
uint256 accountPresumedTotalRepayUsd;
uint256 accountTotalBorrowUsd;
uint256 accountTotalCollateralUsdAfter;
uint256 accountTotalBorrowUsdAfter;
uint256 seizeAmount;
}
/**
* @notice GET The maximum allowable value of a healthy factor after liquidation, scaled by 1e18
*/
function healthyFactorLimit() external view returns (uint256);
/**
* @notice get keccak-256 hash of TRUSTED_LIQUIDATOR role
*/
function TRUSTED_LIQUIDATOR() external view returns (bytes32);
/**
* @notice get keccak-256 hash of TIMELOCK role
*/
function TIMELOCK() external view returns (bytes32);
/**
* @notice Liquidate insolvent debt position
* @param seizeMarket Market from which the account's collateral will be seized
* @param repayMarket Market from which the account's debt will be repaid
* @param borrower Account which is being liquidated
* @param repayAmount Amount of debt to be repaid
* @return (seizeAmount, repayAmount)
* @dev RESTRICTION: Trusted liquidator only
*/
function liquidateUnsafeLoan(
IMToken seizeMarket,
IMToken repayMarket,
address borrower,
uint256 repayAmount
) external returns (uint256, uint256);
/**
* @notice Accrues interest for repay and seize markets
* @param seizeMarket Market from which the account's collateral will be seized
* @param repayMarket Market from which the account's debt will be repaid
*/
function accrue(IMToken seizeMarket, IMToken repayMarket) external;
/**
* @notice Calculates account states: total balances, seize amount, new collateral and borrow state
* @param account_ The address of the borrower
* @param marketAddresses An array with addresses of markets where the debtor is in
* @param seizeMarket Market from which the account's collateral will be seized
* @param repayMarket Market from which the account's debt will be repaid
* @param repayAmount Amount of debt to be repaid
* @return accountState Struct that contains all balance parameters
*/
function calculateLiquidationAmounts(
address account_,
IMToken[] memory marketAddresses,
IMToken seizeMarket,
IMToken repayMarket,
uint256 repayAmount
) external view returns (AccountLiquidationAmounts memory);
/**
* @notice Sets a new value for healthyFactorLimit
* @dev RESTRICTION: Timelock only
*/
function setHealthyFactorLimit(uint256 newValue_) external;
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"LayerZeroEndpointSet","inputs":[{"type":"address","name":"previosLzEndpoint","internalType":"contract ILayerZeroEndpoint","indexed":false},{"type":"address","name":"newLzEndpoint","internalType":"contract ILayerZeroEndpoint","indexed":false}],"anonymous":false},{"type":"event","name":"LinkageRootSwitched","inputs":[{"type":"address","name":"newRoot","internalType":"contract ILinkageRoot","indexed":false},{"type":"address","name":"oldRoot","internalType":"contract ILinkageRoot","indexed":false}],"anonymous":false},{"type":"event","name":"MessageFailed","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16","indexed":false},{"type":"bytes","name":"_srcAddress","internalType":"bytes","indexed":false},{"type":"uint64","name":"_nonce","internalType":"uint64","indexed":false},{"type":"bytes","name":"_payload","internalType":"bytes","indexed":false},{"type":"bytes","name":"_reason","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"NewBaseUri","inputs":[{"type":"string","name":"newBaseUri","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"ReceiveBatchFromChain","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16","indexed":true},{"type":"bytes","name":"_srcAddress","internalType":"bytes","indexed":true},{"type":"address","name":"_toAddress","internalType":"address","indexed":true},{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"ReceiveFromChain","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16","indexed":true},{"type":"bytes","name":"_srcAddress","internalType":"bytes","indexed":true},{"type":"address","name":"_toAddress","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RetryMessageSuccess","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16","indexed":false},{"type":"bytes","name":"_srcAddress","internalType":"bytes","indexed":false},{"type":"uint64","name":"_nonce","internalType":"uint64","indexed":false},{"type":"bytes32","name":"_payloadHash","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SendBatchToChain","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16","indexed":true},{"type":"address","name":"_from","internalType":"address","indexed":true},{"type":"bytes","name":"_toAddress","internalType":"bytes","indexed":true},{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"SendToChain","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16","indexed":true},{"type":"address","name":"_from","internalType":"address","indexed":true},{"type":"bytes","name":"_toAddress","internalType":"bytes","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SetMinDstGas","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16","indexed":false},{"type":"uint16","name":"_type","internalType":"uint16","indexed":false},{"type":"uint256","name":"_minDstGas","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SetPrecrime","inputs":[{"type":"address","name":"precrime","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetTrustedRemote","inputs":[{"type":"uint16","name":"_remoteChainId","internalType":"uint16","indexed":false},{"type":"bytes","name":"_path","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"SetTrustedRemoteAddress","inputs":[{"type":"uint16","name":"_remoteChainId","internalType":"uint16","indexed":false},{"type":"bytes","name":"_remoteAddress","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"event","name":"SetUseCustomAdapterParams","inputs":[{"type":"bool","name":"_useCustomAdapterParams","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"TransferBatch","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256[]","name":"ids","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"values","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"TransferSingle","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"URI","inputs":[{"type":"string","name":"value","internalType":"string","indexed":false},{"type":"uint256","name":"id","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"DEFAULT_PAYLOAD_SIZE_LIMIT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"FUNCTION_TYPE_SEND","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"FUNCTION_TYPE_SEND_BATCH","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"GATEKEEPER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"NO_EXTRA_GAS","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"_initialize","inputs":[{"type":"string","name":"_baseURI","internalType":"string"},{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_lzEndpoint","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"balanceOfBatch","inputs":[{"type":"address[]","name":"accounts","internalType":"address[]"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"nativeFee","internalType":"uint256"},{"type":"uint256","name":"zroFee","internalType":"uint256"}],"name":"estimateSendBatchFee","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"bytes","name":"_toAddress","internalType":"bytes"},{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]"},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]"},{"type":"bool","name":"_useZro","internalType":"bool"},{"type":"bytes","name":"_adapterParams","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"nativeFee","internalType":"uint256"},{"type":"uint256","name":"zroFee","internalType":"uint256"}],"name":"estimateSendFee","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"bytes","name":"_toAddress","internalType":"bytes"},{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"bool","name":"_useZro","internalType":"bool"},{"type":"bytes","name":"_adapterParams","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"failedMessages","inputs":[{"type":"uint16","name":"","internalType":"uint16"},{"type":"bytes","name":"","internalType":"bytes"},{"type":"uint64","name":"","internalType":"uint64"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"forceResumeReceive","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16"},{"type":"bytes","name":"_srcAddress","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"getConfig","inputs":[{"type":"uint16","name":"_version","internalType":"uint16"},{"type":"uint16","name":"_chainId","internalType":"uint16"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"_configType","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IInterconnector"}],"name":"getInterconnector","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"getTrustedRemoteAddress","inputs":[{"type":"uint16","name":"_remoteChainId","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"string","name":"_baseURI","internalType":"string"},{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initializeLZEndpoint","inputs":[{"type":"address","name":"_lzEndpoint","internalType":"contract ILayerZeroEndpoint"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedRemote","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16"},{"type":"bytes","name":"_srcAddress","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ILayerZeroEndpoint"}],"name":"lzEndpoint","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lzReceive","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16"},{"type":"bytes","name":"_srcAddress","internalType":"bytes"},{"type":"uint64","name":"_nonce","internalType":"uint64"},{"type":"bytes","name":"_payload","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minDstGasLookup","inputs":[{"type":"uint16","name":"","internalType":"uint16"},{"type":"uint16","name":"","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mint","inputs":[{"type":"address","name":"account_","internalType":"address"},{"type":"uint256","name":"amount_","internalType":"uint256"},{"type":"bytes","name":"data_","internalType":"bytes"},{"type":"uint256","name":"tier_","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mintBatch","inputs":[{"type":"address","name":"account_","internalType":"address"},{"type":"uint256[]","name":"amounts_","internalType":"uint256[]"},{"type":"bytes","name":"data_","internalType":"bytes"},{"type":"uint256[]","name":"tiers_","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nextIdToBeMinted","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"nonblockingLzReceive","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16"},{"type":"bytes","name":"_srcAddress","internalType":"bytes"},{"type":"uint64","name":"_nonce","internalType":"uint64"},{"type":"bytes","name":"_payload","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"payloadSizeLimitLookup","inputs":[{"type":"uint16","name":"","internalType":"uint16"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"precrime","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"retryMessage","inputs":[{"type":"uint16","name":"_srcChainId","internalType":"uint16"},{"type":"bytes","name":"_srcAddress","internalType":"bytes"},{"type":"uint64","name":"_nonce","internalType":"uint64"},{"type":"bytes","name":"_payload","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeBatchTransfer","inputs":[{"type":"address","name":"to_","internalType":"address"},{"type":"uint256[]","name":"ids_","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts_","internalType":"uint256[]"},{"type":"bytes","name":"data_","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeBatchTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransfer","inputs":[{"type":"address","name":"to_","internalType":"address"},{"type":"uint256","name":"id_","internalType":"uint256"},{"type":"uint256","name":"amount_","internalType":"uint256"},{"type":"bytes","name":"data_","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendBatchFrom","inputs":[{"type":"address","name":"_from","internalType":"address"},{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"bytes","name":"_toAddress","internalType":"bytes"},{"type":"uint256[]","name":"_tokenIds","internalType":"uint256[]"},{"type":"uint256[]","name":"_amounts","internalType":"uint256[]"},{"type":"address","name":"_refundAddress","internalType":"address payable"},{"type":"address","name":"_zroPaymentAddress","internalType":"address"},{"type":"bytes","name":"_adapterParams","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendFrom","inputs":[{"type":"address","name":"_from","internalType":"address"},{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"bytes","name":"_toAddress","internalType":"bytes"},{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_refundAddress","internalType":"address payable"},{"type":"address","name":"_zroPaymentAddress","internalType":"address"},{"type":"bytes","name":"_adapterParams","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setConfig","inputs":[{"type":"uint16","name":"_version","internalType":"uint16"},{"type":"uint16","name":"_chainId","internalType":"uint16"},{"type":"uint256","name":"_configType","internalType":"uint256"},{"type":"bytes","name":"_config","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinDstGas","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"uint16","name":"_packetType","internalType":"uint16"},{"type":"uint256","name":"_minGas","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPayloadSizeLimit","inputs":[{"type":"uint16","name":"_dstChainId","internalType":"uint16"},{"type":"uint256","name":"_size","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPrecrime","inputs":[{"type":"address","name":"_precrime","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setReceiveVersion","inputs":[{"type":"uint16","name":"_version","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSendVersion","inputs":[{"type":"uint16","name":"_version","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTrustedRemote","inputs":[{"type":"uint16","name":"_remoteChainId","internalType":"uint16"},{"type":"bytes","name":"_path","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTrustedRemoteAddress","inputs":[{"type":"uint16","name":"_remoteChainId","internalType":"uint16"},{"type":"bytes","name":"_remoteAddress","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setURI","inputs":[{"type":"string","name":"newBaseUri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setUseCustomAdapterParams","inputs":[{"type":"bool","name":"_useCustomAdapterParams","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"switchLinkageRoot","inputs":[{"type":"address","name":"newRoot","internalType":"contract ILinkageRoot"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"trustedRemoteLookup","inputs":[{"type":"uint16","name":"","internalType":"uint16"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"uri","inputs":[{"type":"uint256","name":"tokenId_","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"useCustomAdapterParams","inputs":[]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b5060408051808201909152600881526768747470733a2f2f60c01b60208201526200003c816200004d565b50620000476200005f565b62000291565b60086200005b8282620001c5565b5050565b600954610100900460ff1615620000cc5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60095460ff908116146200011e576009805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200014b57607f821691505b6020821081036200016c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001c057600081815260208120601f850160051c810160208610156200019b5750805b601f850160051c820191505b81811015620001bc57828155600101620001a7565b5050505b505050565b81516001600160401b03811115620001e157620001e162000120565b620001f981620001f2845462000136565b8462000172565b602080601f831160018114620002315760008415620002185750858301515b600019600386901b1c1916600185901b178555620001bc565b600085815260208120601f198616915b82811015620002625788860151825594840194600190910190840162000241565b5085821015620002815787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61597e80620002a16000396000f3fe60806040526004361061038a5760003560e01c806366ad5c8a116101dc578063b353aaa711610102578063df2a5b3b116100a0578063ed629c5c1161006f578063ed629c5c14610b1c578063f242432a14610b36578063f5417e4514610b56578063f5ecbdbc14610b7857600080fd5b8063df2a5b3b14610a73578063e985e9c514610a93578063eab45d9c14610adc578063eb8d72b714610afc57600080fd5b8063c4461834116100dc578063c446183414610a0a578063cbed8b9c14610a20578063d1deba1f14610a40578063d547741f14610a5357600080fd5b8063b353aaa7146109aa578063baf3292d146109ca578063bf3fcdf7146109ea57600080fd5b806395d89b411161017a578063a6c3d16511610149578063a6c3d16514610935578063ae28b68c14610955578063af3fb21c14610975578063b25356631461098a57600080fd5b806395d89b41146108c55780639f38369a146108f5578063a217fddf146106ec578063a22cb4651461091557600080fd5b80638608e5f8116101b65780638608e5f8146108185780638cfd8f5c1461084d57806391d1485414610885578063950c8a74146108a557600080fd5b806366ad5c8a146107b85780637533d788146107d85780637ab4339d146107f857600080fd5b80632eb2c2d6116102c15780633f1f4fa41161025f5780634db8226a1161022e5780634db8226a146107145780634e1273f4146107275780635b8c41e61461075457806363799713146107a357600080fd5b80633f1f4fa41461069f57806342d65a8d146106cc57806344770515146106ec5780634ab4e6871461070157600080fd5b806336568abe1161029b57806336568abe14610612578063368b2842146106325780633afcad14146106525780633d8b38f61461067f57600080fd5b80632eb2c2d6146105b25780632f2ff15d146105d25780632fdacd9b146105f257600080fd5b80630e89341c1161032e57806317538e4a1161030857806317538e4a146105225780632332aa6714610542578063248a9ca31461056257806325dc7ff61461059257600080fd5b80630e89341c146104ba57806310ddb137146104da578063149e3e1f146104fa57600080fd5b806302fe53051161036a57806302fe53051461041457806306fdde031461043457806307e0db171461047a5780630df374831461049a57600080fd5b80621d35671461038f578062fdd58e146103b157806301ffc9a7146103e4575b600080fd5b34801561039b57600080fd5b506103af6103aa36600461400e565b610b98565b005b3480156103bd57600080fd5b506103d16103cc3660046140c1565b610db4565b6040519081526020015b60405180910390f35b3480156103f057600080fd5b506104046103ff366004614103565b610e4a565b60405190151581526020016103db565b34801561042057600080fd5b506103af61042f3660046141e5565b610e8a565b34801561044057600080fd5b5061046d6040518060400160405280600d81526020016c135a5b9d195c995cdd08139195609a1b81525081565b6040516103db9190614271565b34801561048657600080fd5b506103af610495366004614284565b610ed9565b3480156104a657600080fd5b506103af6104b536600461429f565b610f48565b3480156104c657600080fd5b5061046d6104d53660046142bb565b610f69565b3480156104e657600080fd5b506103af6104f5366004614284565b610fa4565b34801561050657600080fd5b5061050f600281565b60405161ffff90911681526020016103db565b34801561052e57600080fd5b506103af61053d3660046142d4565b610fe2565b34801561054e57600080fd5b506103af61055d3660046143cb565b61100c565b34801561056e57600080fd5b506103d161057d3660046142bb565b6000908152600a602052604090206001015490565b34801561059e57600080fd5b506103af6105ad366004614465565b611184565b3480156105be57600080fd5b506103af6105cd366004614482565b6112b9565b3480156105de57600080fd5b506103af6105ed36600461452f565b6112fe565b3480156105fe57600080fd5b506103af61060d36600461455f565b611323565b34801561061e57600080fd5b506103af61062d36600461452f565b6113c1565b34801561063e57600080fd5b506103af61064d3660046145bf565b61143f565b34801561065e57600080fd5b50610667611452565b6040516001600160a01b0390911681526020016103db565b34801561068b57600080fd5b5061040461069a36600461464d565b61148a565b3480156106ab57600080fd5b506103d16106ba366004614284565b60036020526000908152604090205481565b3480156106d857600080fd5b506103af6106e736600461464d565b611556565b3480156106f857600080fd5b506103d1600081565b6103af61070f36600461469f565b6115c2565b6103af61072236600461478e565b6115dc565b34801561073357600080fd5b50610747610742366004614834565b6115fc565b6040516103db919061493b565b34801561076057600080fd5b506103d161076f36600461494e565b6005602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b3480156107af57600080fd5b506103d1611725565b3480156107c457600080fd5b506103af6107d336600461400e565b61173b565b3480156107e457600080fd5b5061046d6107f3366004614284565b61180f565b34801561080457600080fd5b506103af6108133660046149ab565b6118a9565b34801561082457600080fd5b50610838610833366004614a01565b611a1a565b604080519283526020830191909152016103db565b34801561085957600080fd5b506103d1610868366004614a97565b600260209081526000928352604080842090915290825290205481565b34801561089157600080fd5b506104046108a036600461452f565b611a4a565b3480156108b157600080fd5b50600454610667906001600160a01b031681565b3480156108d157600080fd5b5061046d604051806040016040528060048152602001631353919560e21b81525081565b34801561090157600080fd5b5061046d610910366004614284565b611a75565b34801561092157600080fd5b506103af610930366004614aca565b611b8b565b34801561094157600080fd5b506103af61095036600461464d565b611b96565b34801561096157600080fd5b506103af610970366004614af6565b611c14565b34801561098157600080fd5b5061050f600181565b34801561099657600080fd5b506108386109a5366004614b4c565b611c21565b3480156109b657600080fd5b50600054610667906001600160a01b031681565b3480156109d657600080fd5b506103af6109e5366004614465565b611ce2565b3480156109f657600080fd5b506103af610a05366004614465565b611da7565b348015610a1657600080fd5b506103d161271081565b348015610a2c57600080fd5b506103af610a3b366004614be8565b611ea4565b6103af610a4e36600461400e565b611f1f565b348015610a5f57600080fd5b506103af610a6e36600461452f565b612135565b348015610a7f57600080fd5b506103af610a8e366004614c56565b61215a565b348015610a9f57600080fd5b50610404610aae366004614c92565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610ae857600080fd5b506103af610af7366004614cc0565b61220e565b348015610b0857600080fd5b506103af610b1736600461464d565b612259565b348015610b2857600080fd5b50600c546104049060ff1681565b348015610b4257600080fd5b506103af610b51366004614cdb565b6122b5565b348015610b6257600080fd5b506103d160008051602061592983398151915281565b348015610b8457600080fd5b5061046d610b93366004614d43565b6122fa565b6000546001600160a01b0316336001600160a01b031614610c005760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff861660009081526001602052604081208054610c1e90614d90565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4a90614d90565b8015610c975780601f10610c6c57610100808354040283529160200191610c97565b820191906000526020600020905b815481529060010190602001808311610c7a57829003601f168201915b50505050509050805186869050148015610cb2575060008151115b8015610cda575080516020820120604051610cd09088908890614dca565b6040518091039020145b610d355760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b6064820152608401610bf7565b610dab8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061238d92505050565b50505050505050565b60006001600160a01b038316610e1f5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b6064820152608401610bf7565b5060008181526006602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216639d21323f60e01b1480610e7b57506001600160e01b031982166301ffc9a760e01b145b80610e445750610e4482612406565b6000610e958161242b565b610e9e82612438565b7fdb26230ffa9e2bd79c063acaff0a79b0926186d7edcaf06f306658ae2472c42782604051610ecd9190614271565b60405180910390a15050565b610ee3600061242b565b6000546040516307e0db1760e01b815261ffff831660048201526001600160a01b03909116906307e0db17906024015b600060405180830381600087803b158015610f2d57600080fd5b505af1158015610f41573d6000803e3d6000fd5b5050505050565b610f52600061242b565b61ffff909116600090815260036020526040902055565b6060610f7482612444565b610f7d836124d8565b604051602001610f8e929190614dda565b6040516020818303038152906040529050919050565b610fae600061242b565b6000546040516310ddb13760e01b815261ffff831660048201526001600160a01b03909116906310ddb13790602401610f13565b600080546001600160a01b0319166001600160a01b03831617905561100783836118a9565b505050565b6000805160206159298339815191526110248161242b565b8351825114604051806040016040528060048152602001634534313960e01b815250906110645760405162461bcd60e51b8152600401610bf79190614271565b50600084516001600160401b0381111561108057611080614120565b6040519080825280602002602001820160405280156110a9578160200160208202803683370190505b50905060005b8551811015611104576110c6600b80546001019055565b60006110d1600b5490565b9050808383815181106110e6576110e6614e19565b602090810291909101015250806110fc81614e45565b9150506110af565b506111118682878761256a565b6111196126c5565b6001600160a01b031663acb69f52878388876040518563ffffffff1660e01b815260040161114a9493929190614e5e565b600060405180830381600087803b15801561116457600080fd5b505af1158015611178573d6000803e3d6000fd5b50505050505050505050565b6040805180820190915260048152634533323960e01b60208201526001600160a01b0382166111c65760405162461bcd60e51b8152600401610bf79190614271565b507fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf80546001600160a01b03908116908316810361120357505050565b6001600160a01b038116158061122157506001600160a01b03811633145b604051806040016040528060048152602001632298981960e11b8152509061125c5760405162461bcd60e51b8152600401610bf79190614271565b5081546001600160a01b0319166001600160a01b0384811691821784556040805192835290831660208301527f0a3a2d206ef02a769e7aaad7c9fb6d95dc9033159cd6ae7aaae65223fc32171691015b60405180910390a1505050565b6001600160a01b0385163314806112d557506112d58533610aae565b6112f15760405162461bcd60e51b8152600401610bf790614eb3565b610f418585858585612730565b6000828152600a60205260409020600101546113198161242b565b61100783836128d5565b60008051602061592983398151915261133b8161242b565b611349600b80546001019055565b6000611354600b5490565b90506113628682878761295b565b82156113b9576113706126c5565b6001600160a01b031663acb69f528761138884612a3d565b61139189612a3d565b61139a88612a3d565b6040518563ffffffff1660e01b815260040161114a9493929190614e5e565b505050505050565b6001600160a01b03811633146114315760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610bf7565b61143b8282612a88565b5050565b61144c33858585856112b9565b50505050565b60006114857fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf546001600160a01b031690565b905090565b61ffff8316600090815260016020526040812080548291906114ab90614d90565b80601f01602080910402602001604051908101604052809291908181526020018280546114d790614d90565b80156115245780601f106114f957610100808354040283529160200191611524565b820191906000526020600020905b81548152906001019060200180831161150757829003601f168201915b50505050509050838360405161153b929190614dca565b60405180910390208180519060200120149150509392505050565b611560600061242b565b6000546040516342d65a8d60e01b81526001600160a01b03909116906342d65a8d9061159490869086908690600401614f2a565b600060405180830381600087803b1580156115ae57600080fd5b505af1158015610dab573d6000803e3d6000fd5b6115d28888888888888888612aef565b5050505050505050565b6115d28888886115eb89612a3d565b6115f489612a3d565b888888612aef565b606081518351146116615760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610bf7565b600083516001600160401b0381111561167c5761167c614120565b6040519080825280602002602001820160405280156116a5578160200160208202803683370190505b50905060005b845181101561171d576116f08582815181106116c9576116c9614e19565b60200260200101518583815181106116e3576116e3614e19565b6020026020010151610db4565b82828151811061170257611702614e19565b602090810291909101015261171681614e45565b90506116ab565b509392505050565b6000611730600b5490565b611485906001614f48565b3330146117995760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b6064820152608401610bf7565b6113b98686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f890181900481028201810190925287815289935091508790879081908401838280828437600092019190915250612cdb92505050565b6001602052600090815260409020805461182890614d90565b80601f016020809104026020016040519081016040528092919081815260200182805461185490614d90565b80156118a15780601f10611876576101008083540402835291602001916118a1565b820191906000526020600020905b81548152906001019060200180831161188457829003601f168201915b505050505081565b600954610100900460ff16158080156118c95750600954600160ff909116105b806118e35750303b1580156118e3575060095460ff166001145b6119465760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610bf7565b6009805460ff191660011790558015611969576009805461ff0019166101001790555b6040805180820190915260048152634534303560e01b60208201526001600160a01b0383166119ab5760405162461bcd60e51b8152600401610bf79190614271565b506119b76000836128d5565b6119cf600080516020615929833981519152836128d5565b6119d883612438565b8015611007576009805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016112ac565b600080611a3b8888611a2b89612a3d565b611a3489612a3d565b8888611c21565b91509150965096945050505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61ffff8116600090815260016020526040812080546060929190611a9890614d90565b80601f0160208091040260200160405190810160405280929190818152602001828054611ac490614d90565b8015611b115780601f10611ae657610100808354040283529160200191611b11565b820191906000526020600020905b815481529060010190602001808311611af457829003601f168201915b505050505090508051600003611b695760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152606401610bf7565b611b84600060148351611b7c9190614f5b565b839190612e2d565b9392505050565b61143b338383612f3a565b611ba0600061242b565b818130604051602001611bb593929190614f6e565b60408051601f1981840301815291815261ffff8516600090815260016020522090611be09082614fda565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8383836040516112ac93929190614f2a565b61144c33858585856122b5565b6000806000611c2f8761301a565b9050600088888389604051602001611c4a9493929190615099565b60408051601f198184030181529082905260005463040a7bb160e41b83529092506001600160a01b0316906340a7bb1090611c91908d90309086908c908c906004016150d2565b6040805180830381865afa158015611cad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd19190615126565b935093505050965096945050505050565b611cec600061242b565b6001600160a01b038116611d525760405162461bcd60e51b815260206004820152602760248201527f4c7a4170703a207072656372696d652063616e206e6f74206265207a65726f206044820152666164647265737360c81b6064820152608401610bf7565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b906020015b60405180910390a150565b611db1600061242b565b6040805180820190915260048152634534303560e01b60208201526001600160a01b038216611df35760405162461bcd60e51b8152600401610bf79190614271565b50600054604080518082019091526004815263229a181960e11b6020820152906001600160a01b031615611e3a5760405162461bcd60e51b8152600401610bf79190614271565b50600054604080516001600160a01b03928316815291831660208301527f78eb7c757af523b9d0af9093bbcaa92f3defbf615c6052169e60e322cb048abe910160405180910390a1600080546001600160a01b0319166001600160a01b0392909216919091179055565b611eae600061242b565b6000546040516332fb62e760e21b81526001600160a01b039091169063cbed8b9c90611ee6908890889088908890889060040161514a565b600060405180830381600087803b158015611f0057600080fd5b505af1158015611f14573d6000803e3d6000fd5b505050505050505050565b61ffff86166000908152600560205260408082209051611f429088908890614dca565b90815260408051602092819003830190206001600160401b03871660009081529252902054905080611fc25760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b6064820152608401610bf7565b808383604051611fd3929190614dca565b6040518091039020146120325760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b6064820152608401610bf7565b61ffff871660009081526005602052604080822090516120559089908990614dca565b90815260408051602092819003830181206001600160401b038916600090815290845282902093909355601f880182900482028301820190528682526120ed918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250612cdb92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e58787878785604051612124959493929190615178565b60405180910390a150505050505050565b6000828152600a60205260409020600101546121508161242b565b6110078383612a88565b612164600061242b565b600081116121ac5760405162461bcd60e51b81526020600482015260156024820152744c7a4170703a20696e76616c6964206d696e47617360581b6044820152606401610bf7565b61ffff83811660008181526002602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016112ac565b612218600061242b565b600c805460ff19168215159081179091556040519081527f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a490602001611d9c565b612263600061242b565b61ffff831660009081526001602052604090206122818284836151b3565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8383836040516112ac93929190614f2a565b6001600160a01b0385163314806122d157506122d18533610aae565b6122ed5760405162461bcd60e51b8152600401610bf790614eb3565b610f418585858585613134565b600054604051633d7b2f6f60e21b815261ffff808716600483015285166024820152306044820152606481018390526060916001600160a01b03169063f5ecbdbc90608401600060405180830381865afa15801561235c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261238491908101906152c1565b95945050505050565b6000806123f05a60966366ad5c8a60e01b898989896040516024016123b594939291906152f5565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915230929190613265565b91509150816113b9576113b986868686856132ef565b60006001600160e01b031982166319abbbbb60e11b1480610e445750610e448261338c565b61243581336133b1565b50565b600861143b8282614fda565b60606008805461245390614d90565b80601f016020809104026020016040519081016040528092919081815260200182805461247f90614d90565b80156124cc5780601f106124a1576101008083540402835291602001916124cc565b820191906000526020600020905b8154815290600101906020018083116124af57829003601f168201915b50505050509050919050565b606060006124e58361340a565b60010190506000816001600160401b0381111561250457612504614120565b6040519080825280601f01601f19166020018201604052801561252e576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461253857509392505050565b6001600160a01b0384166125905760405162461bcd60e51b8152600401610bf790615333565b81518351146125b15760405162461bcd60e51b8152600401610bf790615374565b336125c1816000878787876134e2565b60005b845181101561265d578381815181106125df576125df614e19565b6020026020010151600660008784815181106125fd576125fd614e19565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546126459190614f48565b9091555081905061265581614e45565b9150506125c4565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516126ae9291906153bc565b60405180910390a4610f418160008787878761352a565b60006126cf611452565b6001600160a01b03166311a259076040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148591906153e1565b81518351146127515760405162461bcd60e51b8152600401610bf790615374565b6001600160a01b0384166127775760405162461bcd60e51b8152600401610bf7906153fe565b336127868187878787876134e2565b60005b845181101561286f5760008582815181106127a6576127a6614e19565b6020026020010151905060008583815181106127c4576127c4614e19565b60209081029190910181015160008481526006835260408082206001600160a01b038e1683529093529190912054909150818110156128155760405162461bcd60e51b8152600401610bf790615443565b60008381526006602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612854908490614f48565b925050819055505050508061286890614e45565b9050612789565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516128bf9291906153bc565b60405180910390a46113b981878787878761352a565b6128df8282611a4a565b61143b576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556129173390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b0384166129815760405162461bcd60e51b8152600401610bf790615333565b33600061298d85612a3d565b9050600061299a85612a3d565b90506129ab836000898585896134e2565b60008681526006602090815260408083206001600160a01b038b168452909152812080548792906129dd908490614f48565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610dab83600089898989613685565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612a7757612a77614e19565b602090810291909101015292915050565b612a928282611a4a565b1561143b576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000612afa8661301a565b9050612b0a89898989858a613740565b600087878388604051602001612b239493929190615099565b60405160208183030381529060405290508651600103612c2857600c5460ff1615612b5b57612b568960018560006137cc565b612b7a565b825115612b7a5760405162461bcd60e51b8152600401610bf79061548d565b87604051612b8891906154d1565b60405180910390208a6001600160a01b03168a61ffff167f968b0d61ebcf43e5d76ed87bd2c4ee2f22b4969b9f4ca49e3373c025eddd5eeb8a600081518110612bd357612bd3614e19565b60200260200101518a600081518110612bee57612bee614e19565b6020026020010151604051612c0d929190918252602082015260400190565b60405180910390a4612c238982878787346138ab565b611178565b60018751111561117857600c5460ff1615612c5057612c4b8960028560006137cc565b612c6f565b825115612c6f5760405162461bcd60e51b8152600401610bf79061548d565b87604051612c7d91906154d1565b60405180910390208a6001600160a01b03168a61ffff167fddd15f7cfbd674ac2096d598f1650367f8a8bd72b4e3abd85591099ea3b57e338a8a604051612cc59291906153bc565b60405180910390a46111788982878787346138ab565b60008060008084806020019051810190612cf59190615553565b601484015193975091955093509150612d118982868686613a34565b8351600103612dba57806001600160a01b031688604051612d3291906154d1565b60405180910390208a61ffff167f1bf64e58d19fc43de4c44b3d1bb1fae313979af831a7a39f3297564294329f0f87600081518110612d7357612d73614e19565b602002602001015186600081518110612d8e57612d8e614e19565b6020026020010151604051612dad929190918252602082015260400190565b60405180910390a4611f14565b600184511115611f1457806001600160a01b031688604051612ddc91906154d1565b60405180910390208a61ffff167f1ae08edbbcd7baa8d064835de8593ce16b313414525ac89534e349f4da7926e48786604051612e1a9291906153bc565b60405180910390a4505050505050505050565b606081612e3b81601f614f48565b1015612e7a5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610bf7565b612e848284614f48565b84511015612ec85760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610bf7565b606082158015612ee75760405191506000825260208201604052612f31565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612f20578051835260209283019201612f08565b5050858452601f01601f1916604052505b50949350505050565b816001600160a01b0316836001600160a01b031603612fad5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610bf7565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6060600082516001600160401b0381111561303757613037614120565b604051908082528060200260200182016040528015613060578160200160208202803683370190505b50905060005b835181101561312d57613077613a88565b6001600160a01b031663649e705f85838151811061309757613097614e19565b60200260200101516040518263ffffffff1660e01b81526004016130bd91815260200190565b602060405180830381865afa1580156130da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130fe91906155f3565b82828151811061311057613110614e19565b60209081029190910101528061312581614e45565b915050613066565b5092915050565b6001600160a01b03841661315a5760405162461bcd60e51b8152600401610bf7906153fe565b33600061316685612a3d565b9050600061317385612a3d565b90506131838389898585896134e2565b60008681526006602090815260408083206001600160a01b038c168452909152902054858110156131c65760405162461bcd60e51b8152600401610bf790615443565b60008781526006602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290613205908490614f48565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611f14848a8a8a8a8a613685565b6000606060008060008661ffff166001600160401b0381111561328a5761328a614120565b6040519080825280601f01601f1916602001820160405280156132b4576020820181803683370190505b50905060008087516020890160008d8df191503d9250868311156132d6578692505b828152826000602083013e909890975095505050505050565b8180519060200120600560008761ffff1661ffff1681526020019081526020016000208560405161332091906154d1565b9081526040805191829003602090810183206001600160401b0388166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061337d908790879087908790879061560c565b60405180910390a15050505050565b60006001600160e01b03198216639d21323f60e01b1480610e445750610e4482613a92565b6133bb8282611a4a565b61143b576133c881613ab7565b6133d3836020613ac9565b6040516020016133e492919061565e565b60408051601f198184030181529082905262461bcd60e51b8252610bf791600401614271565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106134495772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613475576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061349357662386f26fc10000830492506010015b6305f5e10083106134ab576305f5e100830492506008015b61271083106134bf57612710830492506004015b606483106134d1576064830492506002015b600a8310610e445760010192915050565b6001600160a01b038516156113b9576134f96126c5565b6001600160a01b03166388173e1c868686866040518563ffffffff1660e01b815260040161114a94939291906156d3565b6001600160a01b0384163b156113b95760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061356e9089908990889088908890600401615711565b6020604051808303816000875af19250505080156135a9575060408051601f3d908101601f191682019092526135a69181019061574f565b60015b613655576135b561576c565b806308c379a0036135ee57506135c9615788565b806135d457506135f0565b8060405162461bcd60e51b8152600401610bf79190614271565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610bf7565b6001600160e01b0319811663bc197c8160e01b14610dab5760405162461bcd60e51b8152600401610bf790615811565b6001600160a01b0384163b156113b95760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906136c99089908990889088908890600401615859565b6020604051808303816000875af1925050508015613704575060408051601f3d908101601f191682019092526137019181019061574f565b60015b613710576135b561576c565b6001600160e01b0319811663f23a6e6160e01b14610dab5760405162461bcd60e51b8152600401610bf790615811565b336001600160a01b03871681148061375d575061375d8782610aae565b6137c15760405162461bcd60e51b815260206004820152602f60248201527f4f4e4654313135353a2073656e642063616c6c6572206973206e6f74206f776e60448201526e195c881b9bdc88185c1c1c9bdd9959608a1b6064820152608401610bf7565b610dab878584613c64565b60006137d783613e7b565b61ffff808716600090815260026020908152604080832093891683529290529081205491925090613809908490614f48565b90506000811161385b5760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152606401610bf7565b808210156113b95760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152606401610bf7565b61ffff8616600090815260016020526040812080546138c990614d90565b80601f01602080910402602001604051908101604052809291908181526020018280546138f590614d90565b80156139425780601f1061391757610100808354040283529160200191613942565b820191906000526020600020905b81548152906001019060200180831161392557829003601f168201915b5050505050905080516000036139b35760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b6064820152608401610bf7565b6139be878751613ed7565b60005460405162c5803160e81b81526001600160a01b039091169063c58031009084906139f9908b9086908c908c908c908c90600401615893565b6000604051808303818588803b158015613a1257600080fd5b505af1158015613a26573d6000803e3d6000fd5b505050505050505050505050565b613a4f8484836040518060200160405280600081525061256a565b613a576126c5565b6001600160a01b031663acb69f52858584866040518563ffffffff1660e01b8152600401611ee69493929190614e5e565b60006114856126c5565b60006001600160e01b03198216637965db0b60e01b1480610e445750610e4482613f48565b6060610e446001600160a01b03831660145b60606000613ad88360026158fa565b613ae3906002614f48565b6001600160401b03811115613afa57613afa614120565b6040519080825280601f01601f191660200182016040528015613b24576020820181803683370190505b509050600360fc1b81600081518110613b3f57613b3f614e19565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613b6e57613b6e614e19565b60200101906001600160f81b031916908160001a9053506000613b928460026158fa565b613b9d906001614f48565b90505b6001811115613c15576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613bd157613bd1614e19565b1a60f81b828281518110613be757613be7614e19565b60200101906001600160f81b031916908160001a90535060049490941c93613c0e81615911565b9050613ba0565b508315611b845760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610bf7565b6001600160a01b038316613cc65760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610bf7565b8051825114613ce75760405162461bcd60e51b8152600401610bf790615374565b6000339050613d0a818560008686604051806020016040528060008152506134e2565b60005b8351811015613e0e576000848281518110613d2a57613d2a614e19565b602002602001015190506000848381518110613d4857613d48614e19565b60209081029190910181015160008481526006835260408082206001600160a01b038c168352909352919091205490915081811015613dd55760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610bf7565b60009283526006602090815260408085206001600160a01b038b1686529091529092209103905580613e0681614e45565b915050613d0d565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613e5f9291906153bc565b60405180910390a460408051602081019091526000905261144c565b6000602282511015613ecf5760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152606401610bf7565b506022015190565b61ffff821660009081526003602052604081205490819003613ef857506127105b808211156110075760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152606401610bf7565b60006001600160e01b03198216636cdb3d1360e11b1480613f7957506001600160e01b031982166303a24d0760e21b145b80610e4457506301ffc9a760e01b6001600160e01b0319831614610e44565b803561ffff81168114613faa57600080fd5b919050565b60008083601f840112613fc157600080fd5b5081356001600160401b03811115613fd857600080fd5b602083019150836020828501011115613ff057600080fd5b9250929050565b80356001600160401b0381168114613faa57600080fd5b6000806000806000806080878903121561402757600080fd5b61403087613f98565b955060208701356001600160401b038082111561404c57600080fd5b6140588a838b01613faf565b909750955085915061406c60408a01613ff7565b9450606089013591508082111561408257600080fd5b5061408f89828a01613faf565b979a9699509497509295939492505050565b6001600160a01b038116811461243557600080fd5b8035613faa816140a1565b600080604083850312156140d457600080fd5b82356140df816140a1565b946020939093013593505050565b6001600160e01b03198116811461243557600080fd5b60006020828403121561411557600080fd5b8135611b84816140ed565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b038111828210171561415b5761415b614120565b6040525050565b60006001600160401b0382111561417b5761417b614120565b50601f01601f191660200190565b600082601f83011261419a57600080fd5b81356141a581614162565b6040516141b28282614136565b8281528560208487010111156141c757600080fd5b82602086016020830137600092810160200192909252509392505050565b6000602082840312156141f757600080fd5b81356001600160401b0381111561420d57600080fd5b61421984828501614189565b949350505050565b60005b8381101561423c578181015183820152602001614224565b50506000910152565b6000815180845261425d816020860160208601614221565b601f01601f19169290920160200192915050565b602081526000611b846020830184614245565b60006020828403121561429657600080fd5b611b8482613f98565b600080604083850312156142b257600080fd5b6140df83613f98565b6000602082840312156142cd57600080fd5b5035919050565b6000806000606084860312156142e957600080fd5b83356001600160401b038111156142ff57600080fd5b61430b86828701614189565b935050602084013561431c816140a1565b9150604084013561432c816140a1565b809150509250925092565b60006001600160401b0382111561435057614350614120565b5060051b60200190565b600082601f83011261436b57600080fd5b8135602061437882614337565b6040516143858282614136565b83815260059390931b85018201928281019150868411156143a557600080fd5b8286015b848110156143c057803583529183019183016143a9565b509695505050505050565b600080600080608085870312156143e157600080fd5b84356143ec816140a1565b935060208501356001600160401b038082111561440857600080fd5b6144148883890161435a565b9450604087013591508082111561442a57600080fd5b61443688838901614189565b9350606087013591508082111561444c57600080fd5b506144598782880161435a565b91505092959194509250565b60006020828403121561447757600080fd5b8135611b84816140a1565b600080600080600060a0868803121561449a57600080fd5b85356144a5816140a1565b945060208601356144b5816140a1565b935060408601356001600160401b03808211156144d157600080fd5b6144dd89838a0161435a565b945060608801359150808211156144f357600080fd5b6144ff89838a0161435a565b9350608088013591508082111561451557600080fd5b5061452288828901614189565b9150509295509295909350565b6000806040838503121561454257600080fd5b823591506020830135614554816140a1565b809150509250929050565b6000806000806080858703121561457557600080fd5b8435614580816140a1565b93506020850135925060408501356001600160401b038111156145a257600080fd5b6145ae87828801614189565b949793965093946060013593505050565b600080600080608085870312156145d557600080fd5b84356145e0816140a1565b935060208501356001600160401b03808211156145fc57600080fd5b6146088883890161435a565b9450604087013591508082111561461e57600080fd5b61462a8883890161435a565b9350606087013591508082111561464057600080fd5b5061445987828801614189565b60008060006040848603121561466257600080fd5b61466b84613f98565b925060208401356001600160401b0381111561468657600080fd5b61469286828701613faf565b9497909650939450505050565b600080600080600080600080610100898b0312156146bc57600080fd5b6146c5896140b6565b97506146d360208a01613f98565b965060408901356001600160401b03808211156146ef57600080fd5b6146fb8c838d01614189565b975060608b013591508082111561471157600080fd5b61471d8c838d0161435a565b965060808b013591508082111561473357600080fd5b61473f8c838d0161435a565b955061474d60a08c016140b6565b945061475b60c08c016140b6565b935060e08b013591508082111561477157600080fd5b5061477e8b828c01614189565b9150509295985092959890939650565b600080600080600080600080610100898b0312156147ab57600080fd5b88356147b6816140a1565b97506147c460208a01613f98565b965060408901356001600160401b03808211156147e057600080fd5b6147ec8c838d01614189565b975060608b0135965060808b0135955060a08b0135915061480c826140a1565b90935060c08a01359061481e826140a1565b90925060e08a0135908082111561477157600080fd5b6000806040838503121561484757600080fd5b82356001600160401b038082111561485e57600080fd5b818501915085601f83011261487257600080fd5b8135602061487f82614337565b60405161488c8282614136565b83815260059390931b85018201928281019150898411156148ac57600080fd5b948201945b838610156148d35785356148c4816140a1565b825294820194908201906148b1565b965050860135925050808211156148e957600080fd5b506148f68582860161435a565b9150509250929050565b600081518084526020808501945080840160005b8381101561493057815187529582019590820190600101614914565b509495945050505050565b602081526000611b846020830184614900565b60008060006060848603121561496357600080fd5b61496c84613f98565b925060208401356001600160401b0381111561498757600080fd5b61499386828701614189565b9250506149a260408501613ff7565b90509250925092565b600080604083850312156149be57600080fd5b82356001600160401b038111156149d457600080fd5b6149e085828601614189565b9250506020830135614554816140a1565b80358015158114613faa57600080fd5b60008060008060008060c08789031215614a1a57600080fd5b614a2387613f98565b955060208701356001600160401b0380821115614a3f57600080fd5b614a4b8a838b01614189565b96506040890135955060608901359450614a6760808a016149f1565b935060a0890135915080821115614a7d57600080fd5b50614a8a89828a01614189565b9150509295509295509295565b60008060408385031215614aaa57600080fd5b614ab383613f98565b9150614ac160208401613f98565b90509250929050565b60008060408385031215614add57600080fd5b8235614ae8816140a1565b9150614ac1602084016149f1565b60008060008060808587031215614b0c57600080fd5b8435614b17816140a1565b9350602085013592506040850135915060608501356001600160401b03811115614b4057600080fd5b61445987828801614189565b60008060008060008060c08789031215614b6557600080fd5b614b6e87613f98565b955060208701356001600160401b0380821115614b8a57600080fd5b614b968a838b01614189565b96506040890135915080821115614bac57600080fd5b614bb88a838b0161435a565b95506060890135915080821115614bce57600080fd5b614bda8a838b0161435a565b9450614a6760808a016149f1565b600080600080600060808688031215614c0057600080fd5b614c0986613f98565b9450614c1760208701613f98565b93506040860135925060608601356001600160401b03811115614c3957600080fd5b614c4588828901613faf565b969995985093965092949392505050565b600080600060608486031215614c6b57600080fd5b614c7484613f98565b9250614c8260208501613f98565b9150604084013590509250925092565b60008060408385031215614ca557600080fd5b8235614cb0816140a1565b91506020830135614554816140a1565b600060208284031215614cd257600080fd5b611b84826149f1565b600080600080600060a08688031215614cf357600080fd5b8535614cfe816140a1565b94506020860135614d0e816140a1565b9350604086013592506060860135915060808601356001600160401b03811115614d3757600080fd5b61452288828901614189565b60008060008060808587031215614d5957600080fd5b614d6285613f98565b9350614d7060208601613f98565b92506040850135614d80816140a1565b9396929550929360600135925050565b600181811c90821680614da457607f821691505b602082108103614dc457634e487b7160e01b600052602260045260246000fd5b50919050565b8183823760009101908152919050565b60008351614dec818460208801614221565b835190830190614e00818360208801614221565b64173539b7b760d91b9101908152600501949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614e5757614e57614e2f565b5060010190565b6001600160a01b0385168152608060208201819052600090614e8290830186614900565b8281036040840152614e948186614900565b90508281036060840152614ea88185614900565b979650505050505050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201526000612384604083018486614f01565b80820180821115610e4457610e44614e2f565b81810381811115610e4457610e44614e2f565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b601f82111561100757600081815260208120601f850160051c81016020861015614fbb5750805b601f850160051c820191505b818110156113b957828155600101614fc7565b81516001600160401b03811115614ff357614ff3614120565b615007816150018454614d90565b84614f94565b602080601f83116001811461503c57600084156150245750858301515b600019600386901b1c1916600185901b1785556113b9565b600085815260208120601f198616915b8281101561506b5788860151825594840194600190910190840161504c565b50858210156150895787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080815260006150ac6080830187614245565b82810360208401526150be8187614900565b90508281036040840152614e948186614900565b61ffff861681526001600160a01b038516602082015260a06040820181905260009061510090830186614245565b8415156060840152828103608084015261511a8185614245565b98975050505050505050565b6000806040838503121561513957600080fd5b505080516020909101519092909150565b600061ffff808816835280871660208401525084604083015260806060830152614ea8608083018486614f01565b61ffff86168152608060208201526000615196608083018688614f01565b6001600160401b0394909416604083015250606001529392505050565b6001600160401b038311156151ca576151ca614120565b6151de836151d88354614d90565b83614f94565b6000601f84116001811461521257600085156151fa5750838201355b600019600387901b1c1916600186901b178355610f41565b600083815260209020601f19861690835b828110156152435786850135825560209485019460019092019101615223565b50868210156152605760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b600082601f83011261528357600080fd5b815161528e81614162565b60405161529b8282614136565b8281528560208487010111156152b057600080fd5b612384836020830160208801614221565b6000602082840312156152d357600080fd5b81516001600160401b038111156152e957600080fd5b61421984828501615272565b61ffff851681526080602082015260006153126080830186614245565b6001600160401b03851660408401528281036060840152614ea88185614245565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b6040815260006153cf6040830185614900565b82810360208401526123848185614900565b6000602082840312156153f357600080fd5b8151611b84816140a1565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60208082526024908201527f4c7a4170703a205f61646170746572506172616d73206d75737420626520656d604082015263383a3c9760e11b606082015260800190565b600082516154e3818460208701614221565b9190910192915050565b600082601f8301126154fe57600080fd5b8151602061550b82614337565b6040516155188282614136565b83815260059390931b850182019282810191508684111561553857600080fd5b8286015b848110156143c0578051835291830191830161553c565b6000806000806080858703121561556957600080fd5b84516001600160401b038082111561558057600080fd5b61558c88838901615272565b955060208701519150808211156155a257600080fd5b6155ae888389016154ed565b945060408701519150808211156155c457600080fd5b6155d0888389016154ed565b935060608701519150808211156155e657600080fd5b50614459878288016154ed565b60006020828403121561560557600080fd5b5051919050565b61ffff8616815260a06020820152600061562960a0830187614245565b6001600160401b0386166040840152828103606084015261564a8186614245565b9050828103608084015261511a8185614245565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615696816017850160208801614221565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516156c7816028840160208801614221565b01602801949350505050565b6001600160a01b038581168252841660208201526080604082018190526000906156ff90830185614900565b8281036060840152614ea88185614900565b6001600160a01b0386811682528516602082015260a06040820181905260009061573d90830186614900565b828103606084015261564a8186614900565b60006020828403121561576157600080fd5b8151611b84816140ed565b600060033d11156157855760046000803e5060005160e01c5b90565b600060443d10156157965790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156157c557505050505090565b82850191508151818111156157dd5750505050505090565b843d87010160208285010111156157f75750505050505090565b61580660208286010187614136565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614ea890830184614245565b61ffff8716815260c0602082015260006158b060c0830188614245565b82810360408401526158c28188614245565b6001600160a01b0387811660608601528616608085015283810360a085015290506158ed8185614245565b9998505050505050505050565b8082028115828204841417610e4457610e44614e2f565b60008161592057615920614e2f565b50600019019056fe20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b2a2646970667358221220b2c090b9732f9583efb1bfc6e247b01d3e195f0cb9e93e43d5a2c2e28b63ac2964736f6c63430008110033
Deployed ByteCode
0x60806040526004361061038a5760003560e01c806366ad5c8a116101dc578063b353aaa711610102578063df2a5b3b116100a0578063ed629c5c1161006f578063ed629c5c14610b1c578063f242432a14610b36578063f5417e4514610b56578063f5ecbdbc14610b7857600080fd5b8063df2a5b3b14610a73578063e985e9c514610a93578063eab45d9c14610adc578063eb8d72b714610afc57600080fd5b8063c4461834116100dc578063c446183414610a0a578063cbed8b9c14610a20578063d1deba1f14610a40578063d547741f14610a5357600080fd5b8063b353aaa7146109aa578063baf3292d146109ca578063bf3fcdf7146109ea57600080fd5b806395d89b411161017a578063a6c3d16511610149578063a6c3d16514610935578063ae28b68c14610955578063af3fb21c14610975578063b25356631461098a57600080fd5b806395d89b41146108c55780639f38369a146108f5578063a217fddf146106ec578063a22cb4651461091557600080fd5b80638608e5f8116101b65780638608e5f8146108185780638cfd8f5c1461084d57806391d1485414610885578063950c8a74146108a557600080fd5b806366ad5c8a146107b85780637533d788146107d85780637ab4339d146107f857600080fd5b80632eb2c2d6116102c15780633f1f4fa41161025f5780634db8226a1161022e5780634db8226a146107145780634e1273f4146107275780635b8c41e61461075457806363799713146107a357600080fd5b80633f1f4fa41461069f57806342d65a8d146106cc57806344770515146106ec5780634ab4e6871461070157600080fd5b806336568abe1161029b57806336568abe14610612578063368b2842146106325780633afcad14146106525780633d8b38f61461067f57600080fd5b80632eb2c2d6146105b25780632f2ff15d146105d25780632fdacd9b146105f257600080fd5b80630e89341c1161032e57806317538e4a1161030857806317538e4a146105225780632332aa6714610542578063248a9ca31461056257806325dc7ff61461059257600080fd5b80630e89341c146104ba57806310ddb137146104da578063149e3e1f146104fa57600080fd5b806302fe53051161036a57806302fe53051461041457806306fdde031461043457806307e0db171461047a5780630df374831461049a57600080fd5b80621d35671461038f578062fdd58e146103b157806301ffc9a7146103e4575b600080fd5b34801561039b57600080fd5b506103af6103aa36600461400e565b610b98565b005b3480156103bd57600080fd5b506103d16103cc3660046140c1565b610db4565b6040519081526020015b60405180910390f35b3480156103f057600080fd5b506104046103ff366004614103565b610e4a565b60405190151581526020016103db565b34801561042057600080fd5b506103af61042f3660046141e5565b610e8a565b34801561044057600080fd5b5061046d6040518060400160405280600d81526020016c135a5b9d195c995cdd08139195609a1b81525081565b6040516103db9190614271565b34801561048657600080fd5b506103af610495366004614284565b610ed9565b3480156104a657600080fd5b506103af6104b536600461429f565b610f48565b3480156104c657600080fd5b5061046d6104d53660046142bb565b610f69565b3480156104e657600080fd5b506103af6104f5366004614284565b610fa4565b34801561050657600080fd5b5061050f600281565b60405161ffff90911681526020016103db565b34801561052e57600080fd5b506103af61053d3660046142d4565b610fe2565b34801561054e57600080fd5b506103af61055d3660046143cb565b61100c565b34801561056e57600080fd5b506103d161057d3660046142bb565b6000908152600a602052604090206001015490565b34801561059e57600080fd5b506103af6105ad366004614465565b611184565b3480156105be57600080fd5b506103af6105cd366004614482565b6112b9565b3480156105de57600080fd5b506103af6105ed36600461452f565b6112fe565b3480156105fe57600080fd5b506103af61060d36600461455f565b611323565b34801561061e57600080fd5b506103af61062d36600461452f565b6113c1565b34801561063e57600080fd5b506103af61064d3660046145bf565b61143f565b34801561065e57600080fd5b50610667611452565b6040516001600160a01b0390911681526020016103db565b34801561068b57600080fd5b5061040461069a36600461464d565b61148a565b3480156106ab57600080fd5b506103d16106ba366004614284565b60036020526000908152604090205481565b3480156106d857600080fd5b506103af6106e736600461464d565b611556565b3480156106f857600080fd5b506103d1600081565b6103af61070f36600461469f565b6115c2565b6103af61072236600461478e565b6115dc565b34801561073357600080fd5b50610747610742366004614834565b6115fc565b6040516103db919061493b565b34801561076057600080fd5b506103d161076f36600461494e565b6005602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b3480156107af57600080fd5b506103d1611725565b3480156107c457600080fd5b506103af6107d336600461400e565b61173b565b3480156107e457600080fd5b5061046d6107f3366004614284565b61180f565b34801561080457600080fd5b506103af6108133660046149ab565b6118a9565b34801561082457600080fd5b50610838610833366004614a01565b611a1a565b604080519283526020830191909152016103db565b34801561085957600080fd5b506103d1610868366004614a97565b600260209081526000928352604080842090915290825290205481565b34801561089157600080fd5b506104046108a036600461452f565b611a4a565b3480156108b157600080fd5b50600454610667906001600160a01b031681565b3480156108d157600080fd5b5061046d604051806040016040528060048152602001631353919560e21b81525081565b34801561090157600080fd5b5061046d610910366004614284565b611a75565b34801561092157600080fd5b506103af610930366004614aca565b611b8b565b34801561094157600080fd5b506103af61095036600461464d565b611b96565b34801561096157600080fd5b506103af610970366004614af6565b611c14565b34801561098157600080fd5b5061050f600181565b34801561099657600080fd5b506108386109a5366004614b4c565b611c21565b3480156109b657600080fd5b50600054610667906001600160a01b031681565b3480156109d657600080fd5b506103af6109e5366004614465565b611ce2565b3480156109f657600080fd5b506103af610a05366004614465565b611da7565b348015610a1657600080fd5b506103d161271081565b348015610a2c57600080fd5b506103af610a3b366004614be8565b611ea4565b6103af610a4e36600461400e565b611f1f565b348015610a5f57600080fd5b506103af610a6e36600461452f565b612135565b348015610a7f57600080fd5b506103af610a8e366004614c56565b61215a565b348015610a9f57600080fd5b50610404610aae366004614c92565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610ae857600080fd5b506103af610af7366004614cc0565b61220e565b348015610b0857600080fd5b506103af610b1736600461464d565b612259565b348015610b2857600080fd5b50600c546104049060ff1681565b348015610b4257600080fd5b506103af610b51366004614cdb565b6122b5565b348015610b6257600080fd5b506103d160008051602061592983398151915281565b348015610b8457600080fd5b5061046d610b93366004614d43565b6122fa565b6000546001600160a01b0316336001600160a01b031614610c005760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff861660009081526001602052604081208054610c1e90614d90565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4a90614d90565b8015610c975780601f10610c6c57610100808354040283529160200191610c97565b820191906000526020600020905b815481529060010190602001808311610c7a57829003601f168201915b50505050509050805186869050148015610cb2575060008151115b8015610cda575080516020820120604051610cd09088908890614dca565b6040518091039020145b610d355760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b6064820152608401610bf7565b610dab8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061238d92505050565b50505050505050565b60006001600160a01b038316610e1f5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b6064820152608401610bf7565b5060008181526006602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216639d21323f60e01b1480610e7b57506001600160e01b031982166301ffc9a760e01b145b80610e445750610e4482612406565b6000610e958161242b565b610e9e82612438565b7fdb26230ffa9e2bd79c063acaff0a79b0926186d7edcaf06f306658ae2472c42782604051610ecd9190614271565b60405180910390a15050565b610ee3600061242b565b6000546040516307e0db1760e01b815261ffff831660048201526001600160a01b03909116906307e0db17906024015b600060405180830381600087803b158015610f2d57600080fd5b505af1158015610f41573d6000803e3d6000fd5b5050505050565b610f52600061242b565b61ffff909116600090815260036020526040902055565b6060610f7482612444565b610f7d836124d8565b604051602001610f8e929190614dda565b6040516020818303038152906040529050919050565b610fae600061242b565b6000546040516310ddb13760e01b815261ffff831660048201526001600160a01b03909116906310ddb13790602401610f13565b600080546001600160a01b0319166001600160a01b03831617905561100783836118a9565b505050565b6000805160206159298339815191526110248161242b565b8351825114604051806040016040528060048152602001634534313960e01b815250906110645760405162461bcd60e51b8152600401610bf79190614271565b50600084516001600160401b0381111561108057611080614120565b6040519080825280602002602001820160405280156110a9578160200160208202803683370190505b50905060005b8551811015611104576110c6600b80546001019055565b60006110d1600b5490565b9050808383815181106110e6576110e6614e19565b602090810291909101015250806110fc81614e45565b9150506110af565b506111118682878761256a565b6111196126c5565b6001600160a01b031663acb69f52878388876040518563ffffffff1660e01b815260040161114a9493929190614e5e565b600060405180830381600087803b15801561116457600080fd5b505af1158015611178573d6000803e3d6000fd5b50505050505050505050565b6040805180820190915260048152634533323960e01b60208201526001600160a01b0382166111c65760405162461bcd60e51b8152600401610bf79190614271565b507fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf80546001600160a01b03908116908316810361120357505050565b6001600160a01b038116158061122157506001600160a01b03811633145b604051806040016040528060048152602001632298981960e11b8152509061125c5760405162461bcd60e51b8152600401610bf79190614271565b5081546001600160a01b0319166001600160a01b0384811691821784556040805192835290831660208301527f0a3a2d206ef02a769e7aaad7c9fb6d95dc9033159cd6ae7aaae65223fc32171691015b60405180910390a1505050565b6001600160a01b0385163314806112d557506112d58533610aae565b6112f15760405162461bcd60e51b8152600401610bf790614eb3565b610f418585858585612730565b6000828152600a60205260409020600101546113198161242b565b61100783836128d5565b60008051602061592983398151915261133b8161242b565b611349600b80546001019055565b6000611354600b5490565b90506113628682878761295b565b82156113b9576113706126c5565b6001600160a01b031663acb69f528761138884612a3d565b61139189612a3d565b61139a88612a3d565b6040518563ffffffff1660e01b815260040161114a9493929190614e5e565b505050505050565b6001600160a01b03811633146114315760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610bf7565b61143b8282612a88565b5050565b61144c33858585856112b9565b50505050565b60006114857fc34f336ef21a27e6cdbefdb1e201a57e5e6cb9d267e34fc3134d22f9decc8bbf546001600160a01b031690565b905090565b61ffff8316600090815260016020526040812080548291906114ab90614d90565b80601f01602080910402602001604051908101604052809291908181526020018280546114d790614d90565b80156115245780601f106114f957610100808354040283529160200191611524565b820191906000526020600020905b81548152906001019060200180831161150757829003601f168201915b50505050509050838360405161153b929190614dca565b60405180910390208180519060200120149150509392505050565b611560600061242b565b6000546040516342d65a8d60e01b81526001600160a01b03909116906342d65a8d9061159490869086908690600401614f2a565b600060405180830381600087803b1580156115ae57600080fd5b505af1158015610dab573d6000803e3d6000fd5b6115d28888888888888888612aef565b5050505050505050565b6115d28888886115eb89612a3d565b6115f489612a3d565b888888612aef565b606081518351146116615760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610bf7565b600083516001600160401b0381111561167c5761167c614120565b6040519080825280602002602001820160405280156116a5578160200160208202803683370190505b50905060005b845181101561171d576116f08582815181106116c9576116c9614e19565b60200260200101518583815181106116e3576116e3614e19565b6020026020010151610db4565b82828151811061170257611702614e19565b602090810291909101015261171681614e45565b90506116ab565b509392505050565b6000611730600b5490565b611485906001614f48565b3330146117995760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b6064820152608401610bf7565b6113b98686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f890181900481028201810190925287815289935091508790879081908401838280828437600092019190915250612cdb92505050565b6001602052600090815260409020805461182890614d90565b80601f016020809104026020016040519081016040528092919081815260200182805461185490614d90565b80156118a15780601f10611876576101008083540402835291602001916118a1565b820191906000526020600020905b81548152906001019060200180831161188457829003601f168201915b505050505081565b600954610100900460ff16158080156118c95750600954600160ff909116105b806118e35750303b1580156118e3575060095460ff166001145b6119465760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610bf7565b6009805460ff191660011790558015611969576009805461ff0019166101001790555b6040805180820190915260048152634534303560e01b60208201526001600160a01b0383166119ab5760405162461bcd60e51b8152600401610bf79190614271565b506119b76000836128d5565b6119cf600080516020615929833981519152836128d5565b6119d883612438565b8015611007576009805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016112ac565b600080611a3b8888611a2b89612a3d565b611a3489612a3d565b8888611c21565b91509150965096945050505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61ffff8116600090815260016020526040812080546060929190611a9890614d90565b80601f0160208091040260200160405190810160405280929190818152602001828054611ac490614d90565b8015611b115780601f10611ae657610100808354040283529160200191611b11565b820191906000526020600020905b815481529060010190602001808311611af457829003601f168201915b505050505090508051600003611b695760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152606401610bf7565b611b84600060148351611b7c9190614f5b565b839190612e2d565b9392505050565b61143b338383612f3a565b611ba0600061242b565b818130604051602001611bb593929190614f6e565b60408051601f1981840301815291815261ffff8516600090815260016020522090611be09082614fda565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8383836040516112ac93929190614f2a565b61144c33858585856122b5565b6000806000611c2f8761301a565b9050600088888389604051602001611c4a9493929190615099565b60408051601f198184030181529082905260005463040a7bb160e41b83529092506001600160a01b0316906340a7bb1090611c91908d90309086908c908c906004016150d2565b6040805180830381865afa158015611cad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd19190615126565b935093505050965096945050505050565b611cec600061242b565b6001600160a01b038116611d525760405162461bcd60e51b815260206004820152602760248201527f4c7a4170703a207072656372696d652063616e206e6f74206265207a65726f206044820152666164647265737360c81b6064820152608401610bf7565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b906020015b60405180910390a150565b611db1600061242b565b6040805180820190915260048152634534303560e01b60208201526001600160a01b038216611df35760405162461bcd60e51b8152600401610bf79190614271565b50600054604080518082019091526004815263229a181960e11b6020820152906001600160a01b031615611e3a5760405162461bcd60e51b8152600401610bf79190614271565b50600054604080516001600160a01b03928316815291831660208301527f78eb7c757af523b9d0af9093bbcaa92f3defbf615c6052169e60e322cb048abe910160405180910390a1600080546001600160a01b0319166001600160a01b0392909216919091179055565b611eae600061242b565b6000546040516332fb62e760e21b81526001600160a01b039091169063cbed8b9c90611ee6908890889088908890889060040161514a565b600060405180830381600087803b158015611f0057600080fd5b505af1158015611f14573d6000803e3d6000fd5b505050505050505050565b61ffff86166000908152600560205260408082209051611f429088908890614dca565b90815260408051602092819003830190206001600160401b03871660009081529252902054905080611fc25760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b6064820152608401610bf7565b808383604051611fd3929190614dca565b6040518091039020146120325760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b6064820152608401610bf7565b61ffff871660009081526005602052604080822090516120559089908990614dca565b90815260408051602092819003830181206001600160401b038916600090815290845282902093909355601f880182900482028301820190528682526120ed918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250612cdb92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e58787878785604051612124959493929190615178565b60405180910390a150505050505050565b6000828152600a60205260409020600101546121508161242b565b6110078383612a88565b612164600061242b565b600081116121ac5760405162461bcd60e51b81526020600482015260156024820152744c7a4170703a20696e76616c6964206d696e47617360581b6044820152606401610bf7565b61ffff83811660008181526002602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016112ac565b612218600061242b565b600c805460ff19168215159081179091556040519081527f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a490602001611d9c565b612263600061242b565b61ffff831660009081526001602052604090206122818284836151b3565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8383836040516112ac93929190614f2a565b6001600160a01b0385163314806122d157506122d18533610aae565b6122ed5760405162461bcd60e51b8152600401610bf790614eb3565b610f418585858585613134565b600054604051633d7b2f6f60e21b815261ffff808716600483015285166024820152306044820152606481018390526060916001600160a01b03169063f5ecbdbc90608401600060405180830381865afa15801561235c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261238491908101906152c1565b95945050505050565b6000806123f05a60966366ad5c8a60e01b898989896040516024016123b594939291906152f5565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915230929190613265565b91509150816113b9576113b986868686856132ef565b60006001600160e01b031982166319abbbbb60e11b1480610e445750610e448261338c565b61243581336133b1565b50565b600861143b8282614fda565b60606008805461245390614d90565b80601f016020809104026020016040519081016040528092919081815260200182805461247f90614d90565b80156124cc5780601f106124a1576101008083540402835291602001916124cc565b820191906000526020600020905b8154815290600101906020018083116124af57829003601f168201915b50505050509050919050565b606060006124e58361340a565b60010190506000816001600160401b0381111561250457612504614120565b6040519080825280601f01601f19166020018201604052801561252e576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461253857509392505050565b6001600160a01b0384166125905760405162461bcd60e51b8152600401610bf790615333565b81518351146125b15760405162461bcd60e51b8152600401610bf790615374565b336125c1816000878787876134e2565b60005b845181101561265d578381815181106125df576125df614e19565b6020026020010151600660008784815181106125fd576125fd614e19565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546126459190614f48565b9091555081905061265581614e45565b9150506125c4565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516126ae9291906153bc565b60405180910390a4610f418160008787878761352a565b60006126cf611452565b6001600160a01b03166311a259076040518163ffffffff1660e01b8152600401602060405180830381865afa15801561270c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148591906153e1565b81518351146127515760405162461bcd60e51b8152600401610bf790615374565b6001600160a01b0384166127775760405162461bcd60e51b8152600401610bf7906153fe565b336127868187878787876134e2565b60005b845181101561286f5760008582815181106127a6576127a6614e19565b6020026020010151905060008583815181106127c4576127c4614e19565b60209081029190910181015160008481526006835260408082206001600160a01b038e1683529093529190912054909150818110156128155760405162461bcd60e51b8152600401610bf790615443565b60008381526006602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612854908490614f48565b925050819055505050508061286890614e45565b9050612789565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516128bf9291906153bc565b60405180910390a46113b981878787878761352a565b6128df8282611a4a565b61143b576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556129173390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b0384166129815760405162461bcd60e51b8152600401610bf790615333565b33600061298d85612a3d565b9050600061299a85612a3d565b90506129ab836000898585896134e2565b60008681526006602090815260408083206001600160a01b038b168452909152812080548792906129dd908490614f48565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610dab83600089898989613685565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612a7757612a77614e19565b602090810291909101015292915050565b612a928282611a4a565b1561143b576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000612afa8661301a565b9050612b0a89898989858a613740565b600087878388604051602001612b239493929190615099565b60405160208183030381529060405290508651600103612c2857600c5460ff1615612b5b57612b568960018560006137cc565b612b7a565b825115612b7a5760405162461bcd60e51b8152600401610bf79061548d565b87604051612b8891906154d1565b60405180910390208a6001600160a01b03168a61ffff167f968b0d61ebcf43e5d76ed87bd2c4ee2f22b4969b9f4ca49e3373c025eddd5eeb8a600081518110612bd357612bd3614e19565b60200260200101518a600081518110612bee57612bee614e19565b6020026020010151604051612c0d929190918252602082015260400190565b60405180910390a4612c238982878787346138ab565b611178565b60018751111561117857600c5460ff1615612c5057612c4b8960028560006137cc565b612c6f565b825115612c6f5760405162461bcd60e51b8152600401610bf79061548d565b87604051612c7d91906154d1565b60405180910390208a6001600160a01b03168a61ffff167fddd15f7cfbd674ac2096d598f1650367f8a8bd72b4e3abd85591099ea3b57e338a8a604051612cc59291906153bc565b60405180910390a46111788982878787346138ab565b60008060008084806020019051810190612cf59190615553565b601484015193975091955093509150612d118982868686613a34565b8351600103612dba57806001600160a01b031688604051612d3291906154d1565b60405180910390208a61ffff167f1bf64e58d19fc43de4c44b3d1bb1fae313979af831a7a39f3297564294329f0f87600081518110612d7357612d73614e19565b602002602001015186600081518110612d8e57612d8e614e19565b6020026020010151604051612dad929190918252602082015260400190565b60405180910390a4611f14565b600184511115611f1457806001600160a01b031688604051612ddc91906154d1565b60405180910390208a61ffff167f1ae08edbbcd7baa8d064835de8593ce16b313414525ac89534e349f4da7926e48786604051612e1a9291906153bc565b60405180910390a4505050505050505050565b606081612e3b81601f614f48565b1015612e7a5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610bf7565b612e848284614f48565b84511015612ec85760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610bf7565b606082158015612ee75760405191506000825260208201604052612f31565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612f20578051835260209283019201612f08565b5050858452601f01601f1916604052505b50949350505050565b816001600160a01b0316836001600160a01b031603612fad5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610bf7565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6060600082516001600160401b0381111561303757613037614120565b604051908082528060200260200182016040528015613060578160200160208202803683370190505b50905060005b835181101561312d57613077613a88565b6001600160a01b031663649e705f85838151811061309757613097614e19565b60200260200101516040518263ffffffff1660e01b81526004016130bd91815260200190565b602060405180830381865afa1580156130da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130fe91906155f3565b82828151811061311057613110614e19565b60209081029190910101528061312581614e45565b915050613066565b5092915050565b6001600160a01b03841661315a5760405162461bcd60e51b8152600401610bf7906153fe565b33600061316685612a3d565b9050600061317385612a3d565b90506131838389898585896134e2565b60008681526006602090815260408083206001600160a01b038c168452909152902054858110156131c65760405162461bcd60e51b8152600401610bf790615443565b60008781526006602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290613205908490614f48565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611f14848a8a8a8a8a613685565b6000606060008060008661ffff166001600160401b0381111561328a5761328a614120565b6040519080825280601f01601f1916602001820160405280156132b4576020820181803683370190505b50905060008087516020890160008d8df191503d9250868311156132d6578692505b828152826000602083013e909890975095505050505050565b8180519060200120600560008761ffff1661ffff1681526020019081526020016000208560405161332091906154d1565b9081526040805191829003602090810183206001600160401b0388166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061337d908790879087908790879061560c565b60405180910390a15050505050565b60006001600160e01b03198216639d21323f60e01b1480610e445750610e4482613a92565b6133bb8282611a4a565b61143b576133c881613ab7565b6133d3836020613ac9565b6040516020016133e492919061565e565b60408051601f198184030181529082905262461bcd60e51b8252610bf791600401614271565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106134495772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613475576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061349357662386f26fc10000830492506010015b6305f5e10083106134ab576305f5e100830492506008015b61271083106134bf57612710830492506004015b606483106134d1576064830492506002015b600a8310610e445760010192915050565b6001600160a01b038516156113b9576134f96126c5565b6001600160a01b03166388173e1c868686866040518563ffffffff1660e01b815260040161114a94939291906156d3565b6001600160a01b0384163b156113b95760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061356e9089908990889088908890600401615711565b6020604051808303816000875af19250505080156135a9575060408051601f3d908101601f191682019092526135a69181019061574f565b60015b613655576135b561576c565b806308c379a0036135ee57506135c9615788565b806135d457506135f0565b8060405162461bcd60e51b8152600401610bf79190614271565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610bf7565b6001600160e01b0319811663bc197c8160e01b14610dab5760405162461bcd60e51b8152600401610bf790615811565b6001600160a01b0384163b156113b95760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906136c99089908990889088908890600401615859565b6020604051808303816000875af1925050508015613704575060408051601f3d908101601f191682019092526137019181019061574f565b60015b613710576135b561576c565b6001600160e01b0319811663f23a6e6160e01b14610dab5760405162461bcd60e51b8152600401610bf790615811565b336001600160a01b03871681148061375d575061375d8782610aae565b6137c15760405162461bcd60e51b815260206004820152602f60248201527f4f4e4654313135353a2073656e642063616c6c6572206973206e6f74206f776e60448201526e195c881b9bdc88185c1c1c9bdd9959608a1b6064820152608401610bf7565b610dab878584613c64565b60006137d783613e7b565b61ffff808716600090815260026020908152604080832093891683529290529081205491925090613809908490614f48565b90506000811161385b5760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152606401610bf7565b808210156113b95760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152606401610bf7565b61ffff8616600090815260016020526040812080546138c990614d90565b80601f01602080910402602001604051908101604052809291908181526020018280546138f590614d90565b80156139425780601f1061391757610100808354040283529160200191613942565b820191906000526020600020905b81548152906001019060200180831161392557829003601f168201915b5050505050905080516000036139b35760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b6064820152608401610bf7565b6139be878751613ed7565b60005460405162c5803160e81b81526001600160a01b039091169063c58031009084906139f9908b9086908c908c908c908c90600401615893565b6000604051808303818588803b158015613a1257600080fd5b505af1158015613a26573d6000803e3d6000fd5b505050505050505050505050565b613a4f8484836040518060200160405280600081525061256a565b613a576126c5565b6001600160a01b031663acb69f52858584866040518563ffffffff1660e01b8152600401611ee69493929190614e5e565b60006114856126c5565b60006001600160e01b03198216637965db0b60e01b1480610e445750610e4482613f48565b6060610e446001600160a01b03831660145b60606000613ad88360026158fa565b613ae3906002614f48565b6001600160401b03811115613afa57613afa614120565b6040519080825280601f01601f191660200182016040528015613b24576020820181803683370190505b509050600360fc1b81600081518110613b3f57613b3f614e19565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613b6e57613b6e614e19565b60200101906001600160f81b031916908160001a9053506000613b928460026158fa565b613b9d906001614f48565b90505b6001811115613c15576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613bd157613bd1614e19565b1a60f81b828281518110613be757613be7614e19565b60200101906001600160f81b031916908160001a90535060049490941c93613c0e81615911565b9050613ba0565b508315611b845760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610bf7565b6001600160a01b038316613cc65760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b6064820152608401610bf7565b8051825114613ce75760405162461bcd60e51b8152600401610bf790615374565b6000339050613d0a818560008686604051806020016040528060008152506134e2565b60005b8351811015613e0e576000848281518110613d2a57613d2a614e19565b602002602001015190506000848381518110613d4857613d48614e19565b60209081029190910181015160008481526006835260408082206001600160a01b038c168352909352919091205490915081811015613dd55760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b6064820152608401610bf7565b60009283526006602090815260408085206001600160a01b038b1686529091529092209103905580613e0681614e45565b915050613d0d565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613e5f9291906153bc565b60405180910390a460408051602081019091526000905261144c565b6000602282511015613ecf5760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152606401610bf7565b506022015190565b61ffff821660009081526003602052604081205490819003613ef857506127105b808211156110075760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152606401610bf7565b60006001600160e01b03198216636cdb3d1360e11b1480613f7957506001600160e01b031982166303a24d0760e21b145b80610e4457506301ffc9a760e01b6001600160e01b0319831614610e44565b803561ffff81168114613faa57600080fd5b919050565b60008083601f840112613fc157600080fd5b5081356001600160401b03811115613fd857600080fd5b602083019150836020828501011115613ff057600080fd5b9250929050565b80356001600160401b0381168114613faa57600080fd5b6000806000806000806080878903121561402757600080fd5b61403087613f98565b955060208701356001600160401b038082111561404c57600080fd5b6140588a838b01613faf565b909750955085915061406c60408a01613ff7565b9450606089013591508082111561408257600080fd5b5061408f89828a01613faf565b979a9699509497509295939492505050565b6001600160a01b038116811461243557600080fd5b8035613faa816140a1565b600080604083850312156140d457600080fd5b82356140df816140a1565b946020939093013593505050565b6001600160e01b03198116811461243557600080fd5b60006020828403121561411557600080fd5b8135611b84816140ed565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b038111828210171561415b5761415b614120565b6040525050565b60006001600160401b0382111561417b5761417b614120565b50601f01601f191660200190565b600082601f83011261419a57600080fd5b81356141a581614162565b6040516141b28282614136565b8281528560208487010111156141c757600080fd5b82602086016020830137600092810160200192909252509392505050565b6000602082840312156141f757600080fd5b81356001600160401b0381111561420d57600080fd5b61421984828501614189565b949350505050565b60005b8381101561423c578181015183820152602001614224565b50506000910152565b6000815180845261425d816020860160208601614221565b601f01601f19169290920160200192915050565b602081526000611b846020830184614245565b60006020828403121561429657600080fd5b611b8482613f98565b600080604083850312156142b257600080fd5b6140df83613f98565b6000602082840312156142cd57600080fd5b5035919050565b6000806000606084860312156142e957600080fd5b83356001600160401b038111156142ff57600080fd5b61430b86828701614189565b935050602084013561431c816140a1565b9150604084013561432c816140a1565b809150509250925092565b60006001600160401b0382111561435057614350614120565b5060051b60200190565b600082601f83011261436b57600080fd5b8135602061437882614337565b6040516143858282614136565b83815260059390931b85018201928281019150868411156143a557600080fd5b8286015b848110156143c057803583529183019183016143a9565b509695505050505050565b600080600080608085870312156143e157600080fd5b84356143ec816140a1565b935060208501356001600160401b038082111561440857600080fd5b6144148883890161435a565b9450604087013591508082111561442a57600080fd5b61443688838901614189565b9350606087013591508082111561444c57600080fd5b506144598782880161435a565b91505092959194509250565b60006020828403121561447757600080fd5b8135611b84816140a1565b600080600080600060a0868803121561449a57600080fd5b85356144a5816140a1565b945060208601356144b5816140a1565b935060408601356001600160401b03808211156144d157600080fd5b6144dd89838a0161435a565b945060608801359150808211156144f357600080fd5b6144ff89838a0161435a565b9350608088013591508082111561451557600080fd5b5061452288828901614189565b9150509295509295909350565b6000806040838503121561454257600080fd5b823591506020830135614554816140a1565b809150509250929050565b6000806000806080858703121561457557600080fd5b8435614580816140a1565b93506020850135925060408501356001600160401b038111156145a257600080fd5b6145ae87828801614189565b949793965093946060013593505050565b600080600080608085870312156145d557600080fd5b84356145e0816140a1565b935060208501356001600160401b03808211156145fc57600080fd5b6146088883890161435a565b9450604087013591508082111561461e57600080fd5b61462a8883890161435a565b9350606087013591508082111561464057600080fd5b5061445987828801614189565b60008060006040848603121561466257600080fd5b61466b84613f98565b925060208401356001600160401b0381111561468657600080fd5b61469286828701613faf565b9497909650939450505050565b600080600080600080600080610100898b0312156146bc57600080fd5b6146c5896140b6565b97506146d360208a01613f98565b965060408901356001600160401b03808211156146ef57600080fd5b6146fb8c838d01614189565b975060608b013591508082111561471157600080fd5b61471d8c838d0161435a565b965060808b013591508082111561473357600080fd5b61473f8c838d0161435a565b955061474d60a08c016140b6565b945061475b60c08c016140b6565b935060e08b013591508082111561477157600080fd5b5061477e8b828c01614189565b9150509295985092959890939650565b600080600080600080600080610100898b0312156147ab57600080fd5b88356147b6816140a1565b97506147c460208a01613f98565b965060408901356001600160401b03808211156147e057600080fd5b6147ec8c838d01614189565b975060608b0135965060808b0135955060a08b0135915061480c826140a1565b90935060c08a01359061481e826140a1565b90925060e08a0135908082111561477157600080fd5b6000806040838503121561484757600080fd5b82356001600160401b038082111561485e57600080fd5b818501915085601f83011261487257600080fd5b8135602061487f82614337565b60405161488c8282614136565b83815260059390931b85018201928281019150898411156148ac57600080fd5b948201945b838610156148d35785356148c4816140a1565b825294820194908201906148b1565b965050860135925050808211156148e957600080fd5b506148f68582860161435a565b9150509250929050565b600081518084526020808501945080840160005b8381101561493057815187529582019590820190600101614914565b509495945050505050565b602081526000611b846020830184614900565b60008060006060848603121561496357600080fd5b61496c84613f98565b925060208401356001600160401b0381111561498757600080fd5b61499386828701614189565b9250506149a260408501613ff7565b90509250925092565b600080604083850312156149be57600080fd5b82356001600160401b038111156149d457600080fd5b6149e085828601614189565b9250506020830135614554816140a1565b80358015158114613faa57600080fd5b60008060008060008060c08789031215614a1a57600080fd5b614a2387613f98565b955060208701356001600160401b0380821115614a3f57600080fd5b614a4b8a838b01614189565b96506040890135955060608901359450614a6760808a016149f1565b935060a0890135915080821115614a7d57600080fd5b50614a8a89828a01614189565b9150509295509295509295565b60008060408385031215614aaa57600080fd5b614ab383613f98565b9150614ac160208401613f98565b90509250929050565b60008060408385031215614add57600080fd5b8235614ae8816140a1565b9150614ac1602084016149f1565b60008060008060808587031215614b0c57600080fd5b8435614b17816140a1565b9350602085013592506040850135915060608501356001600160401b03811115614b4057600080fd5b61445987828801614189565b60008060008060008060c08789031215614b6557600080fd5b614b6e87613f98565b955060208701356001600160401b0380821115614b8a57600080fd5b614b968a838b01614189565b96506040890135915080821115614bac57600080fd5b614bb88a838b0161435a565b95506060890135915080821115614bce57600080fd5b614bda8a838b0161435a565b9450614a6760808a016149f1565b600080600080600060808688031215614c0057600080fd5b614c0986613f98565b9450614c1760208701613f98565b93506040860135925060608601356001600160401b03811115614c3957600080fd5b614c4588828901613faf565b969995985093965092949392505050565b600080600060608486031215614c6b57600080fd5b614c7484613f98565b9250614c8260208501613f98565b9150604084013590509250925092565b60008060408385031215614ca557600080fd5b8235614cb0816140a1565b91506020830135614554816140a1565b600060208284031215614cd257600080fd5b611b84826149f1565b600080600080600060a08688031215614cf357600080fd5b8535614cfe816140a1565b94506020860135614d0e816140a1565b9350604086013592506060860135915060808601356001600160401b03811115614d3757600080fd5b61452288828901614189565b60008060008060808587031215614d5957600080fd5b614d6285613f98565b9350614d7060208601613f98565b92506040850135614d80816140a1565b9396929550929360600135925050565b600181811c90821680614da457607f821691505b602082108103614dc457634e487b7160e01b600052602260045260246000fd5b50919050565b8183823760009101908152919050565b60008351614dec818460208801614221565b835190830190614e00818360208801614221565b64173539b7b760d91b9101908152600501949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614e5757614e57614e2f565b5060010190565b6001600160a01b0385168152608060208201819052600090614e8290830186614900565b8281036040840152614e948186614900565b90508281036060840152614ea88185614900565b979650505050505050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201526000612384604083018486614f01565b80820180821115610e4457610e44614e2f565b81810381811115610e4457610e44614e2f565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b601f82111561100757600081815260208120601f850160051c81016020861015614fbb5750805b601f850160051c820191505b818110156113b957828155600101614fc7565b81516001600160401b03811115614ff357614ff3614120565b615007816150018454614d90565b84614f94565b602080601f83116001811461503c57600084156150245750858301515b600019600386901b1c1916600185901b1785556113b9565b600085815260208120601f198616915b8281101561506b5788860151825594840194600190910190840161504c565b50858210156150895787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080815260006150ac6080830187614245565b82810360208401526150be8187614900565b90508281036040840152614e948186614900565b61ffff861681526001600160a01b038516602082015260a06040820181905260009061510090830186614245565b8415156060840152828103608084015261511a8185614245565b98975050505050505050565b6000806040838503121561513957600080fd5b505080516020909101519092909150565b600061ffff808816835280871660208401525084604083015260806060830152614ea8608083018486614f01565b61ffff86168152608060208201526000615196608083018688614f01565b6001600160401b0394909416604083015250606001529392505050565b6001600160401b038311156151ca576151ca614120565b6151de836151d88354614d90565b83614f94565b6000601f84116001811461521257600085156151fa5750838201355b600019600387901b1c1916600186901b178355610f41565b600083815260209020601f19861690835b828110156152435786850135825560209485019460019092019101615223565b50868210156152605760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b600082601f83011261528357600080fd5b815161528e81614162565b60405161529b8282614136565b8281528560208487010111156152b057600080fd5b612384836020830160208801614221565b6000602082840312156152d357600080fd5b81516001600160401b038111156152e957600080fd5b61421984828501615272565b61ffff851681526080602082015260006153126080830186614245565b6001600160401b03851660408401528281036060840152614ea88185614245565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b6040815260006153cf6040830185614900565b82810360208401526123848185614900565b6000602082840312156153f357600080fd5b8151611b84816140a1565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60208082526024908201527f4c7a4170703a205f61646170746572506172616d73206d75737420626520656d604082015263383a3c9760e11b606082015260800190565b600082516154e3818460208701614221565b9190910192915050565b600082601f8301126154fe57600080fd5b8151602061550b82614337565b6040516155188282614136565b83815260059390931b850182019282810191508684111561553857600080fd5b8286015b848110156143c0578051835291830191830161553c565b6000806000806080858703121561556957600080fd5b84516001600160401b038082111561558057600080fd5b61558c88838901615272565b955060208701519150808211156155a257600080fd5b6155ae888389016154ed565b945060408701519150808211156155c457600080fd5b6155d0888389016154ed565b935060608701519150808211156155e657600080fd5b50614459878288016154ed565b60006020828403121561560557600080fd5b5051919050565b61ffff8616815260a06020820152600061562960a0830187614245565b6001600160401b0386166040840152828103606084015261564a8186614245565b9050828103608084015261511a8185614245565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615696816017850160208801614221565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516156c7816028840160208801614221565b01602801949350505050565b6001600160a01b038581168252841660208201526080604082018190526000906156ff90830185614900565b8281036060840152614ea88185614900565b6001600160a01b0386811682528516602082015260a06040820181905260009061573d90830186614900565b828103606084015261564a8186614900565b60006020828403121561576157600080fd5b8151611b84816140ed565b600060033d11156157855760046000803e5060005160e01c5b90565b600060443d10156157965790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156157c557505050505090565b82850191508151818111156157dd5750505050505090565b843d87010160208285010111156157f75750505050505090565b61580660208286010187614136565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614ea890830184614245565b61ffff8716815260c0602082015260006158b060c0830188614245565b82810360408401526158c28188614245565b6001600160a01b0387811660608601528616608085015283810360a085015290506158ed8185614245565b9998505050505050505050565b8082028115828204841417610e4457610e44614e2f565b60008161592057615920614e2f565b50600019019056fe20162831d2f54c3e11eebafebfeda495d4c52c67b1708251179ec91fb76dd3b2a2646970667358221220b2c090b9732f9583efb1bfc6e247b01d3e195f0cb9e93e43d5a2c2e28b63ac2964736f6c63430008110033