mirror of
				https://github.com/Instadapp/yield-contract.git
				synced 2024-07-29 21:47:29 +00:00 
			
		
		
		
	Merge pull request #4 from InstaDApp/Multiple-dsa-support
Multiple dsa support
This commit is contained in:
		
						commit
						13f8131257
					
				|  | @ -5,6 +5,7 @@ pragma experimental ABIEncoderV2; | ||||||
| 
 | 
 | ||||||
| interface IndexInterface { | interface IndexInterface { | ||||||
|   function master() external view returns (address); |   function master() external view returns (address); | ||||||
|  |   function build(address _owner, uint accountVersion, address _origin) external returns (address _account); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| contract Registry { | contract Registry { | ||||||
|  | @ -19,6 +20,8 @@ contract Registry { | ||||||
|   event LogUpdateInsureFee(address pool, uint newFee); |   event LogUpdateInsureFee(address pool, uint newFee); | ||||||
|   event LogAddPool(address indexed token, address indexed pool); |   event LogAddPool(address indexed token, address indexed pool); | ||||||
|   event LogRemovePool(address indexed token, address indexed pool); |   event LogRemovePool(address indexed token, address indexed pool); | ||||||
|  |   event LogNewDSA(address indexed pool, address indexed dsa); | ||||||
|  |   event LogRemoveDSA(address indexed pool, address indexed dsa); | ||||||
| 
 | 
 | ||||||
|   IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); |   IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); | ||||||
| 
 | 
 | ||||||
|  | @ -134,13 +137,20 @@ contract Registry { | ||||||
|     emit LogUpdateInsureFee(_pool, _newFee); |     emit LogUpdateInsureFee(_pool, _newFee); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function enableDsa(address _pool, address _dsa) external isMaster { |   function addDsa(address _pool, address _dsa) external isMaster { | ||||||
|     require(isPool[_pool], "not-pool"); |     require(isPool[_pool], "not-pool"); | ||||||
|  |     if (_dsa == address(0)) { | ||||||
|  |       _dsa = instaIndex.build(_pool, 1, address(this)); | ||||||
|  |     } | ||||||
|     isDsa[_pool][_dsa] = true; |     isDsa[_pool][_dsa] = true; | ||||||
|  |     emit LogNewDSA(_pool, _dsa); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function disableDsa(address _pool, address _dsa) external isMaster { |   function removeDsa(address _pool, address _dsa) external isMaster { | ||||||
|  |     require(isPool[_pool], "not-pool"); | ||||||
|  |     require(isDsa[_pool][_dsa], "not-dsa-for-pool"); | ||||||
|     delete isDsa[_pool][_dsa]; |     delete isDsa[_pool][_dsa]; | ||||||
|  |     emit LogRemoveDSA(_pool, _dsa); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   constructor(address _chief) public { |   constructor(address _chief) public { | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ import { DSMath } from "./libs/safeMath.sol"; | ||||||
| 
 | 
 | ||||||
| interface AccountInterface { | interface AccountInterface { | ||||||
|   function enable(address authority) external; |   function enable(address authority) external; | ||||||
|  |   function isAuth(address) external view returns(bool); | ||||||
|   function cast(address[] calldata _targets, bytes[] calldata _datas, address _origin) external payable; |   function cast(address[] calldata _targets, bytes[] calldata _datas, address _origin) external payable; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -66,7 +67,9 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable { | ||||||
| 
 | 
 | ||||||
|     function deploy(address _dsa, uint amount) public isChief { |     function deploy(address _dsa, uint amount) public isChief { | ||||||
|       require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa"); |       require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa"); | ||||||
|  |       require(AccountInterface(_dsa).isAuth(address(this)), "token-pool-not-auth");   | ||||||
|       baseToken.safeTransfer(_dsa, amount); |       baseToken.safeTransfer(_dsa, amount); | ||||||
|  | 
 | ||||||
|       emit LogDeploy(amount); |       emit LogDeploy(amount); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -93,9 +96,12 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable { | ||||||
| 
 | 
 | ||||||
|     function settle(address _dsa, address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief { |     function settle(address _dsa, address[] calldata _targets, bytes[] calldata _datas, address _origin) external isChief { | ||||||
|       require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa"); |       require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa"); | ||||||
|  |       AccountInterface dsaWallet = AccountInterface(_dsa); | ||||||
|       if (_targets.length > 0 && _datas.length > 0) { |       if (_targets.length > 0 && _datas.length > 0) { | ||||||
|         AccountInterface(_dsa).cast(_targets, _datas, _origin); |         dsaWallet.cast(_targets, _datas, _origin); | ||||||
|       } |       } | ||||||
|  |       require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");  | ||||||
|  |   | ||||||
|       setExchangeRate(); |       setExchangeRate(); | ||||||
|       emit LogSettle(block.timestamp); |       emit LogSettle(block.timestamp); | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Samyak Jain
						Samyak Jain