mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
fixed deposit bug
This commit is contained in:
parent
11410e0d5e
commit
dac3be57fe
|
@ -35,7 +35,7 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
|
||||
event LogDeploy(address token, uint amount);
|
||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||
event LogSettle(uint settleTime);
|
||||
event LogSettle(uint settleBlock);
|
||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
||||
event LogAddInsurance(uint amount);
|
||||
|
@ -68,11 +68,11 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
function deploy(address _dsa, address token, uint amount) public isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
require(AccountInterface(_dsa).isAuth(address(this)), "token-pool-not-auth");
|
||||
if (token == address(0)) {
|
||||
if (token == address(0)) { // pool base token
|
||||
baseToken.safeTransfer(_dsa, amount);
|
||||
} else if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE){
|
||||
} else if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE){ // non-pool ethereum
|
||||
payable(_dsa).transfer(amount);
|
||||
} else {
|
||||
} else { // non-pool other tokens
|
||||
IERC20(token).safeTransfer(_dsa, amount);
|
||||
}
|
||||
emit LogDeploy(token, amount);
|
||||
|
@ -122,13 +122,12 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
dsaWallet.cast(_targets, _datas, _origin);
|
||||
}
|
||||
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
||||
|
||||
setExchangeRate();
|
||||
emit LogSettle(block.timestamp);
|
||||
emit LogSettle(block.number);
|
||||
}
|
||||
|
||||
function deposit(uint tknAmt) external whenNotPaused payable returns(uint) {
|
||||
uint _newTokenBal = add(tokenBalance, tknAmt);
|
||||
tokenBalance = add(tokenBalance, tknAmt);
|
||||
|
||||
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
||||
uint _mintAmt = wmul(tknAmt, exchangeRate);
|
||||
|
@ -152,6 +151,8 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
_tknAmt = tknAmt;
|
||||
}
|
||||
|
||||
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||
|
||||
_burn(msg.sender, _burnAmt);
|
||||
|
||||
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
||||
|
|
|
@ -35,7 +35,7 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
|
||||
event LogDeploy(address indexed token, uint amount);
|
||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||
event LogSettle(uint settleTime);
|
||||
event LogSettle(uint settleBlock);
|
||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
||||
event LogAddInsurance(uint amount);
|
||||
|
@ -66,10 +66,10 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
|
||||
function deploy(address _dsa, address token, uint amount) external isChief {
|
||||
require(registry.isDsa(address(this), _dsa), "not-autheticated-dsa");
|
||||
require(AccountInterface(_dsa).isAuth(address(this)), "token-pool-not-auth");
|
||||
if (token == address(0)) {
|
||||
require(AccountInterface(_dsa).isAuth(address(this)), "token-pool-not-auth");
|
||||
if (token == address(0)) { // pool base ETH
|
||||
payable(_dsa).transfer(amount);
|
||||
} else {
|
||||
} else { // non-pool other tokens
|
||||
IERC20(token).safeTransfer(_dsa, amount);
|
||||
}
|
||||
emit LogDeploy(token, amount);
|
||||
|
@ -118,15 +118,14 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
if (_targets.length > 0 && _datas.length > 0) {
|
||||
dsaWallet.cast(_targets, _datas, _origin);
|
||||
}
|
||||
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
||||
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
||||
setExchangeRate();
|
||||
|
||||
emit LogSettle(block.timestamp);
|
||||
emit LogSettle(block.number);
|
||||
}
|
||||
|
||||
function deposit(uint tknAmt) public whenNotPaused payable returns(uint) {
|
||||
require(tknAmt == msg.value, "unmatched-amount");
|
||||
uint _newTokenBal = add(tokenBalance, msg.value);
|
||||
tokenBalance = add(tokenBalance, tknAmt);
|
||||
|
||||
uint _mintAmt = wmul(msg.value, exchangeRate);
|
||||
_mint(msg.sender, _mintAmt);
|
||||
|
@ -149,6 +148,8 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
_tknAmt = tknAmt;
|
||||
}
|
||||
|
||||
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||
|
||||
_burn(msg.sender, _burnAmt);
|
||||
|
||||
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
||||
|
|
Loading…
Reference in New Issue
Block a user