mirror of
				https://github.com/Instadapp/InstaContract.git
				synced 2024-07-29 22:47:45 +00:00 
			
		
		
		
	WIP
This commit is contained in:
		
							parent
							
								
									b6145dd90b
								
							
						
					
					
						commit
						dfcdf53a38
					
				
							
								
								
									
										14
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								README.md
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -1,22 +1,22 @@
 | 
			
		|||
# InstaDApp Contract
 | 
			
		||||
 | 
			
		||||
[](https://github.com/MoatNetwork/MoatContract/blob/master/LICENSE)
 | 
			
		||||
[](https://travis-ci.org/MoatNetwork/MoatContract)
 | 
			
		||||
[](https://coveralls.io/github/MoatNetwork/MoatContract?branch=master)
 | 
			
		||||
[](https://circleci.com/gh/MoatNetwork/MoatContract)
 | 
			
		||||
[](https://github.com/InstaDApp/InstaContract/blob/master/LICENSE)
 | 
			
		||||
[](https://travis-ci.org/InstaDApp/InstaContract)
 | 
			
		||||
[](https://coveralls.io/github/InstaDApp/InstaContract?branch=master)
 | 
			
		||||
[](https://circleci.com/gh/InstaDApp/InstaContract)
 | 
			
		||||
 | 
			
		||||
> Smart Contracts powering InstaDApp
 | 
			
		||||
 | 
			
		||||
### Support
 | 
			
		||||
[](https://github.com/MoatNetwork/MoatContract) [](https://github.com/MoatNetwork/MoatContract/fork) [](https://github.com/MoatNetwork/MoatContract) [](https://github.com/MoatNetwork/MoatContract)
 | 
			
		||||
[](https://github.com/InstaDApp/InstaContract) [](https://github.com/InstaDApp/InstaContract/fork) [](https://github.com/InstaDApp/InstaContract) [](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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
pragma solidity 0.4.24;
 | 
			
		||||
pragma solidity 0.4.25;
 | 
			
		||||
 | 
			
		||||
/* solium-disable mixedcase */
 | 
			
		||||
contract Migrations {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
pragma solidity 0.4.24;
 | 
			
		||||
pragma solidity 0.4.25;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {}
 | 
			
		||||
 | 
			
		||||
// }
 | 
			
		||||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
//         }
 | 
			
		||||
//     }
 | 
			
		||||
 | 
			
		||||
// }
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
pragma solidity ^0.4.24;
 | 
			
		||||
pragma solidity 0.4.25;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
library SafeMath {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
pragma solidity 0.4.24;
 | 
			
		||||
pragma solidity 0.4.25;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
library SafeMath {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										24
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								package.json
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								test/protocols/InstaKyber.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/protocols/InstaKyber.test.js
									
									
									
									
									
										Normal 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)
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										16
									
								
								test/protocols/InstaMaker.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/protocols/InstaMaker.test.js
									
									
									
									
									
										Normal 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)
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										15
									
								
								truffle.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								truffle.js
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user