Skip to content

Commit

Permalink
Merge pull request #23 from 1inch/feature/oz_5
Browse files Browse the repository at this point in the history
[SC-989][SC-990] Feature/oz 5
  • Loading branch information
ZumZoom authored Dec 21, 2023
2 parents 046c05e + fac8ba0 commit 1f11c11
Show file tree
Hide file tree
Showing 8 changed files with 829 additions and 533 deletions.
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();
}
}
5 changes: 2 additions & 3 deletions contracts/FarmingDelegationPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +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);
farm.transferOwnership(msg.sender);
MultiFarmingPlugin farm = new MultiFarmingPlugin(shareToken, _MAX_FARM_REWARDS, msg.sender);
defaultFarms[msg.sender] = address(farm);
}

Expand All @@ -35,7 +34,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.

39 changes: 20 additions & 19 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.1.0",
"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",
"hardhat-dependency-compiler": "1.1.3"
"@1inch/token-plugins": "1.3.0",
"@1inch/farming": "3.2.0",
"@1inch/solidity-utils": "3.5.5",
"@openzeppelin/contracts": "5.0.1"
},
"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.5.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-dependency-compiler": "1.1.3",
"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

0 comments on commit 1f11c11

Please sign in to comment.