mirror of
https://github.com/Instadapp/yield-contract.git
synced 2024-07-29 21:47:29 +00:00
Minor edits
This commit is contained in:
parent
2f0549b709
commit
b4ad315f33
|
@ -136,7 +136,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
|
|
||||||
_burn(msg.sender, _burnAmt);
|
_burn(msg.sender, _burnAmt);
|
||||||
|
|
||||||
payable(to).transfer(_tknAmt);
|
payable(to).transfer(_tknAmt); // TODO - if this is also Reentrancy prone attack or not.
|
||||||
|
|
||||||
emit LogWithdraw(tknAmt, _burnAmt);
|
emit LogWithdraw(tknAmt, _burnAmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,7 @@ contract RateLogic is DSMath {
|
||||||
CTokenInterface ctoken = CTokenInterface(address(0));
|
CTokenInterface ctoken = CTokenInterface(address(0));
|
||||||
CTokenInterface token = CTokenInterface(address(0));
|
CTokenInterface token = CTokenInterface(address(0));
|
||||||
|
|
||||||
uint fee = 1e17; // 10%
|
function getTotalToken() public view returns (uint) {
|
||||||
function totalBalanceDSA() public view returns (uint) {
|
|
||||||
address _dsa;
|
|
||||||
uint abal = atoken.balanceOf(_dsa);
|
|
||||||
uint cbal = wmul(ctoken.balanceOf(_dsa), ctoken.getExchangeRate());
|
|
||||||
uint bal = token.balanceOf(_dsa);
|
|
||||||
return add(abal, add(cbal, bal));
|
|
||||||
}
|
|
||||||
|
|
||||||
function totalBalance() public view returns (uint) {
|
|
||||||
address _dsa;
|
address _dsa;
|
||||||
uint abal = atoken.balanceOf(_dsa);
|
uint abal = atoken.balanceOf(_dsa);
|
||||||
uint cbal = wmul(ctoken.balanceOf(_dsa), ctoken.getExchangeRate());
|
uint cbal = wmul(ctoken.balanceOf(_dsa), ctoken.getExchangeRate());
|
||||||
|
@ -42,13 +33,4 @@ contract RateLogic is DSMath {
|
||||||
uint poolBal = token.balanceOf(address(poolToken));
|
uint poolBal = token.balanceOf(address(poolToken));
|
||||||
return add(add(abal, poolBal) , add(cbal, dsaBal));
|
return add(add(abal, poolBal) , add(cbal, dsaBal));
|
||||||
}
|
}
|
||||||
|
|
||||||
function pricePerToken() public view returns(uint256) {
|
|
||||||
// TODO - add security logic
|
|
||||||
uint _totalBalance = totalBalanceDSA();
|
|
||||||
uint profit = sub(_totalBalance, poolToken.dsaAmount());
|
|
||||||
uint leftProfit = wmul(profit, fee);
|
|
||||||
uint leftTotalBalance = add(leftProfit, poolToken.dsaAmount());
|
|
||||||
return wdiv(leftTotalBalance, poolToken.totalSupply());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ contract Registry {
|
||||||
|
|
||||||
event LogAddChief(address indexed chief);
|
event LogAddChief(address indexed chief);
|
||||||
event LogRemoveChief(address indexed chief);
|
event LogRemoveChief(address indexed chief);
|
||||||
|
event LogAddSigner(address indexed signer);
|
||||||
|
event LogRemoveSigner(address indexed signer);
|
||||||
event LogSwitchPool(address pool, bool);
|
event LogSwitchPool(address pool, bool);
|
||||||
event LogUpdatePoolCap(address pool, uint newCap);
|
event LogUpdatePoolCap(address pool, uint newCap);
|
||||||
event LogUpdatePoolLogic(address pool, address newLogic);
|
event LogUpdatePoolLogic(address pool, address newLogic);
|
||||||
|
@ -19,6 +21,7 @@ contract Registry {
|
||||||
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
||||||
|
|
||||||
mapping (address => bool) public chief;
|
mapping (address => bool) public chief;
|
||||||
|
mapping (address => bool) public signer;
|
||||||
mapping (address => bool) public isPool;
|
mapping (address => bool) public isPool;
|
||||||
mapping (address => address) public poolLogic;
|
mapping (address => address) public poolLogic;
|
||||||
mapping (address => uint) public poolCap;
|
mapping (address => uint) public poolCap;
|
||||||
|
@ -56,6 +59,28 @@ contract Registry {
|
||||||
emit LogRemoveChief(_chief);
|
emit LogRemoveChief(_chief);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Enable New Signer.
|
||||||
|
* @param _signer Address of the new signer.
|
||||||
|
*/
|
||||||
|
function enableSigner(address _signer) external isChief {
|
||||||
|
require(_signer != address(0), "address-not-valid");
|
||||||
|
require(!signer[_signer], "signer-already-enabled");
|
||||||
|
signer[_signer] = true;
|
||||||
|
emit LogAddSigner(_signer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Disable Signer.
|
||||||
|
* @param _signer Address of the existing signer.
|
||||||
|
*/
|
||||||
|
function disableSigner(address _signer) external isChief {
|
||||||
|
require(_signer != address(0), "address-not-valid");
|
||||||
|
require(signer[_signer], "signer-already-disabled");
|
||||||
|
delete signer[_signer];
|
||||||
|
emit LogRemoveSigner(_signer);
|
||||||
|
}
|
||||||
|
|
||||||
function switchPool(address _pool) external isMaster {
|
function switchPool(address _pool) external isMaster {
|
||||||
isPool[_pool] = !isPool[_pool];
|
isPool[_pool] = !isPool[_pool];
|
||||||
emit LogSwitchPool(_pool, isPool[_pool]);
|
emit LogSwitchPool(_pool, isPool[_pool]);
|
||||||
|
@ -85,5 +110,4 @@ contract Registry {
|
||||||
chief[_chief] = true;
|
chief[_chief] = true;
|
||||||
emit LogAddChief(_chief);
|
emit LogAddChief(_chief);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ pragma solidity ^0.6.8;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
||||||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
|
||||||
|
|
||||||
import { DSMath } from "./libs/safeMath.sol";
|
import { DSMath } from "./libs/safeMath.sol";
|
||||||
|
@ -26,7 +25,6 @@ interface RegistryInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RateInterface {
|
interface RateInterface {
|
||||||
function totalBalance() external view returns (uint);
|
|
||||||
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
function getTotalToken() external returns (uint totalUnderlyingTkn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +45,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
AccountInterface public immutable dsa; // Pool's DSA account
|
AccountInterface public immutable dsa; // Pool's DSA account
|
||||||
|
|
||||||
uint private tokenBalance; // total token balance since last rebalancing
|
uint private tokenBalance; // total token balance since last rebalancing
|
||||||
uint public exchangeRate = 1000000000000000000; // initial 1 token = 1
|
uint public exchangeRate = 10 ** 18; // initial 1 token = 1
|
||||||
uint public insuranceAmt; // insurance amount to keep pool safe
|
uint public insuranceAmt; // insurance amount to keep pool safe
|
||||||
bool public shutPool; // shutdown deposits and withdrawals
|
bool public shutPool; // shutdown deposits and withdrawals
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ contract PoolToken is ERC20, DSMath {
|
||||||
_currentRate = _previousRate;
|
_currentRate = _previousRate;
|
||||||
} else {
|
} else {
|
||||||
uint difRate = _currentRate - _previousRate;
|
uint difRate = _currentRate - _previousRate;
|
||||||
uint insureFee = wmul(difRate, registry.insureFee(address(this))); // 1e17
|
uint insureFee = wmul(difRate, registry.insureFee(address(this)));
|
||||||
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
uint insureFeeAmt = wmul(_totalToken, insureFee);
|
||||||
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
insuranceAmt = add(insuranceAmt, insureFeeAmt);
|
||||||
_currentRate = sub(_currentRate, insureFee);
|
_currentRate = sub(_currentRate, insureFee);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user