mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
Added token paramater in deploy function
This commit is contained in:
parent
27be4fbfd1
commit
f63a3fc04d
|
@ -2,7 +2,7 @@
|
|||
pragma solidity ^0.6.8;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol";
|
||||
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
|
||||
|
||||
|
@ -31,7 +31,9 @@ interface RateInterface {
|
|||
}
|
||||
|
||||
contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||
event LogDeploy(uint amount);
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
event LogDeploy(address indexed token, uint amount);
|
||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||
event LogSettle(uint settleTime);
|
||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||
|
@ -62,10 +64,14 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
_;
|
||||
}
|
||||
|
||||
function deploy(address _dsa, uint amount) external isChief {
|
||||
function deploy(address _dsa, address token, uint amount) external isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
payable(_dsa).transfer(amount);
|
||||
emit LogDeploy(amount);
|
||||
if (token == address(0)) {
|
||||
payable(_dsa).transfer(amount);
|
||||
} else {
|
||||
IERC20(token).safeTransfer(_dsa, amount);
|
||||
}
|
||||
emit LogDeploy(token, amount);
|
||||
}
|
||||
|
||||
function setExchangeRate() public isChief {
|
||||
|
@ -73,6 +79,7 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
||||
_totalToken = sub(_totalToken, insuranceAmt);
|
||||
uint _currentRate = wdiv(totalSupply(), _totalToken);
|
||||
require(_currentRate != 0, "currentRate-is-0");
|
||||
if (_currentRate > _previousRate) {
|
||||
uint difTkn = sub(tokenBalance, _totalToken);
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
|
|
|
@ -33,7 +33,7 @@ interface RateInterface {
|
|||
contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
event LogDeploy(uint amount);
|
||||
event LogDeploy(address token, uint amount);
|
||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||
event LogSettle(uint settleTime);
|
||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||
|
@ -65,10 +65,16 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
_;
|
||||
}
|
||||
|
||||
function deploy(address _dsa, uint amount) public isChief {
|
||||
function deploy(address _dsa, address token, uint amount) public isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
baseToken.safeTransfer(_dsa, amount);
|
||||
emit LogDeploy(amount);
|
||||
if (token == address(0)) {
|
||||
baseToken.safeTransfer(_dsa, amount);
|
||||
} else if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE){
|
||||
payable(_dsa).transfer(amount);
|
||||
} else {
|
||||
IERC20(token).safeTransfer(_dsa, amount);
|
||||
}
|
||||
emit LogDeploy(token, amount);
|
||||
}
|
||||
|
||||
function setExchangeRate() public isChief {
|
||||
|
@ -76,13 +82,13 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
uint _totalToken = RateInterface(registry.poolLogic(address(this))).getTotalToken();
|
||||
_totalToken = sub(_totalToken, insuranceAmt);
|
||||
uint _currentRate = wdiv(totalSupply(), _totalToken);
|
||||
require(_currentRate != 0, "currentRate-is-0");
|
||||
if (_currentRate > _previousRate) {
|
||||
uint difTkn = sub(tokenBalance, _totalToken);
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
_currentRate = _previousRate;
|
||||
} else {
|
||||
uint fee = registry.insureFee(address(this));
|
||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), fee);
|
||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||
tokenBalance = sub(_totalToken, insureFeeAmt);
|
||||
_currentRate = wdiv(totalSupply(), tokenBalance);
|
||||
|
|
Loading…
Reference in New Issue
Block a user