Contract Overview
Balance:
0 FTM
FTM Value:
$0.00
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Latest 1 internal transaction
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0xad630d16c3ce170be8bb210d0af9abb9b3f4ee14a3de6de0346baf024e450fb3 | 18312303 | 482 days 2 hrs ago | Coffin Finance: Deployer | Contract Creation | 0 FTM |
[ Download CSV Export ]
Contract Name:
GatePolicy
Compiler Version
v0.8.7+commit.e28d00a7
Optimization Enabled:
Yes with 500 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "./interfaces/IGate.sol"; import "./interfaces/IGatePolicy.sol"; import "./interfaces/ITwapOracle.sol"; import "./CoffinOracle.sol"; contract GatePolicy is Ownable, IGatePolicy, Initializable { using SafeMath for uint256; // address public coffinOracle; address public gate; address public dollar; address public collateral; // address public treasury; // wrapped ftm address private wftmAddress = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83; uint256 public override redemption_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public override extra_redemption_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public override minting_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 private constant RATIO_PRECISION = 1e6; // collateral_ratio uint256 public override target_collateral_ratio; // 6 decimals of precision // uint256 public override effective_collateral_ratio; // 6 decimals of precision uint256 public last_refresh_cr_timestamp; uint256 public refresh_cooldown; // Seconds to wait before being able to run refreshCollateralRatio() again uint256 public ratio_step; // Amount to change the collateralization ratio by upon refreshCollateralRatio() // The price of DOLLAR; this value is only used for // the collateral ratio mechanism and not for minting and redeeming which are hardcoded at $1 uint256 public override price_target; // The bound above and below the price target at which the Collateral // ratio is allowed to drop uint256 public price_band; bool public collateral_ratio_paused = false; // during bootstraping phase, collateral_ratio will be fixed at 100% // bool public using_effective_collateral_ratio = true; uint256 private constant COLLATERAL_RATIO_MAX = 1e6; bool public override using_twap_for_tcr = false; bool public override using_twap_for_redeem = false; bool public override using_twap_for_mint = false; // address public oracle_twap; address public oracle; // Number of blocks to wait before being able to collectRedemption() uint256 public override redemption_delay = 120; /* ========== EVENTS ============= */ event TreasuryChanged(address indexed newTreasury); /* ========== CONSTRUCTOR ========== */ constructor() { ratio_step = 2500; // = 0.25% at 6 decimals of precision target_collateral_ratio = 800000; // effective_collateral_ratio = 1000000; // Refresh cooldown period is set to 1 hour (3600 seconds) at genesis refresh_cooldown = 3600; // = $1. (6 decimals of precision). // Collateral ratio will adjust according to the $1 price target at genesis price_target = 1000000; price_band = 5000; minting_fee = 3000; // 0.3 % by defalt redemption_fee = 4000; // 0.4% by default extra_redemption_fee = 4000; // 0.4% by default } function init(address _gate, address _dollar, address _collateral) external onlyOwner initializer { setGate(_gate); setDollar(_dollar); setCollateral(_collateral); } /* ========== VIEWS ========== */ function getEffectiveCollateralRatio() public view override returns (uint256) { // if (!using_effective_collateral_ratio) { // return target_collateral_ratio; // } uint256 total_collateral_value = IGate(gate).globalCollateralValue(); uint256 total_supply_dollar = IERC20(dollar).totalSupply(); if (total_supply_dollar == 0) { return COLLATERAL_RATIO_MAX; } if (total_collateral_value == 0) { return 0; } uint256 ecr = total_collateral_value.mul(PRICE_PRECISION).div(total_supply_dollar); if (ecr > COLLATERAL_RATIO_MAX) { return COLLATERAL_RATIO_MAX; } return ecr; } /* ========== PUBLIC FUNCTIONS ========== */ function canRefresh() view public returns(bool){ if (collateral_ratio_paused) { return false; } if (block.timestamp - last_refresh_cr_timestamp >= refresh_cooldown) { return true; } return false; } function refreshCollateralRatio(bool noerror) external override { if (!noerror) { require(collateral_ratio_paused == false, "Collateral Ratio has been paused"); require( block.timestamp - last_refresh_cr_timestamp >= refresh_cooldown, "Must wait for the refresh cooldown since last refresh" ); } else { if (collateral_ratio_paused) { //Collateral Ratio has been paused return ; } if (block.timestamp - last_refresh_cr_timestamp < refresh_cooldown) { return ; } } uint256 current_dollar_price = 0; if (using_twap_for_tcr) { (uint256 __price, uint8 __d) = ICoffinOracle(oracle).getTwapCOUSDUSD(); current_dollar_price = __price.mul(PRICE_PRECISION).div(10**__d); } if (current_dollar_price==0) { // use corrent COUSD price instaed of TWAP current_dollar_price =IGate(gate).getDollarPrice(); } // Step increments are 0.25% (upon genesis, changable by setRatioStep()) if (current_dollar_price > price_target.add(price_band)) { // decrease collateral ratio if (target_collateral_ratio <= ratio_step) { // if within a step of 0, go to 0 target_collateral_ratio = 0; } else { target_collateral_ratio = target_collateral_ratio.sub(ratio_step); } } // price is below $1 - `price_band`. Need to increase `collateral_ratio` else if (current_dollar_price < price_target.sub(price_band)) { // increase collateral ratio if (target_collateral_ratio.add(ratio_step) >= COLLATERAL_RATIO_MAX) { target_collateral_ratio = COLLATERAL_RATIO_MAX; // cap collateral ratio at 1.000000 } else { target_collateral_ratio = target_collateral_ratio.add(ratio_step); } } // // If using ECR, then calcECR. If not, update ECR = TCR // if (using_effective_collateral_ratio) { // effective_collateral_ratio = getEffectiveCollateralRatio(); // } else { // effective_collateral_ratio = target_collateral_ratio; // } last_refresh_cr_timestamp = block.timestamp; // emit CollateralRatioRefreshed(effective_collateral_ratio, target_collateral_ratio); } /* ========== RESTRICTED FUNCTIONS ========== */ function setRatioStep(uint256 _ratio_step) public onlyOwner { ratio_step = _ratio_step; } function setPriceTarget(uint256 _price_target) public onlyOwner { price_target = _price_target; } function setRefreshCooldown(uint256 _refresh_cooldown) public onlyOwner { refresh_cooldown = _refresh_cooldown; } function setPriceBand(uint256 _price_band) external onlyOwner { price_band = _price_band; } function setDollar(address _dollar) public onlyOwner { require(_dollar != address(0), "invalidAddress"); dollar = _dollar; } function setCollateral(address _addr) public onlyOwner { require(_addr != address(0), "invalidAddress"); collateral = _addr; } // use to retstore CRs incase of using new Treasury function reset(uint256 _target_collateral_ratio) external onlyOwner { require( _target_collateral_ratio <= COLLATERAL_RATIO_MAX, "invalid Ratio" ); target_collateral_ratio = _target_collateral_ratio; // effective_collateral_ratio = _effective_collateral_ratio; } function toggleCollateralRatio() public onlyOwner { collateral_ratio_paused = !collateral_ratio_paused; emit CollateralRatioToggled(collateral_ratio_paused); } function enableTwapForTCR() public onlyOwner { using_twap_for_tcr = true; emit TwapTCRToggled(true); } function disableTwapForTCR() public onlyOwner { using_twap_for_tcr = false; emit TwapTCRToggled(false); } function enableTwapForRedeem() public onlyOwner { using_twap_for_redeem = true; emit TwapTCRToggled(true); } function disableTwapForRedeem() public onlyOwner { using_twap_for_redeem = false; emit TwapRedeemToggled(false); } function enableTwapForMint() public onlyOwner { using_twap_for_mint = true; emit TwapRedeemToggled(true); } function disableTwapForMint() public onlyOwner { using_twap_for_mint = false; emit TwapMintToggled(false); } function setOracle(address _oracle) public onlyOwner { require(_oracle!=address(0), "_oracle address "); oracle = _oracle; } // function toggleEffectiveCollateralRatio() public onlyOwner { // using_effective_collateral_ratio = !using_effective_collateral_ratio; // } function setGate(address _gate) public onlyOwner { require(_gate != address(0), "invalidAddress"); gate = _gate; } function setMintingFee(uint256 min_fee) public onlyOwner { minting_fee = min_fee; // emit MintingFeeSet(min_fee); } function setRedemptionFee(uint256 red_fee) public onlyOwner { redemption_fee = red_fee; // emit RedemptionFeeSet(red_fee); } function setExtraRedemptionFee(uint256 ex_red_fee) public onlyOwner { extra_redemption_fee = ex_red_fee; // emit ExtraRedemptionFeeSet(ex_red_fee); } function setRedemptionDelay(uint256 _redemption_delay) external onlyOwner { redemption_delay = _redemption_delay; } event CollateralRatioToggled(bool collateral_ratio_paused); event TwapTCRToggled(bool using_twap_for_tcr); event TwapRedeemToggled(bool using_twap_for_tcr); event TwapMintToggled(bool using_twap_for_tcr); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 a proxied contract can't have 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. * * 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. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
// SPDX-License-Identifier: MIT 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 no longer needed starting with Solidity 0.8. 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 pragma solidity ^0.8.7; interface IGate { function unclaimed_pool_collateral() external view returns (uint256); function globalCollateralValue() external view returns (uint256) ; function getCollateralPrice() external view returns (uint256); function getDollarPrice() external view returns (uint256) ; function getCoffinPrice() external view returns (uint256) ; // function getCollateralTwap() external view returns (uint256); function getDollarTwap() external view returns (uint256) ; function getCoffinTwap() external view returns (uint256) ; function getDollarSupply() external view returns (uint256) ; function getCoffinSupply() external view returns (uint256) ; function globalCollateralBalance() external view returns (uint256); function getCollateralBalance() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; pragma experimental ABIEncoderV2; interface IGatePolicy { function target_collateral_ratio() external view returns (uint256); function redemption_delay() external view returns (uint256); // function effective_collateral_ratio() external view returns (uint256); function getEffectiveCollateralRatio() external view returns (uint256); function refreshCollateralRatio(bool noerror) external ; function redemption_fee() external view returns (uint256); function extra_redemption_fee() external view returns (uint256); function minting_fee() external view returns (uint256); function price_target() external view returns (uint256); function using_twap_for_redeem() external view returns (bool); function using_twap_for_mint() external view returns (bool); function using_twap_for_tcr() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; pragma experimental ABIEncoderV2; interface ITwapOracle { function consult(address token, uint256 amountIn) external view returns (uint256 amountOut); function update() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/IUniswapV2Router02.sol"; import "./interfaces/IUniswapV2Factory.sol"; import "./interfaces/IUniswapLP.sol"; import "./libs/FixedPoint.sol"; import "./interfaces/IBandStdReference.sol"; interface ICoffinOracle { function PERIOD() external view returns (uint32); function getCOFFINUSD() external view returns (uint256, uint8); function updateTwap(address token0, address token1) external ; function getCOUSDUSD() external view returns (uint256, uint8); function getTwapCOUSDUSD() external view returns (uint256, uint8); function getTwapCOFFINUSD() external view returns (uint256, uint8); function getTwapXCOFFINUSD() external view returns (uint256, uint8); function updateTwapDollar() external ; function updateTwapCoffin() external ; function updateTwapXCoffin() external ; function getXCOFFINUSD() external view returns (uint256, uint8); function getCOUSDFTM() external view returns (uint256, uint8); function getXCOFFINFTM() external view returns (uint256, uint8); function getCOFFINFTM() external view returns (uint256, uint8); function getFTMUSD() external view returns (uint256, uint8); } contract MockCoffinOracle is ICoffinOracle, Ownable { uint256 public xcoffinftm = (1 / 2) * 1 * 10**18; uint256 public coffinftm = 2 * 1 * 10**18; uint256 public ftmusd = (1 / 4) * 1 * 10**18; uint256 public cousdftm = (101 / 100) * 4 * 1 * 10**18; uint32 public override PERIOD = 600; // 10-minute TWAP function updateTwap(address token0, address token1) external override { } function updateTwapDollar() external override{ } function updateTwapCoffin() external override{ } function updateTwapXCoffin() external override{ } function setCOUSDFTM(uint256 val) external { cousdftm = val; } function getCOUSDFTM() public view override returns (uint256, uint8) { return (cousdftm, 18); } function setXCOFFINFTM(uint256 val) external { xcoffinftm = val; } function getXCOFFINFTM() public view override returns (uint256, uint8) { return (xcoffinftm, 18); } function setCOFFINFTM(uint256 val) external { coffinftm = val; } function getCOFFINFTM() public view override returns (uint256, uint8) { return (coffinftm, 18); } uint256 public cousdusd = 1030000000000000000; function setCOUSDUSD(uint256 val) external { cousdusd = val;// decimal 18 } function getCOUSDUSD() public view override returns(uint256,uint8){ return (cousdusd,18);// decimal 18 } function setFTMUSD(uint256 val) external { ftmusd = val; } function getFTMUSD() public view override returns (uint256, uint8) { return (ftmusd, 18); } function getCOFFINUSD() public view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getXCOFFINUSD() public view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getXCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getTwapCOUSDUSD() external view override returns (uint256, uint8){ return getCOUSDUSD(); } function getTwapCOFFINUSD() external view override returns (uint256, uint8){ return getCOFFINUSD(); } function getTwapXCOFFINUSD() external view override returns (uint256, uint8){ return getXCOFFINUSD(); } } contract CoffinOracle is ICoffinOracle, Initializable,Ownable { using SafeMath for uint256; using FixedPoint for *; IUniswapV2Router02 public uniswapv2router; address public coffin; address public dollar; address public xcoffin; address public wftm = 0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83; address public usdc = 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75; address public dai = 0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E; address public boo = 0x841FAD6EAe12c286d1Fd18d1d525DFfA75C7EFFE; IBandStdReference bandRef; uint32 public override PERIOD = 600; // 10-minute TWAP struct Pair { uint256 price0CumulativeLast; uint256 price1CumulativeLast; uint32 blockTimestampLast; FixedPoint.uq112x112 price0Average; FixedPoint.uq112x112 price1Average; bool initialized; } mapping(address => Pair) public getPair; function setPeriod(uint32 _period) external onlyOwner { PERIOD = _period; } function init( address _coffinAddress, address _cousdAddress, address _xcoffinAddress ) external initializer onlyOwner{ // router address. it's spooky router by default. address routerAddress = 0xF491e7B69E4244ad4002BC14e878a34207E38c29; setRouter(routerAddress); address fantomBandProtocol = 0x56E2898E0ceFF0D1222827759B56B28Ad812f92F; setBandOracle(fantomBandProtocol); setCOFFINAddress(_coffinAddress); setDollarAddress(_cousdAddress); setXCOFFINAddress(_xcoffinAddress); } function getBandRate(string memory token0, string memory token1) public view returns (uint256) { IBandStdReference.ReferenceData memory data = bandRef.getReferenceData( token0, token1 ); return data.rate; } function getFTMUSD() public view override returns (uint256, uint8) { return (getBandRate("FTM","USD"), 18); } function setCOFFINAddress(address _coffinAddress) public onlyOwner { coffin = _coffinAddress; } function setXCOFFINAddress(address _xcoffinAddress) public onlyOwner { xcoffin = _xcoffinAddress; } function setDollarAddress(address _cousdAddress) public onlyOwner { dollar = _cousdAddress; } function setRouter(address _uniswapv2routeraddress) public onlyOwner { uniswapv2router = IUniswapV2Router02(_uniswapv2routeraddress); } function setBandOracle(address _bandOracleAddress) public onlyOwner { bandRef = IBandStdReference(_bandOracleAddress); } function getCOFFINUSD() external view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getTwapCOFFINUSD() external view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getTwapCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getUSDCUSD() public view returns (uint256, uint8) { return (getBandRate("USDC","USD"), 18); } function getDAIUSD() public view returns (uint256, uint8) { return (getBandRate("DAI","USD"), 18); } uint8 public oracleMode = 0; function enableFTMOracle() external onlyOwner { oracleMode = 1; } function enableDAIOracle() external onlyOwner { oracleMode = 2 ; } function enableUSDCracle() external onlyOwner { oracleMode = 0 ; } function getCOUSDUSD() external view override returns (uint256, uint8) { if (oracleMode==1) { (uint256 v1, uint8 d1) = getCOUSDFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } else if (oracleMode==2) { (uint256 v1, uint8 d1) = getCOUSDDAI(); (uint256 v2, uint8 d2) = getDAIUSD(); return ((v1 * v2) / (10**d1), d2); } else { (uint256 v1, uint8 d1) = getCOUSDUSDC(); (uint256 v2, uint8 d2) = getUSDCUSD(); return ((v1 * v2) / (10**d1), d2); } } function getTwapCOUSDUSD() external view override returns (uint256, uint8) { if (oracleMode==1) { (uint256 v1, uint8 d1) = getTwapCOUSDFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } else if (oracleMode==2) { (uint256 v1, uint8 d1) = getTwapCOUSDDAI(); (uint256 v2, uint8 d2) = getDAIUSD(); return ((v1 * v2) / (10**d1), d2); } else { (uint256 v1, uint8 d1) = getTwapCOUSDUSDC(); (uint256 v2, uint8 d2) = getUSDCUSD(); return ((v1 * v2) / (10**d1), d2); } } function getXCOFFINUSD() external view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getXCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getTwapXCOFFINUSD() external view override returns (uint256, uint8) { (uint256 v1, uint8 d1) = getTwapXCOFFINFTM(); (uint256 v2, uint8 d2) = getFTMUSD(); return ((v1 * v2) / (10**d1), d2); } function getTwapCOUSDFTM() public view returns (uint256, uint8) { (uint256 a, uint8 b) = getTwapRate(dollar,wftm); if (a>0) { return (a,b); } return getRealtimeRate(dollar,wftm); } function getTwapCOUSDDAI() public view returns (uint256, uint8) { (uint256 a, uint8 b) = getTwapRate(dollar,dai); if (a>0) { return (a,b); } return getRealtimeRate(dollar,usdc); } function getTwapCOUSDUSDC() public view returns (uint256, uint8) { (uint256 a, uint8 b) = getTwapRate(dollar,usdc); if (a>0) { return (a,b); } return getRealtimeRate(dollar,usdc); } function getCOUSDFTM() public view override returns (uint256, uint8) { return getRealtimeRate(dollar,wftm); } function getCOUSDUSDC() public view returns (uint256, uint8) { return getRealtimeRate(dollar,usdc); } function getCOUSDDAI() public view returns (uint256, uint8) { return getRealtimeRate(dollar,dai); } function getTwapXCOFFINFTM() public view returns (uint256, uint8) { (uint256 a, uint8 b) = getTwapRate(xcoffin,wftm); if (a>0) { return (a,b); } return getRealtimeRate(xcoffin,wftm); } function getXCOFFINFTM() public view override returns (uint256, uint8) { return getRealtimeRate(xcoffin,wftm); } function getTwapCOFFINFTM() public view returns (uint256, uint8) { (uint256 a, uint8 b) = getTwapRate(coffin,wftm); if (a>0) { return (a,b); } return getRealtimeRate(coffin,wftm); } function getCOFFINFTM() public view override returns (uint256, uint8) { return getRealtimeRate(coffin,wftm); } function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2**32); } function currentCumulativePrices(address uniswapV2Pair) internal view returns ( uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp ) { // Pair storage pairStorage = getPair[uniswapV2Pair]; blockTimestamp = currentBlockTimestamp(); IUniswapLP uniswapPair = IUniswapLP(uniswapV2Pair); price0Cumulative = uniswapPair.price0CumulativeLast(); price1Cumulative = uniswapPair.price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 _blockTimestampLast) = uniswapPair.getReserves(); if (_blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - _blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint256(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint256(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } function getTwapRate(address token0, address token1) public view returns (uint256 priceLatest, uint8 decimals) { address[] memory path = new address[](2); path[0] = token0; path[1] = token1; address factory = address(uniswapv2router.factory()); address uniswapV2Pair = IUniswapV2Factory(factory).getPair(token0, token1); if (uniswapV2Pair== address(0)) { return (0,0); } // Pair memory pair = getPair[uniswapV2Pair]; Pair storage pairStorage = getPair[uniswapV2Pair]; // require(pairStorage.initialized, "need to setup first"); if (!pairStorage.initialized) { return getRealtimeRate(token0, token1); // return (0,0); } (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = currentCumulativePrices( address(uniswapV2Pair) ); uint32 timeElapsed = blockTimestamp - pairStorage.blockTimestampLast; // Overflow is desired FixedPoint.uq112x112 memory price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - pairStorage.price0CumulativeLast) / timeElapsed)); FixedPoint.uq112x112 memory price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - pairStorage.price1CumulativeLast) / timeElapsed)); uint256 amountIn = 1e18; if (IUniswapLP(uniswapV2Pair).token0() == token0) { priceLatest = uint256(price0Average.mul(amountIn).decode144()); decimals = ERC20(token1).decimals(); } else { require(IUniswapLP(uniswapV2Pair).token0() == token1, "TwapOracle: INVALID_TOKEN"); priceLatest = uint256(price1Average.mul(amountIn).decode144()); decimals = ERC20(token0).decimals(); } } function getTwapRateWithUpdate(address token0, address token1) external returns (uint256 priceLatest, uint8 decimals) { updateTwap(token0,token1); return getTwapRate(token0,token1); } function updateTwapDollarFTM() public { updateTwap(dollar, wftm); } function updateTwapDollar() public override { updateTwap(dollar, dai); } function updateTwapDollarUSDC() public { updateTwap(dollar, usdc); } function updateTwapCoffin() public override { updateTwap(coffin, wftm); } function updateTwapXCoffin() public override { updateTwap(xcoffin, wftm); } function updateTwap(address token0, address token1) public override { address[] memory path = new address[](2); path[0] = token0; path[1] = token1; address factory = address(uniswapv2router.factory()); address uniswapV2Pair = IUniswapV2Factory(factory).getPair(token0, token1); if (uniswapV2Pair== address(0)) { return; } Pair storage pairStorage = getPair[uniswapV2Pair]; // require(pairStorage.initialized, "need to setup first"); (uint256 price0Cumulative, uint256 price1Cumulative, uint32 blockTimestamp) = currentCumulativePrices( address(uniswapV2Pair) ); if (!pairStorage.initialized) { // first time pairStorage.price0CumulativeLast = price0Cumulative; pairStorage.price1CumulativeLast = price1Cumulative; pairStorage.blockTimestampLast = blockTimestamp; pairStorage.initialized = true; return; } // Overflow is desired uint32 timeElapsed = blockTimestamp - pairStorage.blockTimestampLast; // Ensure that at least one full period has passed since the last update if (timeElapsed < PERIOD) { return ; } pairStorage.price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - pairStorage.price0CumulativeLast) / timeElapsed)); pairStorage.price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - pairStorage.price1CumulativeLast) / timeElapsed)); pairStorage.price0CumulativeLast = price0Cumulative; pairStorage.price1CumulativeLast = price1Cumulative; pairStorage.blockTimestampLast = blockTimestamp; } function getRealtimeRate(address tokenA, address tokenB) public view returns (uint256 priceLatest, uint8 decimals) { address factory = address(uniswapv2router.factory()); address pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB); if (pair== address(0)) { return (0,0); } (uint112 reserve0, uint112 reserve1,) = IUniswapLP(pair).getReserves(); if (IUniswapLP(pair).token0()==address(tokenA)) { priceLatest = uint256(reserve1).mul(uint256(10**ERC20(tokenA).decimals())).div(uint256(reserve0)); decimals = ERC20(tokenB).decimals(); } else { priceLatest = uint256(reserve0).mul(uint256(10**ERC20(tokenA).decimals())).div(uint256(reserve1)); decimals = ERC20(tokenB).decimals(); } if ((18-decimals)>0) { priceLatest = priceLatest.mul(10**(18-decimals)); decimals = 18; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT 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 guidelines: functions revert instead * of 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: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, 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}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), 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}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - 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) { _approve(_msgSender(), spender, _allowances[_msgSender()][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) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), 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: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, 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 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 pragma solidity >=0.6.11; import "./IUniswapV2Router01.sol"; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; interface IUniswapV2Factory { function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; pragma experimental ABIEncoderV2; interface IUniswapLP { function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function getTokenWeights() external view returns (uint32 tokenWeight0, uint32 tokenWeight1); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "./Babylonian.sol"; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint256 _x; } uint8 private constant RESOLUTION = 112; uint256 private constant Q112 = uint256(1) << RESOLUTION; uint256 private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint256 y) internal pure returns (uq144x112 memory) { uint256 z; require(y == 0 || (z = uint256(self._x) * y) / y == uint256(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, "FixedPoint: ZERO_RECIPROCAL"); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; interface IBandStdReference { /// A structure returned whenever someone requests for standard reference data. struct ReferenceData { uint256 rate; // base/quote exchange rate, multiplied by 1e18. uint256 lastUpdatedBase; // UNIX epoch of the last time when base price gets updated. uint256 lastUpdatedQuote; // UNIX epoch of the last time when quote price gets updated. } /// Returns the price data for the given base/quote pair. Revert if not available. function getReferenceData(string memory _base, string memory _quote) external view returns (ReferenceData memory); /// Similar to getReferenceData, but with multiple base/quote pairs at once. function getReferenceDataBulk( string[] memory _bases, string[] memory _quotes ) external view returns (ReferenceData[] memory); }
// SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.7; interface IUniswapV2Router01 { function factory() external view returns (address); function WETH() external view returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } }
{ "optimizer": { "enabled": true, "runs": 500 }, "metadata": { "bytecodeHash": "none", "useLiteralContent": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"collateral_ratio_paused","type":"bool"}],"name":"CollateralRatioToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"using_twap_for_tcr","type":"bool"}],"name":"TwapMintToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"using_twap_for_tcr","type":"bool"}],"name":"TwapRedeemToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"using_twap_for_tcr","type":"bool"}],"name":"TwapTCRToggled","type":"event"},{"inputs":[],"name":"canRefresh","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateral_ratio_paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableTwapForMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableTwapForRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableTwapForTCR","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dollar","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableTwapForMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTwapForRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTwapForTCR","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"extra_redemption_fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEffectiveCollateralRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gate","type":"address"},{"internalType":"address","name":"_dollar","type":"address"},{"internalType":"address","name":"_collateral","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"last_refresh_cr_timestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minting_fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price_band","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price_target","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ratio_step","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":[],"name":"redemption_fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"noerror","type":"bool"}],"name":"refreshCollateralRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"refresh_cooldown","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_target_collateral_ratio","type":"uint256"}],"name":"reset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"setCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dollar","type":"address"}],"name":"setDollar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ex_red_fee","type":"uint256"}],"name":"setExtraRedemptionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gate","type":"address"}],"name":"setGate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"min_fee","type":"uint256"}],"name":"setMintingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price_band","type":"uint256"}],"name":"setPriceBand","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price_target","type":"uint256"}],"name":"setPriceTarget","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ratio_step","type":"uint256"}],"name":"setRatioStep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_redemption_delay","type":"uint256"}],"name":"setRedemptionDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"red_fee","type":"uint256"}],"name":"setRedemptionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_refresh_cooldown","type":"uint256"}],"name":"setRefreshCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"target_collateral_ratio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleCollateralRatio","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"using_twap_for_mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"using_twap_for_redeem","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"using_twap_for_tcr","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6080604052600480546001600160a01b0319167321be370d5312f44cb42ce377bc9b8a0cef1a4c83179055600e805463ffffffff191690556078600f5534801561004857600080fd5b5061005233610088565b6109c4600b55620c3500600855610e10600a55620f4240600c55611388600d55610bb8600755610fa060058190556006556100d8565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611955806100e76000396000f3fe608060405234801561001057600080fd5b50600436106102cf5760003560e01c80637a0ebc881161018c578063ac4f843e116100ee578063c3355b8d11610097578063d8dfeb4511610071578063d8dfeb451461055d578063f1a9ee0314610570578063f2fde38b1461058357600080fd5b8063c3355b8d14610538578063cb73999f14610541578063d33f19861461054a57600080fd5b8063bef40ec8116100c8578063bef40ec81461051f578063c03f7be314610527578063c10722091461053057600080fd5b8063ac4f843e146104fb578063af15ce2a14610504578063bbc3ef8f1461050c57600080fd5b806387a140c3116101505780638b3f98e11161012a5780638b3f98e1146104d95780638da5cb5b146104e1578063965ff461146104f257600080fd5b806387a140c3146104a657806388315a40146104b3578063886abef5146104c657600080fd5b80637a0ebc881461044a5780637adbf9731461045d5780637dbc1df0146104705780637dc0d1d01461048357806383df850c1461049e57600080fd5b8063310bd74b1161023557806351adeb57116101f95780636ae74488116101d35780636ae74488146104265780637013da051461042f578063715018a61461044257600080fd5b806351adeb57146103e05780635b134da41461040b5780636140133b1461041357600080fd5b8063310bd74b14610396578063362d5ae3146103a95780634006311b146103bc578063408ab10f146103c55780634ff33ead146103d857600080fd5b80631c5df1e5116102975780632853fb10116102715780632853fb101461037c5780632cb4f63e146103855780632f8777531461038e57600080fd5b80631c5df1e514610344578063238a47091461035757806323936e581461036a57600080fd5b8063050dff0a146102d4578063146a549d146102de5780631512842514610307578063184b95591461031e578063186d9b2e14610331575b600080fd5b6102dc610596565b005b600e546102f2906301000000900460ff1681565b60405190151581526020015b60405180910390f35b610310600f5481565b6040519081526020016102fe565b6102dc61032c3660046116e7565b610627565b6102dc61033f36600461174c565b610762565b6102dc61035236600461174c565b6107af565b6102dc61036536600461174c565b6107fc565b600e546102f290610100900460ff1681565b610310600d5481565b610310600c5481565b6102dc610849565b6102dc6103a436600461174c565b6108d5565b6102dc6103b73660046116cc565b610965565b61031060085481565b6102dc6103d336600461174c565b610a16565b610310610a63565b6002546103f3906001600160a01b031681565b6040516001600160a01b0390911681526020016102fe565b6102dc610bcf565b6102dc61042136600461174c565b610c53565b61031060095481565b600e546102f29062010000900460ff1681565b6102dc610ca0565b6001546103f3906001600160a01b031681565b6102dc61046b3660046116cc565b610cf4565b6102dc61047e36600461174c565b610dd4565b600e546103f39064010000000090046001600160a01b031681565b6102dc610e21565b600e546102f29060ff1681565b6102dc6104c13660046116cc565b610ea9565b6102dc6104d43660046116cc565b610f5a565b6102dc61100b565b6000546001600160a01b03166103f3565b61031060065481565b610310600b5481565b6102f2611090565b6102dc61051a36600461174c565b6110c5565b6102dc611112565b610310600a5481565b6102dc6111a2565b61031060075481565b61031060055481565b6102dc61055836600461172a565b61122c565b6003546103f3906001600160a01b031681565b6102dc61057e36600461174c565b611521565b6102dc6105913660046116cc565b61156e565b6000546001600160a01b031633146105e35760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064015b60405180910390fd5b600e805463ff00000019169055604051600081527fa64354303adf2ce1a64cfd127fcefde507fb53c37da404be87f8859d6dd6debc906020015b60405180910390a1565b6000546001600160a01b0316331461066f5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600054600160a81b900460ff16806106915750600054600160a01b900460ff16155b6107035760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016105da565b600054600160a81b900460ff1615801561072d576000805461ffff60a01b191661010160a01b1790555b61073684610ea9565b61073f83610965565b61074882610f5a565b801561075c576000805460ff60a81b191690555b50505050565b6000546001600160a01b031633146107aa5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600b55565b6000546001600160a01b031633146107f75760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600a55565b6000546001600160a01b031633146108445760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600755565b6000546001600160a01b031633146108915760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805463ff00000019166301000000179055604051600181527f109609b2bd024d7142be784ac1c61664c440672f3e8b1e230e9b5ca0d346bc0b9060200161061d565b6000546001600160a01b0316331461091d5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b620f42408111156109605760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420526174696f60981b60448201526064016105da565b600855565b6000546001600160a01b031633146109ad5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b6001600160a01b0381166109f45760405162461bcd60e51b815260206004820152600e60248201526d696e76616c69644164647265737360901b60448201526064016105da565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610a5e5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600c55565b600080600160009054906101000a90046001600160a01b03166001600160a01b031663d2d97b066040518163ffffffff1660e01b815260040160206040518083038186803b158015610ab457600080fd5b505afa158015610ac8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aec9190611765565b90506000600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b3e57600080fd5b505afa158015610b52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b769190611765565b905080610b8857620f42409250505090565b81610b965760009250505090565b6000610baf82610ba985620f4240611627565b9061163c565b9050620f4240811115610bc857620f4240935050505090565b9392505050565b6000546001600160a01b03163314610c175760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805461ff0019169055604051600081527f0665505cd3e3cb365c83c95c958cddf1901201157c0f80eb31259d0b8ac7b4329060200161061d565b6000546001600160a01b03163314610c9b5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600d55565b6000546001600160a01b03163314610ce85760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b610cf26000611648565b565b6000546001600160a01b03163314610d3c5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b6001600160a01b038116610d925760405162461bcd60e51b815260206004820152601060248201527f5f6f7261636c652061646472657373200000000000000000000000000000000060448201526064016105da565b600e80546001600160a01b03909216640100000000027fffffffffffffffff0000000000000000000000000000000000000000ffffffff909216919091179055565b6000546001600160a01b03163314610e1c5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600555565b6000546001600160a01b03163314610e695760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805461ff001916610100179055604051600181527f0665505cd3e3cb365c83c95c958cddf1901201157c0f80eb31259d0b8ac7b4329060200161061d565b6000546001600160a01b03163314610ef15760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b6001600160a01b038116610f385760405162461bcd60e51b815260206004820152600e60248201526d696e76616c69644164647265737360901b60448201526064016105da565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610fa25760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b6001600160a01b038116610fe95760405162461bcd60e51b815260206004820152600e60248201526d696e76616c69644164647265737360901b60448201526064016105da565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146110535760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805462ff000019169055604051600081527f109609b2bd024d7142be784ac1c61664c440672f3e8b1e230e9b5ca0d346bc0b9060200161061d565b600e5460009060ff16156110a45750600090565b600a546009546110b490426118fb565b106110bf5750600190565b50600090565b6000546001600160a01b0316331461110d5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600655565b6000546001600160a01b0316331461115a5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805460ff8082161560ff1990921682179092556040519116151581527f209068f7bed5a02fb7695c3e3b61bb8324d1facb25523c6422bfd2105ec44d929060200161061d565b6000546001600160a01b031633146111ea5760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600e805462ff0000191662010000179055604051600181527f0665505cd3e3cb365c83c95c958cddf1901201157c0f80eb31259d0b8ac7b4329060200161061d565b8061130d57600e5460ff16156112845760405162461bcd60e51b815260206004820181905260248201527f436f6c6c61746572616c20526174696f20686173206265656e2070617573656460448201526064016105da565b600a5460095461129490426118fb565b10156113085760405162461bcd60e51b815260206004820152603560248201527f4d757374207761697420666f7220746865207265667265736820636f6f6c646f60448201527f776e2073696e6365206c6173742072656672657368000000000000000000000060648201526084016105da565b611334565b600e5460ff161561131b5750565b600a5460095461132b90426118fb565b10156113345750565b600e54600090610100900460ff16156113f457600080600e60049054906101000a90046001600160a01b03166001600160a01b031663d34410ba6040518163ffffffff1660e01b8152600401604080518083038186803b15801561139757600080fd5b505afa1580156113ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113cf919061177e565b90925090506113ef6113e282600a611831565b610ba984620f4240611627565b925050505b8061148257600160009054906101000a90046001600160a01b03166001600160a01b031663e1f095aa6040518163ffffffff1660e01b815260040160206040518083038186803b15801561144757600080fd5b505afa15801561145b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147f9190611765565b90505b600d54600c5461149191611698565b8111156114c457600b54600854116114ad576000600855611519565b600b546008546114bc916116a4565b600855611519565b600d54600c546114d3916116a4565b81101561151957620f42406114f5600b5460085461169890919063ffffffff16565b1061150657620f4240600855611519565b600b5460085461151591611698565b6008555b505042600955565b6000546001600160a01b031633146115695760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b600f55565b6000546001600160a01b031633146115b65760405162461bcd60e51b8152602060048201819052602482015260008051602061192983398151915260448201526064016105da565b6001600160a01b03811661161b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105da565b61162481611648565b50565b600061163382846118dc565b90505b92915050565b600061163382846117cc565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061163382846117b4565b600061163382846118fb565b80356001600160a01b03811681146116c757600080fd5b919050565b6000602082840312156116de57600080fd5b611633826116b0565b6000806000606084860312156116fc57600080fd5b611705846116b0565b9250611713602085016116b0565b9150611721604085016116b0565b90509250925092565b60006020828403121561173c57600080fd5b81358015158114610bc857600080fd5b60006020828403121561175e57600080fd5b5035919050565b60006020828403121561177757600080fd5b5051919050565b6000806040838503121561179157600080fd5b82519150602083015160ff811681146117a957600080fd5b809150509250929050565b600082198211156117c7576117c7611912565b500190565b6000826117e957634e487b7160e01b600052601260045260246000fd5b500490565b600181815b8085111561182957816000190482111561180f5761180f611912565b8085161561181c57918102915b93841c93908002906117f3565b509250929050565b600061163360ff84168360008261184a57506001611636565b8161185757506000611636565b816001811461186d576002811461187757611893565b6001915050611636565b60ff84111561188857611888611912565b50506001821b611636565b5060208310610133831016604e8410600b84101617156118b6575081810a611636565b6118c083836117ee565b80600019048211156118d4576118d4611912565b029392505050565b60008160001904831182151516156118f6576118f6611912565b500290565b60008282101561190d5761190d611912565b500390565b634e487b7160e01b600052601160045260246000fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a164736f6c6343000807000a
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Validator ID :
0 FTM
Amount Staked
0
Amount Delegated
0
Staking Total
0
Staking Start Epoch
0
Staking Start Time
0
Proof of Importance
0
Origination Score
0
Validation Score
0
Active
0
Online
0
Downtime
0 s
Address | Amount | claimed Rewards | Created On Epoch | Created On |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.