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 LogDeploy(address token, uint amount);
|
||||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||||
event LogSettle(uint settleTime);
|
event LogSettle(uint settleBlock);
|
||||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||||
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
||||||
event LogAddInsurance(uint amount);
|
event LogAddInsurance(uint amount);
|
||||||
|
@ -68,11 +68,11 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||||
function deploy(address _dsa, address token, uint amount) public isChief {
|
function deploy(address _dsa, address token, 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");
|
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);
|
baseToken.safeTransfer(_dsa, amount);
|
||||||
} else if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE){
|
} else if (token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE){ // non-pool ethereum
|
||||||
payable(_dsa).transfer(amount);
|
payable(_dsa).transfer(amount);
|
||||||
} else {
|
} else { // non-pool other tokens
|
||||||
IERC20(token).safeTransfer(_dsa, amount);
|
IERC20(token).safeTransfer(_dsa, amount);
|
||||||
}
|
}
|
||||||
emit LogDeploy(token, amount);
|
emit LogDeploy(token, amount);
|
||||||
|
@ -122,13 +122,12 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||||
dsaWallet.cast(_targets, _datas, _origin);
|
dsaWallet.cast(_targets, _datas, _origin);
|
||||||
}
|
}
|
||||||
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
||||||
|
|
||||||
setExchangeRate();
|
setExchangeRate();
|
||||||
emit LogSettle(block.timestamp);
|
emit LogSettle(block.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deposit(uint tknAmt) external whenNotPaused payable returns(uint) {
|
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);
|
baseToken.safeTransferFrom(msg.sender, address(this), tknAmt);
|
||||||
uint _mintAmt = wmul(tknAmt, exchangeRate);
|
uint _mintAmt = wmul(tknAmt, exchangeRate);
|
||||||
|
@ -152,6 +151,8 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
||||||
_tknAmt = tknAmt;
|
_tknAmt = tknAmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||||
|
|
||||||
_burn(msg.sender, _burnAmt);
|
_burn(msg.sender, _burnAmt);
|
||||||
|
|
||||||
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
||||||
|
|
|
@ -35,7 +35,7 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
|
|
||||||
event LogDeploy(address indexed token, uint amount);
|
event LogDeploy(address indexed token, uint amount);
|
||||||
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
event LogExchangeRate(uint exchangeRate, uint tokenBalance, uint insuranceAmt);
|
||||||
event LogSettle(uint settleTime);
|
event LogSettle(uint settleBlock);
|
||||||
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
event LogDeposit(uint depositAmt, uint poolMintAmt);
|
||||||
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
event LogWithdraw(uint withdrawAmt, uint poolBurnAmt, uint feeAmt);
|
||||||
event LogAddInsurance(uint amount);
|
event LogAddInsurance(uint amount);
|
||||||
|
@ -67,9 +67,9 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
function deploy(address _dsa, address token, uint amount) external isChief {
|
function deploy(address _dsa, address token, uint amount) external 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");
|
require(AccountInterface(_dsa).isAuth(address(this)), "token-pool-not-auth");
|
||||||
if (token == address(0)) {
|
if (token == address(0)) { // pool base ETH
|
||||||
payable(_dsa).transfer(amount);
|
payable(_dsa).transfer(amount);
|
||||||
} else {
|
} else { // non-pool other tokens
|
||||||
IERC20(token).safeTransfer(_dsa, amount);
|
IERC20(token).safeTransfer(_dsa, amount);
|
||||||
}
|
}
|
||||||
emit LogDeploy(token, amount);
|
emit LogDeploy(token, amount);
|
||||||
|
@ -120,13 +120,12 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
}
|
}
|
||||||
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
require(dsaWallet.isAuth(address(this)), "token-pool-not-auth");
|
||||||
setExchangeRate();
|
setExchangeRate();
|
||||||
|
emit LogSettle(block.number);
|
||||||
emit LogSettle(block.timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deposit(uint tknAmt) public whenNotPaused payable returns(uint) {
|
function deposit(uint tknAmt) public whenNotPaused payable returns(uint) {
|
||||||
require(tknAmt == msg.value, "unmatched-amount");
|
require(tknAmt == msg.value, "unmatched-amount");
|
||||||
uint _newTokenBal = add(tokenBalance, msg.value);
|
tokenBalance = add(tokenBalance, tknAmt);
|
||||||
|
|
||||||
uint _mintAmt = wmul(msg.value, exchangeRate);
|
uint _mintAmt = wmul(msg.value, exchangeRate);
|
||||||
_mint(msg.sender, _mintAmt);
|
_mint(msg.sender, _mintAmt);
|
||||||
|
@ -149,6 +148,8 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
_tknAmt = tknAmt;
|
_tknAmt = tknAmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tokenBalance = sub(tokenBalance, _tknAmt);
|
||||||
|
|
||||||
_burn(msg.sender, _burnAmt);
|
_burn(msg.sender, _burnAmt);
|
||||||
|
|
||||||
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
uint _withdrawalFee = registry.withdrawalFee(address(this));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user