Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Pavlov authored and andrew528i committed Aug 10, 2022
1 parent 8c9c406 commit 3ac2428
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 266 deletions.
2 changes: 1 addition & 1 deletion abi/IPool.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
},
{
"inputs": [],
"name": "receiveMEV",
"name": "receiveFees",
"outputs": [],
"stateMutability": "payable",
"type": "function"
Expand Down
41 changes: 0 additions & 41 deletions abi/IPoolMEV.json

This file was deleted.

13 changes: 0 additions & 13 deletions abi/IRewardEthToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_poolTips",
"type": "address"
}
],
"name": "setPoolMEV",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion abi/Pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@
},
{
"inputs": [],
"name": "receiveMEV",
"name": "receiveFees",
"outputs": [],
"stateMutability": "payable",
"type": "function"
Expand Down
121 changes: 0 additions & 121 deletions abi/PoolMEV.json

This file was deleted.

13 changes: 0 additions & 13 deletions abi/RewardEthToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,19 +850,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_poolMEV",
"type": "address"
}
],
"name": "setPoolMEV",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
20 changes: 20 additions & 0 deletions contracts/interfaces/IFeesEscrow.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.7.5;

/**
* @dev Interface of the FeesEscrow contract.
*/
interface IFeesEscrow {
/**
* @dev Event for tracking fees withdrawals to Pool contract.
* @param amount - the number of fees.
*/
event FeesTransferred(uint256 amount);

/**
* @dev Function is used to transfer accumulated rewards to .
* Can only be executed by the account with admin role.
*/
function transferToPool() external returns (uint256);
}
5 changes: 4 additions & 1 deletion contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ interface IPool {
*/
function validatorRegistration() external view returns (IDepositContract);

function receiveMEV() external payable;
/**
* @dev Function for receiving native tokens without minting sETH.
*/
function receiveFees() external payable;

/**
* @dev Function for staking ether to the pool to the different tokens' recipient.
Expand Down
27 changes: 0 additions & 27 deletions contracts/interfaces/IPoolMEV.sol

This file was deleted.

6 changes: 0 additions & 6 deletions contracts/interfaces/IRewardEthToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ interface IRewardEthToken is IERC20Upgradeable {
*/
function setProtocolFeeRecipient(address recipient) external;

/**
* @dev Function for changing the poolMEV's address.
* @param _poolTips - new protocol fee recipient's address.
*/
function setPoolMEV(address _poolTips) external;

/**
* @dev Function for getting protocol fee. The percentage fee users pay from their reward for using the pool service.
*/
Expand Down
18 changes: 8 additions & 10 deletions contracts/pool/PoolMEV.sol → contracts/pool/FeesEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pragma solidity 0.7.5;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "../interfaces/IPool.sol";
import "../interfaces/IPoolMEV.sol";
import "../interfaces/IFeesEscrow.sol";

contract PoolMEV is IPoolMEV, Ownable {
contract FeesEscrow is IFeesEscrow, Ownable {
address public pool;

constructor(address _pool) Ownable() {
Expand All @@ -19,17 +19,15 @@ contract PoolMEV is IPoolMEV, Ownable {
_;
}

function setPool(address _pool) onlyOwner external override {
pool = _pool;
}

function transferToPool() public override {
function transferToPool() public override returns (uint256) {
uint256 balance = address(this).balance;
require(balance > 0, "PoolMEV: zero balance");
require(balance > 0, "FeesEscrow: zero balance");

IPool(pool).receiveFees{value: balance}();

IPool(pool).receiveMEV{value: balance}();
emit FeesTransferred(balance);

emit MEVTransferred(pool, balance);
return balance;
}

receive() external payable {}
Expand Down
4 changes: 2 additions & 2 deletions contracts/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ contract Pool is IPool, OwnablePausableUpgradeable {
}

/**
* @dev See {IPool-stakeOnBehalf}.
* @dev See {IPool-receiveFees}.
*/
function receiveMEV() public payable override {}
function receiveFees() public payable override {}

/**
* @dev Function for staking ETH using transfer.
Expand Down
17 changes: 5 additions & 12 deletions contracts/tokens/RewardEthToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "../interfaces/IStakedEthToken.sol";
import "../interfaces/IRewardEthToken.sol";
import "../interfaces/IMerkleDistributor.sol";
import "../interfaces/IOracles.sol";
import "../interfaces/IPoolMEV.sol";
import "../interfaces/IFeesEscrow.sol";
import "./ERC20PermitUpgradeable.sol";

/**
Expand All @@ -28,8 +28,8 @@ contract RewardEthToken is IRewardEthToken, OwnablePausableUpgradeable, ERC20Per
// @dev Address of the Oracles contract.
address private oracles;

// @dev Address of the PoolMEV contract.
address private poolMEV;
// @dev Address of the FeesEscrow contract.
address private feesEscrow;

// @dev Maps account address to its reward checkpoint.
mapping(address => Checkpoint) public override checkpoints;
Expand Down Expand Up @@ -92,13 +92,6 @@ contract RewardEthToken is IRewardEthToken, OwnablePausableUpgradeable, ERC20Per
emit ProtocolFeeRecipientUpdated(recipient);
}

/**
* @dev See {IRewardEthToken-setPoolMEV}.
*/
function setPoolMEV(address _poolMEV) external onlyAdmin override {
poolMEV = _poolMEV;
}

/**
* @dev See {IRewardEthToken-setProtocolFee}.
*/
Expand Down Expand Up @@ -224,8 +217,8 @@ contract RewardEthToken is IRewardEthToken, OwnablePausableUpgradeable, ERC20Per
function updateTotalRewards(uint256 newTotalRewards) external override {
require(msg.sender == oracles, "RewardEthToken: access denied");

uint256 periodRewards = newTotalRewards.sub(totalRewards).add(poolMEV.balance);
IPoolMEV(poolMEV).transferToPool();
uint256 feesAmount = IFeesEscrow(feesEscrow).transferToPool();
uint256 periodRewards = newTotalRewards.sub(totalRewards).add(feesAmount);

if (periodRewards == 0) {
lastUpdateBlockNumber = block.number;
Expand Down
Loading

0 comments on commit 3ac2428

Please sign in to comment.