Skip to content

Commit

Permalink
In auction contract price is check with zero auction protection all t…
Browse files Browse the repository at this point in the history
…oken based function removed all unused variable function is removed new test case update according to change
  • Loading branch information
yashnaman authored and mak2296 committed Jul 24, 2020
1 parent 2962c4e commit 5fadd27
Show file tree
Hide file tree
Showing 22 changed files with 3,859 additions and 949 deletions.
4 changes: 4 additions & 0 deletions contracts/Auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ contract AuctionFundCollector is IndividualBonus {
uint256 _mainTokenPrice = ICurrencyPrices(currencyPricesAddress)
.getCurrencyPrice(mainTokenAddress);

require(_mainTokenPrice > 0, "ERR_TOKEN_PRICE_NOT_SET");

uint256 _tokenAmount = safeDiv(
safeMul(
safeDiv(
Expand Down Expand Up @@ -481,6 +483,8 @@ contract AuctionFundCollector is IndividualBonus {
uint256 _currencyPrices = ICurrencyPrices(currencyPricesAddress)
.getCurrencyPrice(_token);

require(_currencyPrices > 0, "ERR_TOKEN_PRICE_NOT_SET");

uint256 _contributedAmount = safeDiv(
safeMul(_amount, _currencyPrices),
safeExponent(10, _decimal)
Expand Down
2 changes: 0 additions & 2 deletions contracts/Auction/AuctionProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "../common/Ownable.sol";
import "../Proxy/UpgradeabilityProxy.sol";
import "../InterFaces/IERC20Token.sol";


interface InitializeInterface {
function initialize(
uint256 _startTime,
Expand All @@ -18,7 +17,6 @@ interface InitializeInterface {
) external;
}


/**
* @title Registry
* @dev This contract works as a registry of versions, it holds the implementations for the registered versions.
Expand Down
2 changes: 0 additions & 2 deletions contracts/AuctionTagAlong/AuctionTagAlongProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "../common/Ownable.sol";
import "../Proxy/UpgradeabilityProxy.sol";
import "../InterFaces/IERC20Token.sol";


interface InitializeInterface {
function initialize(
address _primaryOwner,
Expand All @@ -15,7 +14,6 @@ interface InitializeInterface {
) external;
}


/**
* @title Registry
* @dev This contract works as a registry of versions, it holds the implementations for the registered versions.
Expand Down
3 changes: 0 additions & 3 deletions contracts/InterFaces/IAuction.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
pragma solidity ^0.5.9;


interface IAuction {
function tokenAuctionEndPrice() external returns (uint256);

function dayWiseMarketPrice(uint256 dayId) external view returns (uint256);

function dayWiseContribution(uint256 dayId) external view returns (uint256);
Expand Down
7 changes: 0 additions & 7 deletions contracts/InterFaces/IAuctionLiquadity.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
pragma solidity ^0.5.9;
import "./IERC20Token.sol";


interface IAuctionLiquadity {
function contributeWithEther() external payable returns (uint256);

function auctionEnded() external returns (bool);

function contributeTowardMainReserve() external returns (uint256);

function contributeWithToken(
IERC20Token _token,
address _from,
uint256 _amount
) external returns (uint256);
}
8 changes: 0 additions & 8 deletions contracts/InterFaces/IAuctionProtection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pragma solidity ^0.5.9;

import "./IERC20Token.sol";


interface IAuctionProtection {
function stackFund(uint256 _amount) external returns (bool);

Expand All @@ -14,13 +13,6 @@ interface IAuctionProtection {
uint256 _amount
) external returns (bool);

function lockTokens(
IERC20Token _token,
address _from,
address _which,
uint256 _amount
) external returns (bool);

function unLockTokens() external returns (bool);

function stackToken() external returns (bool);
Expand Down
38 changes: 18 additions & 20 deletions contracts/InterFaces/IAuctionRegistery.sol
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
pragma solidity ^0.5.9;

contract AuctionRegisteryContracts{

contract AuctionRegisteryContracts {
bytes32 internal constant MAIN_TOKEN = "MAIN_TOKEN";

bytes32 internal constant ETN_TOKEN = "ETN_TOKEN";

bytes32 internal constant STOCK_TOKEN = "STOCK_TOKEN";

bytes32 internal constant AUCTION_PROTECTION = "AUCTION_PROTECTION";

bytes32 internal constant WHITE_LIST = "WHITE_LIST";

bytes32 internal constant AUCTION = "AUCTION";

bytes32 internal constant LIQUADITY = "LIQUADITY";

bytes32 internal constant CURRENCY = "CURRENCY";

bytes32 internal constant INDIVIDUAL_BONUS = "INDIVIDUAL_BONUS";

bytes32 internal constant VAULT = "VAULT";

bytes32 internal constant TAG_ALONG = "TAG_ALONG";

bytes32 internal constant COMPANY_FUND_WALLET = "COMPANY_FUND_WALLET";

bytes32 internal constant COMPANY_MAIN_TOKEN_WALLET = "COMPANY_MAIN_TOKEN_WALLET";

bytes32 internal constant STACKING_TOKEN_WALLET = "STACKING_TOKEN_WALLET";

bytes32 internal constant SMART_SWAP = "SMART_SWAP";

}


interface IAuctionRegistery {
function getAddressOf(bytes32 _contractName) external view returns (address payable);
function getAddressOf(bytes32 _contractName)
external
view
returns (address payable);
}


11 changes: 0 additions & 11 deletions contracts/Liquadity/AuctionLiquadity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -587,17 +587,6 @@ contract Liquadity is
return _getCurrentMarketPrice();
}

// contribution with Token is not avilable for bancor
//bacnor dont have stable coin base conversion
function contributeWithToken(
IERC20Token _token,
address _from,
uint256 _amount
) public allowedAddressOnly(msg.sender) returns (uint256) {
ensureTransferFrom(_token, _from, address(this), _amount);
return _getCurrentMarketPrice();
}

function _recoverReserve(bool isMainToken, uint256 _liquadateRatio)
internal
{
Expand Down
17 changes: 10 additions & 7 deletions contracts/Pricing/PriceTracker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ contract CurrencyPriceTicker is usingProvable, Ownable {
string memory _result,
bytes memory _proof
) public {
require(msg.sender == provable_cbAddress(),ERR_AUTHORIZED_ADDRESS_ONLY);
require(validIds[_myid],"ERR_NOT_VALID_ID");

priceUSD = parseInt(_result);
delete validIds[_myid];
emit LogNewEthPriceTicker(priceUSD);
emit LogProof(_proof);
require(msg.sender == provable_cbAddress());
require(validIds[_myid]);

uint256 _priceUSD = parseInt(_result);
if (_priceUSD > 0) {
priceUSD = _priceUSD;
delete validIds[_myid];
emit LogNewEthPriceTicker(priceUSD);
emit LogProof(_proof);
}
}

function getCurrencyPrice() external view returns (uint256) {
Expand Down
115 changes: 13 additions & 102 deletions contracts/Protection/AuctionProtection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ contract AuctionRegistery is ProxyOwnable, AuctionRegisteryContracts {
contract UtilsStorage {
uint256 public tokenLockDuration;

address[] public allowedTokens;

mapping(address => bool) public tokenAllowed;

mapping(address => bool) public unLockBlock;
Expand All @@ -88,18 +86,6 @@ contract Utils is SafeMath, UtilsStorage, AuctionRegistery {
_;
}

function allowToken(address _which)
external
onlySystem()
notZeroAddress(_which)
returns (bool)
{
require(!tokenAllowed[_which], "ERR_TOKEN_ALREADY_ALLOWED");
allowedTokens.push(_which);
tokenAllowed[_which] = true;
return true;
}

function setVaultRatio(uint256 _vaultRatio)
external
onlyAuthorized()
Expand Down Expand Up @@ -295,8 +281,6 @@ contract Stacking is
lastRound[msg.sender] = 0;
emit StackRemoved(stackRoundId, msg.sender, actulToken);
}


}

contract AuctionProtection is Upgradeable, Stacking {
Expand Down Expand Up @@ -368,25 +352,7 @@ contract AuctionProtection is Upgradeable, Stacking {
"ERR_INVESTMENT_CANCEL_PERIOD_OVER"
);

uint256 _tokenBalance;
IERC20Token _token;
for (uint256 tempX = 0; tempX < allowedTokens.length; tempX++) {
_token = IERC20Token(allowedTokens[tempX]);
_tokenBalance = lockedFunds[msg.sender][address(_token)];
if (_tokenBalance > 0) {
ensureTransferFrom(
_token,
address(this),
msg.sender,
_tokenBalance
);
lockedFunds[msg.sender][address(_token)] = 0;
emit FundTransfer(msg.sender, address(_token), _tokenBalance);
}
}

_tokenBalance = lockedFunds[msg.sender][address(0)];

uint256 _tokenBalance = lockedFunds[msg.sender][address(0)];
if (_tokenBalance > 0) {
msg.sender.transfer(_tokenBalance);
emit FundTransfer(msg.sender, address(0), _tokenBalance);
Expand All @@ -395,8 +361,7 @@ contract AuctionProtection is Upgradeable, Stacking {

_tokenBalance = lockedTokens[msg.sender];
if (_tokenBalance > 0) {
_token = IERC20Token(mainTokenAddress);

IERC20Token _token = IERC20Token(mainTokenAddress);
approveTransferFrom(_token, vaultAddress, _tokenBalance);

ITokenVault(vaultAddress).depositeToken(
Expand All @@ -417,51 +382,14 @@ contract AuctionProtection is Upgradeable, Stacking {
internal
returns (bool)
{
uint256 _tokenBalance;
IERC20Token _token;
uint256 walletAmount;
uint256 tagAlongAmount;

for (uint256 tempX = 0; tempX < allowedTokens.length; tempX++) {
_token = IERC20Token(allowedTokens[tempX]);
_tokenBalance = lockedFunds[_which][address(_token)];
if (_tokenBalance > 0) {
walletAmount = safeDiv(safeMul(_tokenBalance, vaultRatio), 100);
tagAlongAmount = safeSub(_tokenBalance, walletAmount);

approveTransferFrom(_token, tagAlongAddress, tagAlongAmount);

IAuctionTagAlong(tagAlongAddress).depositeToken(
_token,
address(this),
tagAlongAmount
);

ensureTransferFrom(
_token,
address(this),
companyFundWalletAddress,
walletAmount
);

emit FundTransfer(
tagAlongAddress,
address(_token),
tagAlongAmount
);
emit FundTransfer(
companyFundWalletAddress,
address(_token),
walletAmount
);
lockedFunds[_which][address(_token)] = 0;
}
}
_tokenBalance = lockedFunds[_which][address(0)];
uint256 _tokenBalance = lockedFunds[_which][address(0)];

if (_tokenBalance > 0) {
walletAmount = safeDiv(safeMul(_tokenBalance, vaultRatio), 100);
tagAlongAmount = safeSub(_tokenBalance, walletAmount);
uint256 walletAmount = safeDiv(
safeMul(_tokenBalance, vaultRatio),
100
);
uint256 tagAlongAmount = safeSub(_tokenBalance, walletAmount);

tagAlongAddress.transfer(tagAlongAmount);
companyFundWalletAddress.transfer(walletAmount);
Expand All @@ -477,7 +405,8 @@ contract AuctionProtection is Upgradeable, Stacking {
_tokenBalance = lockedTokens[_which];

if (_tokenBalance > 0) {
_token = IERC20Token(mainTokenAddress);
IERC20Token _token = IERC20Token(mainTokenAddress);

if (isStacking) {
addFundToStacking(_which, _tokenBalance);
} else {
Expand Down Expand Up @@ -527,34 +456,16 @@ contract AuctionProtection is Upgradeable, Stacking {

lockedTokens[_which] = safeAdd(lockedTokens[_which], _amount);

uint256 _currentTokenBalance;
IERC20Token _token;

for (uint256 tempX = 0; tempX < allowedTokens.length; tempX++) {
_token = IERC20Token(allowedTokens[tempX]);

_currentTokenBalance = currentLockedFunds[_which][address(_token)];

if (_currentTokenBalance > 0) {
lockedFunds[_which][address(_token)] = safeAdd(
lockedFunds[_which][address(_token)],
_currentTokenBalance
);

currentLockedFunds[_which][address(_token)] = 0;
}
}

if (currentLockedFunds[_which][address(0)] > 0) {
_currentTokenBalance = currentLockedFunds[_which][address(0)];
uint256 _currentTokenBalance = currentLockedFunds[_which][address(
0
)];
lockedFunds[_which][address(0)] = safeAdd(
lockedFunds[_which][address(0)],
_currentTokenBalance
);

currentLockedFunds[_which][address(0)] = 0;
}

emit FundLocked(address(token), _which, _amount);
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/auctionContracts/AuctionRegistery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ pragma solidity ^0.5.9;
import "../common/Ownable.sol";
import "../common/SafeMath.sol";


interface Icontract {
function updateAddresses() external returns (bool);
}


contract AuctionRegistery is Ownable, SafeMath {
// store all contract address with bytes32 representation
mapping(bytes32 => address payable) private contractAddress;
Expand Down
Loading

0 comments on commit 5fadd27

Please sign in to comment.