mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
326 lines
26 KiB
JSON
326 lines
26 KiB
JSON
|
{
|
||
|
"schemaVersion": "2.0.0",
|
||
|
"contractName": "Trade",
|
||
|
"compilerOutput": {
|
||
|
"abi": [
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "srcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "minDestAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dexNum",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeFromSrc",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "maxSrcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "destAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "deadline",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeDestUniswap",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "srcAmt",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "getRateFromSrc",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "maxSrcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "destAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dexNum",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeFromDest",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "srcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "minDestAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "deadline",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeSrcUniswap",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "srcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "minDestAmt",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeSrcKyber",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "tokensBought",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"name": "src",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "maxSrcAmt",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"name": "dest",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"name": "destAmt",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "tradeDestKyber",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "tokensBought",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": true,
|
||
|
"stateMutability": "payable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [],
|
||
|
"name": "addressRegistry",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "",
|
||
|
"type": "address"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
}
|
||
|
],
|
||
|
"devdoc": {
|
||
|
"methods": {
|
||
|
"tradeDestUniswap(address,uint256,address,uint256,uint256)": {
|
||
|
"details": "Uniswap's trade when token to buy Amount fixed",
|
||
|
"params": {
|
||
|
"deadline": "- time for this transaction to be valid",
|
||
|
"dest": "- Token address to buy (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")",
|
||
|
"destAmt": "- amount of token to buy",
|
||
|
"maxSrcAmt": "- max amount of token for sell (slippage)",
|
||
|
"src": "- Token address to sell (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")"
|
||
|
}
|
||
|
},
|
||
|
"tradeSrcKyber(address,uint256,address,uint256)": {
|
||
|
"details": "Kyber's trade when token to sell Amount fixed",
|
||
|
"params": {
|
||
|
"dest": "- Token address to buy (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")",
|
||
|
"minDestAmt": "- min amount of token to buy (slippage)",
|
||
|
"src": "- Token address to sell (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")",
|
||
|
"srcAmt": "- amount of token for sell"
|
||
|
}
|
||
|
},
|
||
|
"tradeSrcUniswap(address,uint256,address,uint256,uint256)": {
|
||
|
"details": "Uniswap's trade when token to sell Amount fixed",
|
||
|
"params": {
|
||
|
"deadline": "- time for this transaction to be valid",
|
||
|
"dest": "- Token address to buy (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")",
|
||
|
"minDestAmt": "- min amount of token to buy (slippage)",
|
||
|
"src": "- Token address to sell (for ETH it's \"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\")",
|
||
|
"srcAmt": "- amount of token for sell"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"sources": {
|
||
|
"Bin/Trade.sol": {
|
||
|
"id": 1
|
||
|
},
|
||
|
"openzeppelin-solidity/contracts/math/SafeMath.sol": {
|
||
|
"id": 8
|
||
|
},
|
||
|
"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol": {
|
||
|
"id": 9
|
||
|
}
|
||
|
},
|
||
|
"sourceCodes": {
|
||
|
"Bin/Trade.sol": "pragma solidity ^0.5.2;\n\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\";\n\ninterface AddressRegistry {\n function getAddr(string calldata name) external view returns (address);\n}\n\n// Kyber's contract Interface\ninterface KyberExchange {\n // Kyber's trade function\n function trade(\n address src,\n uint srcAmount,\n address dest,\n address destAddress,\n uint maxDestAmount,\n uint minConversionRate,\n address walletId\n ) external payable returns (uint);\n // Kyber's Get expected Rate function\n function getExpectedRate(address src, address dest, uint srcQty) external view returns (uint, uint);\n}\n\n// Uniswap's factory Interface\ninterface UniswapFactory {\n // get exchange from token's address\n function getExchange(address token) external view returns (address exchange);\n}\n\n// Uniswap's exchange Interface\ninterface UniswapExchange {\n // Get Prices\n function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256 tokens_bought);\n function getEthToTokenOutputPrice(uint256 tokens_bought) external view returns (uint256 eth_sold);\n function getTokenToEthInputPrice(uint256 tokens_sold) external view returns (uint256 eth_bought);\n function getTokenToEthOutputPrice(uint256 eth_bought) external view returns (uint256 tokens_sold);\n // Trade ETH to ERC20\n function ethToTokenTransferInput(uint256 min_tokens, uint256 deadline, address recipient)\n external\n payable\n returns (uint256 tokens_bought);\n function ethToTokenTransferOutput(uint256 tokens_bought, uint256 deadline, address recipient)\n external\n payable\n returns (uint256 eth_sold);\n // Trade ERC20 to ETH\n function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address recipient)\n external\n returns (uint256 eth_bought);\n function tokenToEthTransferOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline, address recipient)\n external\n returns (uint256 tokens_sold);\n // Trade ERC20 to ERC20\n function tokenToTokenTransferInput(\n uint256 tokens_sold,\n uint256 min_tokens_bought,\n uint256 min_eth_bought,\n uint256 deadline,\n address recipient,\n address token_addr\n ) external returns (uint256 tokens_bought);\n function tokenToTokenTransferOutput(\n uint256 tokens_bought,\n uint256 max_tokens_sold,\n uint256 max_eth_sold,\n uint256 deadline,\n address recipient,\n address token_addr\n ) external returns (uint256 tokens_sold);\n}\n\ncontract Registry {\n address public addressRegistry;\n modifier onlyAdmin() {\n require(msg.sender == _getAddress(\"admin\"), \"Permission Denied\");\n _;\n }\n function _getAddress(string memory name) internal view returns (address) {\n AddressRegistry addrReg = AddressRegistry(addressRegistry);\n return addrReg.getAddr(name);\n }\n}\n\n// common stuffs in Kyber and Uniswap's trade\ncontract CommonStuffs {\n using SafeMath for uint;\n\n // Check required ETH Quantity to execute code\n function _getToken(address trader, address src, uint srcAmt, address eth) internal returns (uint ethQty) {\n if (src == eth) {\n require(msg.value == srcAmt, \"Invalid Operation\");\n ethQty = srcAmt;\n } else {\n IERC20 tokenFunctions = IERC20(src);\n tokenFunctions.transferFrom(trader, address(this), srcAmt);\n ethQty = 0;\n }\n }\n\n function _approveDexes(address token, address dexToApprove) internal returns (bool) {\n IERC20 tokenFunctions = IERC20(token);\n return tokenFunctions.approve(dexToApprove, uint(0 - 1));\n }\n\n function _allowance(address token, address spender) internal view returns (uint) {\n IERC20 tokenFunctions = IERC20(token);\
|
||
|
"openzeppelin-solidity/contracts/math/SafeMath.sol": "pragma solidity ^0.5.2;\n\n/**\n * @title SafeMath\n * @dev Unsigned math operations with safety checks that revert on error\n */\nlibrary SafeMath {\n /**\n * @dev Multiplies two unsigned integers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two unsigned integers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\n }\n\n /**\n * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),\n * reverts when dividing by zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0);\n return a % b;\n }\n}\n",
|
||
|
"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol": "pragma solidity ^0.5.2;\n\n/**\n * @title ERC20 interface\n * @dev see https://eips.ethereum.org/EIPS/eip-20\n */\ninterface IERC20 {\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
|
||
|
},
|
||
|
"sourceTreeHashHex": "0xbee8534ae72caa346db64d4228c956f28b5b6e5bde284b56c91ae92e3a6fa1e2",
|
||
|
"compiler": {
|
||
|
"name": "solc",
|
||
|
"version": "soljson-v0.5.7+commit.6da8b019.js",
|
||
|
"settings": {
|
||
|
"optimizer": {
|
||
|
"enabled": false
|
||
|
},
|
||
|
"outputSelection": {
|
||
|
"*": {
|
||
|
"*": [
|
||
|
"abi",
|
||
|
"devdoc"
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
"remappings": [
|
||
|
"openzeppelin-solidity=/Users/ravindra/code/contract-v2/node_modules/openzeppelin-solidity"
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
"networks": {}
|
||
|
}
|