Contract Address Details

0x875aDBaF8109c9CC9AbCC708a42607F573f594E4

Contract Name
EnergiswapFactory
Creator
0x79f104–b96244 at 0xf6378c–1cf675
Balance
0.00 NRG ( )
Tokens
Fetching tokens...
Transactions
3 Transactions
Transfers
0 Transfers
Gas Used
2,450,696
Last Balance Update
2520621
Contract name:
EnergiswapFactory




Optimization enabled
true
Compiler version
v0.5.16+commit.9c3226ce




Optimization runs
200
EVM Version
petersburg




Verified at
2021-10-03 19:04:24.767811Z

Constructor Arguments

00000000000000000000000079f10487a8c0ed4e09045841160d01a7ecb9624400000000000000000000000000000000000000000000000000000000000003050000000000000000000000000000000000000000000000000000000000000000

Arg [0] (address) : 0x79f10487a8c0ed4e09045841160d01a7ecb96244
Arg [1] (address) : 0x0000000000000000000000000000000000000305
Arg [2] (address) : 0x0000000000000000000000000000000000000000

              

Contract source code

pragma solidity 0.5.16;
// File: ../interfaces/IEnergiswapGovernedContract.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
interface IEnergiswapGovernedContract {
function proxy() external returns(address);
}
// File: ../interfaces/IStorageBase.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
interface IStorageBase {
function setOwner(address _newOwner) external;
}
// File: ../EnergiswapGovernedContract.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity = 0.5.16;
/**
* Genesis version of GovernedContract common base.
*
* Base Consensus interface for upgradable contracts.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
contract EnergiswapGovernedContract is IEnergiswapGovernedContract {
address public proxy;
constructor(address _proxy) public {
proxy = _proxy;
}
modifier requireProxy {
require(msg.sender == proxy, "EnergiswapGovernedContract: FORBIDDEN, not proxy");
_;
}
function getProxy() internal view returns(address _proxy) {
_proxy = proxy;
}
// solium-disable-next-line no-empty-blocks
function _migrate(address) internal {}
function _destroy(address _newImpl) internal {
selfdestruct(address(uint160(_newImpl)));
}
function _callerAddress()
internal view
returns (address payable)
{
if (msg.sender == proxy) {
// This is guarantee of the GovernedProxy
// solium-disable-next-line security/no-tx-origin
return tx.origin;
} else {
return msg.sender;
}
}
}
// File: ../NonReentrant.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* A little helper to protect contract from being re-entrant in state
* modifying functions.
*/
contract NonReentrant {
uint private entry_guard;
modifier noReentry {
require(entry_guard == 0, "Reentry");
entry_guard = 1;
_;
entry_guard = 0;
}
}
// File: IEnergiswapFactory.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IEnergiswapFactory {
function initialized() external view returns (bool);
function _storage() external view returns (address);
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function initialize(address _routerProxy, address _pairsManagerProxy, address _pairsERC20Proxy) external;
function destroy(address _newImpl) external;
function migrate(address _oldImpl) external;
function createPair(
address tokenA,
address tokenB
) external returns (address pairProxy);
function setFeeTo(address _feeTo) external;
function setFeeToSetter(address _feeToSetter) external;
function feeTo() external view returns (address _feeTo);
function feeToSetter() external view returns (address _feeToSetter);
function sporkProxy() external view returns (address _sporkProxy);
function getPair(address tokenA, address tokenB) external view returns (address _pair);
function allPairs(uint index) external view returns (address _pair);
function allPairsLength() external view returns (uint);
}
// File: ../interfaces/IGovernedContract.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Genesis version of GovernedContract interface.
*
* Base Consensus interface for upgradable contracts.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IGovernedContract {
// Return actual proxy address for secure validation
function proxy() external returns(address);
// It must check that the caller is the proxy
// and copy all required data from the old address.
function migrate(IGovernedContract _oldImpl) external;
// It must check that the caller is the proxy
// and self destruct to the new address.
function destroy(IGovernedContract _newImpl) external;
// function () external payable; // This line (from original Energi IGovernedContract) is commented because it
// makes truffle migrations fail
}
// File: ../interfaces/IProposal.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
interface IProposal {
function parent() external view returns(address);
function created_block() external view returns(uint);
function deadline() external view returns(uint);
function fee_payer() external view returns(address payable);
function fee_amount() external view returns(uint);
function accepted_weight() external view returns(uint);
function rejected_weight() external view returns(uint);
function total_weight() external view returns(uint);
function quorum_weight() external view returns(uint);
function isFinished() external view returns(bool);
function isAccepted() external view returns(bool);
function withdraw() external;
function destroy() external;
function collect() external;
function voteAccept() external;
function voteReject() external;
function setFee() external payable;
function canVote(address owner) external view returns(bool);
}
// File: ../interfaces/IUpgradeProposal.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
/**
* Interface of UpgradeProposal
*/
contract IUpgradeProposal is IProposal {
function impl() external view returns(IGovernedContract);
}
// File: ../interfaces/IGovernedProxy.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
//pragma experimental SMTChecker;
/**
* Genesis version of IGovernedProxy interface.
*
* Base Consensus interface for upgradable contracts proxy.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IGovernedProxy {
event UpgradeProposal(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
event Upgraded(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
function impl() external view returns(IGovernedContract);
function proposeUpgrade(IGovernedContract _newImpl, uint _period)
external payable returns(IUpgradeProposal);
function upgrade(IUpgradeProposal _proposal) external;
function upgradeProposalImpl(IUpgradeProposal _proposal) external view returns(IGovernedContract new_impl);
function listUpgradeProposals() external view returns(IUpgradeProposal[] memory proposals);
function collectUpgradeProposal(IUpgradeProposal _proposal) external;
function () external payable;
}
// File: IEnergiswapFactoryGovernedProxy.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
//pragma experimental SMTChecker;
/**
* Genesis version of IGovernedProxy interface.
*
* Base Consensus interface for upgradable contracts proxy.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IEnergiswapFactoryGovernedProxy {
event UpgradeProposal(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
event Upgraded(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
function impl() external view returns (IGovernedContract);
function spork_proxy() external view returns (IGovernedProxy);
function emitPairCreated(address token0, address token1, address pair, uint allPairsLength) external;
function proposeUpgrade(IGovernedContract _newImpl, uint _period) external payable returns(IUpgradeProposal);
function upgrade(IUpgradeProposal _proposal) external;
function upgradeProposalImpl(IUpgradeProposal _proposal) external view returns(IGovernedContract new_impl);
function collectUpgradeProposal(IUpgradeProposal _proposal) external;
function proxy() external view returns (address);
function migrate(IGovernedContract) external pure;
function destroy(IGovernedContract) external pure;
function () external payable;
}
// File: ../interfaces/ISporkRegistry.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
interface ISporkRegistry {
function createUpgradeProposal(
IGovernedContract _impl,
uint _period,
address payable _fee_payer
)
external payable
returns (IUpgradeProposal);
function consensusGasLimits()
external view
returns(uint callGas, uint xferGas);
}
// File: EnergiswapFactoryGovernedProxy.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
/**
* SC-9: This contract has no chance of being updated. It must be stupid simple.
*
* If another upgrade logic is required in the future - it can be done as proxy stage II.
*/
contract EnergiswapFactoryGovernedProxy is IEnergiswapFactoryGovernedProxy, NonReentrant {
IGovernedContract public impl;
IGovernedProxy public spork_proxy;
mapping(address => IGovernedContract) public upgrade_proposals;
IUpgradeProposal[] public upgrade_proposal_list;
event PairCreated(address indexed token0, address indexed token1, address pair, uint allPairsLength);
modifier senderOrigin {
// Internal calls are expected to use impl directly.
// That's due to use of call() instead of delegatecall() on purpose.
// solium-disable-next-line security/no-tx-origin
require(
tx.origin == msg.sender,
"EnergiswapFactoryGovernedProxy: FORBIDDEN, not a direct call");
_;
}
modifier requireImpl {
require(msg.sender == address(impl), "EnergiswapFactoryGovernedProxy: FORBIDDEN, not impl");
_;
}
constructor(address _impl, address payable _sporkProxy) public {
impl = IGovernedContract(_impl);
spork_proxy = IGovernedProxy(_sporkProxy);
}
// Emit PairCreated event
function emitPairCreated(address token0, address token1, address pair, uint allPairsLength) external requireImpl {
emit PairCreated(token0, token1, pair, allPairsLength);
}
/**
* Pre-create a new contract first.
* Then propose upgrade based on that.
*/
function proposeUpgrade(IGovernedContract _newImpl, uint _period)
external payable
senderOrigin
noReentry
returns(IUpgradeProposal)
{
require(_newImpl != impl, "Already active!");
require(_newImpl.proxy() == address(this), "Wrong proxy!");
ISporkRegistry spork_reg = ISporkRegistry(address(spork_proxy.impl()));
IUpgradeProposal proposal = spork_reg.createUpgradeProposal.value(msg.value)(_newImpl, _period, msg.sender);
upgrade_proposals[address(proposal)] = _newImpl;
upgrade_proposal_list.push(proposal);
emit UpgradeProposal(_newImpl, proposal);
return proposal;
}
/**
* Once proposal is accepted, anyone can activate that.
*/
function upgrade(IUpgradeProposal _proposal)
external
noReentry
{
IGovernedContract new_impl = upgrade_proposals[address(_proposal)];
require(new_impl != impl, "Already active!"); // in case it changes in the flight
require(address(new_impl) != address(0), "Not registered!");
require(_proposal.isAccepted(), "Not accepted!");
IGovernedContract old_impl = impl;
new_impl.migrate(old_impl);
impl = new_impl;
old_impl.destroy(new_impl);
// SECURITY: prevent downgrade attack
_cleanupProposal(_proposal);
// Return fee ASAP
_proposal.destroy();
emit Upgraded(new_impl, _proposal);
}
/**
* Map proposal to implementation
*/
function upgradeProposalImpl(IUpgradeProposal _proposal)
external view
returns(IGovernedContract new_impl)
{
new_impl = upgrade_proposals[address(_proposal)];
}
/**
* Lists all available upgrades
*/
function listUpgradeProposals()
external view
returns(IUpgradeProposal[] memory proposals)
{
uint len = upgrade_proposal_list.length;
proposals = new IUpgradeProposal[](len);
for (uint i = 0; i < len; ++i) {
proposals[i] = upgrade_proposal_list[i];
}
return proposals;
}
/**
* Once proposal is reject, anyone can start collect procedure.
*/
function collectUpgradeProposal(IUpgradeProposal _proposal)
external
noReentry
{
IGovernedContract new_impl = upgrade_proposals[address(_proposal)];
require(address(new_impl) != address(0), "Not registered!");
_proposal.collect();
delete upgrade_proposals[address(_proposal)];
_cleanupProposal(_proposal);
}
function _cleanupProposal(IUpgradeProposal _proposal) internal {
delete upgrade_proposals[address(_proposal)];
uint len = upgrade_proposal_list.length;
for (uint i = 0; i < len; ++i) {
if (upgrade_proposal_list[i] == _proposal) {
upgrade_proposal_list[i] = upgrade_proposal_list[len - 1];
upgrade_proposal_list.pop();
break;
}
}
}
/**
* Related to above
*/
function proxy() external view returns (address) {
return address(this);
}
/**
* SECURITY: prevent on-behalf-of calls
*/
function migrate(IGovernedContract) external pure {
revert("Good try");
}
/**
* SECURITY: prevent on-behalf-of calls
*/
function destroy(IGovernedContract) external pure {
revert("Good try");
}
/**
* Proxy all other calls to implementation.
*/
function ()
external
payable
senderOrigin
{
// SECURITY: senderOrigin() modifier is mandatory
IGovernedContract impl_m = impl;
// solium-disable-next-line security/no-inline-assembly
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let res := call(sub(gas(), 10000), impl_m, callvalue(), ptr, calldatasize(), 0, 0)
// NOTE: returndatasize should allow repeatable calls
// what should save one opcode.
returndatacopy(ptr, 0, returndatasize())
switch res
case 0 {
revert(ptr, returndatasize())
}
default {
return(ptr, returndatasize())
}
}
}
}
// File: EnergiswapFactoryAutoProxy.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
contract EnergiswapFactoryAutoProxy is EnergiswapGovernedContract {
constructor (
address _proxy,
address _impl,
address payable _sporkProxy
) public EnergiswapGovernedContract(_proxy) {
// If _proxy is set to address(0), a new EnergiswapFactoryGovernedProxy is deployed
if(_proxy == address(0)){
_proxy = address(new EnergiswapFactoryGovernedProxy(_impl, _sporkProxy));
}
proxy = _proxy;
}
}
// File: ../energiswapPairsManager/IEnergiswapPairsManager.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IEnergiswapPairsManager {
event Mint(address indexed pair, address indexed sender, uint amount0, uint amount1, address indexed to);
event Burn(address indexed pair, 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(address indexed sender, uint112 reserve0, uint112 reserve1);
function _storage() external view returns (address);
function destroy(address _newImpl) external;
function migrate(address _oldImpl) external;
function registerPair(address _pairProxy, address _pairStorage, address _erc20Storage) external;
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 approve(address spender, uint value) external returns (bool result);
function transfer(address to, uint value) external returns (bool result);
function transferFrom(address from, address to, uint value) external returns (bool result);
function redeemLiquidity(address router, address owner, uint value) external returns (bool result);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function emitApproval(address pair, address owner, address spender, uint value) external;
function emitTransfer(address pair, address from, address to, uint value) external;
function factory() external view returns (address _factory);
function getReserves(address pair) external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function token0(address pair) external view returns (address _token0);
function token1(address pair) external view returns (address _token1);
function price0CumulativeLast(address pair) external view returns (uint _price0CumulativeLast);
function price1CumulativeLast(address pair) external view returns (uint _price1CumulativeLast);
function kLast(address pair) external view returns (uint _kLast);
}
// File: ../energiswapPair/IEnergiswapPairProxy.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
pragma solidity >=0.5.0;
/**
* Genesis version of IGovernedProxy interface.
*
* Base Consensus interface for upgradable contracts proxy.
* Unlike common approach, the implementation is NOT expected to be
* called through delegatecall() to minimize risks of shared storage.
*
* NOTE: it MUST NOT change after blockchain launch!
*/
interface IEnergiswapPairProxy {
function pairsManagerProxy() external view returns (address);
function pairsERC20Proxy() external view returns (address);
function routerProxy() external view returns (address);
function emitMint(address sender, uint amount0, uint amount1, address to) external;
function emitBurn(address sender, uint amount0, uint amount1, address to) external;
function emitSwap(address sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address to) external;
function emitSync(uint112 reserve0, uint112 reserve1) external;
function emitApproval(address owner, address spender, uint value) external;
function emitTransfer(address from, address to, uint value) external;
function safeTransfer(address token, address to, uint value, bytes4 SELECTOR) external;
function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function token0() external view returns (address _token0);
function token1() external view returns (address _token1);
function price0CumulativeLast() external view returns (uint _price0CumulativeLast);
function price1CumulativeLast() external view returns (uint _price1CumulativeLast);
function kLast() external view returns (uint _kLast);
function name() external view returns(string memory _name);
function symbol() external view returns(string memory _symbol);
function decimals() external view returns(uint8 _decimals);
function totalSupply() external view returns (uint _totalSupply);
function balanceOf(address account) external view returns (uint _balance);
function allowance(address owner, address spender) external view returns (uint _allowance);
function nonce(address owner) external view returns(uint _nonce);
function () external payable;
}
// File: ../energiswapPairsERC20/IEnergiswapPairsERC20.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
interface IEnergiswapPairsERC20 {
function initialized() external view returns (bool);
function _storage() external view returns (address);
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function initialize(address _pairsManagerProxy) external;
function destroy(address _newImpl) external;
function migrate(address _oldImpl) external;
function registerPair(address _pairProxy, address _erc20Storage) external;
function _mint(address pair, address to, uint value) external;
function _burn(address pair, address from, uint value) external;
function approve(address pair, address owner, address spender, uint value) external returns (bool);
function transfer(address pair, address from, address to, uint value) external returns (bool);
function transferFrom(address pair, address spender, address from, address to, uint value) external returns (bool);
function permit(address pair, address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function nonce(address pair, address owner) external view returns(uint _nonce);
function name() external view returns(string memory _name);
function symbol() external view returns(string memory _symbol);
function decimals() external view returns(uint8 _decimals);
function totalSupply(address pair) external view returns (uint _totalSupply);
function balanceOf(address pair, address account) external view returns (uint _balance);
function allowance(address pair, address owner, address spender) external view returns (uint _allowance);
}
// File: ../energiswapPair/EnergiswapPairProxy.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
/**
* SC-9: This contract has no chance of being updated. It must be stupid simple.
*
* If another upgrade logic is required in the future - it can be done as proxy stage II.
*/
contract EnergiswapPairProxy is IEnergiswapPairProxy {
address public pairsManagerProxy;
address public pairsERC20Proxy;
address public routerProxy;
function pairsManager() private view returns(address _pairsManager) {
_pairsManager = address(IGovernedProxy(address(uint160(pairsManagerProxy))).impl());
}
function pairsERC20() private view returns(address _pairsERC20) {
_pairsERC20 = address(IGovernedProxy(address(uint160(pairsERC20Proxy))).impl());
}
function router() private view returns(address _router) {
_router = address(IGovernedProxy(address(uint160(routerProxy))).impl());
}
modifier senderOrigin {
// solium-disable-next-line security/no-tx-origin
require(
tx.origin == msg.sender
|| msg.sender == router(),
"EnergiswapPairGovernedProxy: FORBIDDEN, not a direct call or a call from router");
_;
}
modifier requireManager {
require(msg.sender == pairsManager(), "EnergiswapPairGovernedProxy: FORBIDDEN, not pairsManager");
_;
}
event Mint(address indexed sender, uint amount0, uint amount1, address indexed to);
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);
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor(address _routerProxy, address _pairsManagerProxy, address _pairsERC20Proxy) public {
routerProxy = _routerProxy;
pairsManagerProxy = _pairsManagerProxy;
pairsERC20Proxy = _pairsERC20Proxy;
}
// Emit Mint event
function emitMint(address sender, uint amount0, uint amount1, address to) external requireManager {
emit Mint(sender, amount0, amount1, to);
}
// Emit Burn event
function emitBurn(address sender, uint amount0, uint amount1, address to) external requireManager {
emit Burn(sender, amount0, amount1, to);
}
// Emit Swap event
function emitSwap(address sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address to) external requireManager {
emit Swap(sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// Emit Sync event
function emitSync(uint112 reserve0, uint112 reserve1) external requireManager {
emit Sync(reserve0, reserve1);
}
// Emit Approval event
function emitApproval(address owner, address spender, uint value) external requireManager {
emit Approval(owner, spender, value);
}
// Emit Transfer event
function emitTransfer(address from, address to, uint value) external requireManager {
emit Transfer(from, to, value);
}
// EnergiswapPairGovernedProxy holds pair assets. This function can be called by EnegiswapPairsManager to transfer funds
function safeTransfer(address token, address to, uint value, bytes4 SELECTOR) external requireManager {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'EnergiswapPairGovernedProxy: TRANSFER_FAILED');
}
// Expose Pair getter functions
function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
(_reserve0, _reserve1, _blockTimestampLast) = IEnergiswapPairsManager(pairsManager()).getReserves(address(this));
}
function token0() external view returns (address _token0) {
_token0 = IEnergiswapPairsManager(pairsManager()).token0(address(this));
}
function token1() external view returns (address _token1) {
_token1 = IEnergiswapPairsManager(pairsManager()).token1(address(this));
}
function price0CumulativeLast() external view returns (uint _price0CumulativeLast) {
_price0CumulativeLast = IEnergiswapPairsManager(pairsManager()).price0CumulativeLast(address(this));
}
function price1CumulativeLast() external view returns (uint _price1CumulativeLast) {
_price1CumulativeLast = IEnergiswapPairsManager(pairsManager()).price1CumulativeLast(address(this));
}
function kLast() external view returns (uint _kLast) {
_kLast = IEnergiswapPairsManager(pairsManager()).kLast(address(this));
}
// Expose ERC20 getter functions
function name() external view returns(string memory _name) {
_name = IEnergiswapPairsERC20(pairsERC20()).name();
}
function symbol() external view returns(string memory _symbol) {
_symbol = IEnergiswapPairsERC20(pairsERC20()).symbol();
}
function decimals() external view returns(uint8 _decimals) {
_decimals = IEnergiswapPairsERC20(pairsERC20()).decimals();
}
function totalSupply() external view returns (uint _totalSupply) {
_totalSupply = IEnergiswapPairsERC20(pairsERC20()).totalSupply(address(this));
}
function balanceOf(address account) external view returns (uint _balance) {
_balance = IEnergiswapPairsERC20(pairsERC20()).balanceOf(address(this), account);
}
function allowance(address owner, address spender) external view returns (uint _allowance) {
_allowance = IEnergiswapPairsERC20(pairsERC20()).allowance(address(this), owner, spender);
}
function nonce(address owner) external view returns(uint _nonce) {
_nonce = IEnergiswapPairsERC20(pairsERC20()).nonce(address(this), owner);
}
/**
* Proxy all other calls to pairsManager.
*/
function ()
external
payable
senderOrigin
{
// SECURITY: senderOrigin() modifier is mandatory
IEnergiswapPairsManager _pairsManager = IEnergiswapPairsManager(pairsManager());
// solium-disable-next-line security/no-inline-assembly
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let res := call(sub(gas(), 10000), _pairsManager, callvalue(), ptr, calldatasize(), 0, 0)
// NOTE: returndatasize should allow repeatable calls
// what should save one opcode.
returndatacopy(ptr, 0, returndatasize())
switch res
case 0 {
revert(ptr, returndatasize())
}
default {
return(ptr, returndatasize())
}
}
}
}
// File: ../StorageBase.sol
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* Base for contract storage (SC-14).
*
* NOTE: it MUST NOT change after blockchain launch!
*/
contract StorageBase {
address payable internal owner;
modifier requireOwner {
require(msg.sender == address(owner), "Not owner!");
_;
}
constructor() public {
owner = msg.sender;
}
function setOwner(IGovernedContract _newOwner) external requireOwner {
owner = address(uint160(address(_newOwner)));
}
function kill() external requireOwner {
selfdestruct(msg.sender);
}
}
// File: ../energiswapPair/IPairStorage.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
interface IPairStorage {
function pairsManagerProxy() external view returns (address);
function kill() external;
function setReserves(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) external;
function setCumulativePrices(uint _price0CumulativeLast, uint _price1CumulativeLast) external;
function setKLast(uint _kLast) external;
function setUnlocked(uint _unlocked) external;
function getTokens()external view returns(address _token0, address _token1);
function getToken0()external view returns(address _token0);
function getToken1()external view returns(address _token1);
function getReserves() external view returns(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function getCumulativePrices() external view returns(uint _price0CumulativeLast, uint _price1CumulativeLast);
function getCumulativePrice0() external view returns(uint _price0CumulativeLast);
function getCumulativePrice1() external view returns(uint _price1CumulativeLast);
function getKLast() external view returns(uint _kLast);
function getUnlocked() external view returns(uint _unlocked);
}
// File: ../energiswapPair/PairStorage.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
contract PairStorage is IPairStorage {
address public pairsManagerProxy;
address private token0;
address private token1;
uint112 private reserve0;
uint112 private reserve1;
uint32 private blockTimestampLast;
// Used to track prices time series (see: https://uniswap.org/blog/uniswap-v2/)
uint private price0CumulativeLast;
uint private price1CumulativeLast;
uint private kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier requirePairsManager {
require(msg.sender == address(IGovernedProxy(address(uint160(pairsManagerProxy))).impl()), "PairStorage: FORBIDDEN, not pairsManager");
_;
}
constructor(address _pairsManagerProxy, address _token0, address _token1) public {
pairsManagerProxy = _pairsManagerProxy;
token0 = _token0;
token1 = _token1;
}
// Self-destruct
function kill() external requirePairsManager {
selfdestruct(msg.sender);
}
function setReserves(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) external requirePairsManager {
reserve0 = _reserve0;
reserve1 = _reserve1;
blockTimestampLast = _blockTimestampLast;
}
function setCumulativePrices(uint _price0CumulativeLast, uint _price1CumulativeLast) external requirePairsManager {
price0CumulativeLast = _price0CumulativeLast;
price1CumulativeLast = _price1CumulativeLast;
}
function setKLast(uint _kLast) external requirePairsManager {
kLast = _kLast;
}
function setUnlocked(uint _unlocked) external requirePairsManager {
unlocked = _unlocked;
}
// Expose getter functions
function getTokens()external view returns(address _token0, address _token1) {
_token0 = token0;
_token1 = token1;
}
function getToken0()external view returns(address _token0) {
_token0 = token0;
}
function getToken1()external view returns(address _token1) {
_token1 = token1;
}
function getReserves() external view returns(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function getCumulativePrices() external view returns(uint _price0CumulativeLast, uint _price1CumulativeLast) {
_price0CumulativeLast = price0CumulativeLast;
_price1CumulativeLast = price1CumulativeLast;
}
function getCumulativePrice0() external view returns(uint _price0CumulativeLast) {
_price0CumulativeLast = price0CumulativeLast;
}
function getCumulativePrice1() external view returns(uint _price1CumulativeLast) {
_price1CumulativeLast = price1CumulativeLast;
}
function getKLast() external view returns(uint _kLast) {
_kLast = kLast;
}
function getUnlocked() external view returns(uint _unlocked) {
_unlocked = unlocked;
}
}
// File: ../energiswapPair/IERC20Storage.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
interface IERC20Storage {
function pairsERC20Proxy() external view returns (address);
function kill() external;
function setBalance(address _owner, uint _amount) external;
function setAllowance(address _owner, address _spender, uint _amount) external;
function setTotalSupply(uint _amount) external;
function setNonce(address _owner, uint _nonce) external;
function getBalance(address _account) external view returns(uint _balance);
function getAllowance(address _owner, address _spender) external view returns(uint _allowance);
function getTotalSupply() external view returns(uint _totalSupply);
function getNonce(address _account) external view returns(uint _nonce);
}
// File: ../energiswapPair/ERC20Storage.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity = 0.5.16;
contract ERC20Storage is IERC20Storage {
address public pairsERC20Proxy;
mapping (address => uint) private balance;
mapping (address => mapping (address => uint)) private allowance;
uint private totalSupply;
mapping(address => uint) private nonce;
modifier requirePairsERC20 {
require(msg.sender == address(IGovernedProxy(address(uint160(pairsERC20Proxy))).impl()), "ERC20Storage: FORBIDDEN, not pairsERC20");
_;
}
constructor(address _pairsERC20Proxy) public {
pairsERC20Proxy = _pairsERC20Proxy;
}
// Self-destruct
function kill() external requirePairsERC20 {
selfdestruct(msg.sender);
}
// ERC20 functions
function setBalance(address _owner, uint _amount) external requirePairsERC20 {
balance[_owner] = _amount;
}
function setAllowance(address _owner, address _spender, uint _amount) external requirePairsERC20 {
allowance[_owner][_spender] = _amount;
}
function setTotalSupply(uint _amount) external requirePairsERC20 {
totalSupply = _amount;
}
function setNonce(address _owner, uint _nonce) external requirePairsERC20 {
nonce[_owner] = _nonce;
}
function getBalance(address _account) external view returns(uint _balance) {
_balance = balance[_account];
}
function getAllowance(address _owner, address _spender) external view returns(uint _allowance) {
_allowance = allowance[_owner][_spender];
}
function getTotalSupply() external view returns(uint _totalSupply){
_totalSupply = totalSupply;
}
function getNonce(address _account) external view returns(uint _nonce) {
_nonce = nonce[_account];
}
}
// File: IEnergiswapFactoryStorage.sol
// Copyright (C) 2020 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
interface IEnergiswapFactoryStorage {
function setFeeTo(address _feeTo) external;
function setFeeToSetter(address _feeToSetter) external;
function setRouterProxy(address _routerProxy) external;
function setPairsManagerProxy(address _pairsManagerProxy) external;
function setPairsERC20Proxy(address _pairsERC20Proxy) external;
function setPair(address token0, address token1, address _pair) external;
function pushPair(address _pair) external;
function getFeeTo() external view returns (address _feeTo);
function getFeeToSetter() external view returns (address _feeToSetter);
function getSporkProxy() external view returns (address _sporkProxy);
function getRouterProxy() external view returns (address _routerProxy);
function getPairsManagerProxy() external view returns (address _pairsManagerProxy);
function getPairsManager() external view returns (address _pairsManager);
function getPairsERC20Proxy() external view returns (address _pairsERC20Proxy);
function getPair(address token0, address token1) external view returns (address _pair);
function allPairs(uint index) external view returns (address _pair);
function allPairsLength() external view returns (uint _length);
}
// File: ../energiswapPairsManager/IEnergiswapPairsManagerGovernedProxy.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.5.0;
interface IEnergiswapPairsManagerGovernedProxy {
event UpgradeProposal(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
event Upgraded(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
function impl() external view returns (address);
function spork_proxy() external view returns (address);
// function factoryProxy() external view returns (address);
// function registerPair(address _pairProxy, address _pairStorage, address _erc20Storage) external;
function proposeUpgrade(IGovernedContract _newImpl, uint _period) external payable returns(IUpgradeProposal);
function upgrade(IUpgradeProposal _proposal) external;
function upgradeProposalImpl(IUpgradeProposal _proposal) external view returns(IGovernedContract new_impl);
function listUpgradeProposals() external view returns(IUpgradeProposal[] memory proposals);
function collectUpgradeProposal(IUpgradeProposal _proposal) external;
function proxy() external view returns (address);
function migrate(IGovernedContract) external pure;
function destroy(IGovernedContract) external pure;
function () external payable;
}
// File: ../energiswapRouter/IEnergiswapRouterGovernedProxy.sol
// Copyright 2019 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.5.0;
interface IEnergiswapRouterGovernedProxy {
event UpgradeProposal(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
event Upgraded(
IGovernedContract indexed impl,
IUpgradeProposal proposal
);
function impl() external view returns (address);
function spork_proxy() external view returns (address);
function safeTransferFrom(address token, address from, address to, uint value) external;
function proposeUpgrade(IGovernedContract _newImpl, uint _period) external payable returns(IUpgradeProposal);
function upgrade(IUpgradeProposal _proposal) external;
function upgradeProposalImpl(IUpgradeProposal _proposal) external view returns(IGovernedContract new_impl);
function listUpgradeProposals() external view returns(IUpgradeProposal[] memory proposals);
function collectUpgradeProposal(IUpgradeProposal _proposal) external;
function proxy() external view returns (address);
function migrate(IGovernedContract) external pure;
function destroy(IGovernedContract) external pure;
function () external payable;
}
// File: ../interfaces/IPausable.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/**
* @title Pausable Interface
*/
interface IPausable {
/**
* @dev Events
*/
event Masterpaused(address account, uint256 unpauseBlock);
event Paused(address account, uint256 unpauseBlock);
event Unpaused(address account);
/**
* @dev state variables
*/
function blockNumberWhenToUnpauseMasterPause() external view returns (uint256);
function blockNumberWhenToUnpausePause() external view returns (uint256);
/**
* @dev setter functions
*/
function masterPause(uint256 blocks) external;
function pause(uint256 blocks) external;
function unpause() external;
}
// File: EnergiswapFactory.sol
// Copyright 2021 The Energi Core Authors
// This file is part of Energi Core.
//
// Energi Core is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Energi Core is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Energi Core. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
contract EnergiswapFactoryStorage is StorageBase, IEnergiswapFactoryStorage {
address private feeTo;
address private feeToSetter;
address private sporkProxy;
address private multicall;
address private routerProxy;
address private pairsManagerProxy;
address private pairsERC20Proxy;
mapping(address => mapping(address => address)) private pair; // token0 -> token1 -> pairProxy
address[] private _allPairs;
constructor(address _feeToSetter, address _sporkProxy) public {
feeToSetter = _feeToSetter;
sporkProxy = _sporkProxy;
}
function setFeeTo(address _feeTo) external requireOwner {
feeTo = _feeTo;
}
function setFeeToSetter(address _feeToSetter) external requireOwner {
feeToSetter = _feeToSetter;
}
function setRouterProxy(address _routerProxy) external requireOwner {
routerProxy = _routerProxy;
}
function setPairsManagerProxy(address _pairsManagerProxy) external requireOwner {
pairsManagerProxy = _pairsManagerProxy;
}
function setPairsERC20Proxy(address _pairsERC20Proxy) external requireOwner {
pairsERC20Proxy = _pairsERC20Proxy;
}
function setPair(address token0, address token1, address _pair) external requireOwner {
pair[token0][token1] = _pair;
}
function pushPair(address _pair) external requireOwner {
_allPairs.push(_pair);
}
function getFeeTo() external view returns (address _feeTo) {
_feeTo = feeTo;
}
function getFeeToSetter() external view returns (address _feeToSetter) {
_feeToSetter = feeToSetter;
}
function getSporkProxy() external view returns (address _sporkProxy) {
_sporkProxy = sporkProxy;
}
function getRouterProxy() external view returns (address _routerProxy) {
_routerProxy = routerProxy;
}
function getPairsManagerProxy() external view returns (address _pairsManagerProxy) {
_pairsManagerProxy = pairsManagerProxy;
}
function getPairsManager() external view returns (address _pairsManager) {
_pairsManager = address(IEnergiswapPairsManagerGovernedProxy(address(uint160(pairsManagerProxy))).impl());
}
function getPairsERC20Proxy() external view returns (address _pairsERC20Proxy) {
_pairsERC20Proxy = pairsERC20Proxy;
}
function getPair(address token0, address token1) external view returns (address _pair) {
_pair = pair[token0][token1];
}
function allPairs(uint index) external view returns (address _pair) {
_pair = _allPairs[index];
}
function allPairsLength() external view returns (uint _length) {
_length = _allPairs.length;
}
}
contract EnergiswapFactory is EnergiswapFactoryAutoProxy, IEnergiswapFactory {
bool public initialized = false;
EnergiswapFactoryStorage public _storage;
modifier requireFeeToSetter {
require(tx.origin == _storage.getFeeToSetter(), 'EnergiswapFactory: FORBIDDEN, not feeToSetter');
_;
}
modifier requireProxy {
require(msg.sender == proxy, 'EnergiswapFactory: FORBIDDEN, not proxy');
_;
}
/**
* @dev Modifier to make a function callable only when EnergiswapPairsManager contract is not paused.
*
* Requirements:
*
* - EnergiswapPairsManager must not be paused or masterPaused.
*/
modifier whenNotPaused {
require(block.number >= IPausable(_storage.getPairsManager()).blockNumberWhenToUnpausePause() &&
block.number >= IPausable(_storage.getPairsManager()).blockNumberWhenToUnpauseMasterPause(),
'Pausable: Revert - Code execution is paused');
_;
}
constructor(
address _feeToSetter,
address _sporkProxy,
address _proxy // If set to address(0), EnergiswapFactoryGovernedProxy will be deployed by EnergiswapFactoryAutoProxy
) public EnergiswapFactoryAutoProxy(
_proxy,
address(this),
address(uint160(_sporkProxy))
) {
_storage = new EnergiswapFactoryStorage(_feeToSetter, _sporkProxy); // Deploy EnergiswapFactoryStorage contract
}
// Initialize contract. This function can only be called once
function initialize(address _routerProxy, address _pairsManagerProxy, address _pairsERC20Proxy) external {
require(initialized == false, 'EnergiswapFactory: already initialized');
_storage.setRouterProxy(_routerProxy);
_storage.setPairsManagerProxy(_pairsManagerProxy);
_storage.setPairsERC20Proxy(_pairsERC20Proxy);
initialized = true;
}
// This function must be called in order to upgrade to a new EnergiswapFactory implementation
function destroy(address _newImpl) external requireProxy {
// Updates EnergiswapFactoryStorage contract with new EnergiswapFactory implementation address as owner
IStorageBase(address(_storage)).setOwner(_newImpl);
// Self destruct
_destroy(_newImpl);
}
// This function (placeholder) would be called on the new implementation if necessary for the upgrade
function migrate(address _oldImpl) external requireProxy {
_migrate(_oldImpl);
}
// Create pair
function createPair(
address tokenA,
address tokenB
) external whenNotPaused returns (address pairProxy) {
// Check that tokens addresses are not identical
require(tokenA != tokenB, 'EnergiswapFactory: IDENTICAL_TOKENS_ADDRESSES');
// Sort tokens addresses
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
// Check that no token address is zero
require(token0 != address(0), 'EnergiswapFactory: ZERO_ADDRESS');
// Check that pair does not already exist
require(_storage.getPair(token0, token1) == address(0), 'EnergiswapFactory: PAIR_EXISTS'); // single check is sufficient
// Deploy pair proxy via CREATE2
bytes memory bytecode = abi.encodePacked(
type(EnergiswapPairProxy).creationCode,
abi.encode(
_storage.getRouterProxy(),
_storage.getPairsManagerProxy(),
_storage.getPairsERC20Proxy()
)
);
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
assembly {
pairProxy := create2(0, add(bytecode, 32), mload(bytecode), salt)
}
// Deploy new PairStorage contract
address pairStorage = address(new PairStorage(_storage.getPairsManagerProxy(), token0, token1));
// Deploy new ERC20Storage contract
address erc20Storage = address(new ERC20Storage(_storage.getPairsERC20Proxy()));
// Register pairProxy, pairStorage and erc20Storage addresses into EnergiswapPairsManager and
// EnergiswapPairsERC20 contracts
IEnergiswapPairsManager(address(uint160(_storage.getPairsManager()))).registerPair(pairProxy, pairStorage, erc20Storage);
// Register pairProxy address into EnergiswapFactoryStorage contract mapping with tokens addresses
_storage.setPair(token0, token1, pairProxy);
_storage.setPair(token1, token0, pairProxy); // populate mapping in the reverse direction
_storage.pushPair(pairProxy);
// Emit pair creation event
IEnergiswapFactoryGovernedProxy(address(uint160(proxy))).emitPairCreated(token0, token1, pairProxy, _storage.allPairsLength());
}
// Set feeTo address
function setFeeTo(address _feeTo) external requireFeeToSetter {
_storage.setFeeTo(_feeTo);
}
// Set feeToSetter address
function setFeeToSetter(address _feeToSetter) external requireFeeToSetter {
_storage.setFeeToSetter(_feeToSetter);
}
// Expose getter functions
function feeTo() external view returns (address _feeTo) {
_feeTo = _storage.getFeeTo();
}
function feeToSetter() external view returns (address _feeToSetter) {
_feeToSetter = _storage.getFeeToSetter();
}
function sporkProxy() external view returns (address _sporkProxy) {
_sporkProxy = _storage.getSporkProxy();
}
function getPair(address tokenA, address tokenB) external view returns (address _pair) {
_pair = _storage.getPair(tokenA, tokenB);
}
function allPairs(uint index) external view returns (address _pair) {
_pair = _storage.allPairs(index);
}
function allPairsLength() external view returns (uint) {
return _storage.allPairsLength();
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"_feeToSetter","internalType":"address"},{"type":"address","name":"_sporkProxy","internalType":"address"},{"type":"address","name":"_proxy","internalType":"address"}]},{"type":"event","name":"PairCreated","inputs":[{"type":"address","name":"token0","internalType":"address","indexed":true},{"type":"address","name":"token1","internalType":"address","indexed":true},{"type":"address","name":"pair","internalType":"address","indexed":false},{"type":"uint256","name":"","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract EnergiswapFactoryStorage"}],"name":"_storage","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_pair","internalType":"address"}],"name":"allPairs","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allPairsLength","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"address","name":"pairProxy","internalType":"address"}],"name":"createPair","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"destroy","inputs":[{"type":"address","name":"_newImpl","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_feeTo","internalType":"address"}],"name":"feeTo","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_feeToSetter","internalType":"address"}],"name":"feeToSetter","inputs":[],"constant":true},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_pair","internalType":"address"}],"name":"getPair","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"}],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_routerProxy","internalType":"address"},{"type":"address","name":"_pairsManagerProxy","internalType":"address"},{"type":"address","name":"_pairsERC20Proxy","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"initialized","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"migrate","inputs":[{"type":"address","name":"_oldImpl","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"address"}],"name":"proxy","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setFeeTo","inputs":[{"type":"address","name":"_feeTo","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"setFeeToSetter","inputs":[{"type":"address","name":"_feeToSetter","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"_sporkProxy","internalType":"address"}],"name":"sporkProxy","inputs":[],"constant":true}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100f45760003560e01c8063a2e74af611610097578063ce5494bb11610066578063ce5494bb1461023c578063e6a4390514610262578063ec55688914610290578063f46901ed14610298576100f4565b8063a2e74af6146101a8578063c0c53b8b146101ce578063c3fb90d614610206578063c9c653961461020e576100f4565b8063158ef93e116100d3578063158ef93e1461014d5780631e3dd18b146101695780634a85261014610186578063574f2ba31461018e576100f4565b8062f55d9d146100f9578063017e7e5814610121578063094b741514610145575b600080fd5b61011f6004803603602081101561010f57600080fd5b50356001600160a01b03166102be565b005b610129610379565b604080516001600160a01b039092168252519081900360200190f35b6101296103ef565b610155610434565b604080519115158252519081900360200190f35b6101296004803603602081101561017f57600080fd5b5035610444565b6101296104c2565b610196610507565b60408051918252519081900360200190f35b61011f600480360360208110156101be57600080fd5b50356001600160a01b031661054c565b61011f600480360360608110156101e457600080fd5b506001600160a01b038135811691602081013582169160409091013516610675565b610129610808565b6101296004803603604081101561022457600080fd5b506001600160a01b0381358116916020013516610817565b61011f6004803603602081101561025257600080fd5b50356001600160a01b0316611355565b6101296004803603604081101561027857600080fd5b506001600160a01b03813581169160200135166113a7565b610129611433565b61011f600480360360208110156102ae57600080fd5b50356001600160a01b0316611442565b6000546001600160a01b031633146103075760405162461bcd60e51b8152600401808060200182810382526027815260200180613a6a6027913960400191505060405180910390fd5b600154604080516313af403560e01b81526001600160a01b038481166004830152915191909216916313af403591602480830192600092919082900301818387803b15801561035557600080fd5b505af1158015610369573d6000803e3d6000fd5b5050505061037681611550565b50565b60015460408051630cc23ea560e31b815290516000926001600160a01b031691636611f528916004808301926020929190829003018186803b1580156103be57600080fd5b505afa1580156103d2573d6000803e3d6000fd5b505050506040513d60208110156103e857600080fd5b5051919050565b60015460408051637a55098160e11b815290516000926001600160a01b03169163f4aa1302916004808301926020929190829003018186803b1580156103be57600080fd5b600054600160a01b900460ff1681565b60015460408051631e3dd18b60e01b81526004810184905290516000926001600160a01b031691631e3dd18b916024808301926020929190829003018186803b15801561049057600080fd5b505afa1580156104a4573d6000803e3d6000fd5b505050506040513d60208110156104ba57600080fd5b505192915050565b6001546040805163e00fe53560e01b815290516000926001600160a01b03169163e00fe535916004808301926020929190829003018186803b1580156103be57600080fd5b6001546040805163574f2ba360e01b815290516000926001600160a01b03169163574f2ba3916004808301926020929190829003018186803b1580156103be57600080fd5b600160009054906101000a90046001600160a01b03166001600160a01b031663f4aa13026040518163ffffffff1660e01b815260040160206040518083038186803b15801561059a57600080fd5b505afa1580156105ae573d6000803e3d6000fd5b505050506040513d60208110156105c457600080fd5b50516001600160a01b0316321461060c5760405162461bcd60e51b815260040180806020018281038252602d815260200180613abc602d913960400191505060405180910390fd5b60015460408051635173a57b60e11b81526001600160a01b0384811660048301529151919092169163a2e74af691602480830192600092919082900301818387803b15801561065a57600080fd5b505af115801561066e573d6000803e3d6000fd5b5050505050565b600054600160a01b900460ff16156106be5760405162461bcd60e51b8152600401808060200182810382526026815260200180613a176026913960400191505060405180910390fd5b600154604080516334760b3960e01b81526001600160a01b038681166004830152915191909216916334760b3991602480830192600092919082900301818387803b15801561070c57600080fd5b505af1158015610720573d6000803e3d6000fd5b505060015460408051631f64bccb60e11b81526001600160a01b0387811660048301529151919092169350633ec979969250602480830192600092919082900301818387803b15801561077257600080fd5b505af1158015610786573d6000803e3d6000fd5b5050600154604080516383f5878760e01b81526001600160a01b03868116600483015291519190921693506383f587879250602480830192600092919082900301818387803b1580156107d857600080fd5b505af11580156107ec573d6000803e3d6000fd5b50506000805460ff60a01b1916600160a01b1790555050505050565b6001546001600160a01b031681565b6001546040805163341a0f9d60e01b815290516000926001600160a01b03169163341a0f9d916004808301926020929190829003018186803b15801561085c57600080fd5b505afa158015610870573d6000803e3d6000fd5b505050506040513d602081101561088657600080fd5b5051604080516348d6d49960e11b815290516001600160a01b03909216916391ada93291600480820192602092909190829003018186803b1580156108ca57600080fd5b505afa1580156108de573d6000803e3d6000fd5b505050506040513d60208110156108f457600080fd5b505143108015906109ec5750600160009054906101000a90046001600160a01b03166001600160a01b031663341a0f9d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561094e57600080fd5b505afa158015610962573d6000803e3d6000fd5b505050506040513d602081101561097857600080fd5b505160408051634a5aea3160e01b815290516001600160a01b0390921691634a5aea3191600480820192602092909190829003018186803b1580156109bc57600080fd5b505afa1580156109d0573d6000803e3d6000fd5b505050506040513d60208110156109e657600080fd5b50514310155b610a275760405162461bcd60e51b815260040180806020018281038252602b815260200180613a91602b913960400191505060405180910390fd5b816001600160a01b0316836001600160a01b03161415610a785760405162461bcd60e51b815260040180806020018281038252602d815260200180613a3d602d913960400191505060405180910390fd5b600080836001600160a01b0316856001600160a01b031610610a9b578385610a9e565b84845b90925090506001600160a01b038216610afe576040805162461bcd60e51b815260206004820152601f60248201527f456e6572676973776170466163746f72793a205a45524f5f4144445245535300604482015290519081900360640190fd5b6001546040805163e6a4390560e01b81526001600160a01b038581166004830152848116602483015291516000939092169163e6a4390591604480820192602092909190829003018186803b158015610b5657600080fd5b505afa158015610b6a573d6000803e3d6000fd5b505050506040513d6020811015610b8057600080fd5b50516001600160a01b031614610bdd576040805162461bcd60e51b815260206004820152601e60248201527f456e6572676973776170466163746f72793a20504149525f4558495354530000604482015290519081900360640190fd5b606060405180602001610bef9061155c565b601f1982820381018352601f9091011660408181526001546362b1fb8f60e11b835290516001600160a01b039091169163c563f71e916004808301926020929190829003018186803b158015610c4457600080fd5b505afa158015610c58573d6000803e3d6000fd5b505050506040513d6020811015610c6e57600080fd5b5051600154604080516317e006a960e01b815290516001600160a01b03909216916317e006a991600480820192602092909190829003018186803b158015610cb557600080fd5b505afa158015610cc9573d6000803e3d6000fd5b505050506040513d6020811015610cdf57600080fd5b505160015460408051633a48ef8960e21b815290516001600160a01b039092169163e923be2491600480820192602092909190829003018186803b158015610d2657600080fd5b505afa158015610d3a573d6000803e3d6000fd5b505050506040513d6020811015610d5057600080fd5b5051604080516001600160a01b03948516602082810191909152938516818301529390911660608085019190915281518085039091018152608084019091528351909260a001918291908501908083835b60208310610dc05780518252601f199092019160209182019101610da1565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610e085780518252601f199092019160209182019101610de9565b51815160209384036101000a60001901801990921691161790526040805192909401828103601f1901835280855260608b811b6bffffffffffffffffffffffff1990811683850152908b901b1660348201528451808203602801815260489091019094528351938101939093208151919750955085945092505084016000f594506000600160009054906101000a90046001600160a01b03166001600160a01b03166317e006a96040518163ffffffff1660e01b815260040160206040518083038186803b158015610ed957600080fd5b505afa158015610eed573d6000803e3d6000fd5b505050506040513d6020811015610f0357600080fd5b505160405186908690610f1590611569565b6001600160a01b03938416815291831660208301529091166040808301919091525190819003606001906000f080158015610f54573d6000803e3d6000fd5b5090506000600160009054906101000a90046001600160a01b03166001600160a01b031663e923be246040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa757600080fd5b505afa158015610fbb573d6000803e3d6000fd5b505050506040513d6020811015610fd157600080fd5b5051604051610fdf90611576565b6001600160a01b03909116815260405190819003602001906000f08015801561100c573d6000803e3d6000fd5b509050600160009054906101000a90046001600160a01b03166001600160a01b031663341a0f9d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561105d57600080fd5b505afa158015611071573d6000803e3d6000fd5b505050506040513d602081101561108757600080fd5b50516040805163bfbd029760e01b81526001600160a01b038a81166004830152858116602483015284811660448301529151919092169163bfbd029791606480830192600092919082900301818387803b1580156110e457600080fd5b505af11580156110f8573d6000803e3d6000fd5b505060015460408051633dda080960e11b81526001600160a01b038b811660048301528a811660248301528c811660448301529151919092169350637bb410129250606480830192600092919082900301818387803b15801561115a57600080fd5b505af115801561116e573d6000803e3d6000fd5b505060015460408051633dda080960e11b81526001600160a01b038a811660048301528b811660248301528c811660448301529151919092169350637bb410129250606480830192600092919082900301818387803b1580156111d057600080fd5b505af11580156111e4573d6000803e3d6000fd5b50506001546040805163098ad3b560e01b81526001600160a01b038c81166004830152915191909216935063098ad3b59250602480830192600092919082900301818387803b15801561123657600080fd5b505af115801561124a573d6000803e3d6000fd5b50506000546001546040805163574f2ba360e01b815290516001600160a01b03938416955063c6a3c43c94508b938b938e9391169163574f2ba391600480820192602092909190829003018186803b1580156112a557600080fd5b505afa1580156112b9573d6000803e3d6000fd5b505050506040513d60208110156112cf57600080fd5b5051604080516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015291909316604483015260648201929092529051608480830192600092919082900301818387803b15801561133157600080fd5b505af1158015611345573d6000803e3d6000fd5b5050505050505050505092915050565b6000546001600160a01b0316331461139e5760405162461bcd60e51b8152600401808060200182810382526027815260200180613a6a6027913960400191505060405180910390fd5b61037681610376565b6001546040805163e6a4390560e01b81526001600160a01b03858116600483015284811660248301529151600093929092169163e6a4390591604480820192602092909190829003018186803b15801561140057600080fd5b505afa158015611414573d6000803e3d6000fd5b505050506040513d602081101561142a57600080fd5b50519392505050565b6000546001600160a01b031681565b600160009054906101000a90046001600160a01b03166001600160a01b031663f4aa13026040518163ffffffff1660e01b815260040160206040518083038186803b15801561149057600080fd5b505afa1580156114a4573d6000803e3d6000fd5b505050506040513d60208110156114ba57600080fd5b50516001600160a01b031632146115025760405162461bcd60e51b815260040180806020018281038252602d815260200180613abc602d913960400191505060405180910390fd5b6001546040805163f46901ed60e01b81526001600160a01b0384811660048301529151919092169163f46901ed91602480830192600092919082900301818387803b15801561065a57600080fd5b806001600160a01b0316ff5b6114df8061158483390190565b61084680612a6383390190565b61076e806132a98339019056fe608060405234801561001057600080fd5b506040516114df3803806114df8339818101604052606081101561003357600080fd5b5080516020820151604090920151600280546001600160a01b039384166001600160a01b03199182161790915560008054948416948216949094179093556001805492909116919092161790556114508061008f6000396000f3fe6080604052600436106101405760003560e01c806370a08231116100b6578063b2cef4ef1161006f578063b2cef4ef146104f0578063d1841a3714610543578063d21220a71461058a578063dd62ed3e1461059f578063e634c486146105da578063fe06655c1461061557610140565b806370a082311461040457806370ae92d2146104375780637464fc3d1461046a5780637df172a61461047f5780638ad6c3c91461049457806395d89b41146104db57610140565b8063313ce56711610108578063313ce567146103425780633f397ebe1461036d5780635687f2b8146103825780635909c0d5146103c55780635a3d5493146103da578063651ddd64146103ef57610140565b806306fdde03146101d65780630902f1ac146102605780630dfe1681146102a557806318160ddd146102d657806323de6651146102fd575b323314806101665750610151610669565b6001600160a01b0316336001600160a01b0316145b6101a15760405162461bcd60e51b815260040180806020018281038252604f8152602001806113cd604f913960600191505060405180910390fd5b60006101ab6106df565b90506040513660008237600080368334866127105a03f13d6000833e8080156101d2573d83f35b3d83fd5b3480156101e257600080fd5b506101eb61072e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022557818101518382015260200161020d565b50505050905090810190601f1680156102525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561026c57600080fd5b50610275610862565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b3480156102b157600080fd5b506102ba610907565b604080516001600160a01b039092168252519081900360200190f35b3480156102e257600080fd5b506102eb610966565b60408051918252519081900360200190f35b34801561030957600080fd5b506103406004803603606081101561032057600080fd5b506001600160a01b038135811691602081013590911690604001356109c5565b005b34801561034e57600080fd5b50610357610a6c565b6040805160ff9092168252519081900360200190f35b34801561037957600080fd5b506102ba610aae565b34801561038e57600080fd5b50610340600480360360608110156103a557600080fd5b506001600160a01b03813581169160208101359091169060400135610abd565b3480156103d157600080fd5b506102eb610b64565b3480156103e657600080fd5b506102eb610bc3565b3480156103fb57600080fd5b506102ba610c22565b34801561041057600080fd5b506102eb6004803603602081101561042757600080fd5b50356001600160a01b0316610c31565b34801561044357600080fd5b506102eb6004803603602081101561045a57600080fd5b50356001600160a01b0316610cbe565b34801561047657600080fd5b506102eb610d19565b34801561048b57600080fd5b506102ba610d78565b3480156104a057600080fd5b50610340600480360360808110156104b757600080fd5b506001600160a01b0381358116916020810135916040820135916060013516610d87565b3480156104e757600080fd5b506101eb610e37565b3480156104fc57600080fd5b50610340600480360360c081101561051357600080fd5b506001600160a01b03813581169160208101359160408201359160608101359160808201359160a0013516610e79565b34801561054f57600080fd5b506103406004803603608081101561056657600080fd5b506001600160a01b0381358116916020810135916040820135916060013516610f2f565b34801561059657600080fd5b506102ba610fdf565b3480156105ab57600080fd5b506102eb600480360360408110156105c257600080fd5b506001600160a01b038135811691602001351661103e565b3480156105e657600080fd5b50610340600480360360408110156105fd57600080fd5b506001600160701b03813581169160200135166110d4565b34801561062157600080fd5b506103406004803603608081101561063857600080fd5b5080356001600160a01b0390811691602081013590911690604081013590606001356001600160e01b031916611174565b60025460408051638abf607760e01b815290516000926001600160a01b031691638abf6077916004808301926020929190829003018186803b1580156106ae57600080fd5b505afa1580156106c2573d6000803e3d6000fd5b505050506040513d60208110156106d857600080fd5b5051919050565b60008060009054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b1580156106ae57600080fd5b6060610738611323565b6001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561077057600080fd5b505afa158015610784573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156107ad57600080fd5b81019080805160405193929190846401000000008211156107cd57600080fd5b9083019060208201858111156107e257600080fd5b82516401000000008111828201881017156107fc57600080fd5b82525081516020918201929091019080838360005b83811015610829578181015183820152602001610811565b50505050905090810190601f1680156108565780820380516001836020036101000a031916815260200191505b50604052505050905090565b600080600061086f6106df565b6001600160a01b0316633e99c1e4306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060606040518083038186803b1580156108c457600080fd5b505afa1580156108d8573d6000803e3d6000fd5b505050506040513d60608110156108ee57600080fd5b5080516020820151604090920151909591945092509050565b60006109116106df565b6001600160a01b03166376bf39a3306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6000610970611323565b6001600160a01b031663e4dc2aa4306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6109cd6106df565b6001600160a01b0316336001600160a01b031614610a1c5760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000610a76611323565b6001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156106ae57600080fd5b6001546001600160a01b031681565b610ac56106df565b6001600160a01b0316336001600160a01b031614610b145760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b816001600160a01b0316836001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b6000610b6e6106df565b6001600160a01b031663e267aa63306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6000610bcd6106df565b6001600160a01b031663db1d5a96306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6000546001600160a01b031681565b6000610c3b611323565b60408051633de222bb60e21b81523060048201526001600160a01b0385811660248301529151929091169163f7888aec91604480820192602092909190829003018186803b158015610c8c57600080fd5b505afa158015610ca0573d6000803e3d6000fd5b505050506040513d6020811015610cb657600080fd5b505192915050565b6000610cc8611323565b6040805163a719536760e01b81523060048201526001600160a01b0385811660248301529151929091169163a719536791604480820192602092909190829003018186803b158015610c8c57600080fd5b6000610d236106df565b6001600160a01b0316638529656d306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6002546001600160a01b031681565b610d8f6106df565b6001600160a01b0316336001600160a01b031614610dde5760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b806001600160a01b0316846001600160a01b03167fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d819364968585604051808381526020018281526020019250505060405180910390a350505050565b6060610e41611323565b6001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561077057600080fd5b610e816106df565b6001600160a01b0316336001600160a01b031614610ed05760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b60408051868152602081018690528082018590526060810184905290516001600160a01b0380841692908916917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a3505050505050565b610f376106df565b6001600160a01b0316336001600160a01b031614610f865760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b806001600160a01b0316846001600160a01b03167fdbba30eb0402b389513e87f51f4db2db80bed454384ec6925a24097c3548a02a8585604051808381526020018281526020019250505060405180910390a350505050565b6000610fe96106df565b6001600160a01b03166337823795306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156106ae57600080fd5b6000611048611323565b6040805163927da10560e01b81523060048201526001600160a01b03868116602483015285811660448301529151929091169163927da10591606480820192602092909190829003018186803b1580156110a157600080fd5b505afa1580156110b5573d6000803e3d6000fd5b505050506040513d60208110156110cb57600080fd5b50519392505050565b6110dc6106df565b6001600160a01b0316336001600160a01b03161461112b5760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b604080516001600160701b0380851682528316602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a15050565b61117c6106df565b6001600160a01b0316336001600160a01b0316146111cb5760405162461bcd60e51b81526004018080602001828103825260388152602001806113696038913960400191505060405180910390fd5b604080516001600160a01b038581166024830152604480830186905283518084039091018152606490920183526020820180516001600160e01b03166001600160e01b0319861617815292518251600094606094938a169392918291908083835b6020831061124b5780518252601f19909201916020918201910161122c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146112ad576040519150601f19603f3d011682016040523d82523d6000602084013e6112b2565b606091505b50915091508180156112e05750805115806112e057508080602001905160208110156112dd57600080fd5b50515b61131b5760405162461bcd60e51b815260040180806020018281038252602c8152602001806113a1602c913960400191505060405180910390fd5b505050505050565b60015460408051638abf607760e01b815290516000926001600160a01b031691638abf6077916004808301926020929190829003018186803b1580156106ae57600080fdfe456e657267697377617050616972476f7665726e656450726f78793a20464f5242494444454e2c206e6f742070616972734d616e61676572456e657267697377617050616972476f7665726e656450726f78793a205452414e534645525f4641494c4544456e657267697377617050616972476f7665726e656450726f78793a20464f5242494444454e2c206e6f742061206469726563742063616c6c206f7220612063616c6c2066726f6d20726f75746572a265627a7a7231582010ab97f5e076ea659e9625373254266f417af2b549ad8d90a06eced41c37361264736f6c634300051000326080604052600160075534801561001557600080fd5b506040516108463803806108468339818101604052606081101561003857600080fd5b5080516020820151604090920151600080546001600160a01b039384166001600160a01b03199182161790915560018054948416948216949094179093556002805492909116919092161790556107b2806100946000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c8063651ddd6411610097578063ba94a31511610066578063ba94a31514610250578063c67a02f314610258578063cbaf75de1461027b578063fb6d21d914610283576100f5565b8063651ddd64146101d55780636f26a710146101f9578063aa6ca80814610201578063b70b47811461022f576100f5565b806318243296116100d3578063182432961461016b578063250ae2c5146101a857806341c0e1b5146101b057806351a0f94b146101b8576100f5565b80630902f1ac146100fa57806311efe7d71461013257806312bf833814610151575b600080fd5b61010261028b565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b61014f6004803603602081101561014857600080fd5b50356102b5565b005b610159610379565b60408051918252519081900360200190f35b61014f6004803603606081101561018157600080fd5b5080356001600160701b03908116916020810135909116906040013563ffffffff1661037f565b6101596104a5565b61014f6104ab565b61014f600480360360208110156101ce57600080fd5b503561056d565b6101dd610631565b604080516001600160a01b039092168252519081900360200190f35b6101dd610640565b61020961064f565b604080516001600160a01b03938416815291909216602082015281519081900390910190f35b610237610666565b6040805192835260208301919091528051918290030190f35b6101dd610670565b61014f6004803603604081101561026e57600080fd5b508035906020013561067f565b610159610749565b61015961074f565b6003546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561030257600080fd5b505afa158015610316573d6000803e3d6000fd5b505050506040513d602081101561032c57600080fd5b50516001600160a01b031633146103745760405162461bcd60e51b81526004018080602001828103825260288152602001806107566028913960400191505060405180910390fd5b600755565b60055490565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b1580156103cc57600080fd5b505afa1580156103e0573d6000803e3d6000fd5b505050506040513d60208110156103f657600080fd5b50516001600160a01b0316331461043e5760405162461bcd60e51b81526004018080602001828103825260288152602001806107566028913960400191505060405180910390fd5b6003805463ffffffff909216600160e01b026001600160e01b036001600160701b03948516600160701b026dffffffffffffffffffffffffffff60701b19959096166dffffffffffffffffffffffffffff1990941693909317939093169390931716179055565b60045490565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b1580156104f857600080fd5b505afa15801561050c573d6000803e3d6000fd5b505050506040513d602081101561052257600080fd5b50516001600160a01b0316331461056a5760405162461bcd60e51b81526004018080602001828103825260288152602001806107566028913960400191505060405180910390fd5b33ff5b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b1580156105ba57600080fd5b505afa1580156105ce573d6000803e3d6000fd5b505050506040513d60208110156105e457600080fd5b50516001600160a01b0316331461062c5760405162461bcd60e51b81526004018080602001828103825260288152602001806107566028913960400191505060405180910390fd5b600655565b6000546001600160a01b031681565b6002546001600160a01b031690565b6001546002546001600160a01b0391821692911690565b6004546005549091565b6001546001600160a01b031690565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b1580156106cc57600080fd5b505afa1580156106e0573d6000803e3d6000fd5b505050506040513d60208110156106f657600080fd5b50516001600160a01b0316331461073e5760405162461bcd60e51b81526004018080602001828103825260288152602001806107566028913960400191505060405180910390fd5b600491909155600555565b60065490565b6007549056fe5061697253746f726167653a20464f5242494444454e2c206e6f742070616972734d616e61676572a265627a7a723158209b48971d43b03a4f9eabb759fc8e63a4e35f12c217f923e6a8e91cca940a3e3d64736f6c63430005100032608060405234801561001057600080fd5b5060405161076e38038061076e8339818101604052602081101561003357600080fd5b5051600080546001600160a01b039092166001600160a01b0319909216919091179055610709806100656000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063c4e41b2211610066578063c4e41b2214610163578063da46098c1461016b578063e30443bc146101a1578063f7ea7a3d146101cd578063f8b2cb4f146101ea5761009e565b80630af4187d146100a35780631d79f325146100e35780632d0335ab146101115780633f397ebe1461013757806341c0e1b51461015b575b600080fd5b6100d1600480360360408110156100b957600080fd5b506001600160a01b0381358116916020013516610210565b60408051918252519081900360200190f35b61010f600480360360408110156100f957600080fd5b506001600160a01b03813516906020013561023b565b005b6100d16004803603602081101561012757600080fd5b50356001600160a01b0316610316565b61013f610331565b604080516001600160a01b039092168252519081900360200190f35b61010f610340565b6100d1610402565b61010f6004803603606081101561018157600080fd5b506001600160a01b03813581169160208101359091169060400135610408565b61010f600480360360408110156101b757600080fd5b506001600160a01b0381351690602001356104f3565b61010f600480360360208110156101e357600080fd5b50356105ce565b6100d16004803603602081101561020057600080fd5b50356001600160a01b0316610692565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561028857600080fd5b505afa15801561029c573d6000803e3d6000fd5b505050506040513d60208110156102b257600080fd5b50516001600160a01b031633146102fa5760405162461bcd60e51b81526004018080602001828103825260278152602001806106ae6027913960400191505060405180910390fd5b6001600160a01b03909116600090815260046020526040902055565b6001600160a01b031660009081526004602052604090205490565b6000546001600160a01b031681565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561038d57600080fd5b505afa1580156103a1573d6000803e3d6000fd5b505050506040513d60208110156103b757600080fd5b50516001600160a01b031633146103ff5760405162461bcd60e51b81526004018080602001828103825260278152602001806106ae6027913960400191505060405180910390fd5b33ff5b60035490565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561045557600080fd5b505afa158015610469573d6000803e3d6000fd5b505050506040513d602081101561047f57600080fd5b50516001600160a01b031633146104c75760405162461bcd60e51b81526004018080602001828103825260278152602001806106ae6027913960400191505060405180910390fd5b6001600160a01b0392831660009081526002602090815260408083209490951682529290925291902055565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561054057600080fd5b505afa158015610554573d6000803e3d6000fd5b505050506040513d602081101561056a57600080fd5b50516001600160a01b031633146105b25760405162461bcd60e51b81526004018080602001828103825260278152602001806106ae6027913960400191505060405180910390fd5b6001600160a01b03909116600090815260016020526040902055565b6000809054906101000a90046001600160a01b03166001600160a01b0316638abf60776040518163ffffffff1660e01b815260040160206040518083038186803b15801561061b57600080fd5b505afa15801561062f573d6000803e3d6000fd5b505050506040513d602081101561064557600080fd5b50516001600160a01b0316331461068d5760405162461bcd60e51b81526004018080602001828103825260278152602001806106ae6027913960400191505060405180910390fd5b600355565b6001600160a01b03166000908152600160205260409020549056fe455243323053746f726167653a20464f5242494444454e2c206e6f742070616972734552433230a265627a7a7231582057fb4ce76b5932bc80e5a40dd66698b7d99965e21285e47cb18284cc8f4d375264736f6c63430005100032456e6572676973776170466163746f72793a20616c726561647920696e697469616c697a6564456e6572676973776170466163746f72793a204944454e544943414c5f544f4b454e535f414444524553534553456e6572676973776170466163746f72793a20464f5242494444454e2c206e6f742070726f78795061757361626c653a20526576657274202d20436f646520657865637574696f6e20697320706175736564456e6572676973776170466163746f72793a20464f5242494444454e2c206e6f7420666565546f536574746572a265627a7a72315820f25b1a2902861877d135792cb8eefe91a84b9ffe609ac95550e89f565ba1787d64736f6c63430005100032