Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
MRe7SolRedemptionVault
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "../RedemptionVault.sol";
import "./MRe7SolMidasAccessControlRoles.sol";
/**
* @title MRe7SolRedemptionVault
* @notice Smart contract that handles mRE7SOL redemptions
* @author RedDuck Software
*/
contract MRe7SolRedemptionVault is
RedemptionVault,
MRe7SolMidasAccessControlRoles
{
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure override returns (bytes32) {
return M_RE7SOL_REDEMPTION_VAULT_ADMIN_ROLE;
}
}// 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);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC20MetadataUpgradeable as IERC20Metadata} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
import "../interfaces/IManageableVault.sol";
import "../interfaces/IMTbill.sol";
import "../interfaces/IDataFeed.sol";
import "../access/Greenlistable.sol";
import "../access/Blacklistable.sol";
import "../abstract/WithSanctionsList.sol";
import "../libraries/DecimalsCorrectionLibrary.sol";
import "../access/Pausable.sol";
/**
* @title ManageableVault
* @author RedDuck Software
* @notice Contract with base Vault methods
*/
abstract contract ManageableVault is
Pausable,
IManageableVault,
Blacklistable,
Greenlistable,
WithSanctionsList
{
using EnumerableSet for EnumerableSet.AddressSet;
using DecimalsCorrectionLibrary for uint256;
using SafeERC20 for IERC20;
using Counters for Counters.Counter;
/**
* @notice address that represents off-chain USD bank transfer
*/
address public constant MANUAL_FULLFILMENT_TOKEN = address(0x0);
/**
* @notice stable coin static rate 1:1 USD in 18 decimals
*/
uint256 public constant STABLECOIN_RATE = 10**18;
/**
* @notice last request id
*/
Counters.Counter public currentRequestId;
/**
* @notice 100 percent with base 100
* @dev for example, 10% will be (10 * 100)%
*/
uint256 public constant ONE_HUNDRED_PERCENT = 100 * 100;
uint256 public constant MAX_UINT = type(uint256).max;
/**
* @notice mToken token
*/
IMTbill public mToken;
/**
* @notice mToken data feed contract
*/
IDataFeed public mTokenDataFeed;
/**
* @notice address to which tokens and mTokens will be sent
*/
address public tokensReceiver;
/**
* @dev fee for initial operations 1% = 100
*/
uint256 public instantFee;
/**
* @dev daily limit for initial operations
* if user exceed this limit he will need
* to create requests
*/
uint256 public instantDailyLimit;
/**
* @dev mapping days (number from 1970) to limit amount
*/
mapping(uint256 => uint256) public dailyLimits;
/**
* @notice address to which fees will be sent
*/
address public feeReceiver;
/**
* @notice variation tolerance of tokenOut rates for "safe" requests approve
*/
uint256 public variationTolerance;
/**
* @notice address restriction with zero fees
*/
mapping(address => bool) public waivedFeeRestriction;
/**
* @dev tokens that can be used as USD representation
*/
EnumerableSet.AddressSet internal _paymentTokens;
/**
* @notice mapping, token address to token config
*/
mapping(address => TokenConfig) public tokensConfig;
/**
* @notice basic min operations amount
*/
uint256 public minAmount;
/**
* @notice mapping, user address => is free frmo min amounts
*/
mapping(address => bool) public isFreeFromMinAmount;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that msg.sender do have a vaultRole() role
*/
modifier onlyVaultAdmin() {
_onlyRole(vaultRole(), msg.sender);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations
*/
// solhint-disable func-name-mixedcase
function __ManageableVault_init(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount
) internal onlyInitializing {
_validateAddress(_mTokenInitParams.mToken, false);
_validateAddress(_mTokenInitParams.mTokenDataFeed, false);
_validateAddress(_receiversInitParams.tokensReceiver, true);
_validateAddress(_receiversInitParams.feeReceiver, true);
require(_instantInitParams.instantDailyLimit > 0, "zero limit");
_validateFee(_variationTolerance, true);
_validateFee(_instantInitParams.instantFee, false);
mToken = IMTbill(_mTokenInitParams.mToken);
__Pausable_init(_ac);
__Greenlistable_init_unchained();
__Blacklistable_init_unchained();
__WithSanctionsList_init_unchained(_sanctionsList);
tokensReceiver = _receiversInitParams.tokensReceiver;
feeReceiver = _receiversInitParams.feeReceiver;
instantFee = _instantInitParams.instantFee;
instantDailyLimit = _instantInitParams.instantDailyLimit;
minAmount = _minAmount;
variationTolerance = _variationTolerance;
mTokenDataFeed = IDataFeed(_mTokenInitParams.mTokenDataFeed);
}
/**
* @inheritdoc IManageableVault
*/
function withdrawToken(
address token,
uint256 amount,
address withdrawTo
) external onlyVaultAdmin {
IERC20(token).safeTransfer(withdrawTo, amount);
emit WithdrawToken(msg.sender, token, withdrawTo, amount);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if token is already added
*/
function addPaymentToken(
address token,
address dataFeed,
uint256 tokenFee,
bool stable
) external onlyVaultAdmin {
require(_paymentTokens.add(token), "MV: already added");
_validateAddress(dataFeed, false);
_validateFee(tokenFee, false);
tokensConfig[token] = TokenConfig({
dataFeed: dataFeed,
fee: tokenFee,
allowance: MAX_UINT,
stable: stable
});
emit AddPaymentToken(msg.sender, token, dataFeed, tokenFee, stable);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if token is not presented
*/
function removePaymentToken(address token) external onlyVaultAdmin {
require(_paymentTokens.remove(token), "MV: not exists");
delete tokensConfig[token];
emit RemovePaymentToken(token, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new allowance zero
*/
function changeTokenAllowance(address token, uint256 allowance)
external
onlyVaultAdmin
{
if (token != MANUAL_FULLFILMENT_TOKEN) {
_requireTokenExists(token);
}
require(allowance > 0, "MV: zero allowance");
tokensConfig[token].allowance = allowance;
emit ChangeTokenAllowance(token, msg.sender, allowance);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new fee > 100%
*/
function changeTokenFee(address token, uint256 fee)
external
onlyVaultAdmin
{
_requireTokenExists(token);
_validateFee(fee, false);
tokensConfig[token].fee = fee;
emit ChangeTokenFee(token, msg.sender, fee);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if new tolerance zero
*/
function setVariationTolerance(uint256 tolerance) external onlyVaultAdmin {
_validateFee(tolerance, true);
variationTolerance = tolerance;
emit SetVariationTolerance(msg.sender, tolerance);
}
/**
* @inheritdoc IManageableVault
*/
function setMinAmount(uint256 newAmount) external onlyVaultAdmin {
minAmount = newAmount;
emit SetMinAmount(msg.sender, newAmount);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if account is already added
*/
function addWaivedFeeAccount(address account) external onlyVaultAdmin {
require(!waivedFeeRestriction[account], "MV: already added");
waivedFeeRestriction[account] = true;
emit AddWaivedFeeAccount(account, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts if account is already removed
*/
function removeWaivedFeeAccount(address account) external onlyVaultAdmin {
require(waivedFeeRestriction[account], "MV: not found");
waivedFeeRestriction[account] = false;
emit RemoveWaivedFeeAccount(account, msg.sender);
}
/**
* @inheritdoc IManageableVault
* @dev reverts address zero or equal address(this)
*/
function setFeeReceiver(address receiver) external onlyVaultAdmin {
_validateAddress(receiver, true);
feeReceiver = receiver;
emit SetFeeReceiver(msg.sender, receiver);
}
/**
* @inheritdoc IManageableVault
* @dev reverts address zero or equal address(this)
*/
function setTokensReceiver(address receiver) external onlyVaultAdmin {
_validateAddress(receiver, true);
tokensReceiver = receiver;
emit SetTokensReceiver(msg.sender, receiver);
}
/**
* @inheritdoc IManageableVault
*/
function setInstantFee(uint256 newInstantFee) external onlyVaultAdmin {
_validateFee(newInstantFee, false);
instantFee = newInstantFee;
emit SetInstantFee(msg.sender, newInstantFee);
}
/**
* @inheritdoc IManageableVault
*/
function setInstantDailyLimit(uint256 newInstantDailyLimit)
external
onlyVaultAdmin
{
require(newInstantDailyLimit > 0, "MV: limit zero");
instantDailyLimit = newInstantDailyLimit;
emit SetInstantDailyLimit(msg.sender, newInstantDailyLimit);
}
/**
* @inheritdoc IManageableVault
*/
function freeFromMinAmount(address user, bool enable)
external
onlyVaultAdmin
{
require(isFreeFromMinAmount[user] != enable, "DV: already free");
isFreeFromMinAmount[user] = enable;
emit FreeFromMinAmount(user, enable);
}
/**
* @notice returns array of stablecoins supported by the vault
* can be called only from permissioned actor.
* @return paymentTokens array of payment tokens
*/
function getPaymentTokens() external view returns (address[] memory) {
return _paymentTokens.values();
}
/**
* @notice AC role of vault administrator
* @return role bytes32 role
*/
function vaultRole() public view virtual returns (bytes32);
/**
* @inheritdoc WithSanctionsList
*/
function sanctionsListAdminRole()
public
view
virtual
override
returns (bytes32)
{
return vaultRole();
}
/**
* @inheritdoc Pausable
*/
function pauseAdminRole() public view override returns (bytes32) {
return vaultRole();
}
/**
* @dev do safeTransferFrom on a given token
* and converts `amount` from base18
* to amount with a correct precision. Sends tokens
* from `msg.sender` to `tokensReceiver`
* @param token address of token
* @param to address of user
* @param amount amount of `token` to transfer from `user` (decimals 18)
* @param tokenDecimals token decimals
*/
function _tokenTransferFromUser(
address token,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransferFrom(msg.sender, to, transferAmount);
}
/**
* @dev do safeTransferFrom on a given token
* and converts `amount` from base18
* to amount with a correct precision.
* @param token address of token
* @param from address
* @param to address
* @param amount amount of `token` to transfer from `user`
* @param tokenDecimals token decimals
*/
function _tokenTransferFromTo(
address token,
address from,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransferFrom(from, to, transferAmount);
}
/**
* @dev do safeTransfer on a given token
* and converts `amount` from base18
* to amount with a correct precision. Sends tokens
* from `contract` to `user`
* @param token address of token
* @param to address of user
* @param amount amount of `token` to transfer from `user` (decimals 18)
* @param tokenDecimals token decimals
*/
function _tokenTransferToUser(
address token,
address to,
uint256 amount,
uint256 tokenDecimals
) internal {
uint256 transferAmount = amount.convertFromBase18(tokenDecimals);
require(
amount == transferAmount.convertToBase18(tokenDecimals),
"MV: invalid rounding"
);
IERC20(token).safeTransfer(to, transferAmount);
}
/**
* @dev retreives decimals of a given `token`
* @param token address of token
* @return decimals decinmals value of a given `token`
*/
function _tokenDecimals(address token) internal view returns (uint8) {
return IERC20Metadata(token).decimals();
}
/**
* @dev checks that `token` is presented in `_paymentTokens`
* @param token address of token
*/
function _requireTokenExists(address token) internal view virtual {
require(_paymentTokens.contains(token), "MV: token not exists");
}
/**
* @dev check if operation exceed daily limit and update limit data
* @param amount operation amount (decimals 18)
*/
function _requireAndUpdateLimit(uint256 amount) internal {
uint256 currentDayNumber = block.timestamp / 1 days;
uint256 nextLimitAmount = dailyLimits[currentDayNumber] + amount;
require(nextLimitAmount <= instantDailyLimit, "MV: exceed limit");
dailyLimits[currentDayNumber] = nextLimitAmount;
}
/**
* @dev check if operation exceed token allowance and update allowance
* @param token address of token
* @param amount operation amount (decimals 18)
*/
function _requireAndUpdateAllowance(address token, uint256 amount)
internal
{
uint256 prevAllowance = tokensConfig[token].allowance;
if (prevAllowance == MAX_UINT) return;
require(prevAllowance >= amount, "MV: exceed allowance");
tokensConfig[token].allowance -= amount;
}
/**
* @dev returns calculated fee amount depends on parameters
* if additionalFee not zero, token fee replaced with additionalFee
* @param sender sender address
* @param token token address
* @param amount amount of token (decimals 18)
* @param isInstant is instant operation
* @param additionalFee fee for fiat operations
* @return fee amount of input token
*/
function _getFeeAmount(
address sender,
address token,
uint256 amount,
bool isInstant,
uint256 additionalFee
) internal view returns (uint256) {
if (waivedFeeRestriction[sender]) return 0;
uint256 feePercent;
if (additionalFee == 0) {
TokenConfig storage tokenConfig = tokensConfig[token];
feePercent = tokenConfig.fee;
} else {
feePercent = additionalFee;
}
if (isInstant) feePercent += instantFee;
if (feePercent > ONE_HUNDRED_PERCENT) feePercent = ONE_HUNDRED_PERCENT;
return (amount * feePercent) / ONE_HUNDRED_PERCENT;
}
/**
* @dev check if prev and new prices diviation fit variationTolerance
* @param prevPrice previous rate
* @param newPrice new rate
*/
function _requireVariationTolerance(uint256 prevPrice, uint256 newPrice)
internal
view
{
uint256 priceDif = newPrice >= prevPrice
? newPrice - prevPrice
: prevPrice - newPrice;
uint256 priceDifPercent = (priceDif * ONE_HUNDRED_PERCENT) / prevPrice;
require(
priceDifPercent <= variationTolerance,
"MV: exceed price diviation"
);
}
/**
* @dev convert value to inputted decimals precision
* @param value value for format
* @param decimals decimals
* @return converted amount
*/
function _truncate(uint256 value, uint256 decimals)
internal
pure
returns (uint256)
{
return value.convertFromBase18(decimals).convertToBase18(decimals);
}
/**
* @dev check if fee <= 100% and check > 0 if needs
* @param fee fee value
* @param checkMin if need to check minimum
*/
function _validateFee(uint256 fee, bool checkMin) internal pure {
require(fee <= ONE_HUNDRED_PERCENT, "fee > 100%");
if (checkMin) require(fee > 0, "fee == 0");
}
/**
* @dev check if address not zero and not address(this)
* @param addr address to check
* @param selfCheck check if address not address(this)
*/
function _validateAddress(address addr, bool selfCheck) internal view {
require(addr != address(0), "zero address");
if (selfCheck) require(addr != address(this), "invalid address");
}
/**
* @dev get token rate depends on data feed and stablecoin flag
* @param dataFeed address of dataFeed from token config
* @param stable is stablecoin
*/
function _getTokenRate(address dataFeed, bool stable)
internal
view
virtual
returns (uint256)
{
// @dev if dataFeed returns rate, all peg checks passed
uint256 rate = IDataFeed(dataFeed).getDataInBase18();
if (stable) return STABLECOIN_RATE;
return rate;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./MidasAccessControl.sol";
import "../abstract/MidasInitializable.sol";
/**
* @title WithMidasAccessControl
* @notice Base contract that consumes MidasAccessControl
* @author RedDuck Software
*/
abstract contract WithMidasAccessControl is
MidasInitializable,
MidasAccessControlRoles
{
/**
* @notice admin role
*/
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @notice MidasAccessControl contract address
*/
MidasAccessControl public accessControl;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that given `address` have `role`
*/
modifier onlyRole(bytes32 role, address account) {
_onlyRole(role, account);
_;
}
/**
* @dev checks that given `address` do not have `role`
*/
modifier onlyNotRole(bytes32 role, address account) {
_onlyNotRole(role, account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
*/
// solhint-disable func-name-mixedcase
function __WithMidasAccessControl_init(address _accessControl)
internal
onlyInitializing
{
require(_accessControl != address(0), "zero address");
accessControl = MidasAccessControl(_accessControl);
}
/**
* @dev checks that given `address` have `role`
*/
function _onlyRole(bytes32 role, address account) internal view {
require(accessControl.hasRole(role, account), "WMAC: hasnt role");
}
/**
* @dev checks that given `address` do not have `role`
*/
function _onlyNotRole(bytes32 role, address account) internal view {
require(!accessControl.hasRole(role, account), "WMAC: has role");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title MidasAccessControlRoles
* @notice Base contract that stores all roles descriptors
* @author RedDuck Software
*/
abstract contract MidasAccessControlRoles {
/**
* @notice actor that can change green list statuses of addresses
*/
bytes32 public constant GREENLIST_OPERATOR_ROLE =
keccak256("GREENLIST_OPERATOR_ROLE");
/**
* @notice actor that can change black list statuses of addresses
*/
bytes32 public constant BLACKLIST_OPERATOR_ROLE =
keccak256("BLACKLIST_OPERATOR_ROLE");
/**
* @notice actor that can mint mTBILL
*/
bytes32 public constant M_TBILL_MINT_OPERATOR_ROLE =
keccak256("M_TBILL_MINT_OPERATOR_ROLE");
/**
* @notice actor that can burn mTBILL
*/
bytes32 public constant M_TBILL_BURN_OPERATOR_ROLE =
keccak256("M_TBILL_BURN_OPERATOR_ROLE");
/**
* @notice actor that can pause mTBILL
*/
bytes32 public constant M_TBILL_PAUSE_OPERATOR_ROLE =
keccak256("M_TBILL_PAUSE_OPERATOR_ROLE");
/**
* @notice actor that have admin rights in deposit vault
*/
bytes32 public constant DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @notice actor that have admin rights in redemption vault
*/
bytes32 public constant REDEMPTION_VAULT_ADMIN_ROLE =
keccak256("REDEMPTION_VAULT_ADMIN_ROLE");
/**
* @notice actor that is greenlisted
*/
bytes32 public constant GREENLISTED_ROLE = keccak256("GREENLISTED_ROLE");
/**
* @notice actor that is blacklisted
*/
bytes32 public constant BLACKLISTED_ROLE = keccak256("BLACKLISTED_ROLE");
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// 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 MathUpgradeable {
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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
/**
* @title IMTbill
* @author RedDuck Software
*/
interface IMTbill is IERC20Upgradeable {
/**
* @notice mints mTBILL token `amount` to a given `to` address.
* should be called only from permissioned actor
* @param to addres to mint tokens to
* @param amount amount to mint
*/
function mint(address to, uint256 amount) external;
/**
* @notice burns mTBILL token `amount` to a given `to` address.
* should be called only from permissioned actor
* @param from addres to burn tokens from
* @param amount amount to burn
*/
function burn(address from, uint256 amount) external;
/**
* @notice updates contract`s metadata.
* should be called only from permissioned actor
* @param key metadata map. key
* @param data metadata map. value
*/
function setMetadata(bytes32 key, bytes memory data) external;
/**
* @notice puts mTBILL token on pause.
* should be called only from permissioned actor
*/
function pause() external;
/**
* @notice puts mTBILL token on pause.
* should be called only from permissioned actor
*/
function unpause() external;
}// 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;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title MRe7SolMidasAccessControlRoles
* @notice Base contract that stores all roles descriptors for mRE7SOL contracts
* @author RedDuck Software
*/
abstract contract MRe7SolMidasAccessControlRoles {
/**
* @notice actor that can manage MRe7SolDepositVault
*/
bytes32 public constant M_RE7SOL_DEPOSIT_VAULT_ADMIN_ROLE =
keccak256("M_RE7SOL_DEPOSIT_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage MRe7SolRedemptionVault
*/
bytes32 public constant M_RE7SOL_REDEMPTION_VAULT_ADMIN_ROLE =
keccak256("M_RE7SOL_REDEMPTION_VAULT_ADMIN_ROLE");
/**
* @notice actor that can manage MRe7SolCustomAggregatorFeed and MRe7SolDataFeed
*/
bytes32 public constant M_RE7SOL_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE =
keccak256("M_RE7SOL_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE");
}// 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 AddressUpgradeable {
/**
* @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);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "../access/WithMidasAccessControl.sol";
import "../libraries/DecimalsCorrectionLibrary.sol";
/**
* @title IDataFeed
* @author RedDuck Software
*/
interface IDataFeed {
/**
* @notice upgradeable pattern contract`s initializer
* @param _ac MidasAccessControl contract address
* @param _aggregator AggregatorV3Interface contract address
* @param _healthyDiff max. staleness time for data feed answers
* @param _minExpectedAnswer min.expected answer value from data feed
* @param _maxExpectedAnswer max.expected answer value from data feed
*/
function initialize(
address _ac,
address _aggregator,
uint256 _healthyDiff,
int256 _minExpectedAnswer,
int256 _maxExpectedAnswer
) external;
/**
* @notice updates `aggregator` address
* @param _aggregator new AggregatorV3Interface contract address
*/
function changeAggregator(address _aggregator) external;
/**
* @notice fetches answer from aggregator
* and converts it to the base18 precision
* @return answer fetched aggregator answer
*/
function getDataInBase18() external view returns (uint256 answer);
/**
* @dev describes a role, owner of which can manage this feed
* @return role descriptor
*/
function feedAdminRole() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @title DecimalsCorrectionLibrary
* @author RedDuck Software
*/
library DecimalsCorrectionLibrary {
/**
* @dev converts `originalAmount` with `originalDecimals` into
* amount with `decidedDecimals`
* @param originalAmount amount to convert
* @param originalDecimals decimals of the original amount
* @param decidedDecimals decimals for the output amount
* @return amount converted amount with `decidedDecimals`
*/
function convert(
uint256 originalAmount,
uint256 originalDecimals,
uint256 decidedDecimals
) internal pure returns (uint256) {
if (originalAmount == 0) return 0;
if (originalDecimals == decidedDecimals) return originalAmount;
uint256 adjustedAmount;
if (originalDecimals > decidedDecimals) {
adjustedAmount =
originalAmount /
(10**(originalDecimals - decidedDecimals));
} else {
adjustedAmount =
originalAmount *
(10**(decidedDecimals - originalDecimals));
}
return adjustedAmount;
}
/**
* @dev converts `originalAmount` with decimals 18 into
* amount with `decidedDecimals`
* @param originalAmount amount to convert
* @param decidedDecimals decimals for the output amount
* @return amount converted amount with `decidedDecimals`
*/
function convertFromBase18(uint256 originalAmount, uint256 decidedDecimals)
internal
pure
returns (uint256)
{
return convert(originalAmount, 18, decidedDecimals);
}
/**
* @dev converts `originalAmount` with `originalDecimals` into
* amount with decimals 18
* @param originalAmount amount to convert
* @param originalDecimals decimals of the original amount
* @return amount converted amount with 18 decimals
*/
function convertToBase18(uint256 originalAmount, uint256 originalDecimals)
internal
pure
returns (uint256)
{
return convert(originalAmount, originalDecimals, 18);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
/**
* @title MidasInitializable
* @author RedDuck Software
* @notice Base Initializable contract that implements constructor
* that calls _disableInitializers() to prevent
* initialization of implementation contract
*/
abstract contract MidasInitializable is Initializable {
constructor() {
_disableInitializers();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IMTbill.sol";
import "./IDataFeed.sol";
/**
* @param dataFeed data feed token/USD address
* @param fee fee by token, 1% = 100
* @param allowance token allowance (decimals 18)
*/
struct TokenConfig {
address dataFeed;
uint256 fee;
uint256 allowance;
bool stable;
}
enum RequestStatus {
Pending,
Processed,
Canceled
}
struct MTokenInitParams {
address mToken;
address mTokenDataFeed;
}
struct ReceiversInitParams {
address tokensReceiver;
address feeReceiver;
}
struct InstantInitParams {
uint256 instantFee;
uint256 instantDailyLimit;
}
/**
* @title IManageableVault
* @author RedDuck Software
*/
interface IManageableVault {
/**
* @param caller function caller (msg.sender)
* @param token token that was withdrawn
* @param withdrawTo address to which tokens were withdrawn
* @param amount `token` transfer amount
*/
event WithdrawToken(
address indexed caller,
address indexed token,
address indexed withdrawTo,
uint256 amount
);
/**
* @param caller function caller (msg.sender)
* @param token address of token that
* @param dataFeed token dataFeed address
* @param fee fee 1% = 100
* @param stable stablecoin flag
*/
event AddPaymentToken(
address indexed caller,
address indexed token,
address indexed dataFeed,
uint256 fee,
bool stable
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
* @param allowance new allowance
*/
event ChangeTokenAllowance(
address indexed token,
address indexed caller,
uint256 allowance
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
* @param fee new fee
*/
event ChangeTokenFee(
address indexed token,
address indexed caller,
uint256 fee
);
/**
* @param token address of token that
* @param caller function caller (msg.sender)
*/
event RemovePaymentToken(address indexed token, address indexed caller);
/**
* @param account address of account
* @param caller function caller (msg.sender)
*/
event AddWaivedFeeAccount(address indexed account, address indexed caller);
/**
* @param account address of account
* @param caller function caller (msg.sender)
*/
event RemoveWaivedFeeAccount(
address indexed account,
address indexed caller
);
/**
* @param caller function caller (msg.sender)
* @param newFee new operation fee value
*/
event SetInstantFee(address indexed caller, uint256 newFee);
/**
* @param caller function caller (msg.sender)
* @param newAmount new min amount for operation
*/
event SetMinAmount(address indexed caller, uint256 newAmount);
/**
* @param caller function caller (msg.sender)
* @param newLimit new operation daily limit
*/
event SetInstantDailyLimit(address indexed caller, uint256 newLimit);
/**
* @param caller function caller (msg.sender)
* @param newTolerance percent of price diviation 1% = 100
*/
event SetVariationTolerance(address indexed caller, uint256 newTolerance);
/**
* @param caller function caller (msg.sender)
* @param reciever new reciever address
*/
event SetFeeReceiver(address indexed caller, address indexed reciever);
/**
* @param caller function caller (msg.sender)
* @param reciever new reciever address
*/
event SetTokensReceiver(address indexed caller, address indexed reciever);
/**
* @param user user address
* @param enable is enabled
*/
event FreeFromMinAmount(address indexed user, bool enable);
/**
* @notice The mTokenDataFeed contract address.
* @return The address of the mTokenDataFeed contract.
*/
function mTokenDataFeed() external view returns (IDataFeed);
/**
* @notice The mToken contract address.
* @return The address of the mToken contract.
*/
function mToken() external view returns (IMTbill);
/**
* @notice withdraws `amount` of a given `token` from the contract.
* can be called only from permissioned actor.
* @param token token address
* @param amount token amount
* @param withdrawTo withdraw destination address
*/
function withdrawToken(
address token,
uint256 amount,
address withdrawTo
) external;
/**
* @notice adds a token to the stablecoins list.
* can be called only from permissioned actor.
* @param token token address
* @param dataFeed dataFeed address
* @param fee 1% = 100
* @param stable is stablecoin flag
*/
function addPaymentToken(
address token,
address dataFeed,
uint256 fee,
bool stable
) external;
/**
* @notice removes a token from stablecoins list.
* can be called only from permissioned actor.
* @param token token address
*/
function removePaymentToken(address token) external;
/**
* @notice set new token allowance.
* if MAX_UINT = infinite allowance
* prev allowance rewrites by new
* can be called only from permissioned actor.
* @param token token address
* @param allowance new allowance (decimals 18)
*/
function changeTokenAllowance(address token, uint256 allowance) external;
/**
* @notice set new token fee.
* can be called only from permissioned actor.
* @param token token address
* @param fee new fee percent 1% = 100
*/
function changeTokenFee(address token, uint256 fee) external;
/**
* @notice set new prices diviation percent.
* can be called only from permissioned actor.
* @param tolerance new prices diviation percent 1% = 100
*/
function setVariationTolerance(uint256 tolerance) external;
/**
* @notice set new min amount.
* can be called only from permissioned actor.
* @param newAmount min amount for operations in mToken
*/
function setMinAmount(uint256 newAmount) external;
/**
* @notice adds a account to waived fee restriction.
* can be called only from permissioned actor.
* @param account user address
*/
function addWaivedFeeAccount(address account) external;
/**
* @notice removes a account from waived fee restriction.
* can be called only from permissioned actor.
* @param account user address
*/
function removeWaivedFeeAccount(address account) external;
/**
* @notice set new reciever for fees.
* can be called only from permissioned actor.
* @param reciever new fee reciever address
*/
function setFeeReceiver(address reciever) external;
/**
* @notice set new reciever for tokens.
* can be called only from permissioned actor.
* @param reciever new token reciever address
*/
function setTokensReceiver(address reciever) external;
/**
* @notice set operation fee percent.
* can be called only from permissioned actor.
* @param newInstantFee new instant operations fee percent 1& = 100
*/
function setInstantFee(uint256 newInstantFee) external;
/**
* @notice set operation daily limit.
* can be called only from permissioned actor.
* @param newInstantDailyLimit new operation daily limit (decimals 18)
*/
function setInstantDailyLimit(uint256 newInstantDailyLimit) external;
/**
* @notice frees given `user` from the minimal deposit
* amount validation in `initiateDepositRequest`
* @param user address of user
*/
function freeFromMinAmount(address user, bool enable) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC20Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev ERC20 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*
* IMPORTANT: This contract does not include public pause and unpause functions. In
* addition to inheriting this contract, you must define both functions, invoking the
* {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate
* access control, e.g. using {AccessControl} or {Ownable}. Not doing so will
* make the contract unpausable.
*/
abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
function __ERC20Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __ERC20Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "../access/WithMidasAccessControl.sol";
/**
* @title Pausable
* @notice Base contract that implements basic functions and modifiers
* with pause functionality
* @author RedDuck Software
*/
abstract contract Pausable is WithMidasAccessControl, PausableUpgradeable {
mapping(bytes4 => bool) public fnPaused;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @param caller caller address (msg.sender)
* @param fn function id
*/
event PauseFn(address indexed caller, bytes4 fn);
/**
* @param caller caller address (msg.sender)
* @param fn function id
*/
event UnpauseFn(address indexed caller, bytes4 fn);
modifier whenFnNotPaused(bytes4 fn) {
_requireNotPaused();
require(!fnPaused[fn], "Pausable: fn paused");
_;
}
/**
* @dev checks that a given `account`
* has a determinedPauseAdminRole
*/
modifier onlyPauseAdmin() {
_onlyRole(pauseAdminRole(), msg.sender);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable-next-line func-name-mixedcase
function __Pausable_init(address _accessControl) internal onlyInitializing {
super.__Pausable_init();
__WithMidasAccessControl_init(_accessControl);
}
function pause() external onlyPauseAdmin {
_pause();
}
function unpause() external onlyPauseAdmin {
_unpause();
}
/**
* @dev pause specific function
* @param fn function id
*/
function pauseFn(bytes4 fn) external onlyPauseAdmin {
require(!fnPaused[fn], "Pausable: fn paused");
fnPaused[fn] = true;
emit PauseFn(msg.sender, fn);
}
/**
* @dev unpause specific function
* @param fn function id
*/
function unpauseFn(bytes4 fn) external onlyPauseAdmin {
require(fnPaused[fn], "Pausable: fn unpaused");
fnPaused[fn] = false;
emit UnpauseFn(msg.sender, fn);
}
/**
* @dev virtual function to determine pauseAdmin role
*/
function pauseAdminRole() public view virtual returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}// 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 SignedMathUpgradeable {
/**
* @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);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "../interfaces/ISanctionsList.sol";
import "../access/WithMidasAccessControl.sol";
import "./MidasInitializable.sol";
/**
* @title WithSanctionsList
* @notice Base contract that uses sanctions oracle from
* Chainalysis to check that user is not sanctioned
* @author RedDuck Software
*/
abstract contract WithSanctionsList is WithMidasAccessControl {
/**
* @notice address of Chainalysis sanctions oracle
*/
address public sanctionsList;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @param caller function caller (msg.sender)
* @param newSanctionsList new address of `sanctionsList`
*/
event SetSanctionsList(
address indexed caller,
address indexed newSanctionsList
);
/**
* @dev checks that a given `user` is not sanctioned
*/
modifier onlyNotSanctioned(address user) {
address _sanctionsList = sanctionsList;
if (_sanctionsList != address(0)) {
require(
!ISanctionsList(_sanctionsList).isSanctioned(user),
"WSL: sanctioned"
);
}
_;
}
/**
* @dev upgradeable pattern contract`s initializer
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init(
address _accesControl,
address _sanctionsList
) internal onlyInitializing {
__WithMidasAccessControl_init(_accesControl);
__WithSanctionsList_init_unchained(_sanctionsList);
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __WithSanctionsList_init_unchained(address _sanctionsList)
internal
onlyInitializing
{
sanctionsList = _sanctionsList;
}
/**
* @notice updates `sanctionsList` address.
* can be called only from permissioned actor that have
* `sanctionsListAdminRole()` role
* @param newSanctionsList new sanctions list address
*/
function setSanctionsList(address newSanctionsList) external {
_onlyRole(sanctionsListAdminRole(), msg.sender);
sanctionsList = newSanctionsList;
emit SetSanctionsList(msg.sender, newSanctionsList);
}
/**
* @notice AC role of sanctions list admin
* @dev address that have this role can use `setSanctionsList`
* @return role bytes32 role
*/
function sanctionsListAdminRole() public view virtual returns (bytes32);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./WithMidasAccessControl.sol";
/**
* @title Greenlistable
* @notice Base contract that implements basic functions and modifiers
* to work with greenlistable
* @author RedDuck Software
*/
abstract contract Greenlistable is WithMidasAccessControl {
/**
* @notice actor that can change green list enable
*/
bytes32 public constant GREENLIST_TOGGLER_ROLE =
keccak256("GREENLIST_TOGGLER_ROLE");
/**
* @notice is greenlist enabled
*/
bool public greenlistEnabled;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
event SetGreenlistEnable(address indexed sender, bool enable);
/**
* @dev checks that a given `account`
* have `greenlistedRole()`
*/
modifier onlyGreenlisted(address account) {
if (greenlistEnabled) _onlyGreenlisted(account);
_;
}
/**
* @dev checks that a given `account`
* have `greenlistedRole()`
* do the check even if greenlist check is off
*/
modifier onlyAlwaysGreenlisted(address account) {
_onlyGreenlisted(account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable func-name-mixedcase
function __Greenlistable_init(address _accessControl)
internal
onlyInitializing
{
__WithMidasAccessControl_init(_accessControl);
__Greenlistable_init_unchained();
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __Greenlistable_init_unchained() internal onlyInitializing {}
/**
* @notice enable or disable greenlist.
* can be called only from permissioned actor.
* @param enable enable
*/
function setGreenlistEnable(bool enable) external {
_onlyGreenlistToggler(msg.sender);
require(greenlistEnabled != enable, "GL: same enable status");
greenlistEnabled = enable;
emit SetGreenlistEnable(msg.sender, enable);
}
/**
* @notice AC role of a greenlist
* @return role bytes32 role
*/
function greenlistedRole() public view virtual returns (bytes32) {
return GREENLISTED_ROLE;
}
/**
* @notice AC role of a greenlist
* @return role bytes32 role
*/
function greenlistTogglerRole() public view virtual returns (bytes32) {
return GREENLIST_TOGGLER_ROLE;
}
/**
* @dev checks that a given `account`
* have a `greenlistedRole()`
*/
function _onlyGreenlisted(address account)
private
view
onlyRole(greenlistedRole(), account)
{}
/**
* @dev checks that a given `account`
* have a `greenlistTogglerRole()`
*/
function _onlyGreenlistToggler(address account)
internal
view
onlyRole(greenlistTogglerRole(), account)
{}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./IManageableVault.sol";
/**
* @notice Redeem request scruct
* @param sender user address who create
* @param tokenOut tokenOut address
* @param status request status
* @param amountMToken amount mToken
* @param mTokenRate rate of mToken at request creation time
* @param tokenOutRate rate of tokenOut at request creation time
*/
struct Request {
address sender;
address tokenOut;
RequestStatus status;
uint256 amountMToken;
uint256 mTokenRate;
uint256 tokenOutRate;
}
struct FiatRedeptionInitParams {
uint256 fiatAdditionalFee;
uint256 fiatFlatFee;
uint256 minFiatRedeemAmount;
}
/**
* @title IRedemptionVault
* @author RedDuck Software
*/
interface IRedemptionVault is IManageableVault {
/**
* @param user function caller (msg.sender)
* @param tokenOut address of tokenOut
* @param amount amount of mToken
* @param feeAmount fee amount in mToken
* @param amountTokenOut amount of tokenOut
*/
event RedeemInstant(
address indexed user,
address indexed tokenOut,
uint256 amount,
uint256 feeAmount,
uint256 amountTokenOut
);
/**
* @param requestId request id
* @param user function caller (msg.sender)
* @param tokenOut address of tokenOut
* @param amountMTokenIn amount of mToken
*/
event RedeemRequest(
uint256 indexed requestId,
address indexed user,
address indexed tokenOut,
uint256 amountMTokenIn,
uint256 feeAmount
);
/**
* @param requestId mint request id
* @param newMTokenRate net mToken rate
*/
event ApproveRequest(uint256 indexed requestId, uint256 newMTokenRate);
/**
* @param requestId mint request id
* @param newMTokenRate net mToken rate
*/
event SafeApproveRequest(uint256 indexed requestId, uint256 newMTokenRate);
/**
* @param requestId mint request id
* @param user address of user
*/
event RejectRequest(uint256 indexed requestId, address indexed user);
/**
* @param caller function caller (msg.sender)
* @param newMinAmount new min amount for fiat requests
*/
event SetMinFiatRedeemAmount(address indexed caller, uint256 newMinAmount);
/**
* @param caller function caller (msg.sender)
* @param feeInMToken fee amount in mToken
*/
event SetFiatFlatFee(address indexed caller, uint256 feeInMToken);
/**
* @param caller function caller (msg.sender)
* @param newfee new fiat fee percent 1% = 100
*/
event SetFiatAdditionalFee(address indexed caller, uint256 newfee);
/**
* @param caller function caller (msg.sender)
* @param redeemer new address of request redeemer
*/
event SetRequestRedeemer(address indexed caller, address redeemer);
/**
* @notice redeem mToken to tokenOut if daily limit and allowance not exceeded
* Burns mTBILL from the user.
* Transfers fee in mToken to feeReceiver
* Transfers tokenOut to user.
* @param tokenOut stable coin token address to redeem to
* @param amountMTokenIn amount of mTBILL to redeem (decimals 18)
* @param minReceiveAmount minimum expected amount of tokenOut to receive (decimals 18)
*/
function redeemInstant(
address tokenOut,
uint256 amountMTokenIn,
uint256 minReceiveAmount
) external;
/**
* @notice creating redeem request if tokenOut not fiat
* Transfers amount in mToken to contract
* Transfers fee in mToken to feeReceiver
* @param tokenOut stable coin token address to redeem to
* @param amountMTokenIn amount of mToken to redeem (decimals 18)
* @return request id
*/
function redeemRequest(address tokenOut, uint256 amountMTokenIn)
external
returns (uint256);
/**
* @notice creating redeem request if tokenOut is fiat
* Transfers amount in mToken to contract
* Transfers fee in mToken to feeReceiver
* @param amountMTokenIn amount of mToken to redeem (decimals 18)
* @return request id
*/
function redeemFiatRequest(uint256 amountMTokenIn)
external
returns (uint256);
/**
* @notice approving redeem request if not exceed tokenOut allowance
* Burns amount mToken from contract
* Transfers tokenOut to user
* Sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate inputted by vault admin
*/
function approveRequest(uint256 requestId, uint256 newMTokenRate) external;
/**
* @notice approving request if inputted token rate fit price diviation percent
* Burns amount mToken from contract
* Transfers tokenOut to user
* Sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate inputted by vault admin
*/
function safeApproveRequest(uint256 requestId, uint256 newMTokenRate)
external;
/**
* @notice rejecting request
* Sets request flag to Canceled.
* @param requestId request id
*/
function rejectRequest(uint256 requestId) external;
/**
* @notice set new min amount for fiat requests
* @param newValue new min amount
*/
function setMinFiatRedeemAmount(uint256 newValue) external;
/**
* @notice set fee amount in mToken for fiat requests
* @param feeInMToken fee amount in mToken
*/
function setFiatFlatFee(uint256 feeInMToken) external;
/**
* @notice set new fee percent for fiat requests
* @param newFee new fee percent 1% = 100
*/
function setFiatAdditionalFee(uint256 newFee) external;
/**
* @notice set address which is designated for standard redemptions, allowing tokens to be pulled from this address
* @param redeemer new address of request redeemer
*/
function setRequestRedeemer(address redeemer) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "./MidasAccessControlRoles.sol";
import "../abstract/MidasInitializable.sol";
/**
* @title MidasAccessControl
* @notice Smart contract that stores all roles for Midas project
* @author RedDuck Software
*/
contract MidasAccessControl is
AccessControlUpgradeable,
MidasInitializable,
MidasAccessControlRoles
{
/**
* @notice upgradeable pattern contract`s initializer
*/
function initialize() external initializer {
__AccessControl_init();
_setupRoles(msg.sender);
}
/**
* @notice grant multiple roles to multiple users
* in one transaction
* @dev length`s of 2 arays should match
* @param roles array of bytes32 roles
* @param addresses array of user addresses
*/
function grantRoleMult(bytes32[] memory roles, address[] memory addresses)
external
{
require(roles.length == addresses.length, "MAC: mismatch arrays");
for (uint256 i = 0; i < roles.length; i++) {
_checkRole(getRoleAdmin(roles[i]), msg.sender);
_grantRole(roles[i], addresses[i]);
}
}
/**
* @notice revoke multiple roles from multiple users
* in one transaction
* @dev length`s of 2 arays should match
* @param roles array of bytes32 roles
* @param addresses array of user addresses
*/
function revokeRoleMult(bytes32[] memory roles, address[] memory addresses)
external
{
require(roles.length == addresses.length, "MAC: mismatch arrays");
for (uint256 i = 0; i < roles.length; i++) {
_checkRole(getRoleAdmin(roles[i]), msg.sender);
_revokeRole(roles[i], addresses[i]);
}
}
//solhint-disable disable-next-line
function renounceRole(bytes32, address) public pure override {
revert("MAC: Forbidden");
}
/**
* @dev setup roles during the contracts initialization
*/
function _setupRoles(address admin) private {
_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(DEPOSIT_VAULT_ADMIN_ROLE, admin);
_grantRole(REDEMPTION_VAULT_ADMIN_ROLE, admin);
_setRoleAdmin(BLACKLISTED_ROLE, BLACKLIST_OPERATOR_ROLE);
_setRoleAdmin(GREENLISTED_ROLE, GREENLIST_OPERATOR_ROLE);
_grantRole(GREENLIST_OPERATOR_ROLE, admin);
_grantRole(BLACKLIST_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_MINT_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_BURN_OPERATOR_ROLE, admin);
_grantRole(M_TBILL_PAUSE_OPERATOR_ROLE, admin);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
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 = MathUpgradeable.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(SignedMathUpgradeable.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, MathUpgradeable.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));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.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) || (!AddressUpgradeable.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;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
function latestRoundData()
external
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC20MetadataUpgradeable as IERC20Metadata} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol";
import "./interfaces/IRedemptionVault.sol";
import "./interfaces/IMTbill.sol";
import "./interfaces/IDataFeed.sol";
import "./abstract/ManageableVault.sol";
import "./access/Greenlistable.sol";
/**
* @title RedemptionVault
* @notice Smart contract that handles mTBILL redemptions
* @author RedDuck Software
*/
contract RedemptionVault is ManageableVault, IRedemptionVault {
using Counters for Counters.Counter;
/**
* @notice min amount for fiat requests
*/
uint256 public minFiatRedeemAmount;
/**
* @notice fee percent for fiat requests
*/
uint256 public fiatAdditionalFee;
/**
* @notice static fee in mToken for fiat requests
*/
uint256 public fiatFlatFee;
/**
* @notice mapping, requestId to request data
*/
mapping(uint256 => Request) public redeemRequests;
/**
* @notice address is designated for standard redemptions, allowing tokens to be pulled from this address
*/
address public requestRedeemer;
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @notice upgradeable pattern contract`s initializer
* @param _ac address of MidasAccessControll contract
* @param _mTokenInitParams init params for mToken
* @param _receiversInitParams init params for receivers
* @param _instantInitParams init params for instant operations
* @param _sanctionsList address of sanctionsList contract
* @param _variationTolerance percent of prices diviation 1% = 100
* @param _minAmount basic min amount for operations
* @param _fiatRedemptionInitParams params fiatAdditionalFee, fiatFlatFee, minFiatRedeemAmount
* @param _requestRedeemer address is designated for standard redemptions, allowing tokens to be pulled from this address
*/
function initialize(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
FiatRedeptionInitParams calldata _fiatRedemptionInitParams,
address _requestRedeemer
) external initializer {
__RedemptionVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount,
_fiatRedemptionInitParams,
_requestRedeemer
);
}
// solhint-disable func-name-mixedcase
function __RedemptionVault_init(
address _ac,
MTokenInitParams calldata _mTokenInitParams,
ReceiversInitParams calldata _receiversInitParams,
InstantInitParams calldata _instantInitParams,
address _sanctionsList,
uint256 _variationTolerance,
uint256 _minAmount,
FiatRedeptionInitParams calldata _fiatRedemptionInitParams,
address _requestRedeemer
) internal onlyInitializing {
__ManageableVault_init(
_ac,
_mTokenInitParams,
_receiversInitParams,
_instantInitParams,
_sanctionsList,
_variationTolerance,
_minAmount
);
_validateFee(_fiatRedemptionInitParams.fiatAdditionalFee, false);
_validateAddress(_requestRedeemer, false);
minFiatRedeemAmount = _fiatRedemptionInitParams.minFiatRedeemAmount;
fiatAdditionalFee = _fiatRedemptionInitParams.fiatAdditionalFee;
fiatFlatFee = _fiatRedemptionInitParams.fiatFlatFee;
requestRedeemer = _requestRedeemer;
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemInstant(
address tokenOut,
uint256 amountMTokenIn,
uint256 minReceiveAmount
)
external
virtual
whenFnNotPaused(this.redeemInstant.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
{
address user = msg.sender;
(
uint256 feeAmount,
uint256 amountMTokenWithoutFee
) = _calcAndValidateRedeem(user, tokenOut, amountMTokenIn, true, false);
_requireAndUpdateLimit(amountMTokenIn);
uint256 tokenDecimals = _tokenDecimals(tokenOut);
uint256 amountMTokenInCopy = amountMTokenIn;
address tokenOutCopy = tokenOut;
uint256 minReceiveAmountCopy = minReceiveAmount;
(uint256 amountMTokenInUsd, uint256 mTokenRate) = _convertMTokenToUsd(
amountMTokenInCopy
);
(uint256 amountTokenOut, uint256 tokenOutRate) = _convertUsdToToken(
amountMTokenInUsd,
tokenOutCopy
);
uint256 amountTokenOutWithoutFee = _truncate(
(amountMTokenWithoutFee * mTokenRate) / tokenOutRate,
tokenDecimals
);
require(
amountTokenOutWithoutFee >= minReceiveAmountCopy,
"RV: minReceiveAmount > actual"
);
_requireAndUpdateAllowance(tokenOutCopy, amountTokenOut);
mToken.burn(user, amountMTokenWithoutFee);
if (feeAmount > 0)
_tokenTransferFromUser(address(mToken), feeReceiver, feeAmount, 18);
_tokenTransferToUser(
tokenOutCopy,
user,
amountTokenOutWithoutFee,
tokenDecimals
);
emit RedeemInstant(
user,
tokenOutCopy,
amountMTokenInCopy,
feeAmount,
amountTokenOutWithoutFee
);
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemRequest(address tokenOut, uint256 amountMTokenIn)
external
whenFnNotPaused(this.redeemRequest.selector)
onlyGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
returns (uint256 requestId)
{
require(tokenOut != MANUAL_FULLFILMENT_TOKEN, "RV: tokenOut == fiat");
return _redeemRequest(tokenOut, amountMTokenIn);
}
/**
* @inheritdoc IRedemptionVault
*/
function redeemFiatRequest(uint256 amountMTokenIn)
external
whenFnNotPaused(this.redeemFiatRequest.selector)
onlyAlwaysGreenlisted(msg.sender)
onlyNotBlacklisted(msg.sender)
onlyNotSanctioned(msg.sender)
returns (uint256 requestId)
{
return _redeemRequest(MANUAL_FULLFILMENT_TOKEN, amountMTokenIn);
}
/**
* @inheritdoc IRedemptionVault
*/
function approveRequest(uint256 requestId, uint256 newMTokenRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newMTokenRate, false);
emit ApproveRequest(requestId, newMTokenRate);
}
/**
* @inheritdoc IRedemptionVault
*/
function safeApproveRequest(uint256 requestId, uint256 newMTokenRate)
external
onlyVaultAdmin
{
_approveRequest(requestId, newMTokenRate, true);
emit SafeApproveRequest(requestId, newMTokenRate);
}
/**
* @inheritdoc IRedemptionVault
*/
function rejectRequest(uint256 requestId) external onlyVaultAdmin {
Request memory request = redeemRequests[requestId];
_validateRequest(request.sender, request.status);
redeemRequests[requestId].status = RequestStatus.Canceled;
emit RejectRequest(requestId, request.sender);
}
/**
* @inheritdoc IRedemptionVault
*/
function setMinFiatRedeemAmount(uint256 newValue) external onlyVaultAdmin {
minFiatRedeemAmount = newValue;
emit SetMinFiatRedeemAmount(msg.sender, newValue);
}
/**
* @inheritdoc IRedemptionVault
*/
function setFiatFlatFee(uint256 feeInMToken) external onlyVaultAdmin {
fiatFlatFee = feeInMToken;
emit SetFiatFlatFee(msg.sender, feeInMToken);
}
/**
* @inheritdoc IRedemptionVault
*/
function setFiatAdditionalFee(uint256 newFee) external onlyVaultAdmin {
_validateFee(newFee, false);
fiatAdditionalFee = newFee;
emit SetFiatAdditionalFee(msg.sender, newFee);
}
/**
* @inheritdoc IRedemptionVault
*/
function setRequestRedeemer(address redeemer) external onlyVaultAdmin {
_validateAddress(redeemer, false);
requestRedeemer = redeemer;
emit SetRequestRedeemer(msg.sender, redeemer);
}
/**
* @inheritdoc ManageableVault
*/
function vaultRole() public pure virtual override returns (bytes32) {
return REDEMPTION_VAULT_ADMIN_ROLE;
}
/**
* @notice validates approve
* burns amount from contract
* transfer tokenOut to user if not fiat
* sets flag Processed
* @param requestId request id
* @param newMTokenRate new mToken rate
* @param isSafe new mToken rate
*/
function _approveRequest(
uint256 requestId,
uint256 newMTokenRate,
bool isSafe
) internal {
Request memory request = redeemRequests[requestId];
_validateRequest(request.sender, request.status);
if (isSafe) {
_requireVariationTolerance(request.mTokenRate, newMTokenRate);
}
mToken.burn(address(this), request.amountMToken);
bool isFiat = request.tokenOut == MANUAL_FULLFILMENT_TOKEN;
uint256 tokenDecimals = isFiat ? 18 : _tokenDecimals(request.tokenOut);
uint256 amountTokenOutWithoutFee = _truncate(
(request.amountMToken * newMTokenRate) / request.tokenOutRate,
tokenDecimals
);
_requireAndUpdateAllowance(request.tokenOut, amountTokenOutWithoutFee);
if (!isFiat) {
_tokenTransferFromTo(
request.tokenOut,
requestRedeemer,
request.sender,
amountTokenOutWithoutFee,
tokenDecimals
);
}
request.status = RequestStatus.Processed;
request.mTokenRate = newMTokenRate;
redeemRequests[requestId] = request;
}
/**
* @notice validates request
* if exist
* if not processed
* @param sender sender address
* @param status request status
*/
function _validateRequest(address sender, RequestStatus status)
internal
pure
{
require(sender != address(0), "RV: request not exist");
require(status == RequestStatus.Pending, "RV: request not pending");
}
/**
* @notice Creating request depends on tokenOut
* @param tokenOut tokenOut address
* @param amountMTokenIn amount of mToken (decimals 18)
*
* @return requestId request id
*/
function _redeemRequest(address tokenOut, uint256 amountMTokenIn)
internal
returns (uint256)
{
address user = msg.sender;
bool isFiat = tokenOut == MANUAL_FULLFILMENT_TOKEN;
(
uint256 feeAmount,
uint256 amountMTokenWithoutFee
) = _calcAndValidateRedeem(
user,
tokenOut,
amountMTokenIn,
false,
isFiat
);
address tokenOutCopy = tokenOut;
// assigning the default value which is gonna be used
// only for fiat redemptions
uint256 tokenOutRate = 1e18;
if (!isFiat) {
TokenConfig storage config = tokensConfig[tokenOutCopy];
tokenOutRate = _getTokenRate(config.dataFeed, config.stable);
}
uint256 amountMTokenInCopy = amountMTokenIn;
uint256 mTokenRate = mTokenDataFeed.getDataInBase18();
_tokenTransferFromUser(
address(mToken),
address(this),
amountMTokenWithoutFee,
18 // mToken always have 18 decimals
);
if (feeAmount > 0)
_tokenTransferFromUser(address(mToken), feeReceiver, feeAmount, 18);
uint256 requestId = currentRequestId.current();
currentRequestId.increment();
redeemRequests[requestId] = Request({
sender: user,
tokenOut: tokenOutCopy,
status: RequestStatus.Pending,
amountMToken: amountMTokenWithoutFee,
mTokenRate: mTokenRate,
tokenOutRate: tokenOutRate
});
emit RedeemRequest(
requestId,
user,
tokenOutCopy,
amountMTokenInCopy,
feeAmount
);
return requestId;
}
/**
* @dev calculates tokenOut amount from USD amount
* @param amountUsd amount of USD (decimals 18)
* @param tokenOut tokenOut address
*
* @return amountToken converted USD to tokenOut
* @return tokenRate conversion rate
*/
function _convertUsdToToken(uint256 amountUsd, address tokenOut)
internal
view
returns (uint256 amountToken, uint256 tokenRate)
{
require(amountUsd > 0, "RV: amount zero");
TokenConfig storage tokenConfig = tokensConfig[tokenOut];
tokenRate = _getTokenRate(tokenConfig.dataFeed, tokenConfig.stable);
require(tokenRate > 0, "RV: rate zero");
amountToken = (amountUsd * (10**18)) / tokenRate;
}
/**
* @dev calculates USD amount from mToken amount
* @param amountMToken amount of mToken (decimals 18)
*
* @return amountUsd converted amount to USD
* @return mTokenRate conversion rate
*/
function _convertMTokenToUsd(uint256 amountMToken)
internal
view
returns (uint256 amountUsd, uint256 mTokenRate)
{
require(amountMToken > 0, "RV: amount zero");
mTokenRate = _getTokenRate(address(mTokenDataFeed), false);
require(mTokenRate > 0, "RV: rate zero");
amountUsd = (amountMToken * mTokenRate) / (10**18);
}
/**
* @dev validate redeem and calculate fee
* @param user user address
* @param tokenOut tokenOut address
* @param amountMTokenIn mToken amount (decimals 18)
* @param isInstant is instant operation
* @param isFiat is fiat operation
*
* @return feeAmount fee amount in mToken
* @return amountMTokenWithoutFee mToken amount without fee
*/
function _calcAndValidateRedeem(
address user,
address tokenOut,
uint256 amountMTokenIn,
bool isInstant,
bool isFiat
)
internal
view
returns (uint256 feeAmount, uint256 amountMTokenWithoutFee)
{
require(amountMTokenIn > 0, "RV: invalid amount");
if (!isFreeFromMinAmount[user]) {
uint256 minRedeemAmount = isFiat ? minFiatRedeemAmount : minAmount;
require(minRedeemAmount <= amountMTokenIn, "RV: amount < min");
}
feeAmount = _getFeeAmount(
user,
tokenOut,
amountMTokenIn,
isInstant,
isFiat ? fiatAdditionalFee : 0
);
if (isFiat) {
require(
tokenOut == MANUAL_FULLFILMENT_TOKEN,
"RV: tokenOut != fiat"
);
if (!waivedFeeRestriction[user]) feeAmount += fiatFlatFee;
} else {
_requireTokenExists(tokenOut);
}
require(amountMTokenIn > feeAmount, "RV: amountMTokenIn < fee");
amountMTokenWithoutFee = amountMTokenIn - feeAmount;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));
}
}// 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 IERC165Upgradeable {
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
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(IAccessControlUpgradeable).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 ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.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());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "./WithMidasAccessControl.sol";
/**
* @title Blacklistable
* @notice Base contract that implements basic functions and modifiers
* to work with blacklistable
* @author RedDuck Software
*/
abstract contract Blacklistable is WithMidasAccessControl {
/**
* @dev leaving a storage gap for futures updates
*/
uint256[50] private __gap;
/**
* @dev checks that a given `account` doesnt
* have BLACKLISTED_ROLE
*/
modifier onlyNotBlacklisted(address account) {
_onlyNotBlacklisted(account);
_;
}
/**
* @dev upgradeable pattern contract`s initializer
* @param _accessControl MidasAccessControl contract address
*/
// solhint-disable func-name-mixedcase
function __Blacklistable_init(address _accessControl)
internal
onlyInitializing
{
__WithMidasAccessControl_init(_accessControl);
__Blacklistable_init_unchained();
}
/**
* @dev upgradeable pattern contract`s initializer unchained
*/
// solhint-disable func-name-mixedcase
function __Blacklistable_init_unchained() internal onlyInitializing {}
/**
* @dev checks that a given `account` doesnt
* have BLACKLISTED_ROLE
*/
function _onlyNotBlacklisted(address account)
internal
view
onlyNotRole(BLACKLISTED_ROLE, account)
{}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
// TODO: add natspec
interface ISanctionsList {
function isSanctioned(address addr) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// 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;
}
}{
"libraries": {},
"metadata": {
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"dataFeed","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bool","name":"stable","type":"bool"}],"name":"AddPaymentToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"AddWaivedFeeAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMTokenRate","type":"uint256"}],"name":"ApproveRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"allowance","type":"uint256"}],"name":"ChangeTokenAllowance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ChangeTokenFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"FreeFromMinAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"PauseFn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"name":"RedeemInstant","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountMTokenIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"RedeemRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"RejectRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"RemovePaymentToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"RemoveWaivedFeeAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMTokenRate","type":"uint256"}],"name":"SafeApproveRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"reciever","type":"address"}],"name":"SetFeeReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newfee","type":"uint256"}],"name":"SetFiatAdditionalFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeInMToken","type":"uint256"}],"name":"SetFiatFlatFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"SetGreenlistEnable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newLimit","type":"uint256"}],"name":"SetInstantDailyLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"SetInstantFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"SetMinAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newMinAmount","type":"uint256"}],"name":"SetMinFiatRedeemAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"address","name":"redeemer","type":"address"}],"name":"SetRequestRedeemer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"newSanctionsList","type":"address"}],"name":"SetSanctionsList","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"reciever","type":"address"}],"name":"SetTokensReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTolerance","type":"uint256"}],"name":"SetVariationTolerance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"UnpauseFn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawToken","type":"event"},{"inputs":[],"name":"BLACKLISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BLACKLIST_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLISTED_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLIST_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GREENLIST_TOGGLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANUAL_FULLFILMENT_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_RE7SOL_CUSTOM_AGGREGATOR_FEED_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_RE7SOL_DEPOSIT_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_RE7SOL_REDEMPTION_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_BURN_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_MINT_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"M_TBILL_PAUSE_OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_HUNDRED_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REDEMPTION_VAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STABLECOIN_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accessControl","outputs":[{"internalType":"contract MidasAccessControl","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"dataFeed","type":"address"},{"internalType":"uint256","name":"tokenFee","type":"uint256"},{"internalType":"bool","name":"stable","type":"bool"}],"name":"addPaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addWaivedFeeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"newMTokenRate","type":"uint256"}],"name":"approveRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"}],"name":"changeTokenAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"changeTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentRequestId","outputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dailyLimits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiatAdditionalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiatFlatFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"fnPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"freeFromMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPaymentTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistTogglerRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"greenlistedRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ac","type":"address"},{"components":[{"internalType":"address","name":"mToken","type":"address"},{"internalType":"address","name":"mTokenDataFeed","type":"address"}],"internalType":"struct MTokenInitParams","name":"_mTokenInitParams","type":"tuple"},{"components":[{"internalType":"address","name":"tokensReceiver","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"}],"internalType":"struct ReceiversInitParams","name":"_receiversInitParams","type":"tuple"},{"components":[{"internalType":"uint256","name":"instantFee","type":"uint256"},{"internalType":"uint256","name":"instantDailyLimit","type":"uint256"}],"internalType":"struct InstantInitParams","name":"_instantInitParams","type":"tuple"},{"internalType":"address","name":"_sanctionsList","type":"address"},{"internalType":"uint256","name":"_variationTolerance","type":"uint256"},{"internalType":"uint256","name":"_minAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"fiatAdditionalFee","type":"uint256"},{"internalType":"uint256","name":"fiatFlatFee","type":"uint256"},{"internalType":"uint256","name":"minFiatRedeemAmount","type":"uint256"}],"internalType":"struct FiatRedeptionInitParams","name":"_fiatRedemptionInitParams","type":"tuple"},{"internalType":"address","name":"_requestRedeemer","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"instantDailyLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"instantFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isFreeFromMinAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mToken","outputs":[{"internalType":"contract IMTbill","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mTokenDataFeed","outputs":[{"internalType":"contract IDataFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minFiatRedeemAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseAdminRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"pauseFn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMTokenIn","type":"uint256"}],"name":"redeemFiatRequest","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountMTokenIn","type":"uint256"},{"internalType":"uint256","name":"minReceiveAmount","type":"uint256"}],"name":"redeemInstant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountMTokenIn","type":"uint256"}],"name":"redeemRequest","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"redeemRequests","outputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"enum RequestStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"amountMToken","type":"uint256"},{"internalType":"uint256","name":"mTokenRate","type":"uint256"},{"internalType":"uint256","name":"tokenOutRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"rejectRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removePaymentToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeWaivedFeeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRedeemer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"newMTokenRate","type":"uint256"}],"name":"safeApproveRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sanctionsList","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sanctionsListAdminRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"setFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"setFiatAdditionalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeInMToken","type":"uint256"}],"name":"setFiatFlatFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enable","type":"bool"}],"name":"setGreenlistEnable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newInstantDailyLimit","type":"uint256"}],"name":"setInstantDailyLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newInstantFee","type":"uint256"}],"name":"setInstantFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"setMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setMinFiatRedeemAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"redeemer","type":"address"}],"name":"setRequestRedeemer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newSanctionsList","type":"address"}],"name":"setSanctionsList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"setTokensReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tolerance","type":"uint256"}],"name":"setVariationTolerance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokensConfig","outputs":[{"internalType":"address","name":"dataFeed","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"bool","name":"stable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"fn","type":"bytes4"}],"name":"unpauseFn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"variationTolerance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"waivedFeeRestriction","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"withdrawTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6142b780620000f36000396000f3fe608060405234801561001057600080fd5b50600436106104695760003560e01c8063769bc79c1161024c578063bc979af611610146578063db74d8b5116100c3578063e6636d8011610087578063e6636d8014610b1e578063e85ba3e914610b45578063eaf896fd14610bab578063ec571c6a14610bb3578063efdcd97414610bc757600080fd5b8063db74d8b514610abf578063dd0081c714610ad2578063e2c4d73714610adb578063e428877e14610b02578063e5b5019a14610b1557600080fd5b8063ca5e553e1161010a578063ca5e553e14610a6b578063cabccc7f14610a80578063d5f73f5c14610a88578063d7fd2bae14610a9b578063daddcb1614610a8057600080fd5b8063bc979af6146109b8578063bfc2d46a14610a27578063c3b6f93914610a3a578063c47d51be14610a4e578063c64b639114610a5857600080fd5b80639af40265116101d4578063a8f9a71d11610198578063a8f9a71d14610931578063ad9e564914610944578063b3f0067414610957578063bbae40861461096b578063bc63773f1461099157600080fd5b80639af40265146108fa5780639b2cb5d814610902578063a217fddf1461090c578063a3ece89314610914578063a51254211461091e57600080fd5b80638978ac451161021b5780638978ac451461088b578063897b0637146108b25780638a0ae615146108c55780638b53f75e146108d8578063978ff560146108eb57600080fd5b8063769bc79c146108535780637af5ca99146108665780638456cb591461087057806388a6de681461087857600080fd5b806339dac34d116103685780635c975abb116102e55780636957463a116102a95780636957463a146107ee5780636dc69e03146108015780637192de4b1461082257806373b7f8731461082c57806373e9e01f1461083f57600080fd5b80635c975abb1461075a57806360348156146107655780636254afb61461078c57806362b199c5146107a057806366bfc539146107c757600080fd5b806349dc5e8d1161032c57806349dc5e8d146106ef5780634a5971eb146107025780635300b4ba14610715578063563b1dbf1461073c5780635ae2bfdb1461074f57600080fd5b806339dac34d146106875780633ccdbb281461069a5780633f4ba83a146106ad57806340985323146106b5578063476abc76146106dc57600080fd5b80631fa1e8d4116103f657806332b30cce116103ba57806332b30cce1461061e57806334c24489146106445780633733337d146106575780633807be7d1461066a5780633972183c1461067d57600080fd5b80631fa1e8d4146105aa57806327abf518146105be5780632c0a90a9146105d15780632d7788db146105e45780632e80c6a8146105f757600080fd5b806313007d551161043d57806313007d551461050c57806315b9598a1461053d57806316683aa514610564578063191f3a3e146105795780631ed411631461058357600080fd5b8062eafebf1461046e578063042da5ee146104a85780630b5a57bd146104dc578063105ed2b2146104ff575b600080fd5b6104957fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6040519081526020015b60405180910390f35b6104cc6104b6366004613bf1565b61016b6020526000908152604090205460ff1681565b604051901515815260200161049f565b6104cc6104ea366004613c0c565b60976020526000908152604090205460ff1681565b60fc546104cc9060ff1681565b600054610525906201000090046001600160a01b031681565b6040516001600160a01b03909116815260200161049f565b6104957f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b610577610572366004613bf1565b610bda565b005b6104956101a45481565b6104957fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b61016554610525906001600160a01b031681565b6105776105cc366004613c44565b610c95565b6105776105df366004613c61565b610d3a565b6105776105f2366004613c83565b610d8f565b6104957f4d94b4292928820575e235996b429e6637143146fc4a1b5c3e054e8d7945675681565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df9601442610495565b610577610652366004613c83565b610e97565b610577610665366004613c0c565b610ee5565b610577610678366004613c0c565b610f81565b6104956101675481565b610577610695366004613c9c565b611041565b6105776106a8366004613cd3565b611108565b610577611183565b6104957f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6105776106ea366004613bf1565b611198565b6105776106fd366004613bf1565b6111fb565b610577610710366004613d27565b611253565b6104957f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b61057761074a366004613c83565b611376565b610162546104959081565b60655460ff166104cc565b6104957f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b61016454610525906001600160a01b031681565b6104957f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b6104957f06eedf8d6f31879c73bbae06fd13a702c2faed8dd4116d3cc7808bea5843665481565b6105776107fc366004613c83565b6113b9565b61049561080f366004613c83565b6101686020526000908152604090205481565b61049561016a5481565b61057761083a366004613c83565b61143d565b6101a754610525906001600160a01b031681565b610577610861366004613c83565b61148b565b6104956101a35481565b6105776114ce565b610577610886366004613c61565b6114e1565b6104957f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b6105776108c0366004613c83565b61152a565b6105776108d3366004613dd4565b61156d565b6105776108e6366004613dfe565b611635565b610495670de0b6b3a764000081565b610525600081565b61049561016f5481565b610495600081565b6104956101a55481565b61057761092c366004613bf1565b61191e565b61057761093f366004613bf1565b6119dd565b610577610952366004613c83565b611a44565b61016954610525906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd8610495565b6104957fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b6109fb6109c6366004613bf1565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b0390951685526020850193909352918301521515606082015260800161049f565b610495610a35366004613dd4565b611a92565b61016354610525906001600160a01b031681565b6104956101665481565b610577610a66366004613e31565b611c0c565b610a73611d39565b60405161049f9190613e80565b610495611d4b565b610495610a96366004613c83565b611d55565b6104cc610aa9366004613bf1565b6101706020526000908152604090205460ff1681565b610577610acd366004613dd4565b611e76565b61049561271081565b6104957f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b610577610b10366004613bf1565b611ee9565b61049560001981565b6104957f9b4e55e8de230bedd27d0e7c47d1fbab2b169fb1e77d738bf687b70d7cd90fe181565b610b99610b53366004613c83565b6101a660205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b60405161049f96959493929190613ee3565b610495611fa1565b61012f54610525906001600160a01b031681565b610577610bd5366004613bf1565b611fc5565b610beb610be5611fa1565b33612028565b6001600160a01b038116600090815261016b602052604090205460ff16610c495760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610c9e336120f6565b60fc5460ff1615158115151415610cf05760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610c40565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f54906020015b60405180910390a250565b610d45610be5611fa1565b610d5182826000612128565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610d8391815260200190565b60405180910390a25050565b610d9a610be5611fa1565b60008181526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610df357610df3613ecd565b6002811115610e0457610e04613ecd565b815260200160028201548152602001600382015481526020016004820154815250509050610e3a81600001518260400151612388565b60008281526101a66020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610ea2610be5611fa1565b610ead816001612437565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610d2f565b610ef0610be5611d4b565b6001600160e01b0319811660009081526097602052604090205460ff1615610f2a5760405162461bcd60e51b8152600401610c4090613f3c565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610d2f565b610f8c610be5611d4b565b6001600160e01b0319811660009081526097602052604090205460ff16610fed5760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610c40565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610d2f565b61104c610be5611fa1565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156110af5760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610c40565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610d83565b611113610be5611fa1565b6111276001600160a01b03841682846124b7565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b7468560405161117691815260200190565b60405180910390a4505050565b61118e610be5611d4b565b61119661251a565b565b6111a3610be5611fa1565b6111ae81600161256c565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b611206610be5611d4b565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b600054610100900460ff16158080156112735750600054600160ff909116105b8061128d5750303b15801561128d575060005460ff166001145b6112f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c40565b6000805460ff191660011790558015611313576000805461ff0019166101001790555b6113248a8a8a8a8a8a8a8a8a612602565b801561136a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b611381610be5611fa1565b6101a581905560405181815233907f72bae0b4c0979f93d77dce748bd8dfbc89d0f1cd524eee95367e3d2ce5eca93f90602001610d2f565b6113c4610be5611fa1565b600081116114055760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610c40565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610d2f565b611448610be5611fa1565b611453816000612437565b6101a481905560405181815233907fa627d2a34207df740c6b90691350e2a762296cbf59affeb2282e6a54d631d4db90602001610d2f565b611496610be5611fa1565b6101a381905560405181815233907f8855fe6f9cbc4052017b3546fa14e167c5af2daad7f1c64db7f897fbcfb657b090602001610d2f565b6114d9610be5611d4b565b611196612691565b6114ec610be5611fa1565b6114f882826001612128565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610d8391815260200190565b611535610be5611fa1565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610d2f565b611578610be5611fa1565b6001600160a01b0382161561159057611590826126ce565b600081116115d55760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610c40565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906116299085815260200190565b60405180910390a35050565b6345a9fbaf60e11b611645612720565b6001600160e01b0319811660009081526097602052604090205460ff161561167f5760405162461bcd60e51b8152600401610c4090613f3c565b60fc54339060ff16156116955761169581612766565b3361169f8161278c565b61012f5433906001600160a01b0316801561174a5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b1580156116f557600080fd5b505afa158015611709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172d9190613f69565b1561174a5760405162461bcd60e51b8152600401610c4090613f86565b3360008061175c838c8c6001856127b8565b915091506117698a612994565b60006117748c612a1e565b60ff1690508a8c8b60008061178885612a97565b915091506000806117998487612b5a565b909250905060006117be826117ae868d613fc5565b6117b89190613fe4565b8a612c3a565b9050858110156118105760405162461bcd60e51b815260206004820152601d60248201527f52563a206d696e52656365697665416d6f756e74203e2061637475616c0000006044820152606401610c40565b61181a8784612c57565b61016354604051632770a7eb60e21b81526001600160a01b038e81166004830152602482018d905290911690639dc29fac90604401600060405180830381600087803b15801561186957600080fd5b505af115801561187d573d6000803e3d6000fd5b5050505060008b11156118ab5761016354610169546118ab916001600160a01b0390811691168d6012612d00565b6118b7878d838c612d52565b60408051898152602081018d90529081018290526001600160a01b0380891691908e16907f1af12536d161c2c30ad907b0abe442f94c4a7824f2463585b3fc893275247cce9060600160405180910390a35050505050505050505050505050505050505050565b611929610be5611fa1565b61193561016c82612d9c565b6119725760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610c40565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b6119e8610be5611fa1565b6119f381600061256c565b6101a780546001600160a01b0319166001600160a01b03831690811790915560405190815233907f5059e224ac539671fe0261fc6672c365607aa98da29c849726ac5956902221b490602001610d2f565b611a4f610be5611fa1565b611a5a816000612437565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610d2f565b6000635fe16a3560e11b611aa4612720565b6001600160e01b0319811660009081526097602052604090205460ff1615611ade5760405162461bcd60e51b8152600401610c4090613f3c565b60fc54339060ff1615611af457611af481612766565b33611afe8161278c565b61012f5433906001600160a01b03168015611ba95760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611b5457600080fd5b505afa158015611b68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8c9190613f69565b15611ba95760405162461bcd60e51b8152600401610c4090613f86565b6001600160a01b038816611bf65760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d080f4f48199a585d60621b6044820152606401610c40565b611c008888612db1565b98975050505050505050565b611c17610be5611fa1565b611c2361016c85613031565b611c635760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610c40565b611c6e83600061256c565b611c79826000612437565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b6060611d4661016c613046565b905090565b6000611d46611fa1565b600063357dcfd760e21b611d67612720565b6001600160e01b0319811660009081526097602052604090205460ff1615611da15760405162461bcd60e51b8152600401610c4090613f3c565b33611dab81612766565b33611db58161278c565b61012f5433906001600160a01b03168015611e605760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611e0b57600080fd5b505afa158015611e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e439190613f69565b15611e605760405162461bcd60e51b8152600401610c4090613f86565b611e6b600088612db1565b979650505050505050565b611e81610be5611fa1565b611e8a826126ce565b611e95816000612437565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906116299085815260200190565b611ef4610be5611fa1565b6001600160a01b038116600090815261016b602052604090205460ff1615611f525760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610c40565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b7f06eedf8d6f31879c73bbae06fd13a702c2faed8dd4116d3cc7808bea5843665490565b611fd0610be5611fa1565b611fdb81600161256c565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561207b57600080fd5b505afa15801561208f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b39190613f69565b6120f25760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610c40565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b816121238282612028565b505050565b60008381526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff16600281111561218157612181613ecd565b600281111561219257612192613ecd565b8152602001600282015481526020016003820154815260200160048201548152505090506121c881600001518260400151612388565b81156121dc576121dc816080015184613053565b610163546060820151604051632770a7eb60e21b815230600482015260248101919091526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b15801561222f57600080fd5b505af1158015612243573d6000803e3d6000fd5b5050505060208101516001600160a01b03161560008161226f5761226a8360200151612a1e565b612272565b60125b60ff16905060006122a18460a001518786606001516122919190613fc5565b61229b9190613fe4565b83612c3a565b90506122b1846020015182612c57565b826122d75760208401516101a75485516122d792916001600160a01b03169084866130ec565b600160408501819052506080840186905260008781526101a66020908152604091829020865181546001600160a01b039182166001600160a01b0319918216178355928801516001830180549190921693811684178255938801518894929390926001600160a81b03191617600160a01b83600281111561235a5761235a613ecd565b0217905550606082015160028201556080820151600382015560a09091015160049091015550505050505050565b6001600160a01b0382166123d65760405162461bcd60e51b815260206004820152601560248201527414958e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610c40565b60008160028111156123ea576123ea613ecd565b146120f25760405162461bcd60e51b815260206004820152601760248201527f52563a2072657175657374206e6f742070656e64696e670000000000000000006044820152606401610c40565b6127108211156124765760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610c40565b80156120f257600082116120f25760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610c40565b6040516001600160a01b03831660248201526044810182905261212390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261313f565b612522613214565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382166125b15760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610c40565b80156120f2576001600160a01b0382163014156120f25760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610c40565b600054610100900460ff166126295760405162461bcd60e51b8152600401610c4090614006565b6126388989898989898961325d565b61264482356000612437565b61264f81600061256c565b60408201356101a35581356101a4556020909101356101a5556101a780546001600160a01b0319166001600160a01b0390921691909117905550505050505050565b612699612720565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861254f3390565b6126da61016c82613435565b61271d5760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610c40565b50565b60655460ff16156111965760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c40565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd8612118565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816121238282613457565b600080600085116128005760405162461bcd60e51b815260206004820152601260248201527114958e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610c40565b6001600160a01b0387166000908152610170602052604090205460ff1661287d576000836128315761016f54612836565b6101a3545b90508581111561287b5760405162461bcd60e51b815260206004820152601060248201526f292b1d1030b6b7bab73a101e1036b4b760811b6044820152606401610c40565b505b6128998787878787612890576000613520565b6101a454613520565b91508215612926576001600160a01b038616156128ef5760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d08084f48199a585d60621b6044820152606401610c40565b6001600160a01b038716600090815261016b602052604090205460ff16612921576101a55461291e9083614051565b91505b61292f565b61292f866126ce565b81851161297e5760405162461bcd60e51b815260206004820152601860248201527f52563a20616d6f756e744d546f6b656e496e203c2066656500000000000000006044820152606401610c40565b6129888286614069565b90509550959350505050565b60006129a36201518042613fe4565b60008181526101686020526040812054919250906129c2908490614051565b905061016754811115612a0a5760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610c40565b600091825261016860205260409091205550565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612a5957600080fd5b505afa158015612a6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a919190614080565b92915050565b60008060008311612adc5760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610c40565b61016454612af4906001600160a01b031660006135c1565b905060008111612b365760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610c40565b670de0b6b3a7640000612b498285613fc5565b612b539190613fe4565b9150915091565b60008060008411612b9f5760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610c40565b6001600160a01b03808416600090815261016e60205260409020805460038201549192612bd19291169060ff166135c1565b915060008211612c135760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610c40565b81612c2686670de0b6b3a7640000613fc5565b612c309190613fe4565b9250509250929050565b6000612c5082612c4a858261364e565b9061365c565b9392505050565b6001600160a01b038216600090815261016e6020526040902060020154600019811415612c8357505050565b81811015612cca5760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610c40565b6001600160a01b038316600090815261016e602052604081206002018054849290612cf6908490614069565b9091555050505050565b6000612d0c838361364e565b9050612d18818361365c565b8314612d365760405162461bcd60e51b8152600401610c40906140a3565b612d4b6001600160a01b03861633868461366a565b5050505050565b6000612d5e838361364e565b9050612d6a818361365c565b8314612d885760405162461bcd60e51b8152600401610c40906140a3565b612d4b6001600160a01b03861685836124b7565b6000612c50836001600160a01b0384166136a2565b6000336001600160a01b038416158280612dce84888884876127b8565b909250905086670de0b6b3a764000084612e18576001600160a01b03808316600090815261016e60205260409020805460038201549192612e149291169060ff166135c1565b9150505b6101645460408051636369290560e01b815290518a926000926001600160a01b0390911691636369290591600480820192602092909190829003018186803b158015612e6357600080fd5b505afa158015612e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9b91906140d1565b61016354909150612eb8906001600160a01b031630876012612d00565b8515612edf576101635461016954612edf916001600160a01b039081169116886012612d00565b6000612eeb6101625490565b9050612efc61016280546001019055565b6040805160c0810182526001600160a01b03808c168252871660208201529081016000815260208082018990526040808301869052606090920187905260008481526101a68252829020835181546001600160a01b039182166001600160a01b0319918216178355928501516001830180549190921693811684178255938501519193919290916001600160a81b03191617600160a01b836002811115612fa557612fa5613ecd565b0217905550606082015181600201556080820151816003015560a08201518160040155905050846001600160a01b0316896001600160a01b0316827f55ba94d231fa70a45e82b0a1c6a60ef72e41bb2455385128ee5cf8d98c0c1c0e868b60405161301a929190918252602082015260400190565b60405180910390a49b9a5050505050505050505050565b6000612c50836001600160a01b038416613795565b60606000612c50836137e4565b60008282101561306c576130678284614069565b613076565b6130768383614069565b905060008361308761271084613fc5565b6130919190613fe4565b905061016a548111156130e65760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610c40565b50505050565b60006130f8838361364e565b9050613104818361365c565b83146131225760405162461bcd60e51b8152600401610c40906140a3565b6131376001600160a01b03871686868461366a565b505050505050565b6000613194826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138409092919063ffffffff16565b90508051600014806131b55750808060200190518101906131b59190613f69565b6121235760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c40565b60655460ff166111965760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c40565b600054610100900460ff166132845760405162461bcd60e51b8152600401610c4090614006565b61329b6132946020880188613bf1565b600061256c565b6132ae6132946040880160208901613bf1565b6132c56132be6020870187613bf1565b600161256c565b6132d86132be6040870160208801613bf1565b60008460200135116133195760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610c40565b613324826001612437565b61333084356000612437565b61333d6020870187613bf1565b61016380546001600160a01b0319166001600160a01b039290921691909117905561336787613857565b61336f61388f565b61337761388f565b613380836138b6565b61338d6020860186613bf1565b61016580546001600160a01b0319166001600160a01b03929092169190911790556133be6040860160208701613bf1565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a83905561340b9060408801908801613bf1565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6001600160a01b03811660009081526001830160205260408120541515612c50565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b1580156134aa57600080fd5b505afa1580156134be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e29190613f69565b156120f25760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610c40565b6001600160a01b038516600090815261016b602052604081205460ff161561354a575060006135b8565b60008261357457506001600160a01b038516600090815261016e6020526040902060010154613577565b50815b831561358e576101665461358b9082614051565b90505b61271081111561359d57506127105b6127106135aa8287613fc5565b6135b49190613fe4565b9150505b95945050505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156135fd57600080fd5b505afa158015613611573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363591906140d1565b90508215612c5057670de0b6b3a7640000915050612a91565b6000612c5083601284613900565b6000612c5083836012613900565b6040516001600160a01b03808516602483015283166044820152606481018290526130e69085906323b872dd60e01b906084016124e3565b6000818152600183016020526040812054801561378b5760006136c6600183614069565b85549091506000906136da90600190614069565b905081811461373f5760008660000182815481106136fa576136fa6140ea565b906000526020600020015490508087600001848154811061371d5761371d6140ea565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061375057613750614100565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612a91565b6000915050612a91565b60008181526001830160205260408120546137dc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612a91565b506000612a91565b60608160000180548060200260200160405190810160405280929190818152602001828054801561383457602002820191906000526020600020905b815481526020019060010190808311613820575b50505050509050919050565b606061384f848460008561396d565b949350505050565b600054610100900460ff1661387e5760405162461bcd60e51b8152600401610c4090614006565b613886613a3d565b61271d81613a6c565b600054610100900460ff166111965760405162461bcd60e51b8152600401610c4090614006565b600054610100900460ff166138dd5760405162461bcd60e51b8152600401610c4090614006565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60008361390f57506000612c50565b8183141561391e575082612c50565b60008284111561394e576139328385614069565b61393d90600a6141fa565b6139479086613fe4565b905061384f565b6139588484614069565b61396390600a6141fa565b6135b89086613fc5565b6060824710156139ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c40565b600080866001600160a01b031685876040516139ea9190614232565b60006040518083038185875af1925050503d8060008114613a27576040519150601f19603f3d011682016040523d82523d6000602084013e613a2c565b606091505b5091509150611e6b87838387613b02565b600054610100900460ff16613a645760405162461bcd60e51b8152600401610c4090614006565b611196613b78565b600054610100900460ff16613a935760405162461bcd60e51b8152600401610c4090614006565b6001600160a01b038116613ad85760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610c40565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60608315613b6e578251613b67576001600160a01b0385163b613b675760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c40565b508161384f565b61384f8383613bab565b600054610100900460ff16613b9f5760405162461bcd60e51b8152600401610c4090614006565b6065805460ff19169055565b815115613bbb5781518083602001fd5b8060405162461bcd60e51b8152600401610c40919061424e565b80356001600160a01b0381168114613bec57600080fd5b919050565b600060208284031215613c0357600080fd5b612c5082613bd5565b600060208284031215613c1e57600080fd5b81356001600160e01b031981168114612c5057600080fd5b801515811461271d57600080fd5b600060208284031215613c5657600080fd5b8135612c5081613c36565b60008060408385031215613c7457600080fd5b50508035926020909101359150565b600060208284031215613c9557600080fd5b5035919050565b60008060408385031215613caf57600080fd5b613cb883613bd5565b91506020830135613cc881613c36565b809150509250929050565b600080600060608486031215613ce857600080fd5b613cf184613bd5565b925060208401359150613d0660408501613bd5565b90509250925092565b600060408284031215613d2157600080fd5b50919050565b6000806000806000806000806000898b036101c0811215613d4757600080fd5b613d508b613bd5565b9950613d5f8c60208d01613d0f565b9850613d6e8c60608d01613d0f565b9750613d7d8c60a08d01613d0f565b9650613d8b60e08c01613bd5565b95506101008b013594506101208b01359350606061013f1982011215613db057600080fd5b506101408a019150613dc56101a08b01613bd5565b90509295985092959850929598565b60008060408385031215613de757600080fd5b613df083613bd5565b946020939093013593505050565b600080600060608486031215613e1357600080fd5b613e1c84613bd5565b95602085013595506040909401359392505050565b60008060008060808587031215613e4757600080fd5b613e5085613bd5565b9350613e5e60208601613bd5565b9250604085013591506060850135613e7581613c36565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b81811015613ec15783516001600160a01b031683529284019291840191600101613e9c565b50909695505050505050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c0810160038610613f1957634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b600060208284031215613f7b57600080fd5b8151612c5081613c36565b6020808252600f908201526e15d4d30e881cd85b98dd1a5bdb9959608a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613fdf57613fdf613faf565b500290565b60008261400157634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000821982111561406457614064613faf565b500190565b60008282101561407b5761407b613faf565b500390565b60006020828403121561409257600080fd5b815160ff81168114612c5057600080fd5b6020808252601490820152734d563a20696e76616c696420726f756e64696e6760601b604082015260600190565b6000602082840312156140e357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600181815b8085111561415157816000190482111561413757614137613faf565b8085161561414457918102915b93841c939080029061411b565b509250929050565b60008261416857506001612a91565b8161417557506000612a91565b816001811461418b5760028114614195576141b1565b6001915050612a91565b60ff8411156141a6576141a6613faf565b50506001821b612a91565b5060208310610133831016604e8410600b84101617156141d4575081810a612a91565b6141de8383614116565b80600019048211156141f2576141f2613faf565b029392505050565b6000612c508383614159565b60005b83811015614221578181015183820152602001614209565b838111156130e65750506000910152565b60008251614244818460208701614206565b9190910192915050565b602081526000825180602084015261426d816040850160208701614206565b601f01601f1916919091016040019291505056fea26469706673582212204742436976ec2945bdbbfd0d53ae84a3ebf18707d6e743800d4ebaee8a9f7af564736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104695760003560e01c8063769bc79c1161024c578063bc979af611610146578063db74d8b5116100c3578063e6636d8011610087578063e6636d8014610b1e578063e85ba3e914610b45578063eaf896fd14610bab578063ec571c6a14610bb3578063efdcd97414610bc757600080fd5b8063db74d8b514610abf578063dd0081c714610ad2578063e2c4d73714610adb578063e428877e14610b02578063e5b5019a14610b1557600080fd5b8063ca5e553e1161010a578063ca5e553e14610a6b578063cabccc7f14610a80578063d5f73f5c14610a88578063d7fd2bae14610a9b578063daddcb1614610a8057600080fd5b8063bc979af6146109b8578063bfc2d46a14610a27578063c3b6f93914610a3a578063c47d51be14610a4e578063c64b639114610a5857600080fd5b80639af40265116101d4578063a8f9a71d11610198578063a8f9a71d14610931578063ad9e564914610944578063b3f0067414610957578063bbae40861461096b578063bc63773f1461099157600080fd5b80639af40265146108fa5780639b2cb5d814610902578063a217fddf1461090c578063a3ece89314610914578063a51254211461091e57600080fd5b80638978ac451161021b5780638978ac451461088b578063897b0637146108b25780638a0ae615146108c55780638b53f75e146108d8578063978ff560146108eb57600080fd5b8063769bc79c146108535780637af5ca99146108665780638456cb591461087057806388a6de681461087857600080fd5b806339dac34d116103685780635c975abb116102e55780636957463a116102a95780636957463a146107ee5780636dc69e03146108015780637192de4b1461082257806373b7f8731461082c57806373e9e01f1461083f57600080fd5b80635c975abb1461075a57806360348156146107655780636254afb61461078c57806362b199c5146107a057806366bfc539146107c757600080fd5b806349dc5e8d1161032c57806349dc5e8d146106ef5780634a5971eb146107025780635300b4ba14610715578063563b1dbf1461073c5780635ae2bfdb1461074f57600080fd5b806339dac34d146106875780633ccdbb281461069a5780633f4ba83a146106ad57806340985323146106b5578063476abc76146106dc57600080fd5b80631fa1e8d4116103f657806332b30cce116103ba57806332b30cce1461061e57806334c24489146106445780633733337d146106575780633807be7d1461066a5780633972183c1461067d57600080fd5b80631fa1e8d4146105aa57806327abf518146105be5780632c0a90a9146105d15780632d7788db146105e45780632e80c6a8146105f757600080fd5b806313007d551161043d57806313007d551461050c57806315b9598a1461053d57806316683aa514610564578063191f3a3e146105795780631ed411631461058357600080fd5b8062eafebf1461046e578063042da5ee146104a85780630b5a57bd146104dc578063105ed2b2146104ff575b600080fd5b6104957fa402581169544bec3e7f4fdb6f22f3658bc2f7bad057fd353bca877dc365e4ee81565b6040519081526020015b60405180910390f35b6104cc6104b6366004613bf1565b61016b6020526000908152604090205460ff1681565b604051901515815260200161049f565b6104cc6104ea366004613c0c565b60976020526000908152604090205460ff1681565b60fc546104cc9060ff1681565b600054610525906201000090046001600160a01b031681565b6040516001600160a01b03909116815260200161049f565b6104957f77c5b782690f31cd39b1abf2448215259a688a75920040c399d96a676bd1999d81565b610577610572366004613bf1565b610bda565b005b6104956101a45481565b6104957fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd881565b61016554610525906001600160a01b031681565b6105776105cc366004613c44565b610c95565b6105776105df366004613c61565b610d3a565b6105776105f2366004613c83565b610d8f565b6104957f4d94b4292928820575e235996b429e6637143146fc4a1b5c3e054e8d7945675681565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df9601442610495565b610577610652366004613c83565b610e97565b610577610665366004613c0c565b610ee5565b610577610678366004613c0c565b610f81565b6104956101675481565b610577610695366004613c9c565b611041565b6105776106a8366004613cd3565b611108565b610577611183565b6104957f2728bd32a7e1e24afac41a073e9c92dbb65527c9ec3baa2a8d5ee1d06c0fa77981565b6105776106ea366004613bf1565b611198565b6105776106fd366004613bf1565b6111fb565b610577610710366004613d27565b611253565b6104957f2fdc6683bc8d03effec5b41d3834f28bd219e06ca0a6a26fc737e44b1c7889ff81565b61057761074a366004613c83565b611376565b610162546104959081565b60655460ff166104cc565b6104957f82830251f95316fd2426de66b9298a230aae8afa718479a58eb92f667eaa8b2d81565b61016454610525906001600160a01b031681565b6104957f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed81565b6104957f06eedf8d6f31879c73bbae06fd13a702c2faed8dd4116d3cc7808bea5843665481565b6105776107fc366004613c83565b6113b9565b61049561080f366004613c83565b6101686020526000908152604090205481565b61049561016a5481565b61057761083a366004613c83565b61143d565b6101a754610525906001600160a01b031681565b610577610861366004613c83565b61148b565b6104956101a35481565b6105776114ce565b610577610886366004613c61565b6114e1565b6104957f3d63b8d5d9c57f3a193bc98b7ebe0c3f62ed0859cbe92c95839f2c4948a3bbff81565b6105776108c0366004613c83565b61152a565b6105776108d3366004613dd4565b61156d565b6105776108e6366004613dfe565b611635565b610495670de0b6b3a764000081565b610525600081565b61049561016f5481565b610495600081565b6104956101a55481565b61057761092c366004613bf1565b61191e565b61057761093f366004613bf1565b6119dd565b610577610952366004613c83565b611a44565b61016954610525906001600160a01b031681565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd8610495565b6104957fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df960144281565b6109fb6109c6366004613bf1565b61016e6020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b604080516001600160a01b0390951685526020850193909352918301521515606082015260800161049f565b610495610a35366004613dd4565b611a92565b61016354610525906001600160a01b031681565b6104956101665481565b610577610a66366004613e31565b611c0c565b610a73611d39565b60405161049f9190613e80565b610495611d4b565b610495610a96366004613c83565b611d55565b6104cc610aa9366004613bf1565b6101706020526000908152604090205460ff1681565b610577610acd366004613dd4565b611e76565b61049561271081565b6104957f57df534b215589c7ade8c8abe0978debf2ea95cf1d442550f94eec78a69d238e81565b610577610b10366004613bf1565b611ee9565b61049560001981565b6104957f9b4e55e8de230bedd27d0e7c47d1fbab2b169fb1e77d738bf687b70d7cd90fe181565b610b99610b53366004613c83565b6101a660205260009081526040902080546001820154600283015460038401546004909401546001600160a01b039384169493831693600160a01b90930460ff16929086565b60405161049f96959493929190613ee3565b610495611fa1565b61012f54610525906001600160a01b031681565b610577610bd5366004613bf1565b611fc5565b610beb610be5611fa1565b33612028565b6001600160a01b038116600090815261016b602052604090205460ff16610c495760405162461bcd60e51b815260206004820152600d60248201526c13558e881b9bdd08199bdd5b99609a1b60448201526064015b60405180910390fd5b6001600160a01b038116600081815261016b6020526040808220805460ff19169055513392917f57c4a95f59c12f0d4d846443c2d54c7d97f1505080199522fca2819e65213ca291a350565b610c9e336120f6565b60fc5460ff1615158115151415610cf05760405162461bcd60e51b8152602060048201526016602482015275474c3a2073616d6520656e61626c652073746174757360501b6044820152606401610c40565b60fc805460ff191682151590811790915560405190815233907fa8434267b880129bc4ba30249aa4a2ac349e8997c699282a9f70562f0f152f54906020015b60405180910390a250565b610d45610be5611fa1565b610d5182826000612128565b817ff7d1fde87f32720fc30ce6847e0aae77e640b59bfac41b11b270358ccfa7a0ac82604051610d8391815260200190565b60405180910390a25050565b610d9a610be5611fa1565b60008181526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff166002811115610df357610df3613ecd565b6002811115610e0457610e04613ecd565b815260200160028201548152602001600382015481526020016004820154815250509050610e3a81600001518260400151612388565b60008281526101a66020526040808220600101805460ff60a01b1916600160a11b179055825190516001600160a01b039091169184917ece63cc55966b103e4f4cb39f3426cb91718ad4f8eb4ad08c14a7ee749d81579190a35050565b610ea2610be5611fa1565b610ead816001612437565b61016a81905560405181815233907f018be394ba93a0dbca235443cfdc7173b2479180ad766083ce05199fbf3fc62490602001610d2f565b610ef0610be5611d4b565b6001600160e01b0319811660009081526097602052604090205460ff1615610f2a5760405162461bcd60e51b8152600401610c4090613f3c565b6001600160e01b03198116600081815260976020908152604091829020805460ff19166001179055905191825233917f2278e547293e53a66144c1743877f8388ac3101bd21cfd7c7f4ce8c15c14f5c19101610d2f565b610f8c610be5611d4b565b6001600160e01b0319811660009081526097602052604090205460ff16610fed5760405162461bcd60e51b815260206004820152601560248201527414185d5cd8589b194e88199b881d5b9c185d5cd959605a1b6044820152606401610c40565b6001600160e01b03198116600081815260976020908152604091829020805460ff19169055905191825233917f929135cc6324f958693bb5f24a4dbc226a83c721523fc2785545019a3423b2d79101610d2f565b61104c610be5611fa1565b6001600160a01b0382166000908152610170602052604090205460ff16151581151514156110af5760405162461bcd60e51b815260206004820152601060248201526f44563a20616c7265616479206672656560801b6044820152606401610c40565b6001600160a01b03821660008181526101706020908152604091829020805460ff191685151590811790915591519182527f80f6f2f8801c6ac8fc60bf218b44fde97744d8709f69281972ec5557c10226cc9101610d83565b611113610be5611fa1565b6111276001600160a01b03841682846124b7565b806001600160a01b0316836001600160a01b0316336001600160a01b03167f9ca7c1e047552a8048d924a5a8d3c150eb861086a72a9100e5f19d1176c1b7468560405161117691815260200190565b60405180910390a4505050565b61118e610be5611d4b565b61119661251a565b565b6111a3610be5611fa1565b6111ae81600161256c565b61016580546001600160a01b0319166001600160a01b03831690811790915560405133907fdb5a411e1a379f981ff6bc5284aa2c2522a9b8fd33a9db9ca19b34006cefbe9c90600090a350565b611206610be5611d4b565b61012f80546001600160a01b0319166001600160a01b03831690811790915560405133907f7f0c791852a03e270d4c2b78bbd4b959bca234de8d1ccf27eee03afaeafe63c490600090a350565b600054610100900460ff16158080156112735750600054600160ff909116105b8061128d5750303b15801561128d575060005460ff166001145b6112f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c40565b6000805460ff191660011790558015611313576000805461ff0019166101001790555b6113248a8a8a8a8a8a8a8a8a612602565b801561136a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b611381610be5611fa1565b6101a581905560405181815233907f72bae0b4c0979f93d77dce748bd8dfbc89d0f1cd524eee95367e3d2ce5eca93f90602001610d2f565b6113c4610be5611fa1565b600081116114055760405162461bcd60e51b815260206004820152600e60248201526d4d563a206c696d6974207a65726f60901b6044820152606401610c40565b61016781905560405181815233907f5e8309fc6b2360e7438bc53790b00913395fffa870f39043fe63ddc8a438a9b290602001610d2f565b611448610be5611fa1565b611453816000612437565b6101a481905560405181815233907fa627d2a34207df740c6b90691350e2a762296cbf59affeb2282e6a54d631d4db90602001610d2f565b611496610be5611fa1565b6101a381905560405181815233907f8855fe6f9cbc4052017b3546fa14e167c5af2daad7f1c64db7f897fbcfb657b090602001610d2f565b6114d9610be5611d4b565b611196612691565b6114ec610be5611fa1565b6114f882826001612128565b817f03ea09e71742c9c754c9746b3e671ecb27fc372e3d29c31bac0192458ffd9d4b82604051610d8391815260200190565b611535610be5611fa1565b61016f81905560405181815233907f57e764c1fef224e74706b109734513889970db6f1dde107b1bda66e10d80ca9b90602001610d2f565b611578610be5611fa1565b6001600160a01b0382161561159057611590826126ce565b600081116115d55760405162461bcd60e51b81526020600482015260126024820152714d563a207a65726f20616c6c6f77616e636560701b6044820152606401610c40565b6001600160a01b038216600081815261016e602052604090819020600201839055513391907ff7273742887a46d8b97d83d1d12b6d8d8e6d21d814072369e2f4b355690221d7906116299085815260200190565b60405180910390a35050565b6345a9fbaf60e11b611645612720565b6001600160e01b0319811660009081526097602052604090205460ff161561167f5760405162461bcd60e51b8152600401610c4090613f3c565b60fc54339060ff16156116955761169581612766565b3361169f8161278c565b61012f5433906001600160a01b0316801561174a5760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b1580156116f557600080fd5b505afa158015611709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172d9190613f69565b1561174a5760405162461bcd60e51b8152600401610c4090613f86565b3360008061175c838c8c6001856127b8565b915091506117698a612994565b60006117748c612a1e565b60ff1690508a8c8b60008061178885612a97565b915091506000806117998487612b5a565b909250905060006117be826117ae868d613fc5565b6117b89190613fe4565b8a612c3a565b9050858110156118105760405162461bcd60e51b815260206004820152601d60248201527f52563a206d696e52656365697665416d6f756e74203e2061637475616c0000006044820152606401610c40565b61181a8784612c57565b61016354604051632770a7eb60e21b81526001600160a01b038e81166004830152602482018d905290911690639dc29fac90604401600060405180830381600087803b15801561186957600080fd5b505af115801561187d573d6000803e3d6000fd5b5050505060008b11156118ab5761016354610169546118ab916001600160a01b0390811691168d6012612d00565b6118b7878d838c612d52565b60408051898152602081018d90529081018290526001600160a01b0380891691908e16907f1af12536d161c2c30ad907b0abe442f94c4a7824f2463585b3fc893275247cce9060600160405180910390a35050505050505050505050505050505050505050565b611929610be5611fa1565b61193561016c82612d9c565b6119725760405162461bcd60e51b815260206004820152600e60248201526d4d563a206e6f742065786973747360901b6044820152606401610c40565b6001600160a01b038116600081815261016e602052604080822080546001600160a01b03191681556001810183905560028101839055600301805460ff19169055513392917f652fa2f5d587d3f1c189df0081b7bf3121f47d51d5471bf58d7d2c8a084894c391a350565b6119e8610be5611fa1565b6119f381600061256c565b6101a780546001600160a01b0319166001600160a01b03831690811790915560405190815233907f5059e224ac539671fe0261fc6672c365607aa98da29c849726ac5956902221b490602001610d2f565b611a4f610be5611fa1565b611a5a816000612437565b61016681905560405181815233907f45acc8bd6ebd6fbb59ce049b682c124aeccc93c468fcf60fecf61340e86e79d390602001610d2f565b6000635fe16a3560e11b611aa4612720565b6001600160e01b0319811660009081526097602052604090205460ff1615611ade5760405162461bcd60e51b8152600401610c4090613f3c565b60fc54339060ff1615611af457611af481612766565b33611afe8161278c565b61012f5433906001600160a01b03168015611ba95760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611b5457600080fd5b505afa158015611b68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8c9190613f69565b15611ba95760405162461bcd60e51b8152600401610c4090613f86565b6001600160a01b038816611bf65760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d080f4f48199a585d60621b6044820152606401610c40565b611c008888612db1565b98975050505050505050565b611c17610be5611fa1565b611c2361016c85613031565b611c635760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610c40565b611c6e83600061256c565b611c79826000612437565b604080516080810182526001600160a01b038581168083526020808401878152600019858701908152871515606087018181528c8716600081815261016e87528a9020985189546001600160a01b0319169816979097178855925160018801559051600287015590516003909501805460ff19169515159590951790945584518781529081019390935292909133917f619139d13e799b88ce56bff114b5510808a19ea7440710070ef78528a05ed672910160405180910390a450505050565b6060611d4661016c613046565b905090565b6000611d46611fa1565b600063357dcfd760e21b611d67612720565b6001600160e01b0319811660009081526097602052604090205460ff1615611da15760405162461bcd60e51b8152600401610c4090613f3c565b33611dab81612766565b33611db58161278c565b61012f5433906001600160a01b03168015611e605760405163df592f7d60e01b81526001600160a01b03838116600483015282169063df592f7d9060240160206040518083038186803b158015611e0b57600080fd5b505afa158015611e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e439190613f69565b15611e605760405162461bcd60e51b8152600401610c4090613f86565b611e6b600088612db1565b979650505050505050565b611e81610be5611fa1565b611e8a826126ce565b611e95816000612437565b6001600160a01b038216600081815261016e602052604090819020600101839055513391907f1582567d288d96695cf3fe7280c630a4f1c82fc7e665e1db58468f2960fef869906116299085815260200190565b611ef4610be5611fa1565b6001600160a01b038116600090815261016b602052604090205460ff1615611f525760405162461bcd60e51b815260206004820152601160248201527013558e88185b1c9958591e481859191959607a1b6044820152606401610c40565b6001600160a01b038116600081815261016b6020526040808220805460ff19166001179055513392917f221f04b37331150bcfd05e2de362f50785c29ee4ab14f26d4495a51f3c02906091a350565b7f06eedf8d6f31879c73bbae06fd13a702c2faed8dd4116d3cc7808bea5843665490565b611fd0610be5611fa1565b611fdb81600161256c565b61016980546001600160a01b0319166001600160a01b03831690811790915560405133907f1b092cca381ac00a07e1226c164f47c475d212f5e55699475a7f411811f77dd490600090a350565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b15801561207b57600080fd5b505afa15801561208f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b39190613f69565b6120f25760405162461bcd60e51b815260206004820152601060248201526f574d41433a206861736e7420726f6c6560801b6044820152606401610c40565b5050565b7fa28974a2ecc1bcbd5ca81af766b1ac289c6579162f91147085217b9df96014425b816121238282612028565b505050565b60008381526101a660209081526040808320815160c08101835281546001600160a01b039081168252600183015490811694820194909452929091830190600160a01b900460ff16600281111561218157612181613ecd565b600281111561219257612192613ecd565b8152602001600282015481526020016003820154815260200160048201548152505090506121c881600001518260400151612388565b81156121dc576121dc816080015184613053565b610163546060820151604051632770a7eb60e21b815230600482015260248101919091526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b15801561222f57600080fd5b505af1158015612243573d6000803e3d6000fd5b5050505060208101516001600160a01b03161560008161226f5761226a8360200151612a1e565b612272565b60125b60ff16905060006122a18460a001518786606001516122919190613fc5565b61229b9190613fe4565b83612c3a565b90506122b1846020015182612c57565b826122d75760208401516101a75485516122d792916001600160a01b03169084866130ec565b600160408501819052506080840186905260008781526101a66020908152604091829020865181546001600160a01b039182166001600160a01b0319918216178355928801516001830180549190921693811684178255938801518894929390926001600160a81b03191617600160a01b83600281111561235a5761235a613ecd565b0217905550606082015160028201556080820151600382015560a09091015160049091015550505050505050565b6001600160a01b0382166123d65760405162461bcd60e51b815260206004820152601560248201527414958e881c995c5d595cdd081b9bdd08195e1a5cdd605a1b6044820152606401610c40565b60008160028111156123ea576123ea613ecd565b146120f25760405162461bcd60e51b815260206004820152601760248201527f52563a2072657175657374206e6f742070656e64696e670000000000000000006044820152606401610c40565b6127108211156124765760405162461bcd60e51b815260206004820152600a602482015269666565203e203130302560b01b6044820152606401610c40565b80156120f257600082116120f25760405162461bcd60e51b81526020600482015260086024820152670666565203d3d20360c41b6044820152606401610c40565b6040516001600160a01b03831660248201526044810182905261212390849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261313f565b612522613214565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b0382166125b15760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610c40565b80156120f2576001600160a01b0382163014156120f25760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b6044820152606401610c40565b600054610100900460ff166126295760405162461bcd60e51b8152600401610c4090614006565b6126388989898989898961325d565b61264482356000612437565b61264f81600061256c565b60408201356101a35581356101a4556020909101356101a5556101a780546001600160a01b0319166001600160a01b0390921691909117905550505050505050565b612699612720565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861254f3390565b6126da61016c82613435565b61271d5760405162461bcd60e51b81526020600482015260146024820152734d563a20746f6b656e206e6f742065786973747360601b6044820152606401610c40565b50565b60655460ff16156111965760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c40565b7fd2576bd6a4c5558421de15cb8ecdf4eb3282aac06b94d4f004e8cd0d00f3ebd8612118565b7f548c7f0307ab2a7ea894e5c7e8c5353cc750bb9385ee2e945f189a9a83daa8ed816121238282613457565b600080600085116128005760405162461bcd60e51b815260206004820152601260248201527114958e881a5b9d985b1a5908185b5bdd5b9d60721b6044820152606401610c40565b6001600160a01b0387166000908152610170602052604090205460ff1661287d576000836128315761016f54612836565b6101a3545b90508581111561287b5760405162461bcd60e51b815260206004820152601060248201526f292b1d1030b6b7bab73a101e1036b4b760811b6044820152606401610c40565b505b6128998787878787612890576000613520565b6101a454613520565b91508215612926576001600160a01b038616156128ef5760405162461bcd60e51b815260206004820152601460248201527314958e881d1bdad95b93dd5d08084f48199a585d60621b6044820152606401610c40565b6001600160a01b038716600090815261016b602052604090205460ff16612921576101a55461291e9083614051565b91505b61292f565b61292f866126ce565b81851161297e5760405162461bcd60e51b815260206004820152601860248201527f52563a20616d6f756e744d546f6b656e496e203c2066656500000000000000006044820152606401610c40565b6129888286614069565b90509550959350505050565b60006129a36201518042613fe4565b60008181526101686020526040812054919250906129c2908490614051565b905061016754811115612a0a5760405162461bcd60e51b815260206004820152601060248201526f13558e88195e18d95959081b1a5b5a5d60821b6044820152606401610c40565b600091825261016860205260409091205550565b6000816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612a5957600080fd5b505afa158015612a6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a919190614080565b92915050565b60008060008311612adc5760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610c40565b61016454612af4906001600160a01b031660006135c1565b905060008111612b365760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610c40565b670de0b6b3a7640000612b498285613fc5565b612b539190613fe4565b9150915091565b60008060008411612b9f5760405162461bcd60e51b815260206004820152600f60248201526e52563a20616d6f756e74207a65726f60881b6044820152606401610c40565b6001600160a01b03808416600090815261016e60205260409020805460038201549192612bd19291169060ff166135c1565b915060008211612c135760405162461bcd60e51b815260206004820152600d60248201526c52563a2072617465207a65726f60981b6044820152606401610c40565b81612c2686670de0b6b3a7640000613fc5565b612c309190613fe4565b9250509250929050565b6000612c5082612c4a858261364e565b9061365c565b9392505050565b6001600160a01b038216600090815261016e6020526040902060020154600019811415612c8357505050565b81811015612cca5760405162461bcd60e51b81526020600482015260146024820152734d563a2065786365656420616c6c6f77616e636560601b6044820152606401610c40565b6001600160a01b038316600090815261016e602052604081206002018054849290612cf6908490614069565b9091555050505050565b6000612d0c838361364e565b9050612d18818361365c565b8314612d365760405162461bcd60e51b8152600401610c40906140a3565b612d4b6001600160a01b03861633868461366a565b5050505050565b6000612d5e838361364e565b9050612d6a818361365c565b8314612d885760405162461bcd60e51b8152600401610c40906140a3565b612d4b6001600160a01b03861685836124b7565b6000612c50836001600160a01b0384166136a2565b6000336001600160a01b038416158280612dce84888884876127b8565b909250905086670de0b6b3a764000084612e18576001600160a01b03808316600090815261016e60205260409020805460038201549192612e149291169060ff166135c1565b9150505b6101645460408051636369290560e01b815290518a926000926001600160a01b0390911691636369290591600480820192602092909190829003018186803b158015612e6357600080fd5b505afa158015612e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9b91906140d1565b61016354909150612eb8906001600160a01b031630876012612d00565b8515612edf576101635461016954612edf916001600160a01b039081169116886012612d00565b6000612eeb6101625490565b9050612efc61016280546001019055565b6040805160c0810182526001600160a01b03808c168252871660208201529081016000815260208082018990526040808301869052606090920187905260008481526101a68252829020835181546001600160a01b039182166001600160a01b0319918216178355928501516001830180549190921693811684178255938501519193919290916001600160a81b03191617600160a01b836002811115612fa557612fa5613ecd565b0217905550606082015181600201556080820151816003015560a08201518160040155905050846001600160a01b0316896001600160a01b0316827f55ba94d231fa70a45e82b0a1c6a60ef72e41bb2455385128ee5cf8d98c0c1c0e868b60405161301a929190918252602082015260400190565b60405180910390a49b9a5050505050505050505050565b6000612c50836001600160a01b038416613795565b60606000612c50836137e4565b60008282101561306c576130678284614069565b613076565b6130768383614069565b905060008361308761271084613fc5565b6130919190613fe4565b905061016a548111156130e65760405162461bcd60e51b815260206004820152601a60248201527f4d563a2065786365656420707269636520646976696174696f6e0000000000006044820152606401610c40565b50505050565b60006130f8838361364e565b9050613104818361365c565b83146131225760405162461bcd60e51b8152600401610c40906140a3565b6131376001600160a01b03871686868461366a565b505050505050565b6000613194826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138409092919063ffffffff16565b90508051600014806131b55750808060200190518101906131b59190613f69565b6121235760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c40565b60655460ff166111965760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c40565b600054610100900460ff166132845760405162461bcd60e51b8152600401610c4090614006565b61329b6132946020880188613bf1565b600061256c565b6132ae6132946040880160208901613bf1565b6132c56132be6020870187613bf1565b600161256c565b6132d86132be6040870160208801613bf1565b60008460200135116133195760405162461bcd60e51b815260206004820152600a6024820152691e995c9bc81b1a5b5a5d60b21b6044820152606401610c40565b613324826001612437565b61333084356000612437565b61333d6020870187613bf1565b61016380546001600160a01b0319166001600160a01b039290921691909117905561336787613857565b61336f61388f565b61337761388f565b613380836138b6565b61338d6020860186613bf1565b61016580546001600160a01b0319166001600160a01b03929092169190911790556133be6040860160208701613bf1565b61016980546001600160a01b0319166001600160a01b03929092169190911790558335610166556020808501356101675561016f82905561016a83905561340b9060408801908801613bf1565b61016480546001600160a01b0319166001600160a01b039290921691909117905550505050505050565b6001600160a01b03811660009081526001830160205260408120541515612c50565b600054604051632474521560e21b8152600481018490526001600160a01b03838116602483015262010000909204909116906391d148549060440160206040518083038186803b1580156134aa57600080fd5b505afa1580156134be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e29190613f69565b156120f25760405162461bcd60e51b815260206004820152600e60248201526d574d41433a2068617320726f6c6560901b6044820152606401610c40565b6001600160a01b038516600090815261016b602052604081205460ff161561354a575060006135b8565b60008261357457506001600160a01b038516600090815261016e6020526040902060010154613577565b50815b831561358e576101665461358b9082614051565b90505b61271081111561359d57506127105b6127106135aa8287613fc5565b6135b49190613fe4565b9150505b95945050505050565b600080836001600160a01b031663636929056040518163ffffffff1660e01b815260040160206040518083038186803b1580156135fd57600080fd5b505afa158015613611573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363591906140d1565b90508215612c5057670de0b6b3a7640000915050612a91565b6000612c5083601284613900565b6000612c5083836012613900565b6040516001600160a01b03808516602483015283166044820152606481018290526130e69085906323b872dd60e01b906084016124e3565b6000818152600183016020526040812054801561378b5760006136c6600183614069565b85549091506000906136da90600190614069565b905081811461373f5760008660000182815481106136fa576136fa6140ea565b906000526020600020015490508087600001848154811061371d5761371d6140ea565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061375057613750614100565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050612a91565b6000915050612a91565b60008181526001830160205260408120546137dc57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612a91565b506000612a91565b60608160000180548060200260200160405190810160405280929190818152602001828054801561383457602002820191906000526020600020905b815481526020019060010190808311613820575b50505050509050919050565b606061384f848460008561396d565b949350505050565b600054610100900460ff1661387e5760405162461bcd60e51b8152600401610c4090614006565b613886613a3d565b61271d81613a6c565b600054610100900460ff166111965760405162461bcd60e51b8152600401610c4090614006565b600054610100900460ff166138dd5760405162461bcd60e51b8152600401610c4090614006565b61012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60008361390f57506000612c50565b8183141561391e575082612c50565b60008284111561394e576139328385614069565b61393d90600a6141fa565b6139479086613fe4565b905061384f565b6139588484614069565b61396390600a6141fa565b6135b89086613fc5565b6060824710156139ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c40565b600080866001600160a01b031685876040516139ea9190614232565b60006040518083038185875af1925050503d8060008114613a27576040519150601f19603f3d011682016040523d82523d6000602084013e613a2c565b606091505b5091509150611e6b87838387613b02565b600054610100900460ff16613a645760405162461bcd60e51b8152600401610c4090614006565b611196613b78565b600054610100900460ff16613a935760405162461bcd60e51b8152600401610c4090614006565b6001600160a01b038116613ad85760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610c40565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60608315613b6e578251613b67576001600160a01b0385163b613b675760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c40565b508161384f565b61384f8383613bab565b600054610100900460ff16613b9f5760405162461bcd60e51b8152600401610c4090614006565b6065805460ff19169055565b815115613bbb5781518083602001fd5b8060405162461bcd60e51b8152600401610c40919061424e565b80356001600160a01b0381168114613bec57600080fd5b919050565b600060208284031215613c0357600080fd5b612c5082613bd5565b600060208284031215613c1e57600080fd5b81356001600160e01b031981168114612c5057600080fd5b801515811461271d57600080fd5b600060208284031215613c5657600080fd5b8135612c5081613c36565b60008060408385031215613c7457600080fd5b50508035926020909101359150565b600060208284031215613c9557600080fd5b5035919050565b60008060408385031215613caf57600080fd5b613cb883613bd5565b91506020830135613cc881613c36565b809150509250929050565b600080600060608486031215613ce857600080fd5b613cf184613bd5565b925060208401359150613d0660408501613bd5565b90509250925092565b600060408284031215613d2157600080fd5b50919050565b6000806000806000806000806000898b036101c0811215613d4757600080fd5b613d508b613bd5565b9950613d5f8c60208d01613d0f565b9850613d6e8c60608d01613d0f565b9750613d7d8c60a08d01613d0f565b9650613d8b60e08c01613bd5565b95506101008b013594506101208b01359350606061013f1982011215613db057600080fd5b506101408a019150613dc56101a08b01613bd5565b90509295985092959850929598565b60008060408385031215613de757600080fd5b613df083613bd5565b946020939093013593505050565b600080600060608486031215613e1357600080fd5b613e1c84613bd5565b95602085013595506040909401359392505050565b60008060008060808587031215613e4757600080fd5b613e5085613bd5565b9350613e5e60208601613bd5565b9250604085013591506060850135613e7581613c36565b939692955090935050565b6020808252825182820181905260009190848201906040850190845b81811015613ec15783516001600160a01b031683529284019291840191600101613e9c565b50909695505050505050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b0387811682528616602082015260c0810160038610613f1957634e487b7160e01b600052602160045260246000fd5b8560408301528460608301528360808301528260a0830152979650505050505050565b60208082526013908201527214185d5cd8589b194e88199b881c185d5cd959606a1b604082015260600190565b600060208284031215613f7b57600080fd5b8151612c5081613c36565b6020808252600f908201526e15d4d30e881cd85b98dd1a5bdb9959608a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613fdf57613fdf613faf565b500290565b60008261400157634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000821982111561406457614064613faf565b500190565b60008282101561407b5761407b613faf565b500390565b60006020828403121561409257600080fd5b815160ff81168114612c5057600080fd5b6020808252601490820152734d563a20696e76616c696420726f756e64696e6760601b604082015260600190565b6000602082840312156140e357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b600181815b8085111561415157816000190482111561413757614137613faf565b8085161561414457918102915b93841c939080029061411b565b509250929050565b60008261416857506001612a91565b8161417557506000612a91565b816001811461418b5760028114614195576141b1565b6001915050612a91565b60ff8411156141a6576141a6613faf565b50506001821b612a91565b5060208310610133831016604e8410600b84101617156141d4575081810a612a91565b6141de8383614116565b80600019048211156141f2576141f2613faf565b029392505050565b6000612c508383614159565b60005b83811015614221578181015183820152602001614209565b838111156130e65750506000910152565b60008251614244818460208701614206565b9190910192915050565b602081526000825180602084015261426d816040850160208701614206565b601f01601f1916919091016040019291505056fea26469706673582212204742436976ec2945bdbbfd0d53ae84a3ebf18707d6e743800d4ebaee8a9f7af564736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.