Contract Overview
Balance:
0 CRO
CRO Value:
$0.00
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
Pool
Compiler Version
v0.8.4+commit.c7e474f2
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.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./interfaces/ITreasury.sol"; import "./interfaces/IOracle.sol"; import "./interfaces/IPool.sol"; interface I10MBToken { function mint(address _to, uint256 _amount) external; function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function poolBurnFrom(address _address, uint256 _amount) external; function poolMint(address _address, uint256 _amount) external; } interface I10SHAREToken { function mint(address _to, uint256 _amount) external; function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function poolBurnFrom(address _address, uint256 _amount) external; function poolMint(address _address, uint256 _amount) external; } contract Pool is ReentrancyGuard, IPool { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ address public collateral; address public _10MB; address public treasury; address public _10SHARE; mapping(address => uint256) public redeem_share_balances; mapping(address => uint256) public redeem_collateral_balances; uint256 public unclaimed_pool_collateral; uint256 public unclaimed_pool_share; mapping(address => uint256) public last_redeemed; uint256 public netMinted; uint256 public netRedeemed; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_MAX = 1e6; // Number of decimals needed to get to 18 uint256 private missing_decimals; // Pool_ceiling is the total units of collateral that a pool contract can hold uint256 public pool_ceiling = 0; // Number of blocks to wait before being able to collectRedemption() uint256 public redemption_delay = 1; uint256 public twapPriceScalingPercentage = 9800; // 98% to start // AccessControl state variables bool public mint_paused = true; bool public redeem_paused = false; bool public migrated = false; address public operator; /* ========== MODIFIERS ========== */ modifier onlyOperator() { require(operator == msg.sender, "Pool: caller is not the operator"); _; } modifier notMigrated() { require(!migrated, "migrated"); _; } modifier onlyTreasury() { require(msg.sender == treasury, "!treasury"); _; } /* ========== CONSTRUCTOR ========== */ constructor( address __10MB, address __10SHARE, address _collateral, address _treasury, uint256 _pool_ceiling ) public { operator = msg.sender; _10MB = __10MB; _10SHARE = __10SHARE; collateral = _collateral; treasury = _treasury; pool_ceiling = _pool_ceiling; missing_decimals = uint256(18).sub(ERC20(_collateral).decimals()); } /* ========== VIEWS ========== */ // Returns 10MB value of collateral held in this pool function collateral10MBBalance() external view override returns (uint256) { return (ERC20(collateral).balanceOf(address(this)).sub(unclaimed_pool_collateral)).mul(10**missing_decimals);//.mul(collateral_usd_price).div(PRICE_PRECISION); } function info() external view returns ( uint256, uint256, uint256, uint256, uint256, bool, bool ) { return ( pool_ceiling, // Ceiling of pool - collateral-amount ERC20(collateral).balanceOf(address(this)), // amount of COLLATERAL locked in this contract unclaimed_pool_collateral, // unclaimed amount of COLLATERAL unclaimed_pool_share, // unclaimed amount of SHARE getCollateralPrice(), // collateral price mint_paused, redeem_paused ); } /* ========== PUBLIC FUNCTIONS ========== */ function getCollateralPrice() public pure override returns (uint256) { // only for USDT return PRICE_PRECISION; } function getCollateralToken() external view override returns (address) { return collateral; } function netSupplyMinted() external view override returns (uint256) { if (netMinted > netRedeemed) return netMinted.sub(netRedeemed); return 0; } function mint( uint256 _collateral_amount, uint256 _share_amount, uint256 _10MB_out_min ) external notMigrated { require(block.timestamp >= ITreasury(treasury).startTime(), "Minting hasnt started yet!"); require(mint_paused == false, "Minting is paused"); (uint256 _10MBPrice, uint256 _share_price, , uint256 _target_collateral_ratio, , , uint256 _minting_fee, ) = ITreasury(treasury).info(); require(ERC20(collateral).balanceOf(address(this)).sub(unclaimed_pool_collateral).add(_collateral_amount) <= pool_ceiling, ">poolCeiling"); uint256 _total_10MB_value = 0; uint256 _required_share_amount = 0; if (_target_collateral_ratio > 0) { uint256 _collateral_value = (_collateral_amount * (10**missing_decimals));//.mul(_price_collateral).div(PRICE_PRECISION); _total_10MB_value = _collateral_value.mul(COLLATERAL_RATIO_PRECISION).div(_target_collateral_ratio); if (_target_collateral_ratio < COLLATERAL_RATIO_MAX) { _required_share_amount = _total_10MB_value.sub(_collateral_value).mul(PRICE_PRECISION).div(_share_price); } } else { _total_10MB_value = _share_amount.mul(_share_price).div(PRICE_PRECISION); _required_share_amount = _share_amount; } // 10mb is 1/10 usd uint256 _actual_10MB_amount = _total_10MB_value.sub((_total_10MB_value.mul(_minting_fee)).div(PRICE_PRECISION)).mul(10); if (_10MBPrice > 1e5) { _actual_10MB_amount = _actual_10MB_amount.mul(1e5).div(_10MBPrice.sub(1e5).mul(twapPriceScalingPercentage).div(10000).add(1e5)); } require(_10MB_out_min <= _actual_10MB_amount, ">slippage"); if (_required_share_amount > 0) { require(_required_share_amount <= _share_amount, "<shareBalance"); I10SHAREToken(_10SHARE).poolBurnFrom(msg.sender, _required_share_amount); } if (_collateral_amount > 0) { ERC20(collateral).transferFrom(msg.sender, address(this), _collateral_amount); } netMinted = netMinted.add(_actual_10MB_amount); I10MBToken(_10MB).poolMint(msg.sender, _actual_10MB_amount); ITreasury(treasury).treasuryUpdates(); emit Minted(msg.sender, _collateral_amount, _required_share_amount, _actual_10MB_amount); } function redeem( uint256 _10MB_amount, uint256 _share_out_min, uint256 _collateral_out_min ) external notMigrated { require(block.timestamp >= ITreasury(treasury).startTime(), "Redeeming hasnt started yet!"); require(redeem_paused == false, "Redeeming is paused"); (, uint256 _share_price, , , uint256 _effective_collateral_ratio, , , uint256 _redemption_fee) = ITreasury(treasury).info(); uint256 _10MB_amount_post_fee = _10MB_amount.sub((_10MB_amount.mul(_redemption_fee)).div(PRICE_PRECISION)); uint256 _collateral_output_amount = 0; uint256 _share_output_amount = 0; _effective_collateral_ratio = _effective_collateral_ratio.mul(10); if (_effective_collateral_ratio < COLLATERAL_RATIO_MAX) { uint256 _share_output_value = _10MB_amount_post_fee.sub(_10MB_amount_post_fee.mul(_effective_collateral_ratio).div(PRICE_PRECISION)); _share_output_amount = _share_price == 0 ? 0 : _share_output_value.mul(PRICE_PRECISION).div(_share_price); } if (_effective_collateral_ratio > 0) { uint256 _collateral_output_value = _10MB_amount_post_fee.mul(_effective_collateral_ratio).div(10**missing_decimals).div(PRICE_PRECISION); _collateral_output_amount = _collateral_output_value;//.mul(PRICE_PRECISION).div(PRICE_PRECISION); } // 10mb is 1/10 usd _collateral_output_amount = _collateral_output_amount.div(10); _share_output_amount = _share_output_amount.div(10); // Check if collateral balance meets and meet output expectation require(_collateral_output_amount <= ERC20(collateral).balanceOf(address(this)).sub(unclaimed_pool_collateral), "<collateralBlanace"); require(_collateral_out_min <= _collateral_output_amount && _share_out_min <= _share_output_amount, ">slippage"); if (_collateral_output_amount > 0) { redeem_collateral_balances[msg.sender] = redeem_collateral_balances[msg.sender].add(_collateral_output_amount); unclaimed_pool_collateral = unclaimed_pool_collateral.add(_collateral_output_amount); } if (_share_output_amount > 0) { redeem_share_balances[msg.sender] = redeem_share_balances[msg.sender].add(_share_output_amount); unclaimed_pool_share = unclaimed_pool_share.add(_share_output_amount); } last_redeemed[msg.sender] = block.number; netRedeemed = netRedeemed.add(_10MB_amount); // Move all external functions to the end I10MBToken(_10MB).poolBurnFrom(msg.sender, _10MB_amount); if (_share_output_amount > 0) { I10SHAREToken(_10SHARE).poolMint(address(this), _share_output_amount); } ITreasury(treasury).treasuryUpdates(); emit Redeemed(msg.sender, _10MB_amount, _collateral_output_amount, _share_output_amount); } function collectRedemption() external { // Redeem and Collect cannot happen in the same transaction to avoid flash loan attack require((last_redeemed[msg.sender].add(redemption_delay)) <= block.number, "<redemption_delay"); bool _send_share = false; bool _send_collateral = false; uint256 _share_amount; uint256 _collateral_amount; // Use Checks-Effects-Interactions pattern if (redeem_share_balances[msg.sender] > 0) { _share_amount = redeem_share_balances[msg.sender]; redeem_share_balances[msg.sender] = 0; unclaimed_pool_share = unclaimed_pool_share.sub(_share_amount); _send_share = true; } if (redeem_collateral_balances[msg.sender] > 0) { _collateral_amount = redeem_collateral_balances[msg.sender]; redeem_collateral_balances[msg.sender] = 0; unclaimed_pool_collateral = unclaimed_pool_collateral.sub(_collateral_amount); _send_collateral = true; } if (_send_share) { ERC20(_10SHARE).transfer(msg.sender, _share_amount); } if (_send_collateral) { ERC20(collateral).transfer(msg.sender, _collateral_amount); } emit RedeemCollected(msg.sender, _collateral_amount, _share_amount); } /* ========== RESTRICTED FUNCTIONS ========== */ // move collateral to new pool address function migrate(address _new_pool) external override nonReentrant onlyOperator notMigrated { migrated = true; uint256 availableCollateral = ERC20(collateral).balanceOf(address(this)).sub(unclaimed_pool_collateral); ERC20(collateral).safeTransfer(_new_pool, availableCollateral); } function toggleMinting() external onlyOperator { mint_paused = !mint_paused; } function toggleRedeeming() external onlyOperator { redeem_paused = !redeem_paused; } function setPoolCeiling(uint256 _pool_ceiling) external onlyOperator { pool_ceiling = _pool_ceiling; } function setTwapPriceScalingPercentage(uint256 _twapPriceScalingPercentage) external onlyOperator { require(_twapPriceScalingPercentage <= 10000, "percentage out of range"); twapPriceScalingPercentage = _twapPriceScalingPercentage; } function setRedemptionDelay(uint256 _redemption_delay) external onlyOperator { redemption_delay = _redemption_delay; } function setTreasury(address _treasury) external onlyOperator { emit TreasuryTransferred(treasury, _treasury); treasury = _treasury; } // Transfer collateral to Treasury to execute strategies function transferCollateralToTreasury(uint256 amount) external override onlyTreasury { require(amount > 0, "zeroAmount"); require(treasury != address(0), "invalidTreasury"); ERC20(collateral).safeTransfer(treasury, amount); } // Transfer collateral to Treasury to execute strategies function transferCollateralToOperator(uint256 amount) external onlyOperator { require(amount > 0, "zeroAmount"); ERC20(collateral).safeTransfer(msg.sender, amount); } // EVENTS event TreasuryTransferred(address indexed previousTreasury, address indexed newTreasury); event Minted(address indexed user, uint256 usdtAmountIn, uint256 _10SHAREAmountIn, uint256 _10MBAmountOut); event Redeemed(address indexed user, uint256 _10MBAmountIn, uint256 usdtAmountOut, uint256 _10SHAREAmountOut); event RedeemCollected(address indexed user, uint256 usdtAmountOut, uint256 _10SHAREAmountOut); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * 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 ERC20 is Context, IERC20, IERC20Metadata { 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}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _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 value {ERC20} uses, unless this function is * 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, _allowances[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 = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * 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; } _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; _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; } _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 Spend `amount` form the allowance of `owner` toward `spender`. * * 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 {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity >0.6.12; interface ITreasury { function epoch() external view returns (uint256); function startTime() external view returns (uint256); function nextEpochPoint() external view returns (uint256); function get10MBPrice() external view returns (uint256); function get10MBUpdatedPrice() external view returns (uint256); function buyBonds(uint256 amount, uint256 targetPrice) external; function redeemBonds(uint256 amount, uint256 targetPrice) external; function treasuryUpdates() external; function _update10MBPrice() external; function _update10SHAREPrice() external; function refreshCollateralRatio() external; function allocateSeigniorage() external; function hasPool(address _address) external view returns (bool); function info() external view returns ( uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256 ); function epochInfo() external view returns ( uint256, uint256, uint256, uint256 ); }
// SPDX-License-Identifier: MIT pragma solidity >0.6.12; interface IOracle { function update() external; function consult(address _token, uint256 _amountIn) external view returns (uint144 amountOut); function twap(address _token, uint256 _amountIn) external view returns (uint144 _amountOut); }
// SPDX-License-Identifier: MIT pragma solidity >0.6.12; pragma experimental ABIEncoderV2; interface IPool { function collateral10MBBalance() external view returns (uint256); function migrate(address _new_pool) external; function transferCollateralToTreasury(uint256 amount) external; function getCollateralPrice() external view returns (uint256); function netSupplyMinted() external view returns (uint256); function getCollateralToken() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `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); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @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 // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"__10MB","type":"address"},{"internalType":"address","name":"__10SHARE","type":"address"},{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_pool_ceiling","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"usdtAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_10SHAREAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_10MBAmountOut","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"usdtAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_10SHAREAmountOut","type":"uint256"}],"name":"RedeemCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_10MBAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usdtAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_10SHAREAmountOut","type":"uint256"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousTreasury","type":"address"},{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryTransferred","type":"event"},{"inputs":[],"name":"_10MB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_10SHARE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateral10MBBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectRedemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCollateralPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getCollateralToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"info","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"last_redeemed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_new_pool","type":"address"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"migrated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_collateral_amount","type":"uint256"},{"internalType":"uint256","name":"_share_amount","type":"uint256"},{"internalType":"uint256","name":"_10MB_out_min","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mint_paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"netMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"netRedeemed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"netSupplyMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool_ceiling","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_10MB_amount","type":"uint256"},{"internalType":"uint256","name":"_share_out_min","type":"uint256"},{"internalType":"uint256","name":"_collateral_out_min","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeem_collateral_balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redeem_paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeem_share_balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"redemption_delay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pool_ceiling","type":"uint256"}],"name":"setPoolCeiling","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_redemption_delay","type":"uint256"}],"name":"setRedemptionDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_twapPriceScalingPercentage","type":"uint256"}],"name":"setTwapPriceScalingPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleMinting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleRedeeming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferCollateralToOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferCollateralToTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twapPriceScalingPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unclaimed_pool_collateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unclaimed_pool_share","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040526000600d556001600e819055612648600f556010805462ffffff191690911790553480156200003257600080fd5b506040516200217638038062002176833981016040819052620000559162000196565b60016000819055601080546301000000600160b81b03191633630100000002179055600280546001600160a01b03199081166001600160a01b03898116919091179092556004805482168884161781558354821687841690811790945560038054909216928616929092179055600d8390556040805163313ce56760e01b8152905162000155939263313ce56792808201926020929091829003018186803b1580156200010157600080fd5b505afa15801562000116573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200013c9190620001fc565b60ff1660126200016460201b620018c51790919060201c565b600c5550620002439350505050565b60006200017282846200021f565b9392505050565b80516001600160a01b03811681146200019157600080fd5b919050565b600080600080600060a08688031215620001ae578081fd5b620001b98662000179565b9450620001c96020870162000179565b9350620001d96040870162000179565b9250620001e96060870162000179565b9150608086015190509295509295909350565b6000602082840312156200020e578081fd5b815160ff8116811462000172578182fd5b6000828210156200023e57634e487b7160e01b81526011600452602481fd5b500390565b611f2380620002536000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c806380a66d0511610125578063d71f52c4116100ad578063e86bc6191161007c578063e86bc6191461046d578063f0f4426014610480578063f1a9ee0314610493578063f7683bbc146104a6578063ff626c5f146104af57600080fd5b8063d71f52c41461042a578063d8dfeb4514610432578063daa5048514610445578063dc0d2a981461044d57600080fd5b8063b8192205116100f4578063b8192205146103ce578063c7d27228146103e1578063c82c4d0e146103ee578063ce5494bb146103f7578063d0d132f31461040a57600080fd5b806380a66d051461038557806385f851f21461039757806391e20369146103aa57806396423663146103bd57600080fd5b8063365625eb116101a8578063570ca73511610177578063570ca7351461032657806361d027b3146103585780636526a12a1461036b5780636e33346f146103745780637d55094d1461037d57600080fd5b8063365625eb146102a9578063370158ea146102b2578063378f3576146102f3578063543671351461030657600080fd5b806316606ca2116101e457806316606ca2146102625780631869f4401461026b5780631e07d202146102735780632c678c641461028657600080fd5b806302acc94b1461021657806310a6b3aa1461022b57806312ace5a21461023e5780631512842514610246575b600080fd5b610229610224366004611c21565b6104b8565b005b610229610239366004611bf1565b610b0d565b610229610b95565b61024f600e5481565b6040519081526020015b60405180910390f35b61024f600a5481565b61024f610dd6565b610229610281366004611bf1565b610e25565b6010546102999062010000900460ff1681565b6040519015158152602001610259565b61024f600f5481565b6102ba610ead565b6040805197885260208801969096529486019390935260608501919091526080840152151560a0830152151560c082015260e001610259565b610229610301366004611bf1565b610f68565b61024f610314366004611baa565b60056020526000908152604090205481565b60105461034090630100000090046001600160a01b031681565b6040516001600160a01b039091168152602001610259565b600354610340906001600160a01b031681565b61024f600d5481565b61024f600b5481565b610229611052565b60105461029990610100900460ff1681565b600454610340906001600160a01b031681565b600254610340906001600160a01b031681565b6001546001600160a01b0316610340565b6102296103dc366004611c21565b611097565b6010546102999060ff1681565b61024f60085481565b610229610405366004611baa565b611639565b61024f610418366004611baa565b60066020526000908152604090205481565b61024f61175b565b600154610340906001600160a01b031681565b61022961177e565b61024f61045b366004611baa565b60096020526000908152604090205481565b61022961047b366004611bf1565b6117cc565b61022961048e366004611baa565b611802565b6102296104a1366004611bf1565b61188f565b620f424061024f565b61024f60075481565b60105462010000900460ff16156104ea5760405162461bcd60e51b81526004016104e190611cf7565b60405180910390fd5b600360009054906101000a90046001600160a01b03166001600160a01b03166378e979256040518163ffffffff1660e01b815260040160206040518083038186803b15801561053857600080fd5b505afa15801561054c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105709190611c09565b4210156105bf5760405162461bcd60e51b815260206004820152601a60248201527f4d696e74696e67206861736e742073746172746564207965742100000000000060448201526064016104e1565b60105460ff16156106065760405162461bcd60e51b8152602060048201526011602482015270135a5b9d1a5b99c81a5cc81c185d5cd959607a1b60448201526064016104e1565b600080600080600360009054906101000a90046001600160a01b03166001600160a01b031663370158ea6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561065b57600080fd5b505afa15801561066f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106939190611c4c565b50600d546007546001546040516370a0823160e01b8152306004820152999d50979b509499509097509561073b958e95506107359493506001600160a01b031691506370a08231906024015b60206040518083038186803b1580156106f757600080fd5b505afa15801561070b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072f9190611c09565b906118c5565b906118da565b11156107785760405162461bcd60e51b815260206004820152600c60248201526b3e706f6f6c4365696c696e6760a01b60448201526064016104e1565b60008083156107e6576000600c54600a6107929190611dc9565b61079c908b611e71565b90506107b5856107af83620f42406118e6565b906118f2565b9250620f42408510156107e0576107dd866107af620f42406107d787866118c5565b906118e6565b91505b506107fd565b6107f7620f42406107af8a886118e6565b91508790505b600061081f600a6107d7610818620f42406107af888a6118e6565b86906118c5565b9050620186a087111561086857610865610858620186a06107356127106107af600f546107d7620186a08f6118c590919063ffffffff16565b6107af83620186a06118e6565b90505b808811156108a45760405162461bcd60e51b81526020600482015260096024820152683e736c69707061676560b81b60448201526064016104e1565b811561095057888211156108ea5760405162461bcd60e51b815260206004820152600d60248201526c3c736861726542616c616e636560981b60448201526064016104e1565b600480546040516305060b2d60e11b81523392810192909252602482018490526001600160a01b031690630a0c165a90604401600060405180830381600087803b15801561093757600080fd5b505af115801561094b573d6000803e3d6000fd5b505050505b89156109e2576001546040516323b872dd60e01b8152336004820152306024820152604481018c90526001600160a01b03909116906323b872dd90606401602060405180830381600087803b1580156109a857600080fd5b505af11580156109bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e09190611bd1565b505b600a546109ef90826118da565b600a556002546040516306203eab60e11b8152336004820152602481018390526001600160a01b0390911690630c407d5690604401600060405180830381600087803b158015610a3e57600080fd5b505af1158015610a52573d6000803e3d6000fd5b50505050600360009054906101000a90046001600160a01b03166001600160a01b031663af44f7246040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610aa657600080fd5b505af1158015610aba573d6000803e3d6000fd5b5050604080518d8152602081018690529081018490523392507f5a3358a3d27a5373c0df2604662088d37894d56b7cfd27f315770440f4e0d919915060600160405180910390a250505050505050505050565b601054630100000090046001600160a01b03163314610b3e5760405162461bcd60e51b81526004016104e190611d19565b60008111610b7b5760405162461bcd60e51b815260206004820152600a6024820152691e995c9bd05b5bdd5b9d60b21b60448201526064016104e1565b600154610b92906001600160a01b031633836118fe565b50565b600e54336000908152600960205260409020544391610bb491906118da565b1115610bf65760405162461bcd60e51b81526020600482015260116024820152703c726564656d7074696f6e5f64656c617960781b60448201526064016104e1565b3360009081526005602052604081205481908190819015610c3d573360009081526005602052604081208054919055600854909250610c3590836118c5565b600855600193505b3360009081526006602052604090205415610c7c57503360009081526006602052604081208054919055600754610c7490826118c5565b600755600192505b8315610d09576004805460405163a9059cbb60e01b81523392810192909252602482018490526001600160a01b03169063a9059cbb90604401602060405180830381600087803b158015610ccf57600080fd5b505af1158015610ce3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d079190611bd1565b505b8215610d955760015460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401602060405180830381600087803b158015610d5b57600080fd5b505af1158015610d6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d939190611bd1565b505b604080518281526020810184905233917ff5f901d4e76283e46f1175e35a0b79b533feacc3dfc09f9693cbfe125f26f515910160405180910390a250505050565b6000610e20600c54600a610dea9190611dc9565b6007546001546040516370a0823160e01b81523060048201526107d792916001600160a01b0316906370a08231906024016106df565b905090565b601054630100000090046001600160a01b03163314610e565760405162461bcd60e51b81526004016104e190611d19565b612710811115610ea85760405162461bcd60e51b815260206004820152601760248201527f70657263656e74616765206f7574206f662072616e676500000000000000000060448201526064016104e1565b600f55565b600d546001546040516370a0823160e01b8152306004820152600092839283928392839283928392916001600160a01b0316906370a082319060240160206040518083038186803b158015610f0157600080fd5b505afa158015610f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f399190611c09565b600754600854620f4240601054949c939b509199509750955060ff808316955061010090920490911692509050565b6003546001600160a01b03163314610fae5760405162461bcd60e51b815260206004820152600960248201526821747265617375727960b81b60448201526064016104e1565b60008111610feb5760405162461bcd60e51b815260206004820152600a6024820152691e995c9bd05b5bdd5b9d60b21b60448201526064016104e1565b6003546001600160a01b03166110355760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964547265617375727960881b60448201526064016104e1565b600354600154610b92916001600160a01b039182169116836118fe565b601054630100000090046001600160a01b031633146110835760405162461bcd60e51b81526004016104e190611d19565b6010805460ff19811660ff90911615179055565b60105462010000900460ff16156110c05760405162461bcd60e51b81526004016104e190611cf7565b600360009054906101000a90046001600160a01b03166001600160a01b03166378e979256040518163ffffffff1660e01b815260040160206040518083038186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111469190611c09565b4210156111955760405162461bcd60e51b815260206004820152601c60248201527f52656465656d696e67206861736e74207374617274656420796574210000000060448201526064016104e1565b601054610100900460ff16156111e35760405162461bcd60e51b815260206004820152601360248201527214995919595b5a5b99c81a5cc81c185d5cd959606a1b60448201526064016104e1565b6000806000600360009054906101000a90046001600160a01b03166001600160a01b031663370158ea6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561123757600080fd5b505afa15801561124b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126f9190611c4c565b975050509550505093505060006112a0611299620f42406107af858b6118e690919063ffffffff16565b88906118c5565b90506000806112b085600a6118e6565b9450620f42408510156112ff5760006112da6112d3620f42406107af878a6118e6565b85906118c5565b905086156112f8576112f3876107af83620f42406118e6565b6112fb565b60005b9150505b841561132e57600061132a620f42406107af600c54600a6113209190611dc9565b6107af888b6118e6565b9250505b61133982600a6118f2565b915061134681600a6118f2565b6007546001546040516370a0823160e01b8152306004820152929350611380926001600160a01b03909116906370a08231906024016106df565b8211156113c45760405162461bcd60e51b81526020600482015260126024820152713c636f6c6c61746572616c426c616e61636560701b60448201526064016104e1565b8187111580156113d45750808811155b61140c5760405162461bcd60e51b81526020600482015260096024820152683e736c69707061676560b81b60448201526064016104e1565b811561144d573360009081526006602052604090205461142c90836118da565b3360009081526006602052604090205560075461144990836118da565b6007555b801561148e573360009081526005602052604090205461146d90826118da565b3360009081526005602052604090205560085461148a90826118da565b6008555b336000908152600960205260409020439055600b546114ad908a6118da565b600b556002546040516305060b2d60e11b8152336004820152602481018b90526001600160a01b0390911690630a0c165a90604401600060405180830381600087803b1580156114fc57600080fd5b505af1158015611510573d6000803e3d6000fd5b50505050600081111561158357600480546040516306203eab60e11b81523092810192909252602482018390526001600160a01b031690630c407d5690604401600060405180830381600087803b15801561156a57600080fd5b505af115801561157e573d6000803e3d6000fd5b505050505b600360009054906101000a90046001600160a01b03166001600160a01b031663af44f7246040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115d357600080fd5b505af11580156115e7573d6000803e3d6000fd5b5050604080518c8152602081018690529081018490523392507f484c40561359f3e3b8be9101897f8680aa82fbe1df9fd9038e0dbc6284032646915060600160405180910390a2505050505050505050565b6002600054141561168c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104e1565b6002600055601054630100000090046001600160a01b031633146116c25760405162461bcd60e51b81526004016104e190611d19565b60105462010000900460ff16156116eb5760405162461bcd60e51b81526004016104e190611cf7565b6010805462ff00001916620100001790556007546001546040516370a0823160e01b81523060048201526000926117389290916001600160a01b03909116906370a08231906024016106df565b600154909150611752906001600160a01b031683836118fe565b50506001600055565b6000600b54600a54111561177857600b54600a54610e20916118c5565b50600090565b601054630100000090046001600160a01b031633146117af5760405162461bcd60e51b81526004016104e190611d19565b6010805461ff001981166101009182900460ff1615909102179055565b601054630100000090046001600160a01b031633146117fd5760405162461bcd60e51b81526004016104e190611d19565b600d55565b601054630100000090046001600160a01b031633146118335760405162461bcd60e51b81526004016104e190611d19565b6003546040516001600160a01b038084169216907febebcc22237fa047dcfebf54b185ec126c9b24d45f4bd2a18e4fa02e07308c4090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b601054630100000090046001600160a01b031633146118c05760405162461bcd60e51b81526004016104e190611d19565b600e55565b60006118d18284611e90565b90505b92915050565b60006118d18284611d4e565b60006118d18284611e71565b60006118d18284611d66565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611950908490611955565b505050565b60006119aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a279092919063ffffffff16565b80519091501561195057808060200190518101906119c89190611bd1565b6119505760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104e1565b6060611a368484600085611a40565b90505b9392505050565b606082471015611aa15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104e1565b6001600160a01b0385163b611af85760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104e1565b600080866001600160a01b03168587604051611b149190611ca8565b60006040518083038185875af1925050503d8060008114611b51576040519150601f19603f3d011682016040523d82523d6000602084013e611b56565b606091505b5091509150611b66828286611b71565b979650505050505050565b60608315611b80575081611a39565b825115611b905782518084602001fd5b8160405162461bcd60e51b81526004016104e19190611cc4565b600060208284031215611bbb578081fd5b81356001600160a01b0381168114611a39578182fd5b600060208284031215611be2578081fd5b81518015158114611a39578182fd5b600060208284031215611c02578081fd5b5035919050565b600060208284031215611c1a578081fd5b5051919050565b600080600060608486031215611c35578182fd5b505081359360208301359350604090920135919050565b600080600080600080600080610100898b031215611c68578384fd5b505086516020880151604089015160608a015160808b015160a08c015160c08d015160e0909d0151959e949d50929b919a50985090965094509092509050565b60008251611cba818460208701611ea7565b9190910192915050565b6020815260008251806020840152611ce3816040850160208701611ea7565b601f01601f19169190910160400192915050565b6020808252600890820152671b5a59dc985d195960c21b604082015260600190565b6020808252818101527f506f6f6c3a2063616c6c6572206973206e6f7420746865206f70657261746f72604082015260600190565b60008219821115611d6157611d61611ed7565b500190565b600082611d8157634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115611dc1578160001904821115611da757611da7611ed7565b80851615611db457918102915b93841c9390800290611d8b565b509250929050565b60006118d18383600082611ddf575060016118d4565b81611dec575060006118d4565b8160018114611e025760028114611e0c57611e28565b60019150506118d4565b60ff841115611e1d57611e1d611ed7565b50506001821b6118d4565b5060208310610133831016604e8410600b8410161715611e4b575081810a6118d4565b611e558383611d86565b8060001904821115611e6957611e69611ed7565b029392505050565b6000816000190483118215151615611e8b57611e8b611ed7565b500290565b600082821015611ea257611ea2611ed7565b500390565b60005b83811015611ec2578181015183820152602001611eaa565b83811115611ed1576000848401525b50505050565b634e487b7160e01b600052601160045260246000fdfea264697066735822122078db994e07cf689ec4f076499694e1d647b3a560e5c96819644516124850240364736f6c6343000804003300000000000000000000000002a8dc66334b1cc6cd8f28fe8dbf6b58b49b47b6000000000000000000000000d8d40dcee0c2b486eebd1fedb3f507b011de7ff0000000000000000000000000c21223249ca28397b4b6541dffaecc539bff0c59000000000000000000000000562fe5786e0d16f9f84c53d8364d74a5a983fdb200000000000000000000000000000000000004ee2d6d415b85acef8100000000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000002a8dc66334b1cc6cd8f28fe8dbf6b58b49b47b6000000000000000000000000d8d40dcee0c2b486eebd1fedb3f507b011de7ff0000000000000000000000000c21223249ca28397b4b6541dffaecc539bff0c59000000000000000000000000562fe5786e0d16f9f84c53d8364d74a5a983fdb200000000000000000000000000000000000004ee2d6d415b85acef8100000000
-----Decoded View---------------
Arg [0] : __10MB (address): 0x02a8dc66334b1cc6cd8f28fe8dbf6b58b49b47b6
Arg [1] : __10SHARE (address): 0xd8d40dcee0c2b486eebd1fedb3f507b011de7ff0
Arg [2] : _collateral (address): 0xc21223249ca28397b4b6541dffaecc539bff0c59
Arg [3] : _treasury (address): 0x562fe5786e0d16f9f84c53d8364d74a5a983fdb2
Arg [4] : _pool_ceiling (uint256): 100000000000000000000000000000000
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000002a8dc66334b1cc6cd8f28fe8dbf6b58b49b47b6
Arg [1] : 000000000000000000000000d8d40dcee0c2b486eebd1fedb3f507b011de7ff0
Arg [2] : 000000000000000000000000c21223249ca28397b4b6541dffaecc539bff0c59
Arg [3] : 000000000000000000000000562fe5786e0d16f9f84c53d8364d74a5a983fdb2
Arg [4] : 00000000000000000000000000000000000004ee2d6d415b85acef8100000000
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.