This commit is contained in:
Ravindra Kumar 2018-12-09 01:13:22 +05:30
parent b6145dd90b
commit dfcdf53a38
11 changed files with 75 additions and 214 deletions

View File

@ -1,22 +1,22 @@
# InstaDApp Contract
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/MoatNetwork/MoatContract/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/MoatNetwork/MoatContract.svg?branch=master)](https://travis-ci.org/MoatNetwork/MoatContract)
[![Coverage Status](https://coveralls.io/repos/github/MoatNetwork/MoatContract/badge.svg?branch=master)](https://coveralls.io/github/MoatNetwork/MoatContract?branch=master)
[![CircleCI](https://circleci.com/gh/MoatNetwork/MoatContract.svg?style=svg)](https://circleci.com/gh/MoatNetwork/MoatContract)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/InstaDApp/InstaContract/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/InstaDApp/InstaContract.svg?branch=master)](https://travis-ci.org/InstaDApp/InstaContract)
[![Coverage Status](https://coveralls.io/repos/github/InstaDApp/InstaContract/badge.svg?branch=master)](https://coveralls.io/github/InstaDApp/InstaContract?branch=master)
[![CircleCI](https://circleci.com/gh/InstaDApp/InstaContract.svg?style=svg)](https://circleci.com/gh/InstaDApp/InstaContract)
> Smart Contracts powering InstaDApp
### Support
[![GitHub stars](https://img.shields.io/github/stars/MoatNetwork/MoatContract.svg?style=social&label=Star)](https://github.com/MoatNetwork/MoatContract) [![GitHub forks](https://img.shields.io/github/forks/MoatNetwork/MoatContract.svg?style=social&label=Fork)](https://github.com/MoatNetwork/MoatContract/fork) [![GitHub watchers](https://img.shields.io/github/watchers/MoatNetwork/MoatContract.svg?style=social&label=Watch)](https://github.com/MoatNetwork/MoatContract) [![GitHub followers](https://img.shields.io/github/followers/ravidsrk.svg?style=social&label=Follow)](https://github.com/MoatNetwork/MoatContract)
[![GitHub stars](https://img.shields.io/github/stars/InstaDApp/InstaContract.svg?style=social&label=Star)](https://github.com/InstaDApp/InstaContract) [![GitHub forks](https://img.shields.io/github/forks/InstaDApp/InstaContract.svg?style=social&label=Fork)](https://github.com/InstaDApp/InstaContract/fork) [![GitHub watchers](https://img.shields.io/github/watchers/InstaDApp/InstaContract.svg?style=social&label=Watch)](https://github.com/InstaDApp/InstaContract) [![GitHub followers](https://img.shields.io/github/followers/ravidsrk.svg?style=social&label=Follow)](https://github.com/InstaDApp/InstaContract)
## This project uses:
- [Truffle v5](https://truffleframework.com/)
- [Ganache](https://truffleframework.com/ganache)
- [Solium](https://github.com/duaraghav8/Solium)
- [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-solidity)
- [Travis CI](https://travis-ci.org/MoatNetwork/MoatContract) and [Circle CI](https://circleci.com/gh/MoatNetwork/MoatContract)
- [Coveralls](https://coveralls.io/github/MoatNetwork/MoatContract?branch=master)
- [Travis CI](https://travis-ci.org/InstaDApp/InstaContract) and [Circle CI](https://circleci.com/gh/InstaDApp/InstaContract)
- [Coveralls](https://coveralls.io/github/InstaDApp/InstaContract?branch=master)
## Installation

View File

@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.4.25;
/* solium-disable mixedcase */
contract Migrations {
@ -10,7 +10,7 @@ contract Migrations {
_;
}
constructor()
constructor()
public
{
owner = msg.sender;
@ -26,4 +26,4 @@ contract Migrations {
}
}
/* solium-enable mixedcase */
/* solium-enable mixedcase */

View File

@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.4.25;
/**
@ -36,4 +36,4 @@ contract Ownable {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
}

View File

@ -1,116 +0,0 @@
// // withdraw the extra assets other than global balance (in case anyone donated for free) and then no need for seperate brokerage calculation
// // IMPORTANT CHECK - decimals() - how the balance of tokens with less than 18 decimals are stored. Factor it.
// // update the balance along with "transferAssets" functions and also check the for onlyAllowedResolver
// // transfer assets to different address (create 2 different mappings) - 48 hour time to transfer all - send email for this
// pragma solidity ^0.4.24;
// import "openzeppelin-solidity/contracts/math/SafeMath.sol";
// import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
// interface AddressRegistry {
// function getAddr(string name) external view returns(address);
// function isApprovedResolver(address user) external view returns(bool);
// }
// contract Registry {
// address public registryAddress;
// AddressRegistry addrReg = AddressRegistry(registryAddress);
// modifier onlyAllowedResolver(address user) {
// require(
// addrReg.isApprovedResolver(user),
// "Permission Denied"
// );
// _;
// }
// function getAddress(string name) internal view returns(address addr) {
// addr = addrReg.getAddr(name);
// require(addr != address(0), "Invalid Address");
// }
// }
// contract AssetDB is Registry {
// using SafeMath for uint;
// using SafeMath for uint256;
// mapping(address => mapping(address => uint)) balances;
// address eth = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// function getBalance(
// address assetHolder,
// address tokenAddr
// ) public view returns (uint256 balance)
// {
// balance = balances[assetHolder][tokenAddr];
// }
// function deposit(address tknAddr, uint amount) public payable {
// if (msg.value > 0) {
// balances[msg.sender][eth] = balances[msg.sender][eth].add(msg.value);
// } else {
// IERC20 tokenFunctions = IERC20(tknAddr);
// tokenFunctions.transferFrom(msg.sender, address(this), amount);
// balances[msg.sender][tknAddr] = balances[msg.sender][tknAddr].add(amount);
// }
// }
// function withdraw(address tknAddr, uint amount) public {
// require(balances[msg.sender][tknAddr] >= amount, "Insufficient Balance");
// balances[msg.sender][tknAddr] = balances[msg.sender][tknAddr].sub(amount);
// if (tknAddr == eth) {
// msg.sender.transfer(amount);
// } else {
// IERC20 tokenFunctions = IERC20(tknAddr);
// tokenFunctions.transfer(msg.sender, amount);
// }
// }
// function updateBalance(
// address tokenAddr,
// uint amount,
// bool credit,
// address user
// ) public onlyAllowedResolver(user)
// {
// if (credit) {
// balances[user][tokenAddr] = balances[user][tokenAddr].add(amount);
// } else {
// balances[user][tokenAddr] = balances[user][tokenAddr].sub(amount);
// }
// }
// function transferAssets(
// address tokenAddress,
// uint amount,
// address sendTo,
// address user
// ) public onlyAllowedResolver(user)
// {
// if (tokenAddress == eth) {
// sendTo.transfer(amount);
// } else {
// IERC20 tokenFunctions = IERC20(tokenAddress);
// tokenFunctions.transfer(sendTo, amount);
// }
// balances[user][tokenAddress] = balances[user][tokenAddress].sub(amount);
// }
// }
// contract MoatAsset is AssetDB {
// constructor(address rAddr) public {
// registryAddress = rAddr;
// }
// function () public payable {}
// }

View File

@ -1,58 +0,0 @@
// pragma solidity ^0.4.24;
// import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
// interface AddressRegistry {
// function getAddr(string name) external view returns(address);
// }
// contract Registry {
// address public registryAddress;
// modifier onlyAdmin() {
// require(
// msg.sender == getAddress("admin"),
// "Permission Denied"
// );
// _;
// }
// function getAddress(string name) internal view returns(address addr) {
// AddressRegistry addrReg = AddressRegistry(registryAddress);
// addr = addrReg.getAddr(name);
// require(addr != address(0), "Invalid Address");
// }
// }
// contract FeeDetail is Registry {
// uint public fees;
// function setFees(uint cut) public onlyAdmin { // 200 means 0.5%
// fees = cut;
// }
// }
// contract MoatResolver is FeeDetail {
// function () public payable {}
// constructor(address rAddr, uint cut) public { // 200 means 0.5%
// registryAddress = rAddr;
// setFees(cut);
// }
// function collectAsset(address tokenAddress, uint amount) public onlyAdmin {
// if (tokenAddress == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
// msg.sender.transfer(amount);
// } else {
// IERC20 tokenFunctions = IERC20(tokenAddress);
// tokenFunctions.transfer(msg.sender, amount);
// }
// }
// }

View File

@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity 0.4.25;
library SafeMath {
@ -11,7 +11,7 @@ library SafeMath {
require(c / a == b, "Assertion Failed");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "Assertion Failed");
uint256 c = a / b;
@ -86,7 +86,7 @@ contract Trade is Registry {
address src,
address dest,
uint srcAmt
) public view returns (uint, uint)
) public view returns (uint, uint)
{
Kyber kyberFunctions = Kyber(getAddress("kyber"));
return kyberFunctions.getExpectedRate(
@ -115,7 +115,7 @@ contract Trade is Registry {
uint ethQty = getToken(
msg.sender, src, srcAmt, eth
);
// Interacting with Kyber Proxy Contract
Kyber kyberFunctions = Kyber(getAddress("kyber"));
destAmt = kyberFunctions.trade.value(ethQty)(
@ -173,4 +173,4 @@ contract InstaKyber is Trade {
function () public payable {}
}
}

View File

@ -1,4 +1,4 @@
pragma solidity 0.4.24;
pragma solidity 0.4.25;
library SafeMath {
@ -11,7 +11,7 @@ library SafeMath {
require(c / a == b, "Assertion Failed");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "Assertion Failed");
uint256 c = a / b;
@ -80,7 +80,7 @@ contract Registry {
);
_;
}
function getAddress(string name) internal view returns(address) {
AddressRegistry addrReg = AddressRegistry(addressRegistry);
return addrReg.getAddr(name);
@ -206,7 +206,7 @@ contract RepayLoan is IssueLoan {
address mkr,
uint mkrCharged,
uint ethQty
) internal
) internal
{
InstaKyber instak = InstaKyber(getAddress("InstaKyber"));
uint minRate;
@ -293,4 +293,4 @@ contract InstaMaker is BorrowTasks {
emit MKRCollected(amount);
}
}
}

View File

@ -22,14 +22,14 @@
"build": "npm run clean:contracts && truffle compile"
},
"dependencies": {
"web3": "^1.0.0-beta.36",
"bn.js": "^4.11.8",
"dotenv": "^6.1.0",
"dotenv": "^6.2.0",
"openzeppelin-solidity": "^2.0.0",
"prettier": "^1.14.3",
"truffle": "^5.0.0-beta.0",
"webpack": "^4.23.1",
"truffle-hdwallet-provider": "^1.0.0-web3one.0"
"prettier": "^1.15.3",
"truffle": "^5.0.0-beta.2",
"truffle-hdwallet-provider": "^1.0.0-web3one.0",
"web3": "^1.0.0-beta.37",
"webpack": "^4.27.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
@ -42,13 +42,13 @@
"babel-register": "6.26.0",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"chai-bignumber": "2.0.2",
"chai-bignumber": "3.0.0",
"coveralls": "3.0.2",
"eslint": "5.8.0",
"eslint-config-prettier": "^3.1.0",
"eslint": "5.10.0",
"eslint-config-prettier": "^3.3.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-babel": "^5.2.1",
"eslint-plugin-compat": "^2.6.2",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-compat": "^2.6.3",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "8.0.0",
"eslint-plugin-prettier": "^3.0.0",
@ -56,7 +56,7 @@
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.0",
"eth-gas-reporter": "^0.1.12",
"ganache-cli": "^6.1.8",
"ganache-cli": "^6.2.3",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi-reporters": "^1.1.7",
"solidity-coverage": "0.5.11",

View File

@ -0,0 +1,16 @@
// const { assertRevert } = require('./helpers/general')
const InstaKyber = artifacts.require('InstaKyber')
contract('InstaKyber', accounts => {
let instaKyber
beforeEach(async () => {
instaKyber = await InstaKyber.new(accounts[0])
})
it('should have an owner', async () => {
const addressRegistry = await instaKyber.addressRegistry()
assert.isTrue(addressRegistry !== 0)
})
})

View File

@ -0,0 +1,16 @@
// const { assertRevert } = require('./helpers/general')
const InstaMaker = artifacts.require('InstaMaker')
contract('InstaMaker', accounts => {
let instaMaker
beforeEach(async () => {
instaMaker = await InstaMaker.new(accounts[0])
})
it('should have an owner', async () => {
const addressRegistry = await instaMaker.addressRegistry()
assert.isTrue(addressRegistry == 0)
})
})

View File

@ -40,12 +40,6 @@ module.exports = {
provider: () => rinkebyProvider
}
},
solc: {
optimizer: {
enabled: true,
runs: 500
}
},
mocha: {
reporter: 'mocha-multi-reporters',
useColors: true,
@ -53,5 +47,14 @@ module.exports = {
reporterOptions: {
configFile: './mocha-smart-contracts-config.json'
}
},
compilers: {
solc: {
version: '0.4.25',
optimizer: {
enabled: true,
runs: 500
}
}
}
}