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

[SC-989][SC-990] Feature/oz 5 #23

Merged
merged 12 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
16 changes: 4 additions & 12 deletions contracts/DelegatedShare.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ contract DelegatedShare is IDelegatedShare, ERC20Plugins {
error ApproveDisabled();
error TransferDisabled();
error NotOwnerPlugin();

/// @notice The address of the owner plugin.
address immutable public ownerPlugin;
address immutable public OWNER_PLUGIN;

/// @dev Throws if called by any account other than the ownerPlugin.
modifier onlyOwnerPlugin {
if (msg.sender != ownerPlugin) revert NotOwnerPlugin();
if (msg.sender != OWNER_PLUGIN) revert NotOwnerPlugin();
_;
}

Expand All @@ -32,7 +32,7 @@ contract DelegatedShare is IDelegatedShare, ERC20Plugins {
uint256 maxUserPlugins_,
uint256 pluginCallGasLimit_
) ERC20(name_, symbol_) ERC20Plugins(maxUserPlugins_, pluginCallGasLimit_) {
ownerPlugin = msg.sender;
OWNER_PLUGIN = msg.sender;
}

/// @notice Add default farm for an account if it doesn't exist.
Expand Down Expand Up @@ -75,12 +75,4 @@ contract DelegatedShare is IDelegatedShare, ERC20Plugins {
function transferFrom(address /* from */, address /* to */, uint256 /* amount */) public pure override(IERC20, ERC20) returns (bool) {
revert TransferDisabled();
}

function increaseAllowance(address /* spender */, uint256 /* addedValue */) public pure override returns (bool) {
revert ApproveDisabled();
}

function decreaseAllowance(address /* spender */, uint256 /* subtractedValue */) public pure override returns (bool) {
revert ApproveDisabled();
}
}
10 changes: 1 addition & 9 deletions contracts/DelegationPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract DelegationPlugin is IDelegationPlugin, Plugin, ERC20 {
if (prevDelegatee != delegatee) {
delegated[msg.sender] = delegatee;
emit Delegated(msg.sender, delegatee);
uint256 balance = IERC20Plugins(token).pluginBalanceOf(address(this), msg.sender);
uint256 balance = IERC20Plugins(TOKEN).pluginBalanceOf(address(this), msg.sender);
if (balance > 0) {
_updateBalances(msg.sender, msg.sender, prevDelegatee, delegatee, balance);
}
Expand Down Expand Up @@ -64,12 +64,4 @@ contract DelegationPlugin is IDelegationPlugin, Plugin, ERC20 {
function approve(address /* spender */, uint256 /* amount */) public pure override(ERC20, IERC20) returns (bool) {
revert ApproveDisabled();
}

function increaseAllowance(address /* spender */, uint256 /* addedValue */) public pure override returns (bool) {
revert ApproveDisabled();
}

function decreaseAllowance(address /* spender */, uint256 /* subtractedValue */) public pure override returns (bool) {
revert ApproveDisabled();
}
}
4 changes: 2 additions & 2 deletions contracts/FarmingDelegationPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract FarmingDelegationPlugin is IFarmingDelegationPlugin, TokenizedDelegatio

function register(string memory name_, string memory symbol_) public override(ITokenizedDelegationPlugin, TokenizedDelegationPlugin) returns(IDelegatedShare shareToken) {
shareToken = super.register(name_, symbol_);
MultiFarmingPlugin farm = new MultiFarmingPlugin(shareToken, _MAX_FARM_REWARDS);
MultiFarmingPlugin farm = new MultiFarmingPlugin(shareToken, _MAX_FARM_REWARDS, address(this));
farm.transferOwnership(msg.sender);
ZumZoom marked this conversation as resolved.
Show resolved Hide resolved
defaultFarms[msg.sender] = address(farm);
}
Expand All @@ -35,7 +35,7 @@ contract FarmingDelegationPlugin is IFarmingDelegationPlugin, TokenizedDelegatio
}

function setDefaultFarm(address farm) external onlyRegistered {
if (farm != address(0) && IPlugin(farm).token() != registration[msg.sender]) revert DefaultFarmTokenMismatch();
if (farm != address(0) && IPlugin(farm).TOKEN() != registration[msg.sender]) revert DefaultFarmTokenMismatch();
defaultFarms[msg.sender] = farm;
emit DefaultFarmSet(farm);
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/TokenizedDelegationPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ contract TokenizedDelegationPlugin is ITokenizedDelegationPlugin, DelegationPlug
error NotRegisteredDelegatee();
error AlreadyRegistered();

uint256 public immutable maxSharePlugins;
uint256 public immutable sharePluginGasLimit;
uint256 public immutable MAX_SHARE_PLUGINS;
uint256 public immutable SHARE_PLUGIN_GAS_LIMIT;

mapping(address => IDelegatedShare) public registration;

Expand All @@ -27,8 +27,8 @@ contract TokenizedDelegationPlugin is ITokenizedDelegationPlugin, DelegationPlug
}

constructor(string memory name_, string memory symbol_, IERC20Plugins token_, uint256 maxSharePlugins_, uint256 sharePluginGasLimit_) DelegationPlugin(name_, symbol_, token_) {
maxSharePlugins = maxSharePlugins_;
sharePluginGasLimit = sharePluginGasLimit_;
MAX_SHARE_PLUGINS = maxSharePlugins_;
SHARE_PLUGIN_GAS_LIMIT = sharePluginGasLimit_;
}

function delegate(address delegatee) public virtual override(IDelegationPlugin, DelegationPlugin) {
Expand All @@ -37,7 +37,7 @@ contract TokenizedDelegationPlugin is ITokenizedDelegationPlugin, DelegationPlug
}

function register(string memory name_, string memory symbol_) public virtual onlyNotRegistered returns(IDelegatedShare shareToken) {
shareToken = new DelegatedShare(name_, symbol_, maxSharePlugins, sharePluginGasLimit);
shareToken = new DelegatedShare(name_, symbol_, MAX_SHARE_PLUGINS, SHARE_PLUGIN_GAS_LIMIT);
registration[msg.sender] = shareToken;
emit RegisterDelegatee(msg.sender);
}
Expand Down
11 changes: 5 additions & 6 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ require('@nomicfoundation/hardhat-chai-matchers');
require('solidity-coverage');
require('hardhat-dependency-compiler');
require('hardhat-deploy');
require('hardhat-tracer');
require('hardhat-gas-reporter');
require('dotenv').config();
const { Networks, getNetwork } = require('@1inch/solidity-utils/hardhat-setup');

const { networks, etherscan } = require('./hardhat.networks');
const { networks, etherscan } = (new Networks()).registerAll();

module.exports = {
etherscan,
solidity: {
version: '0.8.19',
version: '0.8.23',
settings: {
optimizer: {
enabled: true,
runs: 1000000,
},
evmVersion: networks[getNetwork()]?.hardfork || 'shanghai',
viaIR: true,
},
},
Expand All @@ -27,10 +30,6 @@ module.exports = {
default: 0,
},
},
gasReporter: {
enable: true,
currency: 'USD',
},
dependencyCompiler: {
paths: [
'@1inch/token-plugins/contracts/mocks/ERC20PluginsMock.sol',
Expand Down
88 changes: 0 additions & 88 deletions hardhat.networks.js

This file was deleted.

37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1inch/delegating",
"version": "1.0.1",
"version": "1.0.2",
"description": "Set of contracts for delegating incentives",
"homepage": "https://github.com/1inch/delegating#readme",
"author": "1inch",
Expand All @@ -14,30 +14,31 @@
},
"license": "MIT",
"dependencies": {
"@1inch/token-plugins": "1.1.2",
"@1inch/farming": "3.0.2",
"@1inch/solidity-utils": "3.0.1",
"@openzeppelin/contracts": "4.9.2",
"@1inch/token-plugins": "https://github.com/1inch/token-plugins.git#feature/bump-solidity",
"@1inch/farming": "https://github.com/1inch/farming.git#feature/bump-solidity",
ZumZoom marked this conversation as resolved.
Show resolved Hide resolved
"@1inch/solidity-utils": "3.5.5",
"@openzeppelin/contracts": "5.0.1",
"hardhat-dependency-compiler": "1.1.3"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "2.0.1",
"@nomicfoundation/hardhat-ethers": "3.0.4",
"@nomicfoundation/hardhat-verify": "1.0.4",
"chai": "4.3.7",
"@nomicfoundation/hardhat-chai-matchers": "2.0.2",
"@nomicfoundation/hardhat-ethers": "3.0.5",
"@nomicfoundation/hardhat-verify": "2.0.2",
"chai": "4.3.10",
"dotenv": "16.3.1",
"eslint": "8.45.0",
"eslint": "8.56.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-n": "16.0.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-n": "16.4.0",
"eslint-plugin-promise": "6.1.1",
"ethers": "6.6.5",
"hardhat": "2.17.0",
"hardhat-deploy": "0.11.34",
"ethers": "6.9.0",
"hardhat": "2.19.2",
"hardhat-deploy": "0.11.45",
"hardhat-gas-reporter": "1.0.9",
"rimraf": "5.0.1",
"solhint": "3.4.1",
"solidity-coverage": "0.8.4"
"hardhat-tracer": "2.7.0",
"rimraf": "5.0.5",
"solhint": "3.6.2",
"solidity-coverage": "0.8.5"
},
"scripts": {
"test": "hardhat test --parallel",
Expand Down
Loading
Loading