From 7f0e326c5f41ba4434cb18117dc461641176c21a Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 16:22:29 +0300 Subject: [PATCH 1/9] ignore VSCode settings --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d959af7..cd9932e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,5 +35,8 @@ types/* coverage coverage.json +# IDE config +.vscode/ + # MacOS junk .DS_Store \ No newline at end of file From a54edb1186a222dba4b243514b0ef790de99a42c Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 16:31:48 +0300 Subject: [PATCH 2/9] DD-1493 Fix MixBytes MAJOR 1 --- contracts/modules/staking/StakingPool.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/modules/staking/StakingPool.sol b/contracts/modules/staking/StakingPool.sol index ab7ae72..917c64f 100644 --- a/contracts/modules/staking/StakingPool.sol +++ b/contracts/modules/staking/StakingPool.sol @@ -136,8 +136,8 @@ contract StakingPool is StakingPoolBase { expectedBalance = expectedBalance.add(totalStaked()); } uint256 actualBalance = IERC20(rt).balanceOf(address(this)); - uint256 distributionAmount = actualBalance.sub(expectedBalance); if(actualBalance > expectedBalance) { + uint256 distributionAmount = actualBalance.sub(expectedBalance); uint256 totalShares = totalStaked(); rewards[rt].distributions.push(RewardDistribution({ totalShares: totalShares, From 38c4305aaa046218938546e5bc248f6cc5cc252e Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 16:39:49 +0300 Subject: [PATCH 3/9] DD-1493 Fix MixBytes MAJOR 2 --- contracts/modules/reward/RewardVestingModule.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/modules/reward/RewardVestingModule.sol b/contracts/modules/reward/RewardVestingModule.sol index 296acd8..9533df8 100644 --- a/contracts/modules/reward/RewardVestingModule.sol +++ b/contracts/modules/reward/RewardVestingModule.sol @@ -104,6 +104,7 @@ contract RewardVestingModule is Module, RewardManagerRole { RewardInfo storage ri = r.rewardInfo[token]; uint256 epochsLength = ri.epochs.length; require(epochsLength > 0, "RewardVesting: protocol or token not registered"); + if(epochsLength == 1) return; // We can never claim from epoch 0 Epoch storage lastEpoch = ri.epochs[epochsLength-1]; uint256 previousClaim = ri.lastClaim; @@ -129,7 +130,7 @@ contract RewardVestingModule is Module, RewardManagerRole { break; } } - if(ep.end > block.timestamp) { + if(i > 0 && ep.end > block.timestamp) { //Half-claim uint256 epStart = ri.epochs[i-1].end; uint256 claimStart = (previousClaim > epStart)?previousClaim:epStart; From f64d86a868e5c8fec537aae57d3fc090c486cac5 Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 16:43:15 +0300 Subject: [PATCH 4/9] DD-1493 Fix MixBytes WARNINGS 1 --- contracts/modules/staking/StakingPoolBase.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/modules/staking/StakingPoolBase.sol b/contracts/modules/staking/StakingPoolBase.sol index 6ae7a07..debaf40 100644 --- a/contracts/modules/staking/StakingPoolBase.sol +++ b/contracts/modules/staking/StakingPoolBase.sol @@ -337,7 +337,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { for(uint256 i=personalStakeIndex; i Date: Wed, 16 Dec 2020 16:47:10 +0300 Subject: [PATCH 5/9] DD-1493 Fix MixBytes WARNINGS 2 --- contracts/modules/staking/StakingPoolBase.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/modules/staking/StakingPoolBase.sol b/contracts/modules/staking/StakingPoolBase.sol index debaf40..f35643e 100644 --- a/contracts/modules/staking/StakingPoolBase.sol +++ b/contracts/modules/staking/StakingPoolBase.sol @@ -480,13 +480,6 @@ contract StakingPoolBase is Module, IERC900, CapperRole { personalStake.actualAmount == _amount, "The unstake amount does not match the current stake"); - // Transfer the staked tokens from this contract back to the sender - // Notice that we are using transfer instead of transferFrom here, so - // no approval is needed beforehand. - require( - stakingToken.transfer(_msgSender(), _amount), - "Unable to withdraw stake"); - stakeHolders[personalStake.stakedFor].totalStakedFor = stakeHolders[personalStake.stakedFor] .totalStakedFor.sub(personalStake.actualAmount); @@ -495,6 +488,13 @@ contract StakingPoolBase is Module, IERC900, CapperRole { totalStakedAmount = totalStakedAmount.sub(_amount); + // Transfer the staked tokens from this contract back to the sender + // Notice that we are using transfer instead of transferFrom here, so + // no approval is needed beforehand. + require( + stakingToken.transfer(_msgSender(), _amount), + "Unable to withdraw stake"); + emit Unstaked( personalStake.stakedFor, _amount, From fe1e4da1e8b595e9a9a78daf7031074c655e67bf Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 16:49:14 +0300 Subject: [PATCH 6/9] DD-1493 Fix MixBytes WARNINGS 3 --- contracts/modules/staking/StakingPoolBase.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/modules/staking/StakingPoolBase.sol b/contracts/modules/staking/StakingPoolBase.sol index f35643e..9eac796 100644 --- a/contracts/modules/staking/StakingPoolBase.sol +++ b/contracts/modules/staking/StakingPoolBase.sol @@ -108,7 +108,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { modifier isUserCapEnabledForStakeFor(uint256 stake) { if (stakingCapEnabled && !(vipUserEnabled && isVipUser[_msgSender()])) { - require((stakingCap > totalStaked() && (stakingCap-totalStaked() >= stake)), "StakingModule: stake exeeds staking cap"); + require((stakingCap > totalStaked() && (stakingCap-totalStaked() >= stake)), "StakingPoolBase: stake exeeds staking cap"); } if(userCapEnabled) { @@ -124,7 +124,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { } } - require(cap >= stake, "StakingModule: stake exeeds cap"); + require(cap >= stake, "StakingPoolBase: stake exeeds cap"); cap = cap.sub(stake); userCap[_msgSender()] = cap; emit UserCapChanged(_msgSender(), cap); @@ -200,7 +200,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { } function setUserCap(address[] memory users, uint256[] memory caps) public onlyCapper { - require(users.length == caps.length, "SavingsModule: arrays length not match"); + require(users.length == caps.length, "StakingPoolBase: arrays length not match"); for(uint256 i=0; i < users.length; i++) { userCap[users[i]] = caps[i]; emit UserCapChanged(users[i], caps[i]); From 537975390def3998257a9bd14c33036a4617eeff Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Wed, 16 Dec 2020 18:04:24 +0300 Subject: [PATCH 7/9] DD-1493 Fix MixBytes COMMENTS 1 --- contracts/modules/staking/StakingPoolBase.sol | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/contracts/modules/staking/StakingPoolBase.sol b/contracts/modules/staking/StakingPoolBase.sol index 9eac796..d28f95f 100644 --- a/contracts/modules/staking/StakingPoolBase.sol +++ b/contracts/modules/staking/StakingPoolBase.sol @@ -70,6 +70,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { uint256 public coeffScore; + uint256 private _guardCounter; // See OpenZeppelin ReentrancyGuard. Copied here to allow upgrade of already deployed contracts event VipUserEnabledChange(bool enabled); @@ -89,6 +90,18 @@ contract StakingPoolBase is Module, IERC900, CapperRole { event setLockInDuration(uint256 defaultLockInDuration); event CoeffScoreUpdated(uint256 coeff); + + /** + * @dev Prevents a contract from calling itself, directly or indirectly. + * See OpenZeppelin ReentrancyGuard + */ + modifier nonReentrant() { + _guardCounter += 1; + uint256 localCounter = _guardCounter; + _; + require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); + } + /** * @dev Modifier that checks that this contract can transfer tokens from the * balance in the stakingToken contract for the given address. @@ -292,7 +305,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { * @param _amount uint256 the amount of tokens to stake * @param _data bytes optional data to include in the Stake event */ - function stake(uint256 _amount, bytes memory _data) public isUserCapEnabledForStakeFor(_amount) { + function stake(uint256 _amount, bytes memory _data) public nonReentrant isUserCapEnabledForStakeFor(_amount) { createStake( _msgSender(), _amount, @@ -307,7 +320,7 @@ contract StakingPoolBase is Module, IERC900, CapperRole { * @param _amount uint256 the amount of tokens to stake * @param _data bytes optional data to include in the Stake event */ - function stakeFor(address _user, uint256 _amount, bytes memory _data) public checkUserCapDisabled { + function stakeFor(address _user, uint256 _amount, bytes memory _data) public nonReentrant checkUserCapDisabled { createStake( _user, _amount, @@ -502,5 +515,5 @@ contract StakingPoolBase is Module, IERC900, CapperRole { _data); } - uint256[49] private ______gap; + uint256[48] private ______gap; } \ No newline at end of file From 8062eca4769441507f7a867dc33c03c889a7a169 Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Thu, 17 Dec 2020 10:14:47 +0300 Subject: [PATCH 8/9] Add prettier and update ABIs --- .prettierrc | 3 + .solhint.json | 4 +- abi/APRWithPoolOracle.json | 299 +++++++++ abi/APRWithPoolOracleStub.json | 299 +++++++++ abi/AToken.json | 17 + abi/ATokenStub.json | 466 ++++++++++++++ abi/Aave.json | 27 + abi/AaveStub.json | 190 ++++++ abi/AccessModule.json | 121 +++- abi/CallExecutor.json | 106 ++++ abi/Compound.json | 59 ++ abi/DyDx.json | 148 +++++ abi/DyDxStub.json | 300 +++++++++ abi/Fulcrum.json | 75 +++ abi/FulcrumStub.json | 504 +++++++++++++++ abi/IAccessModule.json | 21 + abi/IEarnAPRWithPool.json | 797 ++++++++++++++++++++++++ abi/IIEarnManager.json | 43 ++ abi/ILendingPoolAddressesProvider.json | 17 + abi/IUniswapAPR.json | 69 +++ abi/IUniswapFactory.json | 23 + abi/IUniswapROI.json | 28 + abi/IYToken.json | 32 + abi/InvestingModule.json | 9 + abi/LendingPoolAddressesProvider.json | 32 + abi/ReentrancyGuard.json | 8 + abi/SavingsModule.json | 29 +- abi/Structs.json | 1 + abi/yDAI.json | 807 +++++++++++++++++++++++++ package.json | 7 +- yarn.lock | 82 +++ 31 files changed, 4601 insertions(+), 22 deletions(-) create mode 100644 .prettierrc create mode 100644 abi/APRWithPoolOracle.json create mode 100644 abi/APRWithPoolOracleStub.json create mode 100644 abi/AToken.json create mode 100644 abi/ATokenStub.json create mode 100644 abi/Aave.json create mode 100644 abi/AaveStub.json create mode 100644 abi/CallExecutor.json create mode 100644 abi/Compound.json create mode 100644 abi/DyDx.json create mode 100644 abi/DyDxStub.json create mode 100644 abi/Fulcrum.json create mode 100644 abi/FulcrumStub.json create mode 100644 abi/IEarnAPRWithPool.json create mode 100644 abi/IIEarnManager.json create mode 100644 abi/ILendingPoolAddressesProvider.json create mode 100644 abi/IUniswapAPR.json create mode 100644 abi/IUniswapFactory.json create mode 100644 abi/IUniswapROI.json create mode 100644 abi/IYToken.json create mode 100644 abi/LendingPoolAddressesProvider.json create mode 100644 abi/ReentrancyGuard.json create mode 100644 abi/Structs.json create mode 100644 abi/yDAI.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..d1ce8f3 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "printWidth": 180 +} \ No newline at end of file diff --git a/.solhint.json b/.solhint.json index 471ff62..6788692 100644 --- a/.solhint.json +++ b/.solhint.json @@ -1,5 +1,6 @@ { "extends": "solhint:default", + "plugins": ["prettier"], "rules": { "avoid-low-level-calls": "off", "avoid-tx-origin": "warn", @@ -16,6 +17,7 @@ "quotes": ["error", "double"], "separate-by-one-line-in-contract": "error", "space-after-comma": "error", - "statement-indent": "error" + "statement-indent": "error", + "prettier/prettier": "error" } } \ No newline at end of file diff --git a/abi/APRWithPoolOracle.json b/abi/APRWithPoolOracle.json new file mode 100644 index 0000000..f96cb62 --- /dev/null +++ b/abi/APRWithPoolOracle.json @@ -0,0 +1,299 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getDDEXAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getDDEXAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getLENDFAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getLENDFAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getCompoundAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getCompoundAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getFulcrumAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getFulcrumAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + } + ], + "name": "getDyDxAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getDyDxAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAaveCore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getAaveAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getAaveAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/APRWithPoolOracleStub.json b/abi/APRWithPoolOracleStub.json new file mode 100644 index 0000000..f96cb62 --- /dev/null +++ b/abi/APRWithPoolOracleStub.json @@ -0,0 +1,299 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getDDEXAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getDDEXAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getLENDFAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getLENDFAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getCompoundAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getCompoundAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getFulcrumAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getFulcrumAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + } + ], + "name": "getDyDxAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getDyDxAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAaveCore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getAaveAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getAaveAPRAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/AToken.json b/abi/AToken.json new file mode 100644 index 0000000..c2696cd --- /dev/null +++ b/abi/AToken.json @@ -0,0 +1,17 @@ +[ + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/ATokenStub.json b/abi/ATokenStub.json new file mode 100644 index 0000000..acbbac0 --- /dev/null +++ b/abi/ATokenStub.json @@ -0,0 +1,466 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ownerMint", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/Aave.json b/abi/Aave.json new file mode 100644 index 0000000..6fd437f --- /dev/null +++ b/abi/Aave.json @@ -0,0 +1,27 @@ +[ + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "_referralCode", + "type": "uint16" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/AaveStub.json b/abi/AaveStub.json new file mode 100644 index 0000000..29e6187 --- /dev/null +++ b/abi/AaveStub.json @@ -0,0 +1,190 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + } + ], + "name": "createAToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_reserve", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getLendingPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getLendingPoolCore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/AccessModule.json b/abi/AccessModule.json index 71a48bd..0ef0e87 100644 --- a/abi/AccessModule.json +++ b/abi/AccessModule.json @@ -111,14 +111,28 @@ }, { "anonymous": false, - "inputs": [], - "name": "WhitelistDisabled", + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "WhitelistForAllStatusChange", "type": "event" }, { "anonymous": false, - "inputs": [], - "name": "WhitelistEnabled", + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "WhitelistForIntermediateSendersStatusChange", "type": "event" }, { @@ -291,6 +305,27 @@ "stateMutability": "view", "type": "function" }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "name": "maxGasLeft", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, { "constant": true, "inputs": [], @@ -438,7 +473,22 @@ { "constant": true, "inputs": [], - "name": "whitelistEnabled", + "name": "whitelistEnabledForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "whitelistEnabledForIntermediateSenders", "outputs": [ { "internalType": "bool", @@ -476,8 +526,14 @@ }, { "constant": false, - "inputs": [], - "name": "enableWhitelist", + "inputs": [ + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "setWhitelistForAll", "outputs": [], "payable": false, "stateMutability": "nonpayable", @@ -485,13 +541,60 @@ }, { "constant": false, - "inputs": [], - "name": "disableWhitelist", + "inputs": [ + { + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "setWhitelistForIntermediateSenders", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "internalType": "enum IAccessModule.Operation", + "name": "operation", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "setMaxGasLeft", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "enum IAccessModule.Operation", + "name": "operation", + "type": "uint8" + } + ], + "name": "getMaxGasLeft", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, { "constant": true, "inputs": [ diff --git a/abi/CallExecutor.json b/abi/CallExecutor.json new file mode 100644 index 0000000..bd1f1e6 --- /dev/null +++ b/abi/CallExecutor.json @@ -0,0 +1,106 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "calls", + "outputs": [ + { + "internalType": "address payable", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "clearCalls", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address payable", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "addCall", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "idx", + "type": "uint256" + }, + { + "internalType": "address payable", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "setCall", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "execute", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/Compound.json b/abi/Compound.json new file mode 100644 index 0000000..99fca75 --- /dev/null +++ b/abi/Compound.json @@ -0,0 +1,59 @@ +[ + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "redeemTokens", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "exchangeRateStored", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/DyDx.json b/abi/DyDx.json new file mode 100644 index 0000000..8281de7 --- /dev/null +++ b/abi/DyDx.json @@ -0,0 +1,148 @@ +[ + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "internalType": "struct Structs.Info", + "name": "account", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + } + ], + "name": "getAccountWei", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "sign", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "internalType": "struct Structs.Wei", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "internalType": "struct Structs.Info[]", + "name": "", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "enum Structs.ActionType", + "name": "actionType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "accountId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bool", + "name": "sign", + "type": "bool" + }, + { + "internalType": "enum Structs.AssetDenomination", + "name": "denomination", + "type": "uint8" + }, + { + "internalType": "enum Structs.AssetReference", + "name": "ref", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "internalType": "struct Structs.AssetAmount", + "name": "amount", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "primaryMarketId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "secondaryMarketId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "otherAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "otherAccountId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Structs.ActionArgs[]", + "name": "", + "type": "tuple[]" + } + ], + "name": "operate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/DyDxStub.json b/abi/DyDxStub.json new file mode 100644 index 0000000..d8e418b --- /dev/null +++ b/abi/DyDxStub.json @@ -0,0 +1,300 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "market", + "type": "uint256" + } + ], + "name": "MarketAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "markets", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "addMarket", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "internalType": "struct Structs.Info", + "name": "account", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "marketId", + "type": "uint256" + } + ], + "name": "getAccountWei", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "sign", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "internalType": "struct Structs.Wei", + "name": "", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "number", + "type": "uint256" + } + ], + "internalType": "struct Structs.Info[]", + "name": "accounts", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "enum Structs.ActionType", + "name": "actionType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "accountId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bool", + "name": "sign", + "type": "bool" + }, + { + "internalType": "enum Structs.AssetDenomination", + "name": "denomination", + "type": "uint8" + }, + { + "internalType": "enum Structs.AssetReference", + "name": "ref", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "internalType": "struct Structs.AssetAmount", + "name": "amount", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "primaryMarketId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "secondaryMarketId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "otherAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "otherAccountId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "internalType": "struct Structs.ActionArgs[]", + "name": "args", + "type": "tuple[]" + } + ], + "name": "operate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/Fulcrum.json b/abi/Fulcrum.json new file mode 100644 index 0000000..562657c --- /dev/null +++ b/abi/Fulcrum.json @@ -0,0 +1,75 @@ +[ + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "burnAmount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "loanAmountPaid", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "assetBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/FulcrumStub.json b/abi/FulcrumStub.json new file mode 100644 index 0000000..d73b262 --- /dev/null +++ b/abi/FulcrumStub.json @@ -0,0 +1,504 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "underlying", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "mintAmount", + "type": "uint256" + } + ], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "burnAmount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "loanAmountPaid", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "assetBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IAccessModule.json b/abi/IAccessModule.json index 0f98e7c..132e69b 100644 --- a/abi/IAccessModule.json +++ b/abi/IAccessModule.json @@ -24,5 +24,26 @@ "payable": false, "stateMutability": "view", "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "enum IAccessModule.Operation", + "name": "operation", + "type": "uint8" + } + ], + "name": "getMaxGasLeft", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/abi/IEarnAPRWithPool.json b/abi/IEarnAPRWithPool.json new file mode 100644 index 0000000..7a28a1b --- /dev/null +++ b/abi/IEarnAPRWithPool.json @@ -0,0 +1,797 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "APR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UNI", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UNIAPR", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "UNIROI", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "aave", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "aaveUni", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "compound", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "dydx", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "fulcrum", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pools", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "yTokens", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "recommend", + "outputs": [ + { + "internalType": "string", + "name": "choice", + "type": "string" + }, + { + "internalType": "uint256", + "name": "capr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "iapr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "aapr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dapr", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getAPROptionsInc", + "outputs": [ + { + "internalType": "uint256", + "name": "_uniswap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_compound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unicompound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unifulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_aave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_uniaave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_dydx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_ddex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lendf", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "getAPROptions", + "outputs": [ + { + "internalType": "uint256", + "name": "_uniswap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_compound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unicompound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unifulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_aave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_uniaave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_dydx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_ddex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lendf", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "getAPROptionsAdjusted", + "outputs": [ + { + "internalType": "uint256", + "name": "_uniswap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_compound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unicompound", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_fulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unifulcrum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_aave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_uniaave", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_dydx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_ddex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_lendf", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "viewPool", + "outputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "unipool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "created", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "created", + "type": "uint256" + } + ], + "name": "addPool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "cToken", + "type": "address" + } + ], + "name": "addCToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "iToken", + "type": "address" + } + ], + "name": "addIToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "aToken", + "type": "address" + } + ], + "name": "addAToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "aToken", + "type": "address" + } + ], + "name": "addAUniToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "yToken", + "type": "address" + } + ], + "name": "addYToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "dToken", + "type": "uint256" + } + ], + "name": "addDToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_new_UNIROI", + "type": "address" + } + ], + "name": "set_new_UNIROI", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_new_UNI", + "type": "address" + } + ], + "name": "set_new_UNI", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_new_UNIAPR", + "type": "address" + } + ], + "name": "set_new_UNIAPR", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_new_APR", + "type": "address" + } + ], + "name": "set_new_APR", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_TokenAddress", + "type": "address" + } + ], + "name": "inCaseTokenGetsStuck", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "inCaseETHGetsStuck", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IIEarnManager.json b/abi/IIEarnManager.json new file mode 100644 index 0000000..1b20490 --- /dev/null +++ b/abi/IIEarnManager.json @@ -0,0 +1,43 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "recommend", + "outputs": [ + { + "internalType": "string", + "name": "choice", + "type": "string" + }, + { + "internalType": "uint256", + "name": "capr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "iapr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "aapr", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dapr", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/ILendingPoolAddressesProvider.json b/abi/ILendingPoolAddressesProvider.json new file mode 100644 index 0000000..fda289d --- /dev/null +++ b/abi/ILendingPoolAddressesProvider.json @@ -0,0 +1,17 @@ +[ + { + "constant": true, + "inputs": [], + "name": "getLendingPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IUniswapAPR.json b/abi/IUniswapAPR.json new file mode 100644 index 0000000..47b2cbf --- /dev/null +++ b/abi/IUniswapAPR.json @@ -0,0 +1,69 @@ +[ + { + "constant": true, + "inputs": [], + "name": "getBlocksPerYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "roi", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdAt", + "type": "uint256" + } + ], + "name": "calcUniswapAPRFromROI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "createdAt", + "type": "uint256" + } + ], + "name": "calcUniswapAPR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IUniswapFactory.json b/abi/IUniswapFactory.json new file mode 100644 index 0000000..3f2b965 --- /dev/null +++ b/abi/IUniswapFactory.json @@ -0,0 +1,23 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "getExchange", + "outputs": [ + { + "internalType": "address", + "name": "exchange", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IUniswapROI.json b/abi/IUniswapROI.json new file mode 100644 index 0000000..43207d1 --- /dev/null +++ b/abi/IUniswapROI.json @@ -0,0 +1,28 @@ +[ + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "calcUniswapROI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/IYToken.json b/abi/IYToken.json new file mode 100644 index 0000000..04d1233 --- /dev/null +++ b/abi/IYToken.json @@ -0,0 +1,32 @@ +[ + { + "constant": true, + "inputs": [], + "name": "calcPoolValueInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/InvestingModule.json b/abi/InvestingModule.json index 749cfa8..f654532 100644 --- a/abi/InvestingModule.json +++ b/abi/InvestingModule.json @@ -942,6 +942,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "constant": false, + "inputs": [], + "name": "upgradeGuardCounter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": true, "inputs": [ diff --git a/abi/LendingPoolAddressesProvider.json b/abi/LendingPoolAddressesProvider.json new file mode 100644 index 0000000..a0684e9 --- /dev/null +++ b/abi/LendingPoolAddressesProvider.json @@ -0,0 +1,32 @@ +[ + { + "constant": true, + "inputs": [], + "name": "getLendingPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getLendingPoolCore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/abi/ReentrancyGuard.json b/abi/ReentrancyGuard.json new file mode 100644 index 0000000..be0c43e --- /dev/null +++ b/abi/ReentrancyGuard.json @@ -0,0 +1,8 @@ +[ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + } +] \ No newline at end of file diff --git a/abi/SavingsModule.json b/abi/SavingsModule.json index 73f6e7b..9834cf6 100644 --- a/abi/SavingsModule.json +++ b/abi/SavingsModule.json @@ -626,6 +626,15 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "constant": false, + "inputs": [], + "name": "upgradeGuardCounter", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": false, "inputs": [ @@ -795,9 +804,9 @@ "constant": false, "inputs": [ { - "internalType": "address", - "name": "_protocol", - "type": "address" + "internalType": "address[]", + "name": "_protocols", + "type": "address[]" }, { "internalType": "address[]", @@ -813,9 +822,9 @@ "name": "deposit", "outputs": [ { - "internalType": "uint256", + "internalType": "uint256[]", "name": "", - "type": "uint256" + "type": "uint256[]" } ], "payable": false, @@ -826,9 +835,9 @@ "constant": false, "inputs": [ { - "internalType": "address[]", - "name": "_protocols", - "type": "address[]" + "internalType": "address", + "name": "_protocol", + "type": "address" }, { "internalType": "address[]", @@ -844,9 +853,9 @@ "name": "deposit", "outputs": [ { - "internalType": "uint256[]", + "internalType": "uint256", "name": "", - "type": "uint256[]" + "type": "uint256" } ], "payable": false, diff --git a/abi/Structs.json b/abi/Structs.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/abi/Structs.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/abi/yDAI.json b/abi/yDAI.json new file mode 100644 index 0000000..9a789a4 --- /dev/null +++ b/abi/yDAI.json @@ -0,0 +1,807 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "constant": true, + "inputs": [], + "name": "aave", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "aaveToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "apr", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "compound", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "dToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "dydx", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "fulcrum", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pool", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "provider", + "outputs": [ + { + "internalType": "enum yDAI.Lender", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_shares", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "recommend", + "outputs": [ + { + "internalType": "enum yDAI.Lender", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "supplyDydx", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAave", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAaveCore", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "approveToken", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceDydx", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceCompound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceCompoundInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceFulcrumInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceFulcrum", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "balanceAave", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "rebalance", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "supplyAave", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "supplyFulcrum", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "supplyCompound", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "invest", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "calcPoolValueInToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getPricePerFullShare", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_shares", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/package.json b/package.json index e24c93f..74538a7 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "scripts": { "ganache": "npx ganache-cli --gasLimit 0xfffffffffff -e 10000000 --port 8545", "generate-types": "truffle compile --all && typechain --target=truffle-v5 \"build/contracts/*.json\"", - "generate-abi": "truffle compile --all && truffle-abi -o ./abi", - "generate-artifacts": "truffle compile --all && truffle-abi -o ./abi && typechain --target=truffle-v5 \"build/contracts/*.json\"", + "generate-abi": "truffle compile --all && truffle-abi -o ./abi", + "generate-artifacts": "truffle compile --all && truffle-abi -o ./abi && typechain --target=truffle-v5 \"build/contracts/*.json\"", "postinstall": "npm run generate-artifacts" }, "dependencies": { @@ -29,6 +29,9 @@ "@truffle/hdwallet-provider": "^1.0.38", "@typechain/truffle-v5": "^2.0.2", "eth-gas-reporter": "^0.2.17", + "prettier": "^2.2.1", + "prettier-plugin-solidity": "^1.0.0-beta.2", + "solhint-plugin-prettier": "^0.0.5", "solidity-coverage": "^0.7.9", "truffle": "^5.1.34", "truffle-contract-size": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index db8360a..dc53cba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -693,6 +693,11 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== +"@solidity-parser/parser@^0.10.1": + version "0.10.1" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.10.1.tgz#d3680d1ebebed21eee67f58a41eb92175204f0c7" + integrity sha512-tHDPCRMEBFDxBz5rioQRoKgOQGa/K2digdfR68cd5vO6IufAqoNt1sfjssQDf2KPqHPftICBQOqlcu0w5/Jisg== + "@solidity-parser/parser@^0.5.2": version "0.5.2" resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.5.2.tgz#4d74670ead39e4f4fdab605a393ba8ea2390a2c4" @@ -3489,6 +3494,11 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +dir-to-object@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dir-to-object/-/dir-to-object-2.0.0.tgz#29723e9bd1c3e58e4f307bd04ff634c0370c8f8a" + integrity sha512-sXs0JKIhymON7T1UZuO2Ud6VTNAx/VTBXIl4+3mjb2RgfOpt+hectX0x04YqPOPdkeOAKoJuKqwqnXXURNPNEA== + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -3674,6 +3684,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.0.0: + version "9.2.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.0.tgz#a26da8e832b16a9753309f25e35e3c0efb9a066a" + integrity sha512-DNc3KFPK18bPdElMJnf/Pkv5TXhxFU3YFDEuGLDRtPmV4rkmCjBkCSEp22u6rBHdSN9Vlp/GK7k98prmE1Jgug== + encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" @@ -3813,6 +3828,11 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + escodegen@1.8.x: version "1.8.1" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" @@ -4578,6 +4598,11 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^3.0.3: version "3.2.4" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3" @@ -6580,6 +6605,13 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + ltgt@~2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" @@ -7702,11 +7734,37 @@ preserve@^0.2.0: resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks= +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier-plugin-solidity@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.2.tgz#312a429cd0026b2cbdbe0ad8ef30c4f8db1f74b2" + integrity sha512-afn8Q0E0fY2I26fbagiBo1XRe7Cv/vs3t/N5Xbndzjgln+TXrtNxgWzhdZcFoZLN92WrFbxqqDoP6Lk5L80Fmw== + dependencies: + "@solidity-parser/parser" "^0.10.1" + dir-to-object "^2.0.0" + emoji-regex "^9.0.0" + escape-string-regexp "^4.0.0" + prettier "^2.0.5" + semver "^7.3.2" + solidity-comments-extractor "^0.0.4" + string-width "^4.2.0" + prettier@^1.14.2: version "1.19.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@^2.0.5, prettier@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== + private@^0.1.6, private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -8482,6 +8540,13 @@ semver@^6.2.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.3.2: + version "7.3.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" + integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== + dependencies: + lru-cache "^6.0.0" + semver@~5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" @@ -8692,11 +8757,23 @@ solc@^0.6.0: semver "^5.5.0" tmp "0.0.33" +solhint-plugin-prettier@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/solhint-plugin-prettier/-/solhint-plugin-prettier-0.0.5.tgz#e3b22800ba435cd640a9eca805a7f8bc3e3e6a6b" + integrity sha512-7jmWcnVshIrO2FFinIvDQmhQpfpS2rRRn3RejiYgnjIE68xO2bvrYvjqVNfrio4xH9ghOqn83tKuTzLjEbmGIA== + dependencies: + prettier-linter-helpers "^1.0.0" + solidity-ast@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/solidity-ast/-/solidity-ast-0.4.4.tgz#50bfcf493d4dc1cb00d0c3414d0caa6da99c6f00" integrity sha512-mSU95VtoTWicTlh39YAW2dLfGwYWjJ2acf5bZhE38SmnhENXrrGrxJfsc1fbul+puYqfQ4Pih9YBj+zwp9OeFg== +solidity-comments-extractor@^0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.4.tgz#ce420aef23641ffd0131c7d80ba85b6e1e42147e" + integrity sha512-58glBODwXIKMaQ7rfcJOrWtFQMMOK28tJ0/LcB5Xhu7WtAxk4UX2fpgKPuaL41XjMp/y0gAa1MTLqk018wuSzA== + solidity-coverage@^0.7.9: version "0.7.9" resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.7.9.tgz#6d1c40639066b93c67b21da48f4bc27ae01f0e58" @@ -11222,6 +11299,11 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + yargs-parser@13.1.2, yargs-parser@^13.1.0, yargs-parser@^13.1.2: version "13.1.2" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" From 6bb16cf13c7fa73306e90ab753f9601c310fe1eb Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Thu, 17 Dec 2020 10:25:31 +0300 Subject: [PATCH 9/9] DD-1493 Fix MixBytes COMMENTS 2 --- contracts/modules/staking/StakingPool.sol | 62 +- contracts/modules/staking/StakingPoolBase.sol | 915 +++++++++--------- 2 files changed, 464 insertions(+), 513 deletions(-) diff --git a/contracts/modules/staking/StakingPool.sol b/contracts/modules/staking/StakingPool.sol index 917c64f..0ca003b 100644 --- a/contracts/modules/staking/StakingPool.sol +++ b/contracts/modules/staking/StakingPool.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.5.12; +pragma solidity ^0.5.12; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; @@ -19,7 +19,7 @@ contract StakingPool is StakingPoolBase { } struct UserRewardInfo { - mapping(address=>uint256) nextDistribution; //Next unclaimed distribution + mapping(address => uint256) nextDistribution; //Next unclaimed distribution } struct RewardData { @@ -29,9 +29,8 @@ contract StakingPool is StakingPoolBase { RewardVestingModule public rewardVesting; address[] internal registeredRewardTokens; - mapping(address=>RewardData) internal rewards; - mapping(address=>UserRewardInfo) internal userRewards; - + mapping(address => RewardData) internal rewards; + mapping(address => UserRewardInfo) internal userRewards; modifier onlyRewardDistributionModule() { require(_msgSender() == getModuleAddress(MODULE_REWARD_DISTR), "StakingPool: calls allowed from RewardDistributionModule only"); @@ -48,26 +47,26 @@ contract StakingPool is StakingPoolBase { emit RewardTokenRegistered(token); } - function claimRewardsFromVesting() public onlyCapper{ + function claimRewardsFromVesting() public onlyCapper { _claimRewardsFromVesting(); } - function isRegisteredRewardToken(address token) public view returns(bool) { - for(uint256 i=0; i 0){ + if (rwrds > 0) { rewards[token].unclaimed = rewards[token].unclaimed.sub(rwrds); IERC20(token).transfer(user, rwrds); emit RewardWithdraw(user, token, rwrds); @@ -116,7 +116,12 @@ contract StakingPool is StakingPoolBase { return rwrds; } - function createStake(address _address, uint256 _amount, uint256 _lockInDuration, bytes memory _data) internal { + function createStake( + address _address, + uint256 _amount, + uint256 _lockInDuration, + bytes memory _data + ) internal { _withdrawRewards(_address); super.createStake(_address, _amount, _lockInDuration, _data); } @@ -126,27 +131,22 @@ contract StakingPool is StakingPoolBase { super.withdrawStake(_amount, _data); } - function _claimRewardsFromVesting() internal { rewardVesting.claimRewards(); - for(uint256 i=0; i < registeredRewardTokens.length; i++){ + for (uint256 i = 0; i < registeredRewardTokens.length; i++) { address rt = registeredRewardTokens[i]; uint256 expectedBalance = rewards[rt].unclaimed; - if(rt == address(stakingToken)){ + if (rt == address(stakingToken)) { expectedBalance = expectedBalance.add(totalStaked()); } uint256 actualBalance = IERC20(rt).balanceOf(address(this)); - if(actualBalance > expectedBalance) { + if (actualBalance > expectedBalance) { uint256 distributionAmount = actualBalance.sub(expectedBalance); uint256 totalShares = totalStaked(); - rewards[rt].distributions.push(RewardDistribution({ - totalShares: totalShares, - amount: distributionAmount - })); + rewards[rt].distributions.push(RewardDistribution({totalShares: totalShares, amount: distributionAmount})); rewards[rt].unclaimed = rewards[rt].unclaimed.add(distributionAmount); emit RewardDistributionCreated(rt, distributionAmount, totalShares); } } } - } diff --git a/contracts/modules/staking/StakingPoolBase.sol b/contracts/modules/staking/StakingPoolBase.sol index d28f95f..2995a11 100644 --- a/contracts/modules/staking/StakingPoolBase.sol +++ b/contracts/modules/staking/StakingPoolBase.sol @@ -11,509 +11,460 @@ import "@openzeppelin/contracts-ethereum-package/contracts/access/roles/CapperRo * @title ERC900 Simple Staking Interface basic implementation * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-900.md */ -contract StakingPoolBase is Module, IERC900, CapperRole { - // @TODO: deploy this separately so we don't have to deploy it multiple times for each contract - using SafeMath for uint256; - - // Token used for staking - ERC20 stakingToken; +contract StakingPoolBase is Module, IERC900, CapperRole { + // @TODO: deploy this separately so we don't have to deploy it multiple times for each contract + using SafeMath for uint256; + + // Token used for staking + ERC20 stakingToken; + + // The default duration of stake lock-in (in seconds) + uint256 public defaultLockInDuration; + + // To save on gas, rather than create a separate mapping for totalStakedFor & personalStakes, + // both data structures are stored in a single mapping for a given addresses. + // + // It's possible to have a non-existing personalStakes, but have tokens in totalStakedFor + // if other users are staking on behalf of a given address. + mapping(address => StakeContract) public stakeHolders; + + // Struct for personal stakes (i.e., stakes made by this address) + // unlockedTimestamp - when the stake unlocks (in seconds since Unix epoch) + // actualAmount - the amount of tokens in the stake + // stakedFor - the address the stake was staked for + struct Stake { + uint256 unlockedTimestamp; + uint256 actualAmount; + address stakedFor; + } + + // Struct for all stake metadata at a particular address + // totalStakedFor - the number of tokens staked for this address + // personalStakeIndex - the index in the personalStakes array. + // personalStakes - append only array of stakes made by this address + // exists - whether or not there are stakes that involve this address + struct StakeContract { + uint256 totalStakedFor; + uint256 personalStakeIndex; + Stake[] personalStakes; + bool exists; + } - // The default duration of stake lock-in (in seconds) - uint256 public defaultLockInDuration; + bool public userCapEnabled; - // To save on gas, rather than create a separate mapping for totalStakedFor & personalStakes, - // both data structures are stored in a single mapping for a given addresses. - // - // It's possible to have a non-existing personalStakes, but have tokens in totalStakedFor - // if other users are staking on behalf of a given address. - mapping (address => StakeContract) public stakeHolders; + mapping(address => uint256) public userCap; //Limit of pool tokens which can be minted for a user during deposit - // Struct for personal stakes (i.e., stakes made by this address) - // unlockedTimestamp - when the stake unlocks (in seconds since Unix epoch) - // actualAmount - the amount of tokens in the stake - // stakedFor - the address the stake was staked for - struct Stake { - uint256 unlockedTimestamp; - uint256 actualAmount; - address stakedFor; - } - - // Struct for all stake metadata at a particular address - // totalStakedFor - the number of tokens staked for this address - // personalStakeIndex - the index in the personalStakes array. - // personalStakes - append only array of stakes made by this address - // exists - whether or not there are stakes that involve this address - struct StakeContract { - uint256 totalStakedFor; - - uint256 personalStakeIndex; - - Stake[] personalStakes; + uint256 public defaultUserCap; + bool public stakingCapEnabled; + uint256 public stakingCap; - bool exists; - } - - bool public userCapEnabled; - - mapping(address => uint256) public userCap; //Limit of pool tokens which can be minted for a user during deposit - - - uint256 public defaultUserCap; - bool public stakingCapEnabled; - uint256 public stakingCap; - - - bool public vipUserEnabled; - mapping(address => bool) public isVipUser; - - uint256 internal totalStakedAmount; - - uint256 public coeffScore; - - uint256 private _guardCounter; // See OpenZeppelin ReentrancyGuard. Copied here to allow upgrade of already deployed contracts - - - event VipUserEnabledChange(bool enabled); - event VipUserChanged(address indexed user, bool isVip); - - event StakingCapChanged(uint256 newCap); - event StakingCapEnabledChange(bool enabled); - - //global cap - event DefaultUserCapChanged(uint256 newCap); - - event UserCapEnabledChange(bool enabled); - - event UserCapChanged(address indexed user, uint256 newCap); - event Staked(address indexed user, uint256 amount, uint256 totalStacked, bytes data); - event Unstaked(address indexed user, uint256 amount, uint256 totalStacked, bytes data); - event setLockInDuration(uint256 defaultLockInDuration); - - event CoeffScoreUpdated(uint256 coeff); - - /** - * @dev Prevents a contract from calling itself, directly or indirectly. - * See OpenZeppelin ReentrancyGuard - */ - modifier nonReentrant() { - _guardCounter += 1; - uint256 localCounter = _guardCounter; - _; - require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); - } - - /** - * @dev Modifier that checks that this contract can transfer tokens from the - * balance in the stakingToken contract for the given address. - * @dev This modifier also transfers the tokens. - * @param _address address to transfer tokens from - * @param _amount uint256 the number of tokens - */ - modifier canStake(address _address, uint256 _amount) { - require( - stakingToken.transferFrom(_address, address(this), _amount), - "Stake required"); - - _; - } + bool public vipUserEnabled; + mapping(address => bool) public isVipUser; + uint256 internal totalStakedAmount; - modifier isUserCapEnabledForStakeFor(uint256 stake) { - - if (stakingCapEnabled && !(vipUserEnabled && isVipUser[_msgSender()])) { - require((stakingCap > totalStaked() && (stakingCap-totalStaked() >= stake)), "StakingPoolBase: stake exeeds staking cap"); - } - - if(userCapEnabled) { - uint256 cap = userCap[_msgSender()]; - //check default user cap settings - if (defaultUserCap > 0) { - uint256 totalStaked = totalStakedFor(_msgSender()); - //get new cap - if (defaultUserCap >= totalStaked) { - cap = defaultUserCap.sub(totalStaked); - } else { - cap = 0; - } - } - - require(cap >= stake, "StakingPoolBase: stake exeeds cap"); - cap = cap.sub(stake); - userCap[_msgSender()] = cap; - emit UserCapChanged(_msgSender(), cap); - } - - _; - } + uint256 public coeffScore; + + uint256 private _guardCounter; // See OpenZeppelin ReentrancyGuard. Copied here to allow upgrade of already deployed contracts + + event VipUserEnabledChange(bool enabled); + event VipUserChanged(address indexed user, bool isVip); + + event StakingCapChanged(uint256 newCap); + event StakingCapEnabledChange(bool enabled); + //global cap + event DefaultUserCapChanged(uint256 newCap); - modifier isUserCapEnabledForUnStakeFor(uint256 unStake) { - _; + event UserCapEnabledChange(bool enabled); - if(userCapEnabled){ - uint256 cap = userCap[_msgSender()]; - cap = cap.add(unStake); + event UserCapChanged(address indexed user, uint256 newCap); + event Staked(address indexed user, uint256 amount, uint256 totalStacked, bytes data); + event Unstaked(address indexed user, uint256 amount, uint256 totalStacked, bytes data); + event setLockInDuration(uint256 defaultLockInDuration); - if (cap > defaultUserCap) { - cap = defaultUserCap; + event CoeffScoreUpdated(uint256 coeff); + + /** + * @dev Prevents a contract from calling itself, directly or indirectly. + * See OpenZeppelin ReentrancyGuard + */ + modifier nonReentrant() { + _guardCounter += 1; + uint256 localCounter = _guardCounter; + _; + require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); + } + + /** + * @dev Modifier that checks that this contract can transfer tokens from the + * balance in the stakingToken contract for the given address. + * @dev This modifier also transfers the tokens. + * @param _address address to transfer tokens from + * @param _amount uint256 the number of tokens + */ + modifier canStake(address _address, uint256 _amount) { + require(stakingToken.transferFrom(_address, address(this), _amount), "Stake required"); + + _; + } + + modifier isUserCapEnabledForStakeFor(uint256 stake) { + if (stakingCapEnabled && !(vipUserEnabled && isVipUser[_msgSender()])) { + require((stakingCap > totalStaked() && (stakingCap - totalStaked() >= stake)), "StakingPoolBase: stake exeeds staking cap"); } - userCap[_msgSender()] = cap; - emit UserCapChanged(_msgSender(), cap); - } - } + if (userCapEnabled) { + uint256 cap = userCap[_msgSender()]; + //check default user cap settings + if (defaultUserCap > 0) { + uint256 totalStaked = totalStakedFor(_msgSender()); + //get new cap + if (defaultUserCap >= totalStaked) { + cap = defaultUserCap.sub(totalStaked); + } else { + cap = 0; + } + } + + require(cap >= stake, "StakingPoolBase: stake exeeds cap"); + cap = cap.sub(stake); + userCap[_msgSender()] = cap; + emit UserCapChanged(_msgSender(), cap); + } - modifier checkUserCapDisabled() { - require(isUserCapEnabled() == false, "UserCapEnabled"); - _; - } + _; + } + + modifier isUserCapEnabledForUnStakeFor(uint256 unStake) { + _; + + if (userCapEnabled) { + uint256 cap = userCap[_msgSender()]; + cap = cap.add(unStake); + + if (cap > defaultUserCap) { + cap = defaultUserCap; + } + + userCap[_msgSender()] = cap; + emit UserCapChanged(_msgSender(), cap); + } + } + + modifier checkUserCapDisabled() { + require(isUserCapEnabled() == false, "UserCapEnabled"); + _; + } - modifier checkUserCapEnabled() { - require(isUserCapEnabled(), "UserCapDisabled"); - _; - } - + modifier checkUserCapEnabled() { + require(isUserCapEnabled(), "UserCapDisabled"); + _; + } - function initialize(address _pool, ERC20 _stakingToken, uint256 _defaultLockInDuration) public initializer { + function initialize( + address _pool, + ERC20 _stakingToken, + uint256 _defaultLockInDuration + ) public initializer { stakingToken = _stakingToken; defaultLockInDuration = _defaultLockInDuration; Module.initialize(_pool); CapperRole.initialize(_msgSender()); - } - - function setDefaultLockInDuration(uint256 _defaultLockInDuration) public onlyOwner { - defaultLockInDuration = _defaultLockInDuration; - emit setLockInDuration(_defaultLockInDuration); - } - - function setUserCapEnabled(bool _userCapEnabled) public onlyCapper { - userCapEnabled = _userCapEnabled; - emit UserCapEnabledChange(userCapEnabled); - } - - function setStakingCapEnabled(bool _stakingCapEnabled) public onlyCapper { - stakingCapEnabled= _stakingCapEnabled; - emit StakingCapEnabledChange(stakingCapEnabled); - } - - function setDefaultUserCap(uint256 _newCap) public onlyCapper { - defaultUserCap = _newCap; - emit DefaultUserCapChanged(_newCap); - } - - function setStakingCap(uint256 _newCap) public onlyCapper { - stakingCap = _newCap; - emit StakingCapChanged(_newCap); - } - - function setUserCap(address user, uint256 cap) public onlyCapper { - userCap[user] = cap; - emit UserCapChanged(user, cap); - } - - function setUserCap(address[] memory users, uint256[] memory caps) public onlyCapper { + } + + function setDefaultLockInDuration(uint256 _defaultLockInDuration) public onlyOwner { + defaultLockInDuration = _defaultLockInDuration; + emit setLockInDuration(_defaultLockInDuration); + } + + function setUserCapEnabled(bool _userCapEnabled) public onlyCapper { + userCapEnabled = _userCapEnabled; + emit UserCapEnabledChange(userCapEnabled); + } + + function setStakingCapEnabled(bool _stakingCapEnabled) public onlyCapper { + stakingCapEnabled = _stakingCapEnabled; + emit StakingCapEnabledChange(stakingCapEnabled); + } + + function setDefaultUserCap(uint256 _newCap) public onlyCapper { + defaultUserCap = _newCap; + emit DefaultUserCapChanged(_newCap); + } + + function setStakingCap(uint256 _newCap) public onlyCapper { + stakingCap = _newCap; + emit StakingCapChanged(_newCap); + } + + function setUserCap(address user, uint256 cap) public onlyCapper { + userCap[user] = cap; + emit UserCapChanged(user, cap); + } + + function setUserCap(address[] memory users, uint256[] memory caps) public onlyCapper { require(users.length == caps.length, "StakingPoolBase: arrays length not match"); - for(uint256 i=0; i < users.length; i++) { + for (uint256 i = 0; i < users.length; i++) { userCap[users[i]] = caps[i]; emit UserCapChanged(users[i], caps[i]); } - } - - - function setVipUserEnabled(bool _vipUserEnabled) public onlyCapper { - vipUserEnabled = _vipUserEnabled; - emit VipUserEnabledChange(_vipUserEnabled); - } - - function setVipUser(address user, bool isVip) public onlyCapper { - isVipUser[user] = isVip; - emit VipUserChanged(user, isVip); - } - - - function setCoeffScore(uint256 coeff) public onlyCapper { - coeffScore = coeff; - - emit CoeffScoreUpdated(coeff); - } - - function isUserCapEnabled() public view returns(bool) { - return userCapEnabled; - } - - - function iStakingCapEnabled() public view returns(bool) { - return stakingCapEnabled; - } - - /** - * @dev Returns the timestamps for when active personal stakes for an address will unlock - * @dev These accessors functions are needed until https://github.com/ethereum/web3.js/issues/1241 is solved - * @param _address address that created the stakes - * @return uint256[] array of timestamps - */ - function getPersonalStakeUnlockedTimestamps(address _address) external view returns (uint256[] memory) { - uint256[] memory timestamps; - (timestamps,,) = getPersonalStakes(_address); - - return timestamps; - } - - - - - /** - * @dev Returns the stake actualAmount for active personal stakes for an address - * @dev These accessors functions are needed until https://github.com/ethereum/web3.js/issues/1241 is solved - * @param _address address that created the stakes - * @return uint256[] array of actualAmounts - */ - function getPersonalStakeActualAmounts(address _address) external view returns (uint256[] memory) { - uint256[] memory actualAmounts; - (,actualAmounts,) = getPersonalStakes(_address); - - return actualAmounts; - } - - function getPersonalStakeTotalAmount(address _address) public view returns(uint256) { - uint256[] memory actualAmounts; - (,actualAmounts,) = getPersonalStakes(_address); - uint256 totalStake; - for(uint256 i=0; i