mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
added multiple DSA support
This commit is contained in:
parent
8bde5a5d0f
commit
24e4d6a8df
|
@ -23,6 +23,7 @@ interface RegistryInterface {
|
|||
function poolLogic(address) external returns (address);
|
||||
function poolCap(address) external view returns (uint);
|
||||
function insureFee(address) external view returns (uint);
|
||||
function isDsa(address, address) external view returns (bool);
|
||||
}
|
||||
|
||||
interface RateInterface {
|
||||
|
@ -40,7 +41,6 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
|
||||
RegistryInterface public immutable registry; // Pool Registry
|
||||
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
||||
AccountInterface public immutable dsa; // Pool's DSA account
|
||||
|
||||
IERC20 public immutable baseToken; // Base token.
|
||||
uint private tokenBalance; // total token balance since last rebalancing
|
||||
|
@ -57,7 +57,6 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
baseToken = IERC20(_baseToken);
|
||||
registry = RegistryInterface(_registry);
|
||||
address _dsa = instaIndex.build(address(this), 1, _origin);
|
||||
dsa = AccountInterface(_dsa);
|
||||
}
|
||||
|
||||
modifier isChief() {
|
||||
|
@ -65,8 +64,9 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
_;
|
||||
}
|
||||
|
||||
function deploy(uint amount) external isChief {
|
||||
payable(address(dsa)).transfer(amount);
|
||||
function deploy(address _dsa, uint amount) external isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
payable(_dsa).transfer(amount);
|
||||
emit LogDeploy(amount);
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,10 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
||||
}
|
||||
|
||||
function settle(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");
|
||||
if (_targets.length > 0 && _datas.length > 0) {
|
||||
dsa.cast(_targets, _datas, _origin);
|
||||
AccountInterface(_dsa).cast(_targets, _datas, _origin);
|
||||
}
|
||||
setExchangeRate();
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ contract Registry {
|
|||
mapping (address => address) public poolLogic;
|
||||
mapping (address => uint) public poolCap;
|
||||
mapping (address => uint) public insureFee;
|
||||
mapping (address => mapping(address => bool)) public isDsa; // Pool => DSA address => true/false
|
||||
|
||||
modifier isMaster() {
|
||||
require(msg.sender == instaIndex.master(), "not-master");
|
||||
|
@ -113,7 +114,7 @@ contract Registry {
|
|||
emit LogSwitchPool(_pool, isPool[_pool]);
|
||||
}
|
||||
|
||||
function updatePoolCap(address _pool, uint _newCap) external isChief {
|
||||
function updatePoolCap(address _pool, uint _newCap) external isMaster {
|
||||
require(isPool[_pool], "not-pool");
|
||||
poolCap[_pool] = _newCap;
|
||||
emit LogUpdatePoolCap(_pool, _newCap);
|
||||
|
@ -126,13 +127,22 @@ contract Registry {
|
|||
emit LogUpdatePoolLogic(_pool, _newLogic);
|
||||
}
|
||||
|
||||
function updateInsureFee(address _pool, uint _newFee) external isChief {
|
||||
function updateInsureFee(address _pool, uint _newFee) external isMaster {
|
||||
require(isPool[_pool], "not-pool");
|
||||
require(_newFee < 10 ** 18, "insure-fee-limit-reached");
|
||||
insureFee[_pool] = _newFee;
|
||||
emit LogUpdateInsureFee(_pool, _newFee);
|
||||
}
|
||||
|
||||
function enableDsa(address _pool, address _dsa) external isMaster {
|
||||
require(isPool[_pool], "not-pool");
|
||||
isDsa[_pool][_dsa] = true;
|
||||
}
|
||||
|
||||
function disableDsa(address _pool, address _dsa) external isMaster {
|
||||
delete isDsa[_pool][_dsa];
|
||||
}
|
||||
|
||||
constructor(address _chief) public {
|
||||
chief[_chief] = true;
|
||||
emit LogAddChief(_chief);
|
||||
|
|
|
@ -23,6 +23,7 @@ interface RegistryInterface {
|
|||
function poolLogic(address) external returns (address);
|
||||
function poolCap(address) external view returns (uint);
|
||||
function insureFee(address) external view returns (uint);
|
||||
function isDsa(address, address) external view returns (bool);
|
||||
}
|
||||
|
||||
interface RateInterface {
|
||||
|
@ -43,7 +44,6 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
IERC20 public immutable baseToken; // Base token. Eg:- DAI, USDC, etc.
|
||||
RegistryInterface public immutable registry; // Pool Registry
|
||||
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723); // Main Index
|
||||
AccountInterface public immutable dsa; // Pool's DSA account
|
||||
|
||||
uint private tokenBalance; // total token balance since last rebalancing
|
||||
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
||||
|
@ -53,13 +53,10 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
address _registry,
|
||||
string memory _name,
|
||||
string memory _symbol,
|
||||
address _baseToken,
|
||||
address _origin
|
||||
address _baseToken
|
||||
) public ERC20(_name, _symbol) {
|
||||
baseToken = IERC20(_baseToken);
|
||||
registry = RegistryInterface(_registry);
|
||||
address _dsa = instaIndex.build(address(this), 1, _origin);
|
||||
dsa = AccountInterface(_dsa);
|
||||
}
|
||||
|
||||
modifier isChief() {
|
||||
|
@ -67,8 +64,9 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
_;
|
||||
}
|
||||
|
||||
function deploy(uint amount) public isChief {
|
||||
baseToken.safeTransfer(address(dsa), amount);
|
||||
function deploy(address _dsa, uint amount) public isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
baseToken.safeTransfer(_dsa, amount);
|
||||
emit LogDeploy(amount);
|
||||
}
|
||||
|
||||
|
@ -93,9 +91,10 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
emit LogExchangeRate(exchangeRate, tokenBalance, insuranceAmt);
|
||||
}
|
||||
|
||||
function settle(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");
|
||||
if (_targets.length > 0 && _datas.length > 0) {
|
||||
dsa.cast(_targets, _datas, _origin);
|
||||
AccountInterface(_dsa).cast(_targets, _datas, _origin);
|
||||
}
|
||||
setExchangeRate();
|
||||
emit LogSettle(block.timestamp);
|
||||
|
|
Loading…
Reference in New Issue
Block a user