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");
|
require(_currentRate != 0, "currentRate-is-0");
|
||||||
if (_currentRate > _previousRate) {
|
if (_currentRate > _previousRate) {
|
||||||
uint difTkn = sub(tokenBalance, _totalToken);
|
uint difTkn = sub(tokenBalance, _totalToken);
|
||||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
if (difTkn < insuranceAmt) {
|
||||||
_currentRate = _previousRate;
|
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||||
|
_currentRate = _previousRate;
|
||||||
|
} else {
|
||||||
|
tokenBalance = add(_totalToken, insuranceAmt);
|
||||||
|
_currentRate = wdiv(totalSupply(), tokenBalance);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
||||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||||
|
|
|
@ -82,8 +82,13 @@ contract PoolToken is ReentrancyGuard, ERC20Pausable, DSMath {
|
||||||
require(_currentRate != 0, "currentRate-is-0");
|
require(_currentRate != 0, "currentRate-is-0");
|
||||||
if (_currentRate > _previousRate) {
|
if (_currentRate > _previousRate) {
|
||||||
uint difTkn = sub(tokenBalance, _totalToken);
|
uint difTkn = sub(tokenBalance, _totalToken);
|
||||||
insuranceAmt = sub(insuranceAmt, difTkn);
|
if (difTkn < insuranceAmt) {
|
||||||
_currentRate = _previousRate;
|
insuranceAmt = sub(insuranceAmt, difTkn);
|
||||||
|
_currentRate = _previousRate;
|
||||||
|
} else {
|
||||||
|
tokenBalance = add(_totalToken, insuranceAmt);
|
||||||
|
_currentRate = wdiv(totalSupply(), tokenBalance);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
uint insureFeeAmt = wmul(sub(_totalToken, tokenBalance), registry.insureFee(address(this)));
|
||||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user