Acropolis vs Masonry

Creato Il diff non scade mai
100 rimozioni
266 linee
107 aggiunte
266 linee
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT


pragma solidity 0.6.12;
pragma solidity ^0.8.0;


import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";


import "./utils/ContractGuard.sol";
import "./utils/ContractGuard.sol";
import "./interfaces/IBasisAsset.sol";
import "./interfaces/IBasisAsset.sol";
import "./interfaces/ITreasury.sol";
import "./interfaces/ITreasury.sol";


contract ShareWrapper {
contract ShareWrapper {
using SafeMath for uint256;
using SafeMath for uint256;
using SafeERC20 for IERC20;
using SafeERC20 for IERC20;


IERC20 public share;
IERC20 public share;


uint256 private _totalSupply;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
mapping(address => uint256) private _balances;


function totalSupply() public view returns (uint256) {
function totalSupply() public view returns (uint256) {
return _totalSupply;
return _totalSupply;
}
}


function balanceOf(address account) public view returns (uint256) {
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
return _balances[account];
}
}


function stake(uint256 amount) public virtual {
function stake(uint256 amount) public virtual {
_totalSupply = _totalSupply.add(amount);
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
share.safeTransferFrom(msg.sender, address(this), amount);
share.safeTransferFrom(msg.sender, address(this), amount);
}
}


function withdraw(uint256 amount) public virtual {
function withdraw(uint256 amount) public virtual {
uint256 masonShare = _balances[msg.sender];
uint256 andrasShare = _balances[msg.sender];
require(masonShare >= amount, "Masonry: withdraw request greater than staked amount");
require(andrasShare >= amount, "Acropolis: withdraw request greater than staked amount");
_totalSupply = _totalSupply.sub(amount);
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = masonShare.sub(amount);
_balances[msg.sender] = andrasShare.sub(amount);
share.safeTransfer(msg.sender, amount);
share.safeTransfer(msg.sender, amount);
}
}
}
}


/*
/*
______ __ _______
__________ .___ ___________.__
/_ __/___ ____ ___ / /_ / ____(_)___ ____ _____ ________
\______ \_____ ______ ____ __| _/ \_ _____/|__| ____ _____ ____ ____ ____
/ / / __ \/ __ `__ \/ __ \ / /_ / / __ \/ __ `/ __ \/ ___/ _ \
| | _/\__ \ / ___/_/ __ \ / __ | | __) | | / \ \__ \ / \ _/ ___\_/ __ \
/ / / /_/ / / / / / / /_/ / / __/ / / / / / /_/ / / / / /__/ __/
| | \ / __ \_ \___ \ \ ___/ / /_/ | | \ | || | \ / __ \_| | \\ \___\ ___/
/_/ \____/_/ /_/ /_/_.___/ /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/
|______ /(____ //____ > \___ >\____ | \___ / |__||___| /(____ /|___| / \___ >\___ >

\/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
http://tomb.finance
*/
*/
contract Masonry is ShareWrapper, ContractGuard {
contract Acropolis is ShareWrapper, ContractGuard {
using SafeERC20 for IERC20;
using SafeERC20 for IERC20;
using Address for address;
using Address for address;
using SafeMath for uint256;
using SafeMath for uint256;


/* ========== DATA STRUCTURES ========== */
/* ========== DATA STRUCTURES ========== */


struct Masonseat {
struct Ecclesiaseat {
uint256 lastSnapshotIndex;
uint256 lastSnapshotIndex;
uint256 rewardEarned;
uint256 rewardEarned;
uint256 epochTimerStart;
uint256 epochTimerStart;
}
}


struct MasonrySnapshot {
struct AcropolisSnapshot {
uint256 time;
uint256 time;
uint256 rewardReceived;
uint256 rewardReceived;
uint256 rewardPerShare;
uint256 rewardPerShare;
}
}


/* ========== STATE VARIABLES ========== */
/* ========== STATE VARIABLES ========== */


// governance
// governance
address public operator;
address public operator;


// flags
// flags
bool public initialized = false;
bool public initialized = false;


IERC20 public tomb;
IERC20 public based;
ITreasury public treasury;
ITreasury public treasury;


mapping(address => Masonseat) public masons;
mapping(address => Ecclesiaseat) public demos;
MasonrySnapshot[] public masonryHistory;
AcropolisSnapshot[] public acropolisHistory;


uint256 public withdrawLockupEpochs;
uint256 public withdrawLockupEpochs;
uint256 public rewardLockupEpochs;
uint256 public rewardLockupEpochs;


/* ========== EVENTS ========== */
/* ========== EVENTS ========== */


event Initialized(address indexed executor, uint256 at);
event Initialized(address indexed executor, uint256 at);
event Staked(address indexed user, uint256 amount);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
event RewardPaid(address indexed user, uint256 reward);
event RewardAdded(address indexed user, uint256 reward);
event RewardAdded(address indexed user, uint256 reward);


/* ========== Modifiers =============== */
/* ========== Modifiers =============== */


modifier onlyOperator() {
modifier onlyOperator() {
require(operator == msg.sender, "Masonry: caller is not the operator");
require(operator == msg.sender, "Acropolis: caller is not the operator");
_;
_;
}
}


modifier masonExists {
modifier andrasExists {
require(balanceOf(msg.sender) > 0, "Masonry: The mason does not exist");
require(balanceOf(msg.sender) > 0, "Acropolis: The andras does not exist");
_;
_;
}
}


modifier updateReward(address mason) {
modifier updateReward(address andras) {
if (mason != address(0)) {
if (andras != address(0)) {
Masonseat memory seat = masons[mason];
Ecclesiaseat memory seat = demos[andras];
seat.rewardEarned = earned(mason);
seat.rewardEarned = earned(andras);