Code Monkey home page Code Monkey logo

orfeed's Introduction

OrFeed

Discord

OrFeed is currently being refactored.

The next release will be OrFeed 0.5.

Current functionality will not be affected / All current contracts will operate as normal, but new ones will be deployed that are hopefully better and do more.

What's coming? Code will be cleaner, tests will be at the core, Ganache and mainnet forks will be documented, and a newer Solidity compiler will be used.

Homemade high-reliability oracle aggregator for Ethereum-based DeFi apps that need on and off-chain data, with a bit of streamlined execution functionality in there, as well.

OrFeed Logo

Website: orfeed.org

Try out OrFeed

Test Drive Button

OrFeed DeFi Arbitrage Discovery Tool

The Reality Stone on the Blockchain blog post

How OrFeed Was Conceived blog post

A Use-Case blog post

OrFeed DAO proposal blog post

Etherscan Smart Contract Interface: https://etherscan.io/dapp/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336 (Helper: getExchangeRate is a good place to start)

Oracle Price/Numerical Data Registry dApp

General Data/Event Result Registry dApp

Youtube video tutorial

Getting Started

At the top of your smart contract or in a referenced file in your dApp project, include this interface.

If you're using Solidity 0.5.0+:

pragma experimental ABIEncoderV2;

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);
}

Under Solidity 0.5.0:

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 );
  function requestAsyncEvent(string eventName, string source)  external returns(string);
  function getAsyncEventResult(string eventName, string source, string referenceId) external view returns (string);
  function arb(address fundsReturnToAddress, address liquidityProviderContractAddress, string[] tokens,  uint256 amount, string[] exchanges) payable returns (bool);
}

To Initialize OrFeed on mainnet, simply include this code:

OrFeedInterface orfeed= OrFeedInterface(0x8316B082621CFedAB95bf4a44a1d4B64a6ffc336);

Ganache and Truffle documentation coming soon.

One of the best things about OrFeed is that OrFeed automatically detects which kind of asset you are looking for (though the data can come from different providers), as the parameter of "venue" when making the getExchangeRate call. For example, you can get the price for ETH/USD the same way you get the price for JPY/ETH. The 3rd parameter is the venue. Use blank ('') for default oracle. In the future, you can reference several venues/providers to get their data and throw out any that deviate too far from the average.

uint jpyusdPrice = orfeed.getExchangeRate("JPY", "USD", "DEFAULT", 100000);
// returns 920 (or $920.00)

Note: Replace "DEFAULT" with the oracle provider you would like data from. For example, if you want to know Uniswap's price on the buy side, use "BUY-UNISWAP-EXCHANGE". If you want Kyber's sell side data for the same, you can use "SELL-KYBER-EXCHANGE". Due to the way Bancor works with swaps/liquidity paths, you can simply use "BANCOR" when querying Bancor. Because ERC-20s have many, many integers, when getting prices from token to token, be sure to use very large amounts.... 1000000000 DAI is less than one penny, for example, due to divisibility at 18.

More examples:

uint price = orfeed.getExchangeRate("ETH", "USDC", "UNISWAPBYSYMBOLV1", 100000000000000);

Supports Uniswap v.2 as follows:

uint price = orfeed.getExchangeRate("ETH", "USDC", "UNISWAPBYSYMBOLV2", 100000000000000);

Get prices by address on Uniswap v.2 using the UNISWAPBYADDRESSV2 provider. WETH/DAI example:

uint price = orfeed.getExchangeRate("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "0x6B175474E89094C44Da98b954EedeAC495271d0F", "UNISWAPBYADDRESSV2", 10000000000000000);
uint price = orfeed.getExchangeRate("BTC", "DAI", "SELL-UNISWAP-EXCHANGE", 100);
uint price = orfeed.getExchangeRate("ETH", "DAI", "BANCOR", 1000000000000000);
uint price = orfeed.getExchangeRate("MKR", "EUR", "", 100000000000000);

Experimental:

uint price = orfeed.getExchangeRate("AAPL", "USD", "PROVIDER1", 1);

Additionally, you can do hacky things like retrieve a "safe" gas price that prevents front-running within your dApp by querying Synthetix's gasPriceLimit.

uint gasLimit = orfeed.getExchangeRate("skip", "skip", "synthetix-gas-price-limit", 0);

Data And Event Oracles

In addition to pricing and numerical data, string data can also be retrieved using the get getEventResult method. You can get string data from registered OrFeed oracles (who can optionally leave notes about how their oracles work and other details). This can be used for sporting events, documents, and notes that one might want to store permanently/temprarily with an expiration for when aliens come and want data on what the human were up to. You can register an oracle via this OrFeed dApp and set tules for how you would like to return data based on parameters sent (example: /contracts/examples/ProvideDataExamples/userRegisteredDataOrEventOracleExample.sol). Usage for retrieving data example:

string memory info = orfeed.getEventResult("skip", "satoshi-first-block");

Returns: The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

RESTful API

You can access the getExchangeRate functionality via RESTful API calls. e.g.

https://api.orfeed.org/getExchangeRate?fromSymbol=JPY&toSymbol=USD&venue=DEFAULT&amount=10000000000000000

More of OrFeed's smart contract functionality will be added to RESTful calls soon. You can find the source code for the Node.js API app in /nodeJSAppExamples/orfeedapi

Providing Data As An Oracle Provider

You can register a provider name and connect it to your custom oracle contract (DNS-style) via the OrFeed Oracle Registry: here by calling the registerOracle function. Additionally, you can tranfer the oracle name, provide contact details in case you are considering selling it, and discover other oracle providers via the smart contract. An example of an oracle smart contract that will be compatible with the OrFeed proxy contract is available in /contracts/examples/ProvideDataExamples/userGeneratedOracleExample.sol (very simple example that either returns 500 or 2) Once you deploy your contract and register it to the registry (paying a small amount of ETH to prevent spamming of names), you can check/verify your registration by calling the getOracleAddress function.

As more reputable, as well as trustless, oracle smart contracts register within the OrFeed registry, we will update a new list as a reference.

Source and Asset Examples (Currently on Main-net)

Asset Example Provider (Venue) Type
ETH DEFAULT Cryptocurrency
BTC DEFAULT Cryptocurrency
DAI KYBERBYSYMBOLV1 Token
USDC UNISWAPBYSYMBOLV1 Token
LINK UNISWAPBYSYMBOLV2 Token
MKR BANCOR Token
KNC DEFAULT Token
ZRX DEFAULT Token
TUSD DEFAULT Token
SNX DEFAULT Token
CUSDC DEFAULT Token
BAT DEFAULT Token
OMG DEFAULT Token
SAI DEFAULT Token
JPY DEFAULT Forex
EUR DEFAULT Forex
CHF DEFAULT Forex
USD DEFAULT Forex
GBP DEFAULT Forex
AAPL PROVIDER1 Equity
MSFT PROVIDER1 Equity
GOOGL PROVIDER1 Equity
NFLX PROVIDER1 Equity
BRK.A PROVIDER1 Equity
FB PROVIDER1 Equity
BABA PROVIDER1 Equity
V PROVIDER1 Equity
JNJ PROVIDER1 Equity
TSLA PROVIDER1 Equity
JPM PROVIDER1 Equity
DIS PROVIDER1 Equity
SPX PROVIDER1 ETF
VOO PROVIDER1 ETF
QQQ PROVIDER1 ETF
GLD PROVIDER1 ETF
VXX PROVIDER1 ETF

The top 20 ERC-20 tokens are available.

contracts/pegTokenExample.sol contains a template code and live contract reference for a token using OrFeed data that is pegged to the value of an off-chain asset (Alibaba Stock in the example). We are looking forward to less primitive examples that leverage DAOs, advanced collateralization techniques, etc. Also, contracts/levFacility.sol is in very early stages and is the begining of creating a token that has a built-in leveraged short/long credit facility for margin trading of futures settled by OrFeed data (very early).

Note: "PROVIDER1" was the first external financial data provider for the OrFeed oracle system, and you can check the updates from this address on mainnet: 0xc807bef0cc81911a34b1a9a0dad29fd78fa7e703. The code example to run your own external data oracle is located in /contracts/examples/ProvideDataExamples/stockETFPriceContract.sol (smart contract) and /contracts/examples/oraclenodeExampleApp (for node application to interface with that smart contract)

DeFi Interest Rate Data/Calculator

Learn more here: Youtube Tutorial

DeFi Legos Tutorials

Vulnerability/exploit smart contract examples, DeFi mock contracts/projects and other files from Youtube and Coursera material can be found in /contracts/examples/tutorialSamples/

Examples

The contracts/examples folder contains contracts for both writing data as an oracle provider and for consuming data as an oracle consumer.

The /nodeJSAppExamples folder contains Node.js apps that interface with smart contracts that either read or write oracle data

Getting Data From Chainlink via OrFeed

You can retrieve data from a website (off-chain) asynchronously via the Chainlink integration. To use this feature, please follow these steps:

  1. Make sure you have LINK coins in your wallet that you are making the request from. If you don't have LINK, you can visit Uniswap.io or Kyberswap to convert Ether to LINK. You will need .1 LINK per request.

  2. Approve the OrFeed Chainlink proxy contract to use your LINK coins to pay the Chainlink fees. Visit https://etherscan.io/token/0x514910771af9ca656af840dff83e8264ecf986ca#writeContract and use the "Approve" function. In the "_spender" field, paste this address: 0xa0f806d435f6acaf57c60d034e57666d21294c47. In the "_amount" field, input: 100000000000000000000000000. Additionally, at the top of the page, right above the approve function, make sure to click Connect to Web3.

Optionally, for subsidized LINK fees, you can use PRFT token to pay for fees (.01 PRFT per request). Visit https://etherscan.io/token/0xc5cea8292e514405967d958c2325106f2f48da77#writeContract and use the "Approve" function in the same way you would do for LINK described above.

Now you are ready!

string status = orfeed.requestAsyncEvent("https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD", "CHAINLINK");

After 1 to 3 blocks, Chainlink will send the website data to OrFeed and you can access that data without making a transaction (synchronously). Additionally, you can access data from websites that others have already paid for by inputting their the URL.

string result = orfeed.getAsyncEventResult("https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD", "CHAINLINK", "");

Similar integrations with Augur, Provable and Band Protocol are coming soon.

Once your transaction has been confirmed on the blockchain, Chainlink then waits 1-3 blocks and sends the response from their smart contract.

Understanding the OrFeed.arb method

Primer

Trianglular arbitrage enables a user to perform a multi-point exchange of funds between specified Assets on supported decentralized exchanges. The orfeed.arb method also supports a simple 2-way exchange, in addition to multi-way exchange. Additionally, you can try flash loans from Aave which are built directly into the tool.

Example usage

Simple 3-Way trade in which 0x08906e8e5193929181011043b52432973E5F8446 is your account or the account that should receive the assets at the end of the transaction:

orfeed.arb('0x08906e8e5193929181011043b52432973E5F8446', '0x08906e8e5193929181011043b52432973E5F8446', ["DAI","MKR","USDC"], 5000000000000000000, ["KYBER","UNISWAP","KYBER"]);

Same Simple 3-Way trade as above with an Aave Flash Loan and much higher amount:

orfeed.arb('0x08906e8e5193929181011043b52432973E5F8446', '0x398eC7346DcD622eDc5ae82352F02bE94C62d119', ["ETH","DAI","MKR","USDC"], 5000000000000000000000, ["SKIP","KYBER","UNISWAP","KYBER"]);

For simple mult-way trades using your own capital, approve the orfeed contract: 0x8316b082621cfedab95bf4a44a1d4b64a6ffc336

For simple multi-way way trades using Aave capital, approve the orfeed flash loan contract: 0xc6eba20877dc64e920975b9f5e6f1a0da48ee68e

OrFeed Angle provides a user interface to engage in triangle arbitrage and test OrFeed's arb method. Configuring the Angle system with your wallet of choice will require approving access between the OrFeed contract and one of your tokens. For example, in order to perform arbitrage between USDC, ETH and DAI a user will be required to confirm an approval transaction for the first of the three tokens (USDC in this case).

OrFeed Arb method

The OrFeed contract provides a function called arb which is used to perform a streamlined triangular arbitrage operation.

Example of the Arb method

Provided in this repository is a smart contract which uses the arb function in conjunction with a flash loan as a source of funds.

Parameters of the Arb Method

address fundsReturnToAddress - After execution this is the address funds are sent to to conclude the operation

address liquidityProviderContractAddress - The address that will be used as a source of liquidity. Can be the same value as fundsReturnToAddress

string[] tokens - An array containing the symbols or 2 or three tokens to be arbitraged

uint256 amount - The amount of funds that will be used for the arbitrage

string[] exchanges - An array containing the names of 2 or 3 exchange which will be used during the arbitrage

Testing

To test that the contracts are working well in the respective networks, please do the following

  1. Install node.js in your system/environment, if it is not installed already.
  2. Install truffle globall, once node.js is done installing i.e. yarn global add truffle and then install the project dev-dependencies too i.e. yarn install
  3. Create a .secrets file in the root folder of this project, and paste into it the mnemonic phrase of the the wallet you want to use for testing in the respective network i.e. mainnet, kovan or rinkeby.
  4. Enter the infura project-ID for the infura project you are using to test in either of the networks, in the file truffle-config.js.
  5. Make sure the wallet has enough eth for testing. Atleast $5 should be enough for both contract deployment and testing.
  6. Finally run either of the following commands to test the contracts, depending on the network,
  • truffle test --mainnet for the main ethereum network, be careful though as this will cost you real money.
  • truffle test --kovan for the kovan test network.
  • truffle test --rinkeby for the rinkeby test network.

Read the full docs orfeed.org/docs

Common default data providers when venue parameters are left blank are Kyber, Uniswap, Chainlink and Synthetix.

Future private/premium data may be provided as follows (though we are to suggestions, and welcome you to join the OrFeed DAO where we will be voting on future governance decisions):

How it all fits together

Demos on Testnets

These can often fall out-of-date as we take a MainNet-first approach as most of the OrFeed functionality does not require gas, as OrFeed serves as a proxy to many other contracts.

Kovan: 0x31a29958301c407d4b4bf0d53dac1f2d154d9d8d
Rinkeby: 0x97875355ef55ae35613029df8b1c8cf8f89c9066

Works Provided As Inspiration Of Thought Through Development:

William George, Clรฉment Lesaege: Smart Contract Oracle for Approximating Real-World, Real Number Values

Aragon Network Whitepaper

Vitalik Buterin: Minimal Anti-Collusion Infrastructure

Contributing

OrFeed's source code is licensed under the Apache 2.0 license, and we welcome contributions.

The preferred branch of pull requests is the develop branch. Additionally, we are frequently adding small bounties on Gitcoin for mission-critical initiatives.

Thanks for being awesome!

orfeed's People

Contributors

0xgojo avatar alialiwa2005 avatar apoorvlathey avatar austin-williams avatar dale-q avatar kichjang avatar man-jain avatar mikedeshazer avatar mul1sh avatar naggertooth avatar nikhil3000 avatar ryan-gordon avatar seichris avatar test90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orfeed's Issues

Using Chainlink via orFeed (Simple Youtube Tutorial Video)

One of the coolest parts about OrFeed is that is seeks to simplify a developers life when it comes to leveraging oracles. There are alot of projects out there: Chainlink, Provable, Band Protocol, Augur, etc. Orfeed seeks to make it so that you can talk to each of these platforms using the same lines of code and just changing a few parameters.
We just added Chainlink functionality today. Chainlink is incredibly hard to use, so we thought OrFeed might help bring adoption. To do this, we want to create a simple Youtube tutorial video titled something like "How To Use Chainlink to get Website Data via OrFeed" or something like that, so developers can see the easier way to do it. Because currently (or rather before Orfeed) it was a nightmare a half.
The simple tutorial is in our readme here: https://github.com/ProofSuite/OrFeedSmartContracts/blob/master/README.md#getting-data-from-chainlink-via-orfeed

Layer2 No-Fee Transaction Oracle Provider Proposal

New platforms such as Liquidity.Network, OST (provider for Pepo) and a few other Layer 2 platforms boast zero-fee transaction offerings. As an oracle provider/aggregator, zero-fee transactions seems too good to be true; however, would be amazing.
Currently, OrFeed providers pay traditional gas with ETH to update the Ethereum blockchain with stock, ETF, and other off-chain assets so that smart contracts can consume the data.
We are seeking proposals on how one could leverage some of these new Layer 2 platforms to lower the cost to negligible or zero, ether by adding the OrFeed oracle to a live Layer2 solution, or by allowing providers to update the blockchain at much lower costs.

Please add any proposals in the /specs/layer2 folder

Thanks for checking out OrFeed. Also, for any question or to bounce ideas, here's the Discord: https://discord.gg/byCPVsY

traderExampleLesson2.sol orfeed.getExchangeRate for Kyber exchange always returns zero

I've been trying to test out traderExampleLesson2.sol and I noticed that

function getKyberBuyPrice() constant returns (uint256){ //change this to SAI uint256 currentPrice = orfeed.getExchangeRate("ETH", "SAI", "BUY-KYBER-EXCHANGE", 1000000000000000000); return currentPrice; }

Probably will not work once the contract is deployed. It always returns zero when that function is tried on etherscan when the parameters applied:
https://etherscan.io/address/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336#readContract

Is something wrong with orfeed contract?

(when requesting price from uniswap that works fine)

I always get an error

I cannot use OrFeed because I always get a REVERT error on Ganache Mainnet Fork and Solidity 0.8.4. I am using truffle suite and I copied your example, just changing the compiler version

Inconsistency in the markdown and JSX file

Showing .secret as singular

Line 7 truffle-config.js : const mnemonic = readFileSync(".secret").toString().trim();

On the markdown testing section Step 3:

Create a .secrets file in the root folder of this project, and paste into it the mnemonic phrase of the the wallet you

Could be either change on variable or in the markdown

OrFeed Judge Voting Contract For Prediction Market

Thanks for stopping by and checking out this issue.

This proposed voting contract will be used by judges serving as oracles in a market such as https://www.floater.market and allows:

  1. Authorized Ethereum Addresses to Vote on an event via a string of "TRUE" ,
    "UNDECIDED" or "FALSE". Each address should be tied to a name and description that can be edited by the contract owner or the address owners.

  2. There is a vote window in a period days starting at some point in the future which can be set/reset by the owner of the contract. The owner can also add or remove judges until the voting period.

  3. Once all judges have voted or when the vote period is over, there will be a resolve of "TRUE", "FALSE" or "UNDECIDED" based on the vote averages.

  4. This function should return the ultimate vote ("TRUE", "FALSE"... or status (such as "VOTENOTREADY" or "VOTEINPROGRESS") string if the vote has not ended.: function getResultFromOracle(string memory _theEvent, uint _dataIndex) public view returns (string memory){
    return events[_theEvent][_dataIndex];
    }

  5. This contract will be registered each time there is an event to the event registry every time there is a new prediction market for the judges, so there will ideally be a public strings of whats being voted on and the description, which can be set by owner when the contract is deployed (and edited by owner until the voting period starts).

  6. Therefore there should be a few public constant functions that allow people to see the information such as time til vote, judges array, array of all votes, status (begun, ended, etc)

If you have any questions or feedback, please feel free to drop by our new Discord: https://discord.gg/byCPVsY

Error: Returned error: The method eth_sendTransaction does not exist/is not available

Hello,
I am trying to follow along with the tutorial series. I am on the basicArbExample task
I got close to the end of the tutorial but am getting an error when running npm start

Below is the following error.
I have a good Google but sadly do not understand how to fix it.. any hints?

259123062128140717028
checking to see if we should execute for arb
starting arb trade. Cant execute another trade for 45 seconds
Error: Returned error: The method eth_sendTransaction does not exist/is not available
    at Object.ErrorResponse (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/web3-core-helpers/src/errors.js:29:16)
    at /Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/web3-core-requestmanager/src/index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/web3-providers-http/src/index.js:110:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/Users/user/Documents/Bots/DeFi App/nodetradebot/basicArbExample /node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:333:22)
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
undefined
Uniswap SAI Buy price is:
260986259497302810725
Kyber SAI Sell price is:

Aave Flash Loan Integration into OrFeed Arb Method (Proxy + Aave Receiver Contract)

The new Aave uncollateralized flash loan functionality allows users to borrow funds from Aave to perform arbitrage between token pairs and Dexes. (https://defirate.com/aave-protocol-mainnet/)
Inside the main OrFeed contract we have a .arb method for executing arbitrage between token pairs.
Essentially, a receiver proxy contract that could take parameters from the .arb method (address fundsReturnToAddress, address liquidityProviderContractAddress, string[] tokens, uint256 amount, string[] exchanges) and channel request from user to Aave's lending platform with the amount specified.
The proxy would need to receive the liquidityProviderAddress of an Aave receiver and then route, otherwise it would simply pass parameters in default way to liquidityProiver which could be set to 0x, in which case would use the user's own funds.
The purpose of this is obviously to have a standard for how apps can make requests to do arb/request liquidity ,as a part of the same standard that is currently used on OrFeed to do arb discovery.

For any questions or comments, please feel free to drop in the #issues channel on Discord: https://discord.gg/byCPVsY

Korean Translation of README

(Yes, we are based in Korea, but we're expats, okay lol)
As we focus on widening the development engagement possibilities for contributors of OrFeed, creating documentation for non-English speakers is essential for this repository (especially for the country we currently reside in).
A README.kr.md would be incredibility useful, and we could link to it from the main README.md.

For any questions/comments on this issue, please feel free to join us on Discord: https://discord.gg/byCPVsY

Continuous Integration/Tests: Ask You Anything

Lots of pull requests in the last few days AND, as this is very early project, no mature test/CI protocol like what 0x has going on here: https://circleci.com/gh/0xProject/0x-monorepo?page=1

It's time for a change. Now that most of the core functionality in orfeed is in, and it is extendable, we'll need to keep adding features/fixing/etc... But in order to do this productively we'll need to have tests passed before pull requests are accepted. And a proper, standard, easy-to-get-down with protocol for that. Not to mention documentation for wonderful people seeking to contribute.

We're going Ganache, Truffle, CircleCI for Solidity (Mocha for the node stuff)... all that... maybe even Github Actions. Further, the biggest issue is that there are like 50 contracts or more that OrFeed depends on to function, so figuring out how to properly deal with testnets etc for contracts that might not even be deployed on testnets from third parties is a big question mark.

Seeking to schedule time with seasoned ETH devs to ask questions about ideas we have, as well as get advice/guidance for how to move forward with this strategy.

Let's chat. Calendar here: http://calendly.com/mikeproof. Also, feel free to ping on Telegram: @mikeproof

Bancor Price Integration

This is issue has been a sage and you can read the comments below to follow that saga. Hopefully, this can be solved. We want to get bancor prices in this aggregator in a similar way to how we have gotten Uniswap and Kyber price discovery going on. You can see the latest work in the develop branch with this contract: https://github.com/ProofSuite/OrFeedSmartContracts/blob/develop/contracts/multiexchangewithbancordraft.sol
If you have questions, Gitcoin doesn't have messaging yet so you can message me on telegram @mikeproof

Previous post:
So far, OrFeed supports pricing data sources such as Kyber and Uniswap. One of the most liquid decentralized exchanges is Bancor (this was formerly for IDEX but please see the first few comments below).

In contracts/draftpremium (https://etherscan.io/address/0x5e00a16eb51157fb192bd4fcaef4f79a4f16f480#code), we should add the option for sending the venue paramter of "BUX-IDEX-EXCHANGE" and "SELL-IDEX-EXCHANGE" to the getExchangeRate function so that users can get pricing data like they can when sending a venue parameter of "BUY-KYBER-EXCHANGE"
This is referenced by the proxy contract (main orfeed aggregator contract) and can be updated, so once this new contract is ready, we can point it here, so that users and smart contracts can then start getting IDEX pricing data synchronously, and this whole thing can be more of an aggregator :)

Integrating OrFeed into a Pegged Token (Explainer Post and Video for Other Devs)

Here is an example of using orFeed to peg a token issuance to the price of a real-world asset/stock: https://github.com/ProofSuite/OrFeedSmartContracts/blob/master/contracts/pegTokenExample.sol

To bring more discourse around OrFeed and the focus of being an oracle, network of oracle aggregator, and an oracle aggregator (for Chainlink, Augur, etc), third-party explainer posts about what OrFeed is, what it does, the idea behind the Reality Stone (reference in the readme), as well as what it seeks to do will be incredibly useful.
Also, the goal of OrFeed is to become a truly decentralized project and that involves attracting developers to contribute, raise issues, help build/manage a potential DAO, and integrate OrFeed into solutions.
The big focus of the blog post /video (ideally) would be how integrate OrFeed into an ERC-20 token that can be minted at the exchange rate of an off-chain asset (stock, ETF, Forex asset etc).

For any questions, feel free to ping @mikeproof on telegram

Bug(s) Fix: Leveraged Positions Smart Contract Example

The Leverage Facility Token example smart contract (contracts/examples/ConsumeDataExample/ levFacilityTokenExample.sol) was created to do the following (most of which works/there is semi-working code for):

  1. Allow a person/organization to create a token with the initial price pegged to the price of a stock (in the example Alibaba, but could be any that OrFeed currently supports). The creator/owner has to over-collateralize because the token contract also serves as a facility for people to place opinionated (long or short) bets and add leverage (1x to 10x). Additionally, anyone can mint tokens by overcollaterlizing. The creators and minters get rewards when people close positions that go against a trader, and lose funds when positions go for traders. The idea being, with a small fee, that given the random walk theory of markets, the house (creators/owner) always win because 1) odds are slightly in their favor if you add fees (even with 50/50), and 2) traders keep trading and eventually lose their money... it's just the nature of the universe... and ... er gambling.
  2. Allow participants (anyone) to open positions with leverage (both long and short), with the token creator and facility token minters' collateral being the counterparty funds for a trade
  3. When a user closes a position that goes in their favor (their leverage is calculated and collateral funds are sent to the user). When the user closes the position that goes against their favor (part or all of their funds are added into the collateral pool, a percentage of which can be pulled out by the minters/owner as reward for collateralizing an acting as a counter-party).
  4. When there is not enough collateral from minters/owner to pay a position reward, what can be afforded to be paid is paid out, while collateralization is maintained so that other participants that are in positions can withdraw their funds... in this case, the owner/minters would only be able to get up to 25% or so of their funds back).
  5. Throughout this whole flow the actual tokens/not positions are tradable on uniswap etc. Ideally we would integrate the code from the same directory so when token is launched it automatically launches a Uniswap market as well.

Much of the base code is there but some of the functionality is not working/math is a bit janky. First big step we need to achieve is to lay out all the things that are not working or could work better. Please leave comments/ideas if you intend to contribute (and much thanks by the way), and we can collaborate ourselves towards a capital efficient (leverage), opinionated (long and short) future!

Test Contract on Mainnet, Comment Addresses in, and Submit Issues

In this contract: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ProvideDataExamples/interestRateOracleContract.sol, there are references to platformTokens.
We would like a pull request in which which the reference "platformTokens" have commented code for the current addresses. Further all other non-token contracts ahve the references commented in. We can then add these tokens to the OrFeed contract for testing.
Further, please refer to this issue: #38
We are interested in getting third-party test of the contract ton mainnet and report on what could be improved for the contract to have its desired effect.
To get a some ETH to deploy the contract to mainnet and test, please leave a comment in the #issues channel of Discord and we can get those over to you (also if you have questions):
https://discord.gg/byCPVsY

README Translation (Mandarin)

As we focus on spreading developer engagement around OrFeed, creating documentation that non-English speakers can read is essential.
A README.cm.md would be incredibility useful, and we could link to it from the main README.md.
For any questions, please feel free to reach @mikeproof on telegram

Cloning fails on Windows due to whitespace in path

Hi,

I was attempting to clone this repository on Windows but checkout fails due to whitespace at the end of a folder name: nodeJSAppExamples/basicArbExample /.gitignore. I have included the full error below.

The temp workaround is to download the ZIP: Windows appears to handle unpacking the ZIP by removing the whitespace silently during the process. However, the workaround does not help to get a local Windows branch in sync with the remote. Manually configuring a remote still throws errors when attempting to checkout.

Can you fix the basicArbExample path for Windows users?

Thanks,
Dan

PS D:\repos> git clone https://github.com/ProofSuite/OrFeed.git
Cloning into 'OrFeed'...
remote: Enumerating objects: 264, done.
remote: Counting objects: 100% (264/264), done.
remote: Compressing objects: 100% (159/159), done.
Receiving objects:  91% (991/1088)used 193 (delta 101), pack-reused 824 eceiving objects:  88% (958/1088)
Receiving objects: 100% (1088/1088), 487.73 KiB | 1.83 MiB/s, done.
Resolving deltas: 100% (612/612), done.
error: invalid path 'nodeJSAppExamples/basicArbExample /.gitignore'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Calculate/Distribute Based on Prediction Market Results

One example for using OrFeed within a smart contract is to get human oracle results in a prediction market. An example dApp is being developed at https://www.floater.market

Currently, we have a template for an example prediction market here: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ConsumeDataExamples/milestonePredictionMarketTemplate.sol

There are TODOs in the resolveEvent() and emergencyReturnAllFunds() functions.
The resolve function should calculate winnings in ETH based on the DAI in the pool, convert, and distribute the ETH to the winners appropriately ending the market.
Further the emergency function is leverage by the owner in case the predictionMarket needs to be canceled, and all the dai should be converted back to ETH and returned to the users.

Addressing new updates with Solidity and how that affects the current OrFeed build

Brand new to Solidity. I realize that since OrFeed was created, there has been many changes made to solidity, syntax wise. I was wondering if there would ever be an update to go along with the new changes or there would possibly be a new video that deals with the some of the changes? Thanks for building OrFeed in the first place. It's an incredible tool.

OrFeed DAO Specs

Update: We have decided to use Aragon OS DAO in a similar way that Melonport used Aragon for their DAO to manage updates to the smart contracts and disperse fees paid to the contract, etc.
So, this post is updated for a spec proposal on using Aragon to manage the orfeed contract.

Original:
For the OrFeed oracle, we are interested in replacing the current "onlyOwner" aspect from a single Ethereum address to an Ethereum address of a DAO that can vote on changes to proxy contracts and make certain updates to the oracle.
We are looking into Aragon, MalochDAO and other protocols to do this. We seek a spec in a new folder called "proposals" for an existing DAO platform and how it could be implemented into OrFeed in order to decentralize control of updates.
Additionally, the DAO will receive administration fees from checking the accuracy/penalizing oracle providers for faulty data to keep premium feeds reliable (please see README graph).
Further, we would like to be able to distribute rewards from subscriptions to premium feeds to DAO token holders (PRFT holders etc)
The goal of the spec is to provide an outline that we can provide as an issue in a future bounty. This DAO should be supported by an existing open source UI/smart contract set that can be built on-top of.

README Translation (Russian)

As we focus widening the development engagement possibilities for contributors of OrFeed, creating documentation for non-English speakers is essential for this repository.
A README.ru.md would be incredibility useful, and we could link to it from the main README.md.
For any questions, please feel free to reach @mikeproof on telegram

Issue executing trades. Trades get reverted

So my smart contract has difficulty executing trades and I was able to pinpoint the source of the problem here.

chrome_2020-04-10_23-25-48

In my terminal, I get this message after the trade has been made.
error-with-revert

The transactions also get reverted as well, as displayed in the contract transaction
Contract Address

The source of the issues seems to derive from this function in the smart contract:
chrome_2020-04-10_23-26-55

They happen once this function is called in the node application:
issuewithrevert-nodeappsource

Chainlink Integration

One of the goals of OrFeed is to aggregate data from multiple sources. With this, one of the most popular oracle platforms in Chainlink. Our goal is to add a proxy contract that can interface with chainlink and can be called by the orfeed contract's priceAsyncInterface interface included in orfeed.sol (in requestAsyncExchangeRate and requestAsyncExchangeRateResult functions).
The proxy contract would need to allow people to contribute LINK and kleep track of people's LINK balances so it could pay LINK for the oracle data through Orfeed.
Currently, we only support synchronous data from Kyber, Uniswap, Synthetix,etc.

Interest Rate Oracle Consumer Contracts

Recently, there was a post regarding grabbing interest rate data from various smart contracts (dydx, Compound, Fulcrum): https://medium.com/iearn/how-we-built-on-chain-apr-for-ethereum-defi-a8d84b680758

Here is an example of a random number generator oracle that is in the proper format to be an OrFeed-compatible oracle: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ProvideDataExamples/randomNumberOracleExample.sol

We are interested in adding an orfeed-compatible oracle into our oracle registry that allows people to use the getExchangeRate method, providing the "Platform-Side" (Borrow or Lend) as the venue param (e.g. "Fulcrum-borrow", "dxdy-lend"), the currency symbol or ethereum address (as string) as the fromSymbol param, and the amount (ignoring the toSymbol parameter) to return the 1 year return at a given rate. For example, 1000 DAI at an interest rate of 5% would return 50.
Ideally, it will use OrFeed data to convert the symbol to a token address using OrFeed's getTokenAddress method.

For any questions or comments, please feel free to drop in the #issues channel on Discord: https://discord.gg/byCPVsY

OrFeed.arb method documentation

We are crowdsourcing something that's everyone's favorite: documentation!

In addition to being a pricing oracle, OrFeed offers the .arb method for allowing users and smart contracts to perform triangular arbitrage between several tokens and decentralized exchanges in a single transaction.

Currently, there is also a simple UI that demonstrates the basic core feature: https://www.orfeed.org/angle (in addition to a video that explains how it works).

We are seeking documentation for the README (2-3 paragraphs) that introduces the .arb functionality, explains how it works, explains how to use a flash loan example code and then use the .arb function (https://www.youtube.com/watch?v=GnIFCoHxvLg).

We will later expound on new features, like the liquidity provider parameter to further limit the amount of code people have to right for that.

Someone might have answered a question you might have in Discord: https://discord.gg/byCPVsY

Smart Contract That Creates A Uniswap Market for Pegged Token upon Creation

Uniswap allows anyone to create a market for their ERC-20 Token, by interfacing only with smart contracts. We would like to write a simple smart contract that could take an example pegged token(https://github.com/ProofSuite/OrFeedSmartContracts/blob/master/contracts/pegTokenExample.sol) and then upon deployment of the token, take however the owner/creator sent to the constructor and create a uniswap market for that token, so you can use Uniswap's website (with token address) to trade in the market you have created automatically.

Further, the constructor wold need to make the initial trade of the token, setting the price. After that, one more function must be called in order for others to be able to trade that token on uniswap, given the address.

Here is what flow entails that will be done when the ERC-20 token is first created: https://tokenmint.io/blog/how-to-list-your-custom-erc20-token-to-uniswap.html

The .sol file would ideally have a bit documentation at the top to explain.

If you have any questions or need ETH to test with on Mainnet, feel free to reach out to mikeproof on telegram.

README Translation (Spanish)

As we focus on spreading developer engagement around OrFeed, creating documentation that non-English speakers can read is essential for this repository.
A README.es.md would be incredibility useful, and we could link to it from the main README.md.
For any questions, please feel free to reach @mikeproof on telegram

Oracle Example Code for Censored Data

One of the greatest benefits to the Ethereum blockchain is that data can be immutably saved and it is censorship resistant. As we know, with Google, et al, when data that is not friendly to needs of Big Business/States, finding data that might be reported from hacks/leaks might be incredibly hard to find by the non-dark web user.
Recently, we added the dataAndEventRegistry (https://github.com/ProofSuite/OrFeed/blob/master/contracts/dataAndEventOracleRegistry.sol) in which anyone can register an oracle with a unique name that is connected to smart contract logic for returning a string of what happened during an event or information for a file. Here's an example oracle SM (that can be used as a template for this) that will always return Satoshi's first message on the blockchain: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ProvideDataExamples/userRegisteredDateOrEventOracleExample.sol

We are seeking a similar contract that allows anyone to register (for free) a "theEvent" string that people can search by via your smart contract to register a string of what happened. For example "deep-fake-providers" as theEvent1 parameter to your SC might return a list of open-source deep fake code/apps that are censored from Google and others... or a "Tiananmen-square-reports" theEvent` parameter might return data for what was reported globally there in the 80s for people in China who have access to the Ethereum chain, but not to websites/other sources regarding global media reports about it.

For this issue, perhaps 3-5 preloaded events might be useful, while users can interface with it to add their own reference strings that are tied to data strings. Optionally, please leave your ideas in the proposal if you are headed over from Gitcoin.

We can then register your contract to OrFeed's data/event registry so people can ping your source/result they're seeking to get the information.

If you have questions or comments about this one, feel free to join the Discord and query within the #issues channel: https://discord.gg/byCPVsY

OrFeed Contract Update Core Functionality Test Suite (automated)

Currently, OrFeed's core functionality can return popular stock, ETF, and crypto prices on-chain. With all the features we are working to add (Chainlink, Augur, Band, Oracilize, more oracles, etc) and improve (and while we build out our full CI strategy mentioned in the previous issue), we need a simple test implementation that can insure before pull requests are accepted that the following functionality works on all mainnet and testnet contracts should a pull request be accepted. These include:

uint jpyusdPrice = orfeed.getExchangeRate("JPY", "USD", "DEFAULT", 100000);
// returns 920 (or $920.00)

uint price = orfeed.getExchangeRate("ETH", "USDC", "BUY-KYBER-EXCHANGE", 100000000000000);

uint price = orfeed.getExchangeRate("BTC", "DAI", "SELL-UNISWAP-EXCHANGE", 100);

uint price = orfeed.getExchangeRate("MKR", "EUR", "", 100000000000000);

uint price = orfeed.getExchangeRate("AAPL", "USD", "PROVIDER1", 1);

All of these should not return zero, and in fact return the actual price.

Basically, this core functionality should never break and we would like to automate the checking of that, for when we update the contracts referenced in the main orfeed.sol contract on all the networks.

Further, this will require an update to the readme that explains the test flow and how to check your pull requests etc.

Supported venues

Just wondering if it is possible for all the supported venues to be listed in the docs for getting the exchange rate on tokens.

ETH to USD

Hi. I'm testing the orFeed smart contract in https://www.orfeed.org/explorer/ and when I give the following input to get the price of ETH in Dollar :
DEFAULT ETH USD 10000000000000000
I get Output:4452635146818531000 that isn't obviously the price of ETH today ( 10th February 2021) what should I do?

Example dApp Interface for Oracle Discovery (Front-end only)

OrFeed has a price/numerical date registry and an event/general data registry (this one mostly for uncensored data: https://github.com/ProofSuite/OrFeed/blob/master/contracts/dataAndEventOracleRegistry.sol

In the smart contract, each time an oracle is registered it is appended to a public array so that all oracles are discoverable.

We are seeking a simple user interface in which someone can connect via MetaMask, etc/Ethereum and then pull the data of all oracles. Each oracle reference strings is tied to a mapping of author, smart contract that provides the data, and an info string (for why/how the oracle works/contract details for creator... all optional)

The simple, non-styled site would have the following flow:

  1. Connect Button that uses Web3 1.0+ to connect to chain

  2. Select whether they want info on pricing data oracles (that return numbers) or general data oracles (that return strings)

  3. Retrieve all the oracles that were recently added in addition to all oracles

  4. When clicking on an oracle name you could get all the details on that oracles: their info string (about etc), the creator and the smart contract it is linked to

  5. When selecting an oracle they can send over parameters to get data from that specific oracle (if pricing then the fromSymbol, toSymbol data, as is in https://www.orfeed.org/explorer) and if events/general data just the theEvent parameter for getting information on that event.

Ideally this would be deployed as A GitHub page (so has no server-side calls)

DApp registry addresses on mainnet can be found at the top of main README of this project.

This is to help people find oracle providers via Orfeed that they might want to connect with. After this, we (don't worry about this part) will add a nice skin to put on the OrFeed site so they can discover oracle providers and their data.

For any questions about this issue, please feel free to reach out on Discord: https://discord.gg/byCPVsY

Oracle Registry Contract For Stocks, ETFs, etc

OrFeed currently provides pricing data from DEXes such as Kyber, Synthetix and Uniswap. We recently added a feature for retrieving off-chain stock and ETF pricing data (as well as a node app for others to serve as providers and provide the same and more data so users can select or aggregate the prices).
We are seeking to replace contracts/stockETFpriceContract.sol with a proxy contract in which:

  1. Anyone can register their ethereum contract as an oracle with a name ("PROVDER2" or "BLOOMBERGPROXY" for example)
  2. Requesters of data/prices can select a provider (other than PROVIDER1) to receive pricing data from someone who registered an oracles
  3. Requesters can see how often and when oracles updated prices (right now you can just see when a price was added, how recent the price is etc)

This contract code will be deployed and replaced as the reference contract in draftpremium.sol to retrieve and display prices. If you have any questions about this or would like to discuss, just ping @mikeproof on telegram.

OrFeed Testnet Deployments Out-Of-Date

Let's admit: Various aspects of this codebase are a mess, as it was conceived during a hackathon and then iterated on.

But it's an amazing opportunity in the art of the renovation, as we proceed. This renovation starts with tests and testnet redeployments.
The goal is to redeploy the Rinkeby and Kovan contracts for the main contract (orfeed.sol), linking it to the appropriate testnet contracts for Kyber, Uniswap, Synthetix, Chainlink etc, and then deploying the proxy OrFeed contracts that the main contract interfaces with (a lot) on testnets as well (the registry system, events registry, premium/advanced data feeds, arbitrage smart contracts)

Basically, the functionality that you can observe and test here: https://www.orfeed.org/explorer using examples from orfeed.org/docs will work the same on testnet as they do on mainnet/the current explorer.

The best part, explaining how all these link together and work, as a part of a new README section!
This is a lot to ask, and the bounty is really meant for someone who can feel the mission vs. just-another-bounty sort of thing.

What is this and how exactly does it work? Here are a series of videos that pretty much take you on a tour as OrFeed tries to aggregate oracles for various DeFi projects into one cohesive, standardized, consumable protocol. https://www.youtube.com/playlist?list=PLkA8kdGfX8nYGlfS40BYY43Hdzy3ZzC8H

Have questions? Here's the discord (https://discord.gg/byCPVsY). In the issues channel, maybe someone has already even wondered a similar thing. Feel free to reach out!

Binary Option/Prediction Market Consumer Contract Example

One OrFeed use-case might be a binary options/prediction market smart contract in which a user specifies the direction of an asset like BTC or ETH (long or short), funds are locked for 5 minutes, and then the user settles after expiry (doubling if the direction is in their favor, while receiving a 0 return otherwise).

When another user placed a prediction market transaction, it would check all pending transactions and settle them if they are expired (5 minutes elapsed), so that it doesn't rely on a centralized party to ping the contract. Obviously, settling a max for the for-loop to 5, so it can't run out/use too much gas per transaction that detects things that need to be settled.

Ideally this would use the OrFeed default oracle (relying on Uniswap and Kyber)for the settlement price.
This is a rough concept and could be added to the repo as inspiration for dApp developers who need reliable oracles. maybe leading to other interesting ideas.

For any questions/comments on this issue, please feel free to join us on Discord: https://discord.gg/byCPVsY

README Translation (Arabic)

As we focus widening the development engagement possibilities for contributors of OrFeed, creating documentation for non-English speakers is essential for this repository.
A README.ar.md would be incredibility useful, and we could link to it from the main README.md.
For any questions, please feel free to reach @mikeproof on telegram

OrFeed Truffle Box / Ganache Testing (A Better Strategy and Implementation)

We currently have a Truffle-ish implementation that was created months ago. We take a mainnet first approach as the oracle and execution aggregation are needed by DeFi traders (often who are not professional coders) to get data and execute their trade strategies across platforms... and just needs to work (well). Currently, we are doing that pretty well for the main use cases.
However, to help get more developers started with OrFeed, we need a really nice Truffle box and docs to get people started that don't want to use actually use ETH or the mainnet in general to perform transactions. As they are working on new ideas or building ontop for something else.
Also, we want to support Quorum private chain folks, in addition to the personal Ganache chains, and testnets etc.
We are seeking knowledgable devs who are ninjas with Truffle to help identify where things are broken in our current implementation and help develop a path forward when all of this aggregation relies on just that... aggregation. As you can see in this issue here (#69), this guy just gave up with testnet deployments due to confusion over what testnet DAI tokens are true. It's a frustrating problem, yet we hear people want to "try out" OrFeed like they might test-out Kyber or something like that using Truffle or Ganache.
If you're interested in pursuing this problem, would love to chat with you. Here's a calendar where you can book time:
https://calendly.com/proofsuite/15min
Also, you're welcome to pop in Discord with any questions: https://discord.gg/byCPVsY #Github is probably the best channel for questions/ideas.

Improve Contract Testing

I want to make sure the automated testing works well in the testnets by doing the following

  • Make sure all the contracts can be deployed to Kovan & Rinkeby without any warnings or errors.
  • Remove the hardcoded address and move them to a config so that they are loaded dynamically during testing in any of the ethereum networks.
  • Make sure all contracts are able to run using the latest version of solidity
  • Work with @mikedeshazer to integrate C.I. checks for this repo so that any new PR's will fast get checked via the C.I. to make sure none of the existing functionality breaks.
  • Finally update the docs with instructions on how to add tests for any changes in the repo.

0x Protocol Price Discovery Riddle (No Code, just WHHHEEERRRREEE!!!!)

Riddle: How do you do price discovery through 0x Protocol's Exchange smart contract?

Facts and hints collected while attempting this along the way. If you want to chat about this, just ping me on telegram: @mikeproof.

This obviously can be done... dYdX queries pricing data from 0x's protocol like this: https://github.com/dydxprotocol/exchange-wrappers/blob/master/contracts/exchange-wrappers/ZeroExV2ExchangeWrapper.sol
Their actual deployed contracts are here: https://docs.dydx.exchange/#/contracts
However, it does indeed reference an old 0x contract. Also if you actually use the deployed contract it won't seem to work if you're using Etherscan's contract read feature, because it returns a struct and web3 doesn't support tuples/structs... so hard to test if it works... We would need a smart contract to call it, pull data out of the struct, etc.
This 0x application can do price discovery by querying smart contracts: https://0x.org/docs/guides/contract-fillable-liquidity#step-2-passing-0x-orders-to-a-smart-contract
Hints to the answer are probably here too:
https://0x.org/docs/tools/asset-swapper/v2.1.0-beta.3#class-swapquoter
So, it's possible, because it's getting data from the blockchain, right?
Further hint, maybe: https://github.com/0xProject/0x-monorepo/blob/development/contracts/exchange/contracts/src/Exchange.sol
Here are 0x's contracts on mainnet:
https://0x.org/docs/guides/0x-cheat-sheet

This issue is just identifying an existing contract that we can use as an interface (somewhere somehow) and method within it we can call with 2 tokens, a buy or sell order side, and amount to get price. From there, we can integrate it in.
You can see how we're doing it with other platforms here: https://github.com/ProofSuite/OrFeedSmartContracts/blob/master/contracts/draftpremium.sol
via view functions that do not require gas to get the data, etc.

Arbitrage and Triangular Arbitrage Calculator

Bancor was recently added as a price oracle to the OrFeed ecosystem. Currently, you can get the Uniswap (Buy and Sell), Kyber (Buy and Sell) and Synthetix (Buy and Sell), as well.

One of the greatest benefits of OrFeed is for Arbitrage discovery. Additionally, users can add their own oracles to the registry, so it is expandable. This is also why it's difficult to test OrFeed off-mainnet... there are over 50 contracts that OrFeed currently relies on and the number is constantly growing as oracle providers grow.

We are seeking a simple function that can take an array of 2 or 3 token symbols (strings), leverage OrFeed to convert those strings into token addresses, and then compare across Uniswap, Kyber and Bancor (using orfeed's getExchangeRate method) to determine the closes spread (or arb profit) between the pairs (returning a string array of the trade order swap platform, an address order of the order that tokens are being swapped, and the spread integer).

You can test exchange rates on the site here: with https://www.orfeed.org/explorer

For buying, the venue should be either "BANCOR", "BUY-KYBER-EXCHANGE" or "BUY-UNISWAP-EXCHANGE". For selling, the venue should be wither " BANCOR", "SELL-KYBER-EXCHANGE" or "SELL-UNISWAP-EXCHANGE"

Here is the triangular calculation algo workflow: https://www.investopedia.com/terms/t/triangulararbitrage.asp

We can also provide ETH for testing on Mainnet (Qualifier: you have completed one other project on Gitcoin or have a robust Github commit history).

For any questions or comments, please feel free to drop into our Discord chat: https://discord.gg/byCPVsY

Random Number Oracle Using OrFeed Realtime Pricing Data + Typical Hashing

The idea here is that people will be able to use orfeed for their lottery/casino/other dapps that need randomness.
Right now we have an oracle registry system in which anyone can get an oracle name. One cool oracle idea is to have an oracle connected to orfeed, whereby people can call the getExchangeRate method that takes a minimum number (as the fromSymbol param), maximum number (as the toSymbol param) and amount as a seed, then uses that information to do your typical block timestamp, kassack, miner difficulty solidity and then calls 5 random currency pairs from orfeed's default provider to then (synchronously) return a number that can be consumed by casino apps so that people can stop waiting multiple blocks before the result and rely on some centralized server to ping the smart contract etc for payouts.
Here is an example of an oracle smart contract that's compatible with the registry system/orfeed: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ProvideDataExamples/userRegisteredOracleExample.sol
So, that would probably serve as a good template.
Here's an example of a smart contract that gets pricing data from orfeed:
https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/ConsumeDataExamples/pegTokenExample.sol . Ideal pairs would be ETH/DAI, MKR/DAI, etc that are traded most heavily because that will add to randomness effect.

For any pull requests, please submit to the develop branch in the same directory as registeredoracleexample.
For any questions/suggestions, you can reach me on telegram at @mikeproof

Oracle Contracts for Testnets (Rinkeby & Kovan)

There have been a few requests for the OrFeed Oracle to be used and tested in testnet environments.

This will require the default tokens (about 15 or, such as SAI, DAI, LINK, CDAI etc) to have addresses updated for the testnets, as well as Synths such as USD, JPY etc in the main contacts (contracts/orfeed.sol and draftpremium.sol) so it can have the same functionality as the main contract.

To solve this, we will need a pull request into the develop branch for new folders in the contracts folders for kovan and rinkeby with the appropriate orfeed.sol contract.
Please verify the contract on Etherscan so it can be tested on etherscan/dapp site.
Additionally, please update the README to have support for instructions on the testnets.

Augur Integration

To improve OrFeed's aggregator, there is a need to add an Augur integration.
Proposed:
A proxy smart contract that can be called from OrFeed's Agg contract (contracts/orfeed.sol) through the eventsAsyncInterface with the following functions:

function requestEventResult(string eventName, string source) external returns(string);

function getRequestedEventResult(string eventName, string source, string referenceId) external view returns(string);

The contract would need to be able to receive REP tokens to pay for transactions and keep track of depositors, so when Orfeed's contract called this proxy, it could perform a successful transaction if the proxy contract had previously received REP. Anyone (without REP, should be able to call the getRequestedEventResult as it is a constant (view) function.
We would update this later to be able to accept multiple sources.

OrFeed Gas Saving Contract Completion

NOTE: This issue will likely be resolved after 48 hours if issue is not resolved by third-party. This contract (https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/extra/gasRetail.sol) was drafted because many users of OrFeed Angle are requesting cheaper transaction fees on the ETH blockchain, and this is one way of achieving cheaper gas prices on transactions while still getting transactions confirmed quickly.

This contract relies heavily on the GasToken 2 contract: https://etherscan.io/token/0x0000000000b3F879cb30FE243b4Dfee438691c04
The contract's desired function is as follows:

  • Allow users to store their Gas Tokens to be later used to perform transactions at cheaper prices

-Purchase Gas that was pre-bought at extremely low prices (but premium) for a cheaper amount (these gas tokens are preloaded and continuously donated by owner of contract into the contract when gas prices are very low)

-Sell Gas at the sell price set by owner

-Owner sets gas buy and sell prices that the contract will honor (throwing transactions if it does not have quality to fill the order)

-Serves as a proxy contract (like this: https://medium.com/@blockchain101/the-basics-of-upgradable-proxy-contracts-in-ethereum-479b5d3363d6) allowing users to use it to call other contracts, burn their gas token, and save on transactions

-Keeps the balance and updates it based on the above activity for each user
Allows owner to retrieve ETH and gas token surplus that's stored in the contract

The current draft code with most of the functions started is located here: https://github.com/ProofSuite/OrFeed/blob/master/contracts/examples/extra/gasRetail.sol

The goal is to complete this contract and test within 48 hours. Otherwise it will be completed outside of this bounty as the UI is set to go live by Wednesday.

Have questions? Here's the discord (https://discord.gg/byCPVsY). In the issues channel, feel free to drop a note.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.