Created
July 26, 2020 17:59
-
-
Save rori4/f7b93a15a9ba8a922028f04861d94a33 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.17+commit.d19bba13.js&optimize=false&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.4.22 <0.7.0; | |
| /** | |
| * @title Storage | |
| * @dev Store & retreive value in a variable | |
| */ | |
| contract Storage { | |
| uint256 number; | |
| /** | |
| * @dev Store value in variable | |
| * @param num value to store | |
| */ | |
| function store(uint256 num) public { | |
| number = num; | |
| } | |
| /** | |
| * @dev Return value | |
| * @return value of 'number' | |
| */ | |
| function retreive() public view returns (uint256){ | |
| return number; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.4.22 <0.7.0; | |
| /** | |
| * @title Owner | |
| * @dev Set & change owner | |
| */ | |
| contract Owner { | |
| address private owner; | |
| // event for EVM logging | |
| event OwnerSet(address indexed oldOwner, address indexed newOwner); | |
| // modifier to check if caller is owner | |
| modifier isOwner() { | |
| // If the first argument of 'require' evaluates to 'false', execution terminates and all | |
| // changes to the state and to Ether balances are reverted. | |
| // This used to consume all gas in old EVM versions, but not anymore. | |
| // It is often a good idea to use 'require' to check if functions are called correctly. | |
| // As a second argument, you can also provide an explanation about what went wrong. | |
| require(msg.sender == owner, "Caller is not owner"); | |
| _; | |
| } | |
| /** | |
| * @dev Set contract deployer as owner | |
| */ | |
| constructor() public { | |
| owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor | |
| emit OwnerSet(address(0), owner); | |
| } | |
| /** | |
| * @dev Change owner | |
| * @param newOwner address of new owner | |
| */ | |
| function changeOwner(address newOwner) public isOwner { | |
| emit OwnerSet(owner, newOwner); | |
| owner = newOwner; | |
| } | |
| /** | |
| * @dev Return owner address | |
| * @return address of owner | |
| */ | |
| function getOwner() external view returns (address) { | |
| return owner; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.4.22 <0.7.0; | |
| /** | |
| * @title Ballot | |
| * @dev Implements voting process along with vote delegation | |
| */ | |
| contract Ballot { | |
| struct Voter { | |
| uint weight; // weight is accumulated by delegation | |
| bool voted; // if true, that person already voted | |
| address delegate; // person delegated to | |
| uint vote; // index of the voted proposal | |
| } | |
| struct Proposal { | |
| // If you can limit the length to a certain number of bytes, | |
| // always use one of bytes1 to bytes32 because they are much cheaper | |
| bytes32 name; // short name (up to 32 bytes) | |
| uint voteCount; // number of accumulated votes | |
| } | |
| address public chairperson; | |
| mapping(address => Voter) public voters; | |
| Proposal[] public proposals; | |
| /** | |
| * @dev Create a new ballot to choose one of 'proposalNames'. | |
| * @param proposalNames names of proposals | |
| */ | |
| constructor(bytes32[] memory proposalNames) public { | |
| chairperson = msg.sender; | |
| voters[chairperson].weight = 1; | |
| for (uint i = 0; i < proposalNames.length; i++) { | |
| // 'Proposal({...})' creates a temporary | |
| // Proposal object and 'proposals.push(...)' | |
| // appends it to the end of 'proposals'. | |
| proposals.push(Proposal({ | |
| name: proposalNames[i], | |
| voteCount: 0 | |
| })); | |
| } | |
| } | |
| /** | |
| * @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. | |
| * @param voter address of voter | |
| */ | |
| function giveRightToVote(address voter) public { | |
| require( | |
| msg.sender == chairperson, | |
| "Only chairperson can give right to vote." | |
| ); | |
| require( | |
| !voters[voter].voted, | |
| "The voter already voted." | |
| ); | |
| require(voters[voter].weight == 0); | |
| voters[voter].weight = 1; | |
| } | |
| /** | |
| * @dev Delegate your vote to the voter 'to'. | |
| * @param to address to which vote is delegated | |
| */ | |
| function delegate(address to) public { | |
| Voter storage sender = voters[msg.sender]; | |
| require(!sender.voted, "You already voted."); | |
| require(to != msg.sender, "Self-delegation is disallowed."); | |
| while (voters[to].delegate != address(0)) { | |
| to = voters[to].delegate; | |
| // We found a loop in the delegation, not allowed. | |
| require(to != msg.sender, "Found loop in delegation."); | |
| } | |
| sender.voted = true; | |
| sender.delegate = to; | |
| Voter storage delegate_ = voters[to]; | |
| if (delegate_.voted) { | |
| // If the delegate already voted, | |
| // directly add to the number of votes | |
| proposals[delegate_.vote].voteCount += sender.weight; | |
| } else { | |
| // If the delegate did not vote yet, | |
| // add to her weight. | |
| delegate_.weight += sender.weight; | |
| } | |
| } | |
| /** | |
| * @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. | |
| * @param proposal index of proposal in the proposals array | |
| */ | |
| function vote(uint proposal) public { | |
| Voter storage sender = voters[msg.sender]; | |
| require(sender.weight != 0, "Has no right to vote"); | |
| require(!sender.voted, "Already voted."); | |
| sender.voted = true; | |
| sender.vote = proposal; | |
| // If 'proposal' is out of the range of the array, | |
| // this will throw automatically and revert all | |
| // changes. | |
| proposals[proposal].voteCount += sender.weight; | |
| } | |
| /** | |
| * @dev Computes the winning proposal taking all previous votes into account. | |
| * @return winningProposal_ index of winning proposal in the proposals array | |
| */ | |
| function winningProposal() public view | |
| returns (uint winningProposal_) | |
| { | |
| uint winningVoteCount = 0; | |
| for (uint p = 0; p < proposals.length; p++) { | |
| if (proposals[p].voteCount > winningVoteCount) { | |
| winningVoteCount = proposals[p].voteCount; | |
| winningProposal_ = p; | |
| } | |
| } | |
| } | |
| /** | |
| * @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then | |
| * @return winnerName_ the name of the winner | |
| */ | |
| function winnerName() public view | |
| returns (bytes32 winnerName_) | |
| { | |
| winnerName_ = proposals[winningProposal()].name; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Mainent: 0x99f1b2247381bd89ed695c4b422d13557d9430d4 | |
| pragma solidity >=0.4.26; | |
| pragma experimental ABIEncoderV2; | |
| interface OrFeedInterface { | |
| function getExchangeRate ( string fromSymbol, string toSymbol, string venue, uint256 amount ) external view returns ( uint256 ); | |
| function getTokenDecimalCount ( address tokenAddress ) external view returns ( uint256 ); | |
| function getTokenAddress ( string symbol ) external view returns ( address ); | |
| function getSynthBytes32 ( string symbol ) external view returns ( bytes32 ); | |
| function getForexAddress ( string symbol ) external view returns ( address ); | |
| } | |
| library SafeMath { | |
| function mul(uint256 a, uint256 b) internal view returns(uint256) { | |
| uint256 c = a * b; | |
| assert(a == 0 || c / a == b); | |
| return c; | |
| } | |
| function div(uint256 a, uint256 b) internal view returns(uint256) { | |
| assert(b > 0); // Solidity automatically throws when dividing by 0 | |
| uint256 c = a / b; | |
| assert(a == b * c + a % b); // There is no case in which this doesn't hold | |
| return c; | |
| } | |
| function sub(uint256 a, uint256 b) internal view returns(uint256) { | |
| assert(b <= a); | |
| return a - b; | |
| } | |
| function add(uint256 a, uint256 b) internal view returns(uint256) { | |
| uint256 c = a + b; | |
| assert(c >= a); | |
| return c; | |
| } | |
| } | |
| contract ArbCalc{ | |
| OrFeedInterface orfeed = OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336); | |
| address owner; | |
| modifier onlyOwner() { | |
| if (msg.sender != owner) { | |
| throw; | |
| } | |
| _; | |
| } | |
| constructor() public payable { | |
| owner = msg.sender; | |
| } | |
| function kill() onlyOwner{ | |
| selfdestruct(owner); | |
| } | |
| function() payable{ | |
| } | |
| function arbCalc(uint8[] eOrder, string[] tOrder, uint256 amount, bool back ) public constant returns (uint256){ | |
| uint256 final1 = eOrder.length -1; | |
| uint lastSell = amount; | |
| for(uint i =0; i<eOrder.length; i++){ | |
| uint256 next = i+1; | |
| if(i < final1){ | |
| if(eOrder[i] ==1){ | |
| //kyber buy | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[0], "KYBERBYSYMBOLV1", lastSell); | |
| } | |
| else if(eOrder[i] ==2){ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[next], "UNISWAPBYSYMBOLV1", lastSell); | |
| //lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[next], "BUY-UNISWAP-EXCHANGE", lastSell); | |
| } | |
| else if(eOrder[i] ==4){ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[next], "UNISWAPBYSYMBOLV2", lastSell); | |
| // lastSell = swapTokenOnUniswapCalc(tOrder[i], lastSell, tOrder[0]); | |
| } | |
| else{ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[next], "BANCOR", lastSell); | |
| } | |
| } | |
| else{ | |
| //sell | |
| if(back ==true){ | |
| if(eOrder[i] ==1){ | |
| //kyber buy | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[0], "KYBERBYSYMBOLV1", lastSell); | |
| //lastSell = swapTokenOnKyberCalc(tOrder[i], lastSell, tOrder[0]); | |
| } | |
| else if(eOrder[i] ==2){ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[0], "UNISWAPBYSYMBOLV1", lastSell); | |
| // lastSell = swapTokenOnUniswapCalc(tOrder[i], lastSell, tOrder[0]); | |
| } | |
| else if(eOrder[i] ==4){ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[0], "UNISWAPBYSYMBOLV2", lastSell); | |
| // lastSell = swapTokenOnUniswapCalc(tOrder[i], lastSell, tOrder[0]); | |
| } | |
| else{ | |
| lastSell = orfeed.getExchangeRate(tOrder[i], tOrder[0], "BANCOR", lastSell); | |
| //lastSell = bancorConvert2Calc(tOrder[0], tOrder[i], lastSell); | |
| } | |
| } | |
| } | |
| } | |
| return lastSell; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/FlashLoanReceiverBase.sol"; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/ILendingPool.sol"; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/ILendingPoolAddressesProvider.sol"; | |
| //DAI ADDRESS: 0xFf795577d9AC8bD7D90Ee22b6C1703490b6512FD | |
| // PROVIDER ADDRESS: 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5 | |
| // 1000 dai = 1000000000000000000000 (Due to 18 decimal number) | |
| contract MyfirstFlashLoan is FlashLoanReceiverBase(address(0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5)) { | |
| function flashLoan(uint256 newamount, address _token) external { | |
| bytes memory _params = "0x0"; | |
| address exchangeAddress = addressesProvider.getLendingPool(); | |
| ILendingPool exchange = ILendingPool(exchangeAddress); | |
| exchange.flashLoan(address(this), _token, newamount, _params); | |
| } | |
| function executeOperation( | |
| address _reserve, | |
| uint256 _amount, | |
| uint256 _fee, | |
| bytes calldata _params | |
| ) external { | |
| // INSERT YOUR USE CASE HERE | |
| uint256 totalDebt = _amount.add(_fee); | |
| transferFundsBackToPoolInternal(_reserve, totalDebt); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| pragma experimental ABIEncoderV2; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/FlashLoanReceiverBase.sol"; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/ILendingPool.sol"; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/aave/ILendingPoolAddressesProvider.sol"; | |
| import "https://github.com/mrdavey/ez-flashloan/blob/remix/contracts/utils/Withdrawable.sol"; | |
| interface OrFeedInterface { | |
| function getExchangeRate ( string calldata fromSymbol, string calldata toSymbol, string calldata venue, uint256 amount ) external view returns ( uint256 ); | |
| function getTokenDecimalCount ( address tokenAddress ) external view returns ( uint256 ); | |
| function getTokenAddress ( string calldata symbol ) external view returns ( address ); | |
| function getSynthBytes32 ( string calldata symbol ) external view returns ( bytes32 ); | |
| function getForexAddress ( string calldata symbol ) external view returns ( address ); | |
| function arb(address fundsReturnToAddress, address liquidityProviderContractAddress, string[] calldata tokens, uint256 amount, string[] calldata exchanges) external payable returns (bool); | |
| } | |
| contract Flashloan is FlashLoanReceiverBase(address(0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5)) { | |
| /** | |
| This function is called after your contract has received the flash loaned amount | |
| */ | |
| function executeOperation( | |
| address _reserve, | |
| uint256 _amount, | |
| uint256 _fee, | |
| bytes calldata _params | |
| ) external { | |
| require(_amount <= getBalanceInternal(address(this), _reserve), "Invalid balance, was the flashLoan successful?"); | |
| // | |
| // Your logic goes here. | |
| // !! Ensure that *this contract* has enough of `_reserve` funds to payback the `_fee` !! | |
| // | |
| uint totalDebt = _amount.add(_fee); | |
| transferFundsBackToPoolInternal(_reserve, totalDebt); | |
| } | |
| function flashloan(address _asset, uint256 _amount) public onlyOwner { | |
| /** | |
| * Flash Loan of 1000 DAI | |
| */ | |
| address receiver = address(this); | |
| // address asset = "0x6b175474e89094c44da98b954eedeac495271d0f"; // Dai | |
| uint256 amount = _amount * 1e18; | |
| // If no params are needed, use an empty params: | |
| bytes memory params = ""; | |
| // Else encode the params like below (bytes encoded param of type `address` and `uint`) | |
| // bytes memory params = abi.encode(address(this), 1234); | |
| ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool()); | |
| lendingPool.flashLoan(receiver, _asset, amount, params); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| interface ILendingPool { | |
| function addressesProvider () external view returns ( address ); | |
| function deposit ( address _reserve, uint256 _amount, uint16 _referralCode ) external payable; | |
| function redeemUnderlying ( address _reserve, address _user, uint256 _amount ) external; | |
| function borrow ( address _reserve, uint256 _amount, uint256 _interestRateMode, uint16 _referralCode ) external; | |
| function repay ( address _reserve, uint256 _amount, address _onBehalfOf ) external payable; | |
| function swapBorrowRateMode ( address _reserve ) external; | |
| function rebalanceFixedBorrowRate ( address _reserve, address _user ) external; | |
| function setUserUseReserveAsCollateral ( address _reserve, bool _useAsCollateral ) external; | |
| function liquidationCall ( address _collateral, address _reserve, address _user, uint256 _purchaseAmount, bool _receiveAToken ) external payable; | |
| function flashLoan ( address _receiver, address _reserve, uint256 _amount, bytes calldata _params ) external; | |
| function getReserveConfigurationData ( address _reserve ) external view returns ( uint256 ltv, uint256 liquidationThreshold, uint256 liquidationDiscount, address interestRateStrategyAddress, bool usageAsCollateralEnabled, bool borrowingEnabled, bool fixedBorrowRateEnabled, bool isActive ); | |
| function getReserveData ( address _reserve ) external view returns ( uint256 totalLiquidity, uint256 availableLiquidity, uint256 totalBorrowsFixed, uint256 totalBorrowsVariable, uint256 liquidityRate, uint256 variableBorrowRate, uint256 fixedBorrowRate, uint256 averageFixedBorrowRate, uint256 utilizationRate, uint256 liquidityIndex, uint256 variableBorrowIndex, address aTokenAddress, uint40 lastUpdateTimestamp ); | |
| function getUserAccountData ( address _user ) external view returns ( uint256 totalLiquidityETH, uint256 totalCollateralETH, uint256 totalBorrowsETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); | |
| function getUserReserveData ( address _reserve, address _user ) external view returns ( uint256 currentATokenBalance, uint256 currentUnderlyingBalance, uint256 currentBorrowBalance, uint256 principalBorrowBalance, uint256 borrowRateMode, uint256 borrowRate, uint256 liquidityRate, uint256 originationFee, uint256 variableBorrowIndex, uint256 lastUpdateTimestamp, bool usageAsCollateralEnabled ); | |
| function getReserves () external view; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this line is added to create a gist. Empty file is not allowed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.4.26; | |
| pragma experimental ABIEncoderV2; | |
| interface IKyberNetworkProxy { | |
| function maxGasPrice() external view returns(uint); | |
| function getUserCapInWei(address user) external view returns(uint); | |
| function getUserCapInTokenWei(address user, ERC20 token) external view returns(uint); | |
| function enabled() external view returns(bool); | |
| function info(bytes32 id) external view returns(uint); | |
| function getExpectedRate(ERC20 src, ERC20 dest, uint srcQty) external view returns (uint expectedRate, uint slippageRate); | |
| function tradeWithHint(ERC20 src, uint srcAmount, ERC20 dest, address destAddress, uint maxDestAmount, uint minConversionRate, address walletId, bytes hint) external payable returns(uint); | |
| function swapEtherToToken(ERC20 token, uint minRate) external payable returns (uint); | |
| function swapTokenToEther(ERC20 token, uint tokenQty, uint minRate) external returns (uint); | |
| } | |
| contract IUniswapExchange { | |
| // Address of ERC20 token sold on this exchange | |
| function tokenAddress() external view returns (address token); | |
| // Address of Uniswap Factory | |
| function factoryAddress() external view returns (address factory); | |
| // Provide Liquidity | |
| function addLiquidity(uint256 min_liquidity, uint256 max_tokens, uint256 deadline) external payable returns (uint256); | |
| function removeLiquidity(uint256 amount, uint256 min_eth, uint256 min_tokens, uint256 deadline) external returns (uint256, uint256); | |
| // Get Prices | |
| function getEthToTokenInputPrice(uint256 eth_sold) external view returns (uint256 tokens_bought); | |
| function getEthToTokenOutputPrice(uint256 tokens_bought) external view returns (uint256 eth_sold); | |
| function getTokenToEthInputPrice(uint256 tokens_sold) external view returns (uint256 eth_bought); | |
| function getTokenToEthOutputPrice(uint256 eth_bought) external view returns (uint256 tokens_sold); | |
| // Trade ETH to ERC20 | |
| function ethToTokenSwapInput(uint256 min_tokens, uint256 deadline) external payable returns (uint256 tokens_bought); | |
| function ethToTokenTransferInput(uint256 min_tokens, uint256 deadline, address recipient) external payable returns (uint256 tokens_bought); | |
| function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline) external payable returns (uint256 eth_sold); | |
| function ethToTokenTransferOutput(uint256 tokens_bought, uint256 deadline, address recipient) external payable returns (uint256 eth_sold); | |
| // Trade ERC20 to ETH | |
| function tokenToEthSwapInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline) external returns (uint256 eth_bought); | |
| function tokenToEthTransferInput(uint256 tokens_sold, uint256 min_eth, uint256 deadline, address recipient) external returns (uint256 eth_bought); | |
| function tokenToEthSwapOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline) external returns (uint256 tokens_sold); | |
| function tokenToEthTransferOutput(uint256 eth_bought, uint256 max_tokens, uint256 deadline, address recipient) external returns (uint256 tokens_sold); | |
| // Trade ERC20 to ERC20 | |
| function tokenToTokenSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address token_addr) external returns (uint256 tokens_bought); | |
| function tokenToTokenTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address token_addr) external returns (uint256 tokens_bought); | |
| function tokenToTokenSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address token_addr) external returns (uint256 tokens_sold); | |
| function tokenToTokenTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address token_addr) external returns (uint256 tokens_sold); | |
| // Trade ERC20 to Custom Pool | |
| function tokenToExchangeSwapInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address exchange_addr) external returns (uint256 tokens_bought); | |
| function tokenToExchangeTransferInput(uint256 tokens_sold, uint256 min_tokens_bought, uint256 min_eth_bought, uint256 deadline, address recipient, address exchange_addr) external returns (uint256 tokens_bought); | |
| function tokenToExchangeSwapOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address exchange_addr) external returns (uint256 tokens_sold); | |
| function tokenToExchangeTransferOutput(uint256 tokens_bought, uint256 max_tokens_sold, uint256 max_eth_sold, uint256 deadline, address recipient, address exchange_addr) external returns (uint256 tokens_sold); | |
| // ERC20 comaptibility for liquidity tokens | |
| bytes32 public name; | |
| bytes32 public symbol; | |
| uint256 public decimals; | |
| function transfer(address _to, uint256 _value) external returns (bool); | |
| function transferFrom(address _from, address _to, uint256 value) external returns (bool); | |
| function approve(address _spender, uint256 _value) external returns (bool); | |
| function allowance(address _owner, address _spender) external view returns (uint256); | |
| function balanceOf(address _owner) external view returns (uint256); | |
| function totalSupply() external view returns (uint256); | |
| // Never use | |
| function setup(address token_addr) external; | |
| } | |
| interface IWETH { | |
| function deposit() external payable; | |
| function withdraw(uint wad) external; | |
| function totalSupply() external view returns (uint); | |
| function approve(address guy, uint wad) external returns (bool); | |
| function transfer(address dst, uint wad) external returns (bool); | |
| function transferFrom(address src, address dst, uint wad) external returns (bool); | |
| function () external payable; | |
| } | |
| interface IUniswapFactory { | |
| function createExchange(address token) external returns (address exchange); | |
| function getExchange(address token) external view returns (address exchange); | |
| function getToken(address exchange) external view returns (address token); | |
| function getTokenWithId(uint256 tokenId) external view returns (address token); | |
| function initializeFactory(address template) external; | |
| } | |
| interface ERC20 { | |
| function totalSupply() external view returns (uint supply); | |
| function balanceOf(address _owner) external view returns (uint balance); | |
| function transfer(address _to, uint _value) external returns (bool success); | |
| function transferFrom(address _from, address _to, uint _value) external returns (bool success); | |
| function approve(address _spender, uint _value) external returns (bool success); | |
| function allowance(address _owner, address _spender) external view returns (uint remaining); | |
| function decimals() external view returns(uint digits); | |
| event Approval(address indexed _owner, address indexed _spender, uint _value); | |
| } | |
| contract IERC20Token { | |
| function name() public view returns (string memory) {this;} | |
| function symbol() public view returns (string memory) {this;} | |
| function decimals() public view returns (uint8) {this;} | |
| function totalSupply() public view returns (uint256) {this;} | |
| function balanceOf(address _owner) public view returns (uint256) {_owner; this;} | |
| function allowance(address _owner, address _spender) public view returns (uint256) {_owner; _spender; this;} | |
| function transfer(address _to, uint256 _value) public returns (bool success); | |
| function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); | |
| function approve(address _spender, uint256 _value) public returns (bool success); | |
| } | |
| interface OrFeedInterface { | |
| function getExchangeRate ( string fromSymbol, string toSymbol, string venue, uint256 amount ) external view returns ( uint256 ); | |
| function getTokenDecimalCount ( address tokenAddress ) external view returns ( uint256 ); | |
| function getTokenAddress ( string symbol ) external view returns ( address ); | |
| function getSynthBytes32 ( string symbol ) external view returns ( bytes32 ); | |
| function getForexAddress ( string symbol ) external view returns ( address ); | |
| } | |
| interface IContractRegistry { | |
| function addressOf(bytes32 _contractName) external view returns (address); | |
| } | |
| interface IBancorNetwork { | |
| function getReturnByPath(address[] _path, uint256 _amount) external view returns (uint256, uint256); | |
| function convert2(address[] _path, uint256 _amount, | |
| uint256 _minReturn, | |
| address _affiliateAccount, | |
| uint256 _affiliateFee | |
| ) public payable returns (uint256); | |
| function claimAndConvert2( | |
| address[] _path, | |
| uint256 _amount, | |
| uint256 _minReturn, | |
| address _affiliateAccount, | |
| uint256 _affiliateFee | |
| ) public returns (uint256); | |
| } | |
| interface IBancorNetworkPathFinder { | |
| function generatePath(address _sourceToken, address _targetToken) external view returns (address[]); | |
| } | |
| library SafeMath { | |
| function mul(uint256 a, uint256 b) internal view returns(uint256) { | |
| uint256 c = a * b; | |
| assert(a == 0 || c / a == b); | |
| return c; | |
| } | |
| function div(uint256 a, uint256 b) internal view returns(uint256) { | |
| assert(b > 0); // Solidity automatically throws when dividing by 0 | |
| uint256 c = a / b; | |
| assert(a == b * c + a % b); // There is no case in which this doesn't hold | |
| return c; | |
| } | |
| function sub(uint256 a, uint256 b) internal view returns(uint256) { | |
| assert(b <= a); | |
| return a - b; | |
| } | |
| function add(uint256 a, uint256 b) internal view returns(uint256) { | |
| uint256 c = a + b; | |
| assert(c >= a); | |
| return c; | |
| } | |
| } | |
| contract flashIt{ | |
| function executeOperation( | |
| address _reserve, | |
| uint256 _amount, | |
| uint256 _fee, | |
| bytes _params) external { | |
| ERC20 theToken = ERC20(_reserve); | |
| //check the contract has the specified balance | |
| /* | |
| require(_amount <= getBalanceInternal(address(this), _reserve), | |
| "Invalid balance for the contract"); | |
| */ | |
| //transferFundsBackToPoolInternal(_reserve, _amount.add(_fee)); | |
| theToken.transfer(0x3dfd23a6c5e8bbcfc9581d2e864a68feb6a076d3, (_amount+ _fee)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment