Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Belbix dev #61

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/infrastructure/ControllerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract ControllerV2 is ControllableV3, IController {
/// @dev Contract for holding assets for the Second Stage
address public override investFund;
/// @dev Contract for accumulate TETU rewards for veTETU and weekly distribute them.
address public override veDistributor;
address public veDistributor;
/// @dev Special voter for platform attributes.
address public override platformVoter;

Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/IController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ interface IController {

function investFund() external view returns (address);

function veDistributor() external view returns (address);
// deprecated
// function veDistributor() external view returns (address);

function platformVoter() external view returns (address);

Expand Down
13 changes: 13 additions & 0 deletions contracts/interfaces/IVeDistributorV2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

import "./IVeDistributor.sol";

interface IVeDistributorV2 is IVeDistributor {

function epoch() external view returns (uint);

function lastPaidEpoch(uint veId) external view returns (uint);

}
10 changes: 1 addition & 9 deletions contracts/interfaces/IVeTetu.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ interface IVeTetu is IERC721Metadata {

function balanceOfNFT(uint) external view returns (uint);

function balanceOfNFTAt(uint _tokenId, uint _t) external view returns (uint);

function isApprovedOrOwner(address, uint) external view returns (bool);

function createLockFor(address _token, uint _value, uint _lockDuration, address _to) external returns (uint);
Expand All @@ -49,10 +47,6 @@ interface IVeTetu is IERC721Metadata {

function epoch() external view returns (uint);

function userPointHistory(uint tokenId, uint loc) external view returns (Point memory);

function pointHistory(uint loc) external view returns (Point memory);

function checkpoint() external;

function increaseAmount(address _token, uint _tokenId, uint _value) external;
Expand All @@ -65,7 +59,5 @@ interface IVeTetu is IERC721Metadata {

function abstain(uint tokenId) external;

function totalSupplyAt(uint _block) external view returns (uint);

function totalSupplyAtT(uint timestamp) external view returns (uint);
function totalSupply() external view returns (uint);
}
2 changes: 1 addition & 1 deletion contracts/test/ControllerMinimal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract ControllerMinimal is TetuERC165, IController {
address public override liquidator;
address public override forwarder;
address public override investFund;
address public override veDistributor;
address public veDistributor;
address public override platformVoter;
address[] public override vaults;
mapping(address => bool) public operators;
Expand Down
3 changes: 0 additions & 3 deletions contracts/test/MockPawnshop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ contract MockPawnshop is IERC721Receiver{
function veFlashTransfer(address ve, uint tokenId) external {
IERC721(ve).safeTransferFrom(msg.sender, address(this), tokenId);
require(IVeTetu(ve).balanceOfNFT(tokenId) == 0, "not zero balance");
IVeTetu(ve).totalSupplyAt(block.number);
IVeTetu(ve).checkpoint();
IVeTetu(ve).checkpoint();
IVeTetu(ve).checkpoint();
IVeTetu(ve).checkpoint();
IVeTetu(ve).totalSupplyAt(block.number);
IVeTetu(ve).totalSupplyAt(block.number - 1);
IERC721(ve).safeTransferFrom(address(this), msg.sender, tokenId);
}

Expand Down
142 changes: 71 additions & 71 deletions contracts/tools/BribeDistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,76 @@ import "../interfaces/IERC20.sol";
import "../interfaces/IVeDistributor.sol";

contract BribeDistribution {

string public constant VERSION = "1.0.0";

address public owner;
address public pendingOwner;
address public operator;

IVeDistributor public immutable veDist;
address public immutable token;
uint public round;

constructor(address veDist_, address _token) {
veDist = IVeDistributor(veDist_);
token = _token;
owner = msg.sender;
}

modifier onlyOwner() {
require(msg.sender == owner, "NOT_OWNER");
_;
}

modifier onlyOperator() {
require(msg.sender == operator || msg.sender == owner, "NOT_OPERATOR");
_;
}

function offerOwnership(address newOwner) external onlyOwner {
require(newOwner != address(0), "ZERO_ADDRESS");
pendingOwner = newOwner;
}

function acceptOwnership() external {
require(msg.sender == pendingOwner, "NOT_OWNER");
owner = pendingOwner;
}

function setOperator(address operator_) external onlyOwner {
operator = operator_;
}

////////////////// MAIN LOGIC //////////////////////

function autoNotify() external onlyOperator {
_notify(IERC20(token).balanceOf(msg.sender), round % 2 == 0);
round++;
}

function manualNotify(uint amount, bool fresh) external onlyOperator {
_notify(amount, fresh);
}

function _notify(uint amount, bool fresh) internal {
if (amount != 0) {
IERC20(token).transferFrom(msg.sender, address(this), amount);
}

uint toRewards = IERC20(token).balanceOf(address(this));
require(toRewards != 0, "ZERO_BALANCE");

// assume we will have bribes once per 2 weeks. Need to use a half of the current balance in case of start of new 2 weeks epoch.
if (fresh) {
toRewards = toRewards / 2;
}

IVeDistributor _veDist = veDist;

IERC20(token).transfer(address(_veDist), toRewards);
_veDist.checkpoint();
_veDist.checkpointTotalSupply();
}
//
// string public constant VERSION = "1.0.0";
//
// address public owner;
// address public pendingOwner;
// address public operator;
//
// IVeDistributor public immutable veDist;
// address public immutable token;
// uint public round;
//
// constructor(address veDist_, address _token) {
// veDist = IVeDistributor(veDist_);
// token = _token;
// owner = msg.sender;
// }
//
// modifier onlyOwner() {
// require(msg.sender == owner, "NOT_OWNER");
// _;
// }
//
// modifier onlyOperator() {
// require(msg.sender == operator || msg.sender == owner, "NOT_OPERATOR");
// _;
// }
//
// function offerOwnership(address newOwner) external onlyOwner {
// require(newOwner != address(0), "ZERO_ADDRESS");
// pendingOwner = newOwner;
// }
//
// function acceptOwnership() external {
// require(msg.sender == pendingOwner, "NOT_OWNER");
// owner = pendingOwner;
// }
//
// function setOperator(address operator_) external onlyOwner {
// operator = operator_;
// }
//
// ////////////////// MAIN LOGIC //////////////////////
//
// function autoNotify() external onlyOperator {
// _notify(IERC20(token).balanceOf(msg.sender), round % 2 == 0);
// round++;
// }
//
// function manualNotify(uint amount, bool fresh) external onlyOperator {
// _notify(amount, fresh);
// }
//
// function _notify(uint amount, bool fresh) internal {
// if (amount != 0) {
// IERC20(token).transferFrom(msg.sender, address(this), amount);
// }
//
// uint toRewards = IERC20(token).balanceOf(address(this));
// require(toRewards != 0, "ZERO_BALANCE");
//
// // assume we will have bribes once per 2 weeks. Need to use a half of the current balance in case of start of new 2 weeks epoch.
// if (fresh) {
// toRewards = toRewards / 2;
// }
//
// IVeDistributor _veDist = veDist;
//
// IERC20(token).transfer(address(_veDist), toRewards);
// _veDist.checkpoint();
// _veDist.checkpointTotalSupply();
// }

}
Loading
Loading