Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 13113205 | 1178 days ago | IN | 0 ETH | 0.0584555 |
Loading...
Loading
Contract Name:
OneMinter
Compiler Version
v0.6.12+commit.27d51765
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; import "./utils/Configurable.sol"; import "./oracles/EmaOracle.sol"; import "./tokens/ONE.sol"; import "./tokens/ONS.sol"; import "./utils/Constant.sol"; import "./Vault.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract OneMinter is Constant, Configurable { using SafeMath for uint; using SafeERC20 for IERC20; uint internal constant INITIAL_INPUT = 1e27; Vault public vault; ONE public one; ONS public ons; IAETH public aEth; mapping (address => uint) internal _aEthBalances; mapping (address => uint) internal _onsBalances; mapping (address => uint) internal _aEthRIOs; mapping (address => uint) internal _onsRIOs; mapping (uint => uint) internal _aEthRioIn; mapping (uint => uint) internal _onsRioIn; uint internal _aEthRound; uint internal _onsRound; function __OneMinter_init(address governor_, address vault_) external initializer { __Governable_init_unchained(governor_); __OneMinter_init_unchained(vault_); } function __OneMinter_init_unchained(address vault_) public governance { vault = Vault(vault_); one = ONE(vault.one()); ons = ONS(vault.ons()); aEth = IAETH(vault.aEth()); aEth.approve(address(vault), uint(-1)); ons.approve(address(vault), uint(-1)); _aEthRound = _onsRound = 1; _aEthRioIn[1] = packRIO(1, INITIAL_INPUT, 0); _onsRioIn [1] = packRIO(1, INITIAL_INPUT, 0); } //struct RIO { // uint32 round; // uint112 input; // uint112 output; //} function packRIO(uint256 round, uint256 input, uint256 output) internal pure virtual returns (uint256) { require(round <= uint32(-1) && input <= uint112(-1) && output <= uint112(-1), 'RIO OVERFLOW'); return round << 224 | input << 112 | output; } function unpackRIO(uint256 rio) internal pure virtual returns (uint256 round, uint256 input, uint256 output) { round = rio >> 224; input = uint112(rio >> 112); output = uint112(rio); } function totalSupply() external view returns (uint aEthSupply, uint onsSupply) { aEthSupply = aEth.balanceOf(address(this)); onsSupply = ons.balanceOf(address(this)); } function balanceOf(address acct) public view returns (uint aEthBal, uint onsBal) { uint rio = _aEthRIOs[acct]; (uint r, uint i, ) = unpackRIO(rio); uint RIO = _aEthRioIn[r]; if(RIO != rio) { (, uint I, ) = unpackRIO(RIO); aEthBal = _aEthBalances[acct].mul(I).div(i); } else aEthBal = _aEthBalances[acct]; rio = _onsRIOs[acct]; (r, i, ) = unpackRIO(rio); RIO = _onsRioIn[r]; if(RIO != rio) { (, uint I, ) = unpackRIO(RIO); onsBal = _onsBalances[acct].mul(I).div(i); } else onsBal = _onsBalances[acct]; } function purchaseOneUsingAETHc(uint oneVol) external oneMinBalanceCheck { emit Mint(msg.sender, oneVol); vault.mintONEaETHc(msg.sender, oneVol); } function purchaseOneUsingAETHb(uint oneVol) external oneMinBalanceCheck { emit Mint(msg.sender, oneVol); vault.mintONEaETHb(msg.sender, oneVol); } event Purchase(address acct, uint aEthVol, uint onsVol); function cancel() public { uint aEthVol = _aEthBalances[msg.sender]; uint onsVol = _onsBalances[msg.sender]; _aEthBalances[msg.sender] = _aEthBalances[msg.sender].sub(aEthVol); _onsBalances [msg.sender] = _onsBalances [msg.sender].sub(onsVol); emit Cancel(msg.sender, aEthVol, onsVol); aEth.transfer(msg.sender, aEthVol); ons.transfer (msg.sender, onsVol); } modifier oneMinBalanceCheck { require(vault.onePriceLo() > 0.95 ether, 'ONE price is not high enough to mint'); _; } event Cancel(address acct, uint aEthVol, uint onsVol); event Mint(address acct, uint oneVol); event Rebase(uint aEthVol, uint aEthRatio, uint onsVol, uint onsRatio, uint oneVol); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; interface IVault { function receiveAEthFrom(address from, uint vol) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./utils/Configurable.sol"; import "./oracles/EmaOracle.sol"; import "./tokens/ONE.sol"; import "./tokens/ONS.sol"; import "./utils/Constant.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "./IVault.sol"; interface IAETH is IERC20 { function ratio() external view returns (uint256); } contract Vault is Constant, Configurable { using SafeMath for uint; using SafeERC20 for IERC20; using EmaOracle for EmaOracle.Observations; bytes32 internal constant _periodTwapOne_ = 'periodTwapOne'; bytes32 internal constant _periodTwapOns_ = 'periodTwapOns'; bytes32 internal constant _periodTwapAEth_ = 'periodTwapAEth'; //bytes32 internal constant _thresholdReserve_ = 'thresholdReserve'; bytes32 internal constant _initialMintQuota_ = 'initialMintQuota'; bytes32 internal constant _rebaseInterval_ = 'rebaseInterval'; bytes32 internal constant _rebaseThreshold_ = 'rebaseThreshold'; bytes32 internal constant _rebaseCap_ = 'rebaseCap'; bytes32 internal constant _burnOneThreshold_ = 'burnOneThreshold'; address public oneMinter; ONE public one; ONS public ons; address public onb; IAETH public aEth; address public WETH; uint public begin; uint public span; EmaOracle.Observations public twapOne; EmaOracle.Observations public twapOns; EmaOracle.Observations public twapAEth; uint public totalEthValue; uint public rebaseTime; IERC20 public aETHb; function __Vault_init(address governor_, address _oneMinter, ONE _one, ONS _ons, address _onb, IAETH _aEth, address _WETH, uint _begin, uint _span) external initializer { __Governable_init_unchained(governor_); __Vault_init_unchained(_oneMinter, _one, _ons, _onb, _aEth, _WETH, _begin, _span); } function __Vault_init_unchained(address _oneMinter, ONE _one, ONS _ons, address _onb, IAETH _aETHc, address _WETH, uint _begin, uint _span) internal governance { oneMinter = _oneMinter; one = _one; ons = _ons; onb = _onb; aEth = _aETHc; WETH = _WETH; begin = _begin; span = _span; //config[_thresholdReserve_] = 0.8 ether; config[_ratioAEthWhenMint_] = 0.9 ether; config[_periodTwapOne_] = 8 hours; config[_periodTwapOns_] = 15 minutes; config[_periodTwapAEth_] = 15 minutes; config[_initialMintQuota_] = 10000 ether; config[_rebaseInterval_] = 8 hours; config[_rebaseThreshold_] = 1.05 ether; config[_rebaseCap_] = 0.05 ether; // 5% rebaseTime = now; config[_burnOneThreshold_] = 1.0 ether; } function resetParametersV2(IERC20 _aETHb) external governance { config[_burnOneThreshold_] = 1.05 ether; aETHb = _aETHb; } function twapInit(address swapFactory) external governance { twapOne.initialize(swapFactory, config[_periodTwapOne_], address(one), address(aEth)); twapOns.initialize(swapFactory, config[_periodTwapOns_], address(ons), address(aEth)); twapAEth.initialize(swapFactory, config[_periodTwapAEth_], address(aEth), WETH); } modifier updateTwap { twapOne.update(config[_periodTwapOne_], address(one), address(aEth)); twapOns.update(config[_periodTwapOns_], address(ons), address(aEth)); twapAEth.update(config[_periodTwapAEth_], address(aEth), WETH); _; } function E2B(uint vol) external { } function B2E(uint vol) external { } function onsValueOnlyPercentage(uint amount) public pure returns (uint){ return amount.mul(45).div(10000); } function receiveOnsInPercentage(address from, uint amt) internal { ons.transferFrom(from, address(this), oneToOnsAmount(onsValueOnlyPercentage(amt))); } function mintONEaETHc(address from, uint amt) external { receiveAETHcFrom(from, amt); receiveOnsInPercentage(from, amt); one.mint_(from, amt); } function mintONEaETHb(address from, uint amt) external { receiveAETHbFrom(from, amt); receiveOnsInPercentage(from, amt); one.mint_(from, amt); } function burnONE(uint amt) external { require(onePriceHi() < config[_burnOneThreshold_], 'ONE price is not low enough to burn'); one.burn_(msg.sender, amt); receiveOnsInPercentage(msg.sender, amt); _sendAETHcTo(msg.sender, amt); } function burnONB(uint vol) external { } function onePriceNow() public view returns (uint price) { price = twapOne.consultNow( address(one), 1 ether, address(aEth)); price = twapAEth.consultNow(address(aEth), price, address(WETH)); } function onePriceEma() public view returns (uint price) { price = twapOne.consultEma( config[_periodTwapOne_], address(one), 1 ether, address(aEth)); price = twapAEth.consultEma(config[_periodTwapAEth_], address(aEth), price, address(WETH)); } function onePriceHi() public updateTwap returns (uint) { return Math.max(onePriceNow(), onePriceEma()); } function onePriceLo() public updateTwap returns (uint) { return Math.min(onePriceNow(), onePriceEma()); } function oneToOnsNow(uint amountOne) public view returns (uint price) { price = twapOne.consultNow( address(one), amountOne, address(aEth)); price = twapOns.consultNow(address(aEth), price, address(ons)); } function oneToOnsEma(uint amountOne) public view returns (uint price) { price = twapOne.consultEma( config[_periodTwapOne_], address(one), amountOne, address(aEth)); price = twapOns.consultEma(config[_periodTwapOns_], address(aEth), price, address(ons)); } function oneToOnsAmount(uint amountOne) public view returns (uint) { return Math.max(oneToOnsNow(amountOne), oneToOnsEma(amountOne)); } event Rebase(uint aEthVol, uint aEthRatio, uint onsVol, uint onsRatio, uint oneVol); function receiveAETHcFrom(address from, uint vol) public { aEth.transferFrom(from, address(this), vol); // totalEthValue = totalEthValue.add(vol.mul(1e18).div(aEth.ratio())); } function receiveAETHbFrom(address from, uint vol) public { aETHb.transferFrom(from, address(this), vol); } function _sendAETHcTo(address to, uint vol) internal { // totalEthValue = totalEthValue.sub(vol.mul(1e18).div(aEth.ratio())); aEth.transfer(to, vol); } function _sendAETHbTo(address to, uint vol) internal { aETHb.transfer(to, vol); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "../utils/FixedPoint.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "../uniswap/IUniswapV2Pair.sol"; import "../uniswap/UniswapV2Library.sol"; import "../uniswap/UniswapV2OracleLibrary.sol"; library EmaOracle { using FixedPoint for *; using SafeMath for uint; struct Observation { uint timestamp; uint price0Cumulative; uint price1Cumulative; uint emaPrice0; uint emaPrice1; } struct Observations { address factory; mapping(uint => mapping(address => Observation)) ppos; } function initialize(Observations storage os, address factory, uint period, address tokenA, address tokenB) internal { os.factory = factory; address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); Observation storage o = os.ppos[period][pair]; o.timestamp = blockTimestampLast; o.price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); o.price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); o.emaPrice0 = FixedPoint.fraction(reserve1, reserve0)._x; o.emaPrice1 = FixedPoint.fraction(reserve0, reserve1)._x; } function calcEmaPrice(uint period, uint timestampStart, uint priceCumulativeStart, uint emaPriceStart, uint timestampEnd, uint priceCumulativeEnd) internal pure returns (uint) { uint timeElapsed = timestampEnd.sub(timestampStart); if(timeElapsed == 0) return emaPriceStart; uint priceAverage = priceCumulativeEnd.sub(priceCumulativeStart).div(timeElapsed); if(timeElapsed >= period) return priceAverage; else return period.sub(timeElapsed).mul(emaPriceStart).add(timeElapsed.mul(priceAverage)) / period; } function update(Observations storage os, uint period, address tokenA, address tokenB) internal { address pair = UniswapV2Library.pairFor(os.factory, tokenA, tokenB); Observation storage o = os.ppos[period][pair]; uint timeElapsed = block.timestamp.sub(o.timestamp); if (timeElapsed > period) { (uint price0Cumulative, uint price1Cumulative, ) = UniswapV2OracleLibrary.currentCumulativePrices(pair); o.emaPrice0 = calcEmaPrice(period, o.timestamp, o.price0Cumulative, o.emaPrice0, block.timestamp, price0Cumulative); o.emaPrice1 = calcEmaPrice(period, o.timestamp, o.price1Cumulative, o.emaPrice1, block.timestamp, price1Cumulative); o.timestamp = block.timestamp; o.price0Cumulative = price0Cumulative; o.price1Cumulative = price1Cumulative; } } function consultEma(Observations storage os, uint period, address tokenIn, uint amountIn, address tokenOut) internal view returns (uint amountOut) { address pair = UniswapV2Library.pairFor(os.factory, tokenIn, tokenOut); Observation storage o = os.ppos[period][pair]; (address token0, ) = UniswapV2Library.sortTokens(tokenIn, tokenOut); if (token0 == tokenIn) amountOut = FixedPoint.uq112x112(uint224(o.emaPrice0)).mul(amountIn).decode144(); else amountOut = FixedPoint.uq112x112(uint224(o.emaPrice1)).mul(amountIn).decode144(); } function consultNow(Observations storage os, address tokenIn, uint amountIn, address tokenOut) internal view returns (uint amountOut) { address pair = UniswapV2Library.pairFor(os.factory, tokenIn, tokenOut); (uint112 reserve0, uint112 reserve1, ) = IUniswapV2Pair(pair).getReserves(); (address token0, ) = UniswapV2Library.sortTokens(tokenIn, tokenOut); if (token0 == tokenIn) amountOut = FixedPoint.fraction(reserve1, reserve0).mul(amountIn).decode144(); else amountOut = FixedPoint.fraction(reserve0, reserve1).mul(amountIn).decode144(); } function consultHi(Observations storage os, uint period, address tokenIn, uint amountIn, address tokenOut) internal view returns (uint amountOut) { uint amountOutEma = consultEma(os, period, tokenIn, amountIn, tokenOut); uint amountOutNow = consultNow(os, tokenIn, amountIn, tokenOut); amountOut = Math.max(amountOutEma, amountOutNow); } function consultLo(Observations storage os, uint period, address tokenIn, uint amountIn, address tokenOut) internal view returns (uint amountOut) { uint amountOutEma = consultEma(os, period, tokenIn, amountIn, tokenOut); uint amountOutNow = consultNow(os, tokenIn, amountIn, tokenOut); amountOut = Math.min(amountOutEma, amountOutNow); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "../utils/Configurable.sol"; import "./ERC20UpgradeSafe.sol"; contract ApprovedERC20 is ERC20UpgradeSafe, Configurable { address public operator; function __ApprovedERC20_init_unchained(address operator_) public governance { operator = operator_; } function setNameAndSymbol(string memory newName, string memory newSymbol) external governance { updateNameAndSymbol(newName, newSymbol); } modifier onlyOperator { require(msg.sender == operator, 'called only by operator'); _; } function transferFrom_(address sender, address recipient, uint256 amount) external onlyOperator returns (bool) { _transfer(sender, recipient, amount); return true; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/proxy/Initializable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../utils/ContextUpgradeSafe.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.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 {ERC20MinterPauser}. * * 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 ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name, string memory symbol) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name, symbol); } function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view 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 {_setupDecimals} is * called. * * 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 returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function updateNameAndSymbol(string memory newName, string memory newSymbol) internal { _name = newName; _symbol = newSymbol; } /** * @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); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 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].add(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) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is 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); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(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 * * - `to` 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 = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(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); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is 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 Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @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 to 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 { } uint256[44] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./ApprovedERC20.sol"; contract MintableERC20 is ApprovedERC20 { function mint_(address acct, uint amt) external onlyOperator { _mint(acct, amt); } function burn_(address acct, uint amt) external onlyOperator { _burn(acct, amt); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./MintableERC20.sol"; contract ONE is MintableERC20 { function __ONE_init(address governor_, address vault_, address oneMine) external initializer { __Context_init_unchained(); __ERC20_init_unchained("One Eth", "ONE"); __Governable_init_unchained(governor_); __ApprovedERC20_init_unchained(vault_); __ONE_init_unchained(oneMine); } function __ONE_init_unchained(address oneMine) public governance { _mint(oneMine, 100 * 10 ** uint256(decimals())); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./ApprovedERC20.sol"; contract ONS is ApprovedERC20 { function __ONS_init(address governor_, address oneMinter_, address onsMine, address offering, address timelock) external initializer { __Context_init_unchained(); __ERC20_init("One Share", "ONS"); __Governable_init_unchained(governor_); __ApprovedERC20_init_unchained(oneMinter_); __ONS_init_unchained(onsMine, offering, timelock); } function __ONS_init_unchained(address onsMine, address offering, address timelock) public governance { _mint(onsMine, 90000 * 10 ** uint256(decimals())); // 90% _mint(offering, 5000 * 10 ** uint256(decimals())); // 5% _mint(timelock, 5000 * 10 ** uint256(decimals())); // 5% } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); 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 (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./IUniswapV2Pair.sol"; library UniswapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "../utils/FixedPoint.sol"; import "./IUniswapV2Pair.sol"; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./Governable.sol"; contract Configurable is Governable { mapping (bytes32 => uint) internal config; function getConfig(bytes32 key) public view returns (uint) { return config[key]; } function getConfig(bytes32 key, uint index) public view returns (uint) { return config[bytes32(uint(key) ^ index)]; } function getConfig(bytes32 key, address addr) public view returns (uint) { return config[bytes32(uint(key) ^ uint(addr))]; } function _setConfig(bytes32 key, uint value) internal { if(config[key] != value) config[key] = value; } function _setConfig(bytes32 key, uint index, uint value) internal { _setConfig(bytes32(uint(key) ^ index), value); } function _setConfig(bytes32 key, address addr, uint value) internal { _setConfig(bytes32(uint(key) ^ uint(addr)), value); } function setConfig(bytes32 key, uint value) external governance { _setConfig(key, value); } function setConfig(bytes32 key, uint index, uint value) external governance { _setConfig(bytes32(uint(key) ^ index), value); } function setConfig(bytes32 key, address addr, uint value) public governance { _setConfig(bytes32(uint(key) ^ uint(addr)), value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; contract Constant { bytes32 internal constant _ratioAEthWhenMint_ = 'ratioAEthWhenMint'; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN 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. */ contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; library FullMath { function fullMul(uint256 x, uint256 y) internal pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } function fullDiv( uint256 l, uint256 h, uint256 d ) private pure returns (uint256) { uint256 pow2 = d & -d; d /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; r *= 2 - d * r; return l * r; } function mulDiv( uint256 x, uint256 y, uint256 d ) internal pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); uint256 mm = mulmod(x, y, d); if (mm > l) h -= 1; l -= mm; if (h == 0) return l / d; require(h < d, 'FullMath: FULLDIV_OVERFLOW'); return fullDiv(l, h, d); } } //import './Babylonian.sol'; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { // credit for this implementation goes to // https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; // this block is equivalent to r = uint256(1) << (BitMath.mostSignificantBit(x) / 2); // however that code costs significantly more gas uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } } //import './BitMath.sol'; library BitMath { // returns the 0 indexed position of the most significant bit of the input x // s.t. x >= 2**msb and x < 2**(msb+1) function mostSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::mostSignificantBit: zero'); if (x >= 0x100000000000000000000000000000000) { x >>= 128; r += 128; } if (x >= 0x10000000000000000) { x >>= 64; r += 64; } if (x >= 0x100000000) { x >>= 32; r += 32; } if (x >= 0x10000) { x >>= 16; r += 16; } if (x >= 0x100) { x >>= 8; r += 8; } if (x >= 0x10) { x >>= 4; r += 4; } if (x >= 0x4) { x >>= 2; r += 2; } if (x >= 0x2) r += 1; } // returns the 0 indexed position of the least significant bit of the input x // s.t. (x & 2**lsb) != 0 and (x & (2**(lsb) - 1)) == 0) // i.e. the bit at the index is set and the mask of all lower bits is 0 function leastSignificantBit(uint256 x) internal pure returns (uint8 r) { require(x > 0, 'BitMath::leastSignificantBit: zero'); r = 255; if (x & uint128(-1) > 0) { r -= 128; } else { x >>= 128; } if (x & uint64(-1) > 0) { r -= 64; } else { x >>= 64; } if (x & uint32(-1) > 0) { r -= 32; } else { x >>= 32; } if (x & uint16(-1) > 0) { r -= 16; } else { x >>= 16; } if (x & uint8(-1) > 0) { r -= 8; } else { x >>= 8; } if (x & 0xf > 0) { r -= 4; } else { x >>= 4; } if (x & 0x3 > 0) { r -= 2; } else { x >>= 2; } if (x & 0x1 > 0) r -= 1; } } // 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 public constant RESOLUTION = 112; uint256 public constant Q112 = 0x10000000000000000000000000000; // 2**112 uint256 private constant Q224 = 0x100000000000000000000000000000000000000000000000000000000; // 2**224 uint256 private constant LOWER_MASK = 0xffffffffffffffffffffffffffff; // decimal of UQ*x112 (lower 112 bits) // 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); } // 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); } // 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 = 0; require(y == 0 || (z = self._x * y) / y == self._x, 'FixedPoint::mul: overflow'); return uq144x112(z); } // multiply a UQ112x112 by an int and decode, returning an int // reverts on overflow function muli(uq112x112 memory self, int256 y) internal pure returns (int256) { uint256 z = FullMath.mulDiv(self._x, uint256(y < 0 ? -y : y), Q112); require(z < 2**255, 'FixedPoint::muli: overflow'); return y < 0 ? -int256(z) : int256(z); } // multiply a UQ112x112 by a UQ112x112, returning a UQ112x112 // lossy function muluq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { if (self._x == 0 || other._x == 0) { return uq112x112(0); } uint112 upper_self = uint112(self._x >> RESOLUTION); // * 2^0 uint112 lower_self = uint112(self._x & LOWER_MASK); // * 2^-112 uint112 upper_other = uint112(other._x >> RESOLUTION); // * 2^0 uint112 lower_other = uint112(other._x & LOWER_MASK); // * 2^-112 // partial products uint224 upper = uint224(upper_self) * upper_other; // * 2^0 uint224 lower = uint224(lower_self) * lower_other; // * 2^-224 uint224 uppers_lowero = uint224(upper_self) * lower_other; // * 2^-112 uint224 uppero_lowers = uint224(upper_other) * lower_self; // * 2^-112 // so the bit shift does not overflow require(upper <= uint112(-1), 'FixedPoint::muluq: upper overflow'); // this cannot exceed 256 bits, all values are 224 bits uint256 sum = uint256(upper << RESOLUTION) + uppers_lowero + uppero_lowers + (lower >> RESOLUTION); // so the cast does not overflow require(sum <= uint224(-1), 'FixedPoint::muluq: sum overflow'); return uq112x112(uint224(sum)); } // divide a UQ112x112 by a UQ112x112, returning a UQ112x112 function divuq(uq112x112 memory self, uq112x112 memory other) internal pure returns (uq112x112 memory) { require(other._x > 0, 'FixedPoint::divuq: division by zero'); if (self._x == other._x) { return uq112x112(uint224(Q112)); } if (self._x <= uint144(-1)) { uint256 value = (uint256(self._x) << RESOLUTION) / other._x; require(value <= uint224(-1), 'FixedPoint::divuq: overflow'); return uq112x112(uint224(value)); } uint256 result = FullMath.mulDiv(Q112, self._x, other._x); require(result <= uint224(-1), 'FixedPoint::divuq: overflow'); return uq112x112(uint224(result)); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // can be lossy function fraction(uint256 numerator, uint256 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, 'FixedPoint::fraction: division by zero'); if (numerator == 0) return FixedPoint.uq112x112(0); if (numerator <= uint144(-1)) { uint256 result = (numerator << RESOLUTION) / denominator; require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } else { uint256 result = FullMath.mulDiv(numerator, Q112, denominator); require(result <= uint224(-1), 'FixedPoint::fraction: overflow'); return uq112x112(uint224(result)); } } // take the reciprocal of a UQ112x112 // reverts on overflow // lossy function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint::reciprocal: reciprocal of zero'); require(self._x != 1, 'FixedPoint::reciprocal: overflow'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 // lossy between 0/1 and 40 bits function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { if (self._x <= uint144(-1)) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << 112))); } uint8 safeShiftBits = 255 - BitMath.mostSignificantBit(self._x); safeShiftBits -= safeShiftBits % 2; return uq112x112(uint224(Babylonian.sqrt(uint256(self._x) << safeShiftBits) << ((112 - safeShiftBits) / 2))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "@openzeppelin/contracts/proxy/Initializable.sol"; contract Governable is Initializable { address public governor; event GovernorshipTransferred(address indexed previousGovernor, address indexed newGovernor); /** * @dev Contract initializer. * called once by the factory at time of deployment */ function __Governable_init_unchained(address governor_) virtual public initializer { governor = governor_; emit GovernorshipTransferred(address(0), governor); } modifier governance() { require(msg.sender == governor); _; } /** * @dev Allows the current governor to relinquish control of the contract. * @notice Renouncing to governorship will leave the contract without an governor. * It will not be possible to call the functions with the `governance` * modifier anymore. */ function renounceGovernorship() public governance { emit GovernorshipTransferred(governor, address(0)); governor = address(0); } /** * @dev Allows the current governor to transfer control of the contract to a newGovernor. * @param newGovernor The address to transfer governorship to. */ function transferGovernorship(address newGovernor) public governance { _transferGovernorship(newGovernor); } /** * @dev Transfers control of the contract to a newGovernor. * @param newGovernor The address to transfer governorship to. */ function _transferGovernorship(address newGovernor) internal { require(newGovernor != address(0)); emit GovernorshipTransferred(governor, newGovernor); governor = newGovernor; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ 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) { 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) { 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) { // 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) { 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) { 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) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); 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) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @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. 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) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); 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) { require(b > 0, "SafeMath: modulo by zero"); 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) { 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. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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) { 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) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since 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 {UpgradeableProxy-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 || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.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 SafeMath for uint256; 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' // solhint-disable-next-line max-line-length 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).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"acct","type":"address"},{"indexed":false,"internalType":"uint256","name":"aEthVol","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onsVol","type":"uint256"}],"name":"Cancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"GovernorshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"acct","type":"address"},{"indexed":false,"internalType":"uint256","name":"oneVol","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"acct","type":"address"},{"indexed":false,"internalType":"uint256","name":"aEthVol","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onsVol","type":"uint256"}],"name":"Purchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"aEthVol","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"aEthRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onsVol","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onsRatio","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oneVol","type":"uint256"}],"name":"Rebase","type":"event"},{"inputs":[{"internalType":"address","name":"governor_","type":"address"}],"name":"__Governable_init_unchained","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"governor_","type":"address"},{"internalType":"address","name":"vault_","type":"address"}],"name":"__OneMinter_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault_","type":"address"}],"name":"__OneMinter_init_unchained","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"aEth","outputs":[{"internalType":"contract IAETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"acct","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"aEthBal","type":"uint256"},{"internalType":"uint256","name":"onsBal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"address","name":"addr","type":"address"}],"name":"getConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"one","outputs":[{"internalType":"contract ONE","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ons","outputs":[{"internalType":"contract ONS","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"oneVol","type":"uint256"}],"name":"purchaseOneUsingAETHb","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"oneVol","type":"uint256"}],"name":"purchaseOneUsingAETHc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"aEthSupply","type":"uint256"},{"internalType":"uint256","name":"onsSupply","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newGovernor","type":"address"}],"name":"transferGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract Vault","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50611433806100206000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c806381c0c263116100b8578063db01f56a1161007c578063db01f56a14610316578063ddf2be3f14610333578063df69e0161461035c578063ea8a1af014610382578063f95e61831461038a578063fbfa77cf146103a757610137565b806381c0c2631461028b5780638ec872e314610293578063901717d1146102b6578063b21544f3146102be578063b6aa515b146102f057610137565b80631c789b59116100ff5780631c789b59146101d4578063244aff2f146101dc57806352665f471461020a5780636dd5b69d1461024857806370a082311461026557610137565b8063030581a71461013c5780630c340a241461016057806315fe96dc1461016857806318160ddd1461018d57806318d94704146101ae575b600080fd5b6101446103af565b604080516001600160a01b039092168252519081900360200190f35b6101446103be565b61018b6004803603604081101561017e57600080fd5b50803590602001356103d3565b005b6101956103fe565b6040805192835260208301919091528051918290030190f35b61018b600480360360208110156101c457600080fd5b50356001600160a01b03166104fa565b610144610861565b61018b600480360360408110156101f257600080fd5b506001600160a01b0381358116916020013516610870565b6102366004803603604081101561022057600080fd5b50803590602001356001600160a01b0316610926565b60408051918252519081900360200190f35b6102366004803603602081101561025e57600080fd5b5035610948565b6101956004803603602081101561027b57600080fd5b50356001600160a01b031661095a565b61018b610aa7565b610236600480360360408110156102a957600080fd5b5080359060200135610b15565b610144610b28565b61018b600480360360608110156102d457600080fd5b508035906001600160a01b036020820135169060400135610b37565b61018b6004803603602081101561030657600080fd5b50356001600160a01b0316610b69565b61018b6004803603602081101561032c57600080fd5b5035610b92565b61018b6004803603606081101561034957600080fd5b5080359060208101359060400135610cf1565b61018b6004803603602081101561037257600080fd5b50356001600160a01b0316610d1a565b61018b610e14565b61018b600480360360208110156103a057600080fd5b5035610fba565b6101446110fe565b6005546001600160a01b031681565b6000546201000090046001600160a01b031681565b6000546201000090046001600160a01b031633146103f057600080fd5b6103fa828261110d565b5050565b600554604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561044e57600080fd5b505afa158015610462573d6000803e3d6000fd5b505050506040513d602081101561047857600080fd5b505160048054604080516370a0823160e01b81523093810193909352519294506001600160a01b0316916370a0823191602480820192602092909190829003018186803b1580156104c857600080fd5b505afa1580156104dc573d6000803e3d6000fd5b505050506040513d60208110156104f257600080fd5b505191929050565b6000546201000090046001600160a01b0316331461051757600080fd5b600280546001600160a01b0319166001600160a01b0383811691909117918290556040805163901717d160e01b81529051929091169163901717d191600480820192602092909190829003018186803b15801561057357600080fd5b505afa158015610587573d6000803e3d6000fd5b505050506040513d602081101561059d57600080fd5b5051600380546001600160a01b0319166001600160a01b0392831617905560025460408051631c789b5960e01b815290519190921691631c789b59916004808301926020929190829003018186803b1580156105f857600080fd5b505afa15801561060c573d6000803e3d6000fd5b505050506040513d602081101561062257600080fd5b5051600480546001600160a01b0319166001600160a01b039283161781556002546040805163030581a760e01b81529051919093169263030581a79281810192602092909190829003018186803b15801561067c57600080fd5b505afa158015610690573d6000803e3d6000fd5b505050506040513d60208110156106a657600080fd5b5051600580546001600160a01b0319166001600160a01b0392831617908190556002546040805163095ea7b360e01b81529184166004830152600019602483015251919092169163095ea7b39160448083019260209291908290030181600087803b15801561071457600080fd5b505af1158015610728573d6000803e3d6000fd5b505050506040513d602081101561073e57600080fd5b5050600480546002546040805163095ea7b360e01b81526001600160a01b039283169481019490945260001960248501525191169163095ea7b39160448083019260209291908290030181600087803b15801561079a57600080fd5b505af11580156107ae573d6000803e3d6000fd5b505050506040513d60208110156107c457600080fd5b50506001600d819055600c8190556107ea906b033b2e3c9fd0803ce80000006000611134565b60016000818152600a6020527fbbc70db1b6c7afd11e79c0fb0051300458f1a3acb8ee9789d9b6b26c61ad9bc792909255610832916b033b2e3c9fd0803ce800000090611134565b6001600052600b6020527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf5550565b6004546001600160a01b031681565b600054610100900460ff168061088957506108896111b9565b80610897575060005460ff16155b6108d25760405162461bcd60e51b815260040180806020018281038252602e8152602001806113af602e913960400191505060405180910390fd5b600054610100900460ff161580156108fd576000805460ff1961ff0019909116610100171660011790555b61090683610d1a565b61090f826104fa565b8015610921576000805461ff00191690555b505050565b6001600160a01b03811682186000908152600160205260409020545b92915050565b60009081526001602052604090205490565b6001600160a01b03811660009081526008602052604081205481908180610980836111ca565b506000828152600a602052604090205491935091508381146109e35760006109a7826111ca565b506001600160a01b038a166000908152600660205260409020549092506109db915084906109d590846111e4565b90611244565b9650506109ff565b6001600160a01b03871660009081526006602052604090205495505b6001600160a01b0387166000908152600960205260409020549350610a23846111ca565b506000828152600b602052604090205491945092509050838114610a82576000610a4c826111ca565b506001600160a01b038a16600090815260076020526040902054909250610a7a915084906109d590846111e4565b955050610a9e565b6001600160a01b03871660009081526007602052604090205494505b50505050915091565b6000546201000090046001600160a01b03163314610ac457600080fd5b60008054604051620100009091046001600160a01b0316907fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a908390a36000805462010000600160b01b0319169055565b1860009081526001602052604090205490565b6003546001600160a01b031681565b6000546201000090046001600160a01b03163314610b5457600080fd5b6109216001600160a01b03831684188261110d565b6000546201000090046001600160a01b03163314610b8657600080fd5b610b8f816112ab565b50565b6002546040805163c57b7ba560e01b81529051670d2f13f7789f0000926001600160a01b03169163c57b7ba59160048083019260209291908290030181600087803b158015610be057600080fd5b505af1158015610bf4573d6000803e3d6000fd5b505050506040513d6020811015610c0a57600080fd5b505111610c485760405162461bcd60e51b815260040180806020018281038252602481526020018061138b6024913960400191505060405180910390fd5b604080513381526020810183905281517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885929181900390910190a1600254604080516315a52f2f60e11b81523360048201526024810184905290516001600160a01b0390921691632b4a5e5e9160448082019260009290919082900301818387803b158015610cd657600080fd5b505af1158015610cea573d6000803e3d6000fd5b5050505050565b6000546201000090046001600160a01b03163314610d0e57600080fd5b6109218383188261110d565b600054610100900460ff1680610d335750610d336111b9565b80610d41575060005460ff16155b610d7c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806113af602e913960400191505060405180910390fd5b600054610100900460ff16158015610da7576000805460ff1961ff0019909116610100171660011790555b6000805462010000600160b01b031916620100006001600160a01b0385811682029290921780845560405191900490911691907fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a908290a380156103fa576000805461ff00191690555050565b3360009081526006602081815260408084205460078352932054919052610e3b8280611327565b33600090815260066020908152604080832093909355600790522054610e619082611327565b3360008181526007602090815260409182902093909355805191825291810184905280820183905290517f13f70c3891bf9326a78bedbd802efd57fa4451e8b0eab22d638b4e6b7a878eaf9181900360600190a16005546040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b158015610f0957600080fd5b505af1158015610f1d573d6000803e3d6000fd5b505050506040513d6020811015610f3357600080fd5b5050600480546040805163a9059cbb60e01b8152339381019390935260248301849052516001600160a01b039091169163a9059cbb9160448083019260209291908290030181600087803b158015610f8a57600080fd5b505af1158015610f9e573d6000803e3d6000fd5b505050506040513d6020811015610fb457600080fd5b50505050565b6002546040805163c57b7ba560e01b81529051670d2f13f7789f0000926001600160a01b03169163c57b7ba59160048083019260209291908290030181600087803b15801561100857600080fd5b505af115801561101c573d6000803e3d6000fd5b505050506040513d602081101561103257600080fd5b5051116110705760405162461bcd60e51b815260040180806020018281038252602481526020018061138b6024913960400191505060405180910390fd5b604080513381526020810183905281517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885929181900390910190a16002546040805163f448fd4960e01b81523360048201526024810184905290516001600160a01b039092169163f448fd499160448082019260009290919082900301818387803b158015610cd657600080fd5b6002546001600160a01b031681565b60008281526001602052604090205481146103fa5760009182526001602052604090912055565b600063ffffffff841180159061115157506001600160701b038311155b801561116457506001600160701b038211155b6111a4576040805162461bcd60e51b815260206004820152600c60248201526b52494f204f564552464c4f5760a01b604482015290519081900360640190fd5b5060e083901b607083901b1781179392505050565b60006111c430611384565b15905090565b60e081901c916001600160701b03607083901c8116921690565b6000826111f357506000610942565b8282028284828161120057fe5b041461123d5760405162461bcd60e51b81526004018080602001828103825260218152602001806113dd6021913960400191505060405180910390fd5b9392505050565b600080821161129a576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816112a357fe5b049392505050565b6001600160a01b0381166112be57600080fd5b600080546040516001600160a01b03808516936201000090930416917fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a91a3600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60008282111561137e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b3b15159056fe4f4e45207072696365206973206e6f74206869676820656e6f75676820746f206d696e74496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203ea4a98b0755904220267e44f44436265bbdd2879e4212a124e725281a78456664736f6c634300060c0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101375760003560e01c806381c0c263116100b8578063db01f56a1161007c578063db01f56a14610316578063ddf2be3f14610333578063df69e0161461035c578063ea8a1af014610382578063f95e61831461038a578063fbfa77cf146103a757610137565b806381c0c2631461028b5780638ec872e314610293578063901717d1146102b6578063b21544f3146102be578063b6aa515b146102f057610137565b80631c789b59116100ff5780631c789b59146101d4578063244aff2f146101dc57806352665f471461020a5780636dd5b69d1461024857806370a082311461026557610137565b8063030581a71461013c5780630c340a241461016057806315fe96dc1461016857806318160ddd1461018d57806318d94704146101ae575b600080fd5b6101446103af565b604080516001600160a01b039092168252519081900360200190f35b6101446103be565b61018b6004803603604081101561017e57600080fd5b50803590602001356103d3565b005b6101956103fe565b6040805192835260208301919091528051918290030190f35b61018b600480360360208110156101c457600080fd5b50356001600160a01b03166104fa565b610144610861565b61018b600480360360408110156101f257600080fd5b506001600160a01b0381358116916020013516610870565b6102366004803603604081101561022057600080fd5b50803590602001356001600160a01b0316610926565b60408051918252519081900360200190f35b6102366004803603602081101561025e57600080fd5b5035610948565b6101956004803603602081101561027b57600080fd5b50356001600160a01b031661095a565b61018b610aa7565b610236600480360360408110156102a957600080fd5b5080359060200135610b15565b610144610b28565b61018b600480360360608110156102d457600080fd5b508035906001600160a01b036020820135169060400135610b37565b61018b6004803603602081101561030657600080fd5b50356001600160a01b0316610b69565b61018b6004803603602081101561032c57600080fd5b5035610b92565b61018b6004803603606081101561034957600080fd5b5080359060208101359060400135610cf1565b61018b6004803603602081101561037257600080fd5b50356001600160a01b0316610d1a565b61018b610e14565b61018b600480360360208110156103a057600080fd5b5035610fba565b6101446110fe565b6005546001600160a01b031681565b6000546201000090046001600160a01b031681565b6000546201000090046001600160a01b031633146103f057600080fd5b6103fa828261110d565b5050565b600554604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561044e57600080fd5b505afa158015610462573d6000803e3d6000fd5b505050506040513d602081101561047857600080fd5b505160048054604080516370a0823160e01b81523093810193909352519294506001600160a01b0316916370a0823191602480820192602092909190829003018186803b1580156104c857600080fd5b505afa1580156104dc573d6000803e3d6000fd5b505050506040513d60208110156104f257600080fd5b505191929050565b6000546201000090046001600160a01b0316331461051757600080fd5b600280546001600160a01b0319166001600160a01b0383811691909117918290556040805163901717d160e01b81529051929091169163901717d191600480820192602092909190829003018186803b15801561057357600080fd5b505afa158015610587573d6000803e3d6000fd5b505050506040513d602081101561059d57600080fd5b5051600380546001600160a01b0319166001600160a01b0392831617905560025460408051631c789b5960e01b815290519190921691631c789b59916004808301926020929190829003018186803b1580156105f857600080fd5b505afa15801561060c573d6000803e3d6000fd5b505050506040513d602081101561062257600080fd5b5051600480546001600160a01b0319166001600160a01b039283161781556002546040805163030581a760e01b81529051919093169263030581a79281810192602092909190829003018186803b15801561067c57600080fd5b505afa158015610690573d6000803e3d6000fd5b505050506040513d60208110156106a657600080fd5b5051600580546001600160a01b0319166001600160a01b0392831617908190556002546040805163095ea7b360e01b81529184166004830152600019602483015251919092169163095ea7b39160448083019260209291908290030181600087803b15801561071457600080fd5b505af1158015610728573d6000803e3d6000fd5b505050506040513d602081101561073e57600080fd5b5050600480546002546040805163095ea7b360e01b81526001600160a01b039283169481019490945260001960248501525191169163095ea7b39160448083019260209291908290030181600087803b15801561079a57600080fd5b505af11580156107ae573d6000803e3d6000fd5b505050506040513d60208110156107c457600080fd5b50506001600d819055600c8190556107ea906b033b2e3c9fd0803ce80000006000611134565b60016000818152600a6020527fbbc70db1b6c7afd11e79c0fb0051300458f1a3acb8ee9789d9b6b26c61ad9bc792909255610832916b033b2e3c9fd0803ce800000090611134565b6001600052600b6020527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf5550565b6004546001600160a01b031681565b600054610100900460ff168061088957506108896111b9565b80610897575060005460ff16155b6108d25760405162461bcd60e51b815260040180806020018281038252602e8152602001806113af602e913960400191505060405180910390fd5b600054610100900460ff161580156108fd576000805460ff1961ff0019909116610100171660011790555b61090683610d1a565b61090f826104fa565b8015610921576000805461ff00191690555b505050565b6001600160a01b03811682186000908152600160205260409020545b92915050565b60009081526001602052604090205490565b6001600160a01b03811660009081526008602052604081205481908180610980836111ca565b506000828152600a602052604090205491935091508381146109e35760006109a7826111ca565b506001600160a01b038a166000908152600660205260409020549092506109db915084906109d590846111e4565b90611244565b9650506109ff565b6001600160a01b03871660009081526006602052604090205495505b6001600160a01b0387166000908152600960205260409020549350610a23846111ca565b506000828152600b602052604090205491945092509050838114610a82576000610a4c826111ca565b506001600160a01b038a16600090815260076020526040902054909250610a7a915084906109d590846111e4565b955050610a9e565b6001600160a01b03871660009081526007602052604090205494505b50505050915091565b6000546201000090046001600160a01b03163314610ac457600080fd5b60008054604051620100009091046001600160a01b0316907fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a908390a36000805462010000600160b01b0319169055565b1860009081526001602052604090205490565b6003546001600160a01b031681565b6000546201000090046001600160a01b03163314610b5457600080fd5b6109216001600160a01b03831684188261110d565b6000546201000090046001600160a01b03163314610b8657600080fd5b610b8f816112ab565b50565b6002546040805163c57b7ba560e01b81529051670d2f13f7789f0000926001600160a01b03169163c57b7ba59160048083019260209291908290030181600087803b158015610be057600080fd5b505af1158015610bf4573d6000803e3d6000fd5b505050506040513d6020811015610c0a57600080fd5b505111610c485760405162461bcd60e51b815260040180806020018281038252602481526020018061138b6024913960400191505060405180910390fd5b604080513381526020810183905281517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885929181900390910190a1600254604080516315a52f2f60e11b81523360048201526024810184905290516001600160a01b0390921691632b4a5e5e9160448082019260009290919082900301818387803b158015610cd657600080fd5b505af1158015610cea573d6000803e3d6000fd5b5050505050565b6000546201000090046001600160a01b03163314610d0e57600080fd5b6109218383188261110d565b600054610100900460ff1680610d335750610d336111b9565b80610d41575060005460ff16155b610d7c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806113af602e913960400191505060405180910390fd5b600054610100900460ff16158015610da7576000805460ff1961ff0019909116610100171660011790555b6000805462010000600160b01b031916620100006001600160a01b0385811682029290921780845560405191900490911691907fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a908290a380156103fa576000805461ff00191690555050565b3360009081526006602081815260408084205460078352932054919052610e3b8280611327565b33600090815260066020908152604080832093909355600790522054610e619082611327565b3360008181526007602090815260409182902093909355805191825291810184905280820183905290517f13f70c3891bf9326a78bedbd802efd57fa4451e8b0eab22d638b4e6b7a878eaf9181900360600190a16005546040805163a9059cbb60e01b81523360048201526024810185905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b158015610f0957600080fd5b505af1158015610f1d573d6000803e3d6000fd5b505050506040513d6020811015610f3357600080fd5b5050600480546040805163a9059cbb60e01b8152339381019390935260248301849052516001600160a01b039091169163a9059cbb9160448083019260209291908290030181600087803b158015610f8a57600080fd5b505af1158015610f9e573d6000803e3d6000fd5b505050506040513d6020811015610fb457600080fd5b50505050565b6002546040805163c57b7ba560e01b81529051670d2f13f7789f0000926001600160a01b03169163c57b7ba59160048083019260209291908290030181600087803b15801561100857600080fd5b505af115801561101c573d6000803e3d6000fd5b505050506040513d602081101561103257600080fd5b5051116110705760405162461bcd60e51b815260040180806020018281038252602481526020018061138b6024913960400191505060405180910390fd5b604080513381526020810183905281517f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885929181900390910190a16002546040805163f448fd4960e01b81523360048201526024810184905290516001600160a01b039092169163f448fd499160448082019260009290919082900301818387803b158015610cd657600080fd5b6002546001600160a01b031681565b60008281526001602052604090205481146103fa5760009182526001602052604090912055565b600063ffffffff841180159061115157506001600160701b038311155b801561116457506001600160701b038211155b6111a4576040805162461bcd60e51b815260206004820152600c60248201526b52494f204f564552464c4f5760a01b604482015290519081900360640190fd5b5060e083901b607083901b1781179392505050565b60006111c430611384565b15905090565b60e081901c916001600160701b03607083901c8116921690565b6000826111f357506000610942565b8282028284828161120057fe5b041461123d5760405162461bcd60e51b81526004018080602001828103825260218152602001806113dd6021913960400191505060405180910390fd5b9392505050565b600080821161129a576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816112a357fe5b049392505050565b6001600160a01b0381166112be57600080fd5b600080546040516001600160a01b03808516936201000090930416917fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a91a3600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b60008282111561137e576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b3b15159056fe4f4e45207072696365206973206e6f74206869676820656e6f75676820746f206d696e74496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203ea4a98b0755904220267e44f44436265bbdd2879e4212a124e725281a78456664736f6c634300060c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.