-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a0d5a1
commit 060b7e1
Showing
20 changed files
with
3,781 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.6; | ||
|
||
import "./../contracts/math/SafeMath.sol"; | ||
import "./../utils/Utils.sol"; | ||
import "./../contracts/GSN/Context.sol"; | ||
|
||
|
||
contract Erc20Manager is Context { | ||
|
||
using SafeMath for uint256; | ||
|
||
struct E20 { | ||
address sc; | ||
uint8 flag; //0 no exist 1 exist 2 deleted | ||
|
||
} | ||
|
||
// las index of | ||
uint256 internal _lastIndexE20s; | ||
// store new by internal id (_lastIndexE20s) | ||
mapping(uint256 => E20) internal _E20s; | ||
// store address -> internal id (_lastIndexE20s) | ||
mapping(address => uint256) internal _IDE20sIndex; | ||
uint256 internal _E20Count; | ||
|
||
|
||
|
||
constructor () internal { | ||
|
||
_lastIndexE20s = 0; | ||
_E20Count = 0; | ||
|
||
} | ||
|
||
|
||
function hasContracts() public view returns(bool){ | ||
if(_E20Count==0) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
function getERC20Count() public view returns (uint256) { | ||
return _E20Count; | ||
} | ||
|
||
function getLastIndexERC20s() public view returns (uint256) { | ||
return _lastIndexE20s; | ||
} | ||
|
||
|
||
function ERC20Exist(address sc) public view returns (bool) { | ||
return _E20Exist( _IDE20sIndex[sc]); | ||
} | ||
|
||
function ERC20IndexExist(uint256 index) public view returns (bool) { | ||
|
||
if(_E20Count==0) return false; | ||
|
||
if(index < (_lastIndexE20s + 1) ) return true; | ||
|
||
return false; | ||
} | ||
|
||
|
||
function _E20Exist(uint256 E20ID)internal view returns (bool) { | ||
|
||
//0 no exist 1 exist 2 deleted | ||
if(_E20s[E20ID].flag == 1 ){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
modifier onlyNewERC20(address sc) { | ||
require(!this.ERC20Exist(sc), "E2 Exist"); | ||
_; | ||
} | ||
|
||
|
||
modifier onlyERC20Exist(address sc) { | ||
require(this.ERC20Exist(sc), "E2 !Exist"); | ||
_; | ||
} | ||
|
||
modifier onlyERC20IndexExist(uint256 index) { | ||
require(this.ERC20IndexExist(index), "E2I !Exist"); | ||
_; | ||
} | ||
|
||
|
||
|
||
|
||
event NewERC20(address sc); | ||
|
||
|
||
function newERC20(address sc ) internal onlyNewERC20(sc) returns (uint256){ | ||
_lastIndexE20s=_lastIndexE20s.add(1); | ||
_E20Count= _E20Count.add(1); | ||
|
||
_E20s[_lastIndexE20s].sc = sc; | ||
_E20s[_lastIndexE20s].flag = 1; | ||
|
||
_IDE20sIndex[sc] = _lastIndexE20s; | ||
|
||
emit NewERC20(sc); | ||
return _lastIndexE20s; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
event ERC20Removed(address sc); | ||
|
||
function removeERC20(address sc) internal onlyERC20Exist(sc) { | ||
_E20s[ _IDE20sIndex[sc] ].flag = 2; | ||
_E20s[ _IDE20sIndex[sc] ].sc=address(0); | ||
_E20Count= _E20Count.sub(1); | ||
emit ERC20Removed( sc); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
function getERC20ByIndex(uint256 index) public view returns( address) { | ||
|
||
if(!ERC20IndexExist( index)) return address(0); | ||
|
||
E20 memory p= _E20s[ index ]; | ||
|
||
return p.sc; | ||
} | ||
|
||
|
||
|
||
function getAllERC20() public view returns(uint256[] memory, address[] memory ) { | ||
|
||
uint256[] memory indexs=new uint256[](_E20Count); | ||
address[] memory pACCs=new address[](_E20Count); | ||
uint256 ind=0; | ||
|
||
for (uint32 i = 0; i < (_lastIndexE20s +1) ; i++) { | ||
E20 memory p= _E20s[ i ]; | ||
if(p.flag == 1 ){ | ||
indexs[ind]=i; | ||
pACCs[ind]=p.sc; | ||
ind++; | ||
} | ||
} | ||
|
||
return (indexs, pACCs); | ||
|
||
} | ||
|
||
event AllERC20Removed(); | ||
function removeAllERC20() internal returns(bool){ | ||
for (uint32 i = 0; i < (_lastIndexE20s +1) ; i++) { | ||
_IDE20sIndex[_E20s[ i ].sc] = 0; | ||
_E20s[ i ].flag=0; | ||
_E20s[ i ].sc=address(0); | ||
} | ||
_lastIndexE20s = 0; | ||
_E20Count = 0; | ||
emit AllERC20Removed(); | ||
return true; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.6; | ||
|
||
|
||
interface IInvestable{ | ||
function getFreezeCount() external returns(uint256) ; | ||
function getLastIndexFreezes() external returns(uint256); | ||
function FreezeExist(address account) external returns(bool); | ||
function FreezeIndexExist(uint256 index) external returns(bool); | ||
function newFreeze(address account,uint256 amount,uint256 date ) external returns(uint256); | ||
function removeFreeze(address account) external; | ||
function getFreeze(address account) external returns( uint256 , uint256 , uint256 ); | ||
function getFreezeByIndex(uint256 index) external returns( uint256 , uint256 , uint256 ); | ||
function getAllFreeze() external returns(uint256[] memory, address[] memory ,uint256[] memory , uint256[] memory , uint256[] memory ); | ||
function updateFund(address account,uint256 withdraw) external returns(bool); | ||
function canWithdrawFunds(address account,uint256 withdraw,uint256 currentFund) external returns(bool); | ||
function howMuchCanWithdraw(address account,uint256 currentFund) external returns(uint256); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.6; | ||
|
||
|
||
interface IWStaked{ | ||
function NotifyAddStake(address account, uint256 amount) external returns(bool); | ||
function NotifyWithdrawFunds(address account, uint256 amount) external returns(uint256); | ||
function NotifyActiveChanged(bool activeStatus) external returns(bool); | ||
|
||
function StakeExist(address account) external returns (bool) ; | ||
function setAutoCompound(address account, bool active) external returns(uint256); | ||
function addToStake(address account, uint256 addAmount) external returns(uint256); | ||
function newStake(address account,uint256 amount ) external returns (uint256); | ||
function getStake(address account) external returns( uint256 ,bool); | ||
function removeStake(address account) external; | ||
function renewStake(address account, uint256 newAmount) external returns(uint256); | ||
function getStakeCount() external returns(uint256) ; | ||
function getLastIndexStakes() external returns (uint256) ; | ||
function getStakeByIndex(uint256 index) external returns(address, uint256,bool,uint8) ; | ||
function getAutoCompoundStatus(address account) external returns(bool); | ||
function removeAllStake() external returns(bool); | ||
function balanceOf(address account) external returns(uint256) ; | ||
|
||
} |
Oops, something went wrong.