mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
updated is loss is greater than insurance amount
This commit is contained in:
parent
e11b74d109
commit
f8c117c513
|
@ -87,8 +87,13 @@ contract PoolToken is ReentrancyGuard, DSMath, ERC20Pausable {
|
|||
require(_currentRate != 0, "currentRate-is-0");
|
||||
if (_currentRate > _previousRate) {
|
||||
uint difTkn = sub(tokenBalance, _totalToken);
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
_currentRate = _previousRate;
|
||||
if (difTkn < insuranceAmt) {
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
_currentRate = _previousRate;
|
||||
} else {
|
||||
tokenBalance = add(_totalToken, insuranceAmt);
|
||||
_currentRate = wdiv(totalSupply(), tokenBalance);
|
||||
}
|
||||
} else {
|
||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||
|
|
|
@ -82,8 +82,13 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
|||
require(_currentRate != 0, "currentRate-is-0");
|
||||
if (_currentRate > _previousRate) {
|
||||
uint difTkn = sub(tokenBalance, _totalToken);
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
_currentRate = _previousRate;
|
||||
if (difTkn < insuranceAmt) {
|
||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||
_currentRate = _previousRate;
|
||||
} else {
|
||||
tokenBalance = add(_totalToken, insuranceAmt);
|
||||
_currentRate = wdiv(totalSupply(), tokenBalance);
|
||||
}
|
||||
} else {
|
||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user