Skip to content

Commit 0f28c75

Browse files
author
m
committed
updated mainnet contract references
1 parent c80bf7e commit 0f28c75

File tree

8 files changed

+93
-17
lines changed

8 files changed

+93
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Website: [orfeed.org](https://www.orfeed.org)
1313

1414
[How OrFeed Was Conceived](https://medium.com/proof-of-fintech/introducing-orfeed-aa323342d34c) blog post
1515

16-
Demo: [https://etherscan.io/dapp/0x73f5022bec0e01c0859634b0c7186301c5464b46](https://etherscan.io/dapp/0x73f5022bec0e01c0859634b0c7186301c5464b46)
16+
Demo: [https://etherscan.io/dapp/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336](https://etherscan.io/dapp/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336)
1717

1818
[Youtube video tutorial](https://youtu.be/LK1BiSveEI4)
1919

@@ -38,7 +38,7 @@ interface OrFeedInterface {
3838
To Initialize OrFeed, simply include this code:
3939
4040
```javascript
41-
OrFeedInterface orfeed= OrFeedinterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
41+
OrFeedInterface orfeed= OrFeedinterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
4242

4343
```
4444

README_MANDARIN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
[How OrFeed Was Conceived](https://medium.com/proof-of-fintech/introducing-orfeed-aa323342d34c) 博客帖子
1515

16-
演示: [https://etherscan.io/dapp/0x73f5022bec0e01c0859634b0c7186301c5464b46](https://etherscan.io/dapp/0x73f5022bec0e01c0859634b0c7186301c5464b46)
16+
演示: [https://etherscan.io/dapp/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336](https://etherscan.io/dapp/0x8316b082621cfedab95bf4a44a1d4b64a6ffc336)
1717

1818
[Youtube video tutorial](https://youtu.be/LK1BiSveEI4)
1919

@@ -35,7 +35,7 @@ interface OrFeedInterface {
3535
要初始化OrFeed,只需包含以下代码:
3636
3737
```javascript
38-
OrFeedInterface orfeed= OrFeedinterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
38+
OrFeedInterface orfeed= OrFeedinterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
3939

4040
```
4141

contracts/examples/ConsumeDataExamples/levFacilityTokenExample.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ library SafeMath {
7070
uint256 public RATE = 0;
7171
bool public isMinting = true;
7272
bool public isExchangeListed = false;
73-
OrFeedInterface orfeed= OrFeedInterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
73+
OrFeedInterface orfeed= OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
7474

7575
using SafeMath for uint256;
7676
address public owner;

contracts/examples/ConsumeDataExamples/pegTokenExample.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ library SafeMath {
4646
uint256 public RATE = 0;
4747
bool public isMinting = true;
4848
bool public isExchangeListed = false;
49-
OrFeedInterface orfeed= OrFeedInterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
49+
OrFeedInterface orfeed= OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
5050

5151
using SafeMath for uint256;
5252
address public owner;

contracts/examples/ConsumeDataExamples/traderExample.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ contract UniswapTradeExample{
9292
}
9393

9494
function getDAIPrice() constant returns(uint256){
95-
OrFeedInterface orfeed= OrFeedInterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
95+
OrFeedInterface orfeed= OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
9696
uint256 ethPrice = orfeed.getExchangeRate("ETH", "USD", "", 100000000);
9797
return ethPrice;
9898
}

contracts/examples/ConsumeDataExamples/traderExampleLesson2.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ contract Trader{
103103

104104
ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);
105105
KyberNetworkProxyInterface public proxy = KyberNetworkProxyInterface(0x818E6FECD516Ecc3849DAf6845e3EC868087B755);
106-
OrFeedInterface orfeed= OrFeedInterface(0x73f5022bec0e01c0859634b0c7186301c5464b46);
106+
OrFeedInterface orfeed= OrFeedInterface(0x8316b082621cfedab95bf4a44a1d4b64a6ffc336);
107107
address daiAddress = 0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359;
108108
bytes PERM_HINT = "PERM";
109109
address owner;

contracts/orfeed.sol

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
//Contract: 0x73f5022bec0e01c0859634b0c7186301c5464b46
1+
//MainNet Deployment: 0x8316b082621cfedab95bf4a44a1d4b64a6ffc336
2+
23
//orfeed.org oracle aggregator
4+
5+
36
pragma experimental ABIEncoderV2;
47

58
interface IKyberNetworkProxy {
@@ -364,6 +367,7 @@ contract orfeed {
364367
freeRateTokenSymbols['TUSD'] = 0x0000000000085d4780B73119b644AE5ecd22b376;
365368
freeRateTokenSymbols['ETH'] = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
366369
freeRateTokenSymbols['WETH'] = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2;
370+
freeRateTokenSymbols['ETH2'] = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2;
367371
freeRateTokenSymbols['SNX'] = 0xc011a72400e58ecd99ee497cf89e3775d4bd732f;
368372
freeRateTokenSymbols['CSAI'] = 0xf5dce57282a584d2746faf1593d3121fcac444dc;
369373
freeRateTokenSymbols['CUSDC'] = 0x39aa39c021dfbae8fac545936693ac917d5e7563;
@@ -384,12 +388,16 @@ contract orfeed {
384388
freeRateForexSymbols['CHF'] = 0x0f83287ff768d1c1e17a42f44d644d7f22e8ee1d;
385389
freeRateForexSymbols['JPY'] = 0xf6b1c627e95bfc3c1b4c9b825a032ff0fbf3e07d;
386390
freeRateForexSymbols['GBP'] = 0x97fe22e7341a0cd8db6f6c021a24dc8f4dad855f;
391+
freeRateForexSymbols['sETH'] = 0x57ab1e02fee23774580c119740129eac7081e9d3;
392+
387393

388394
freeRateForexBytes['USD'] = 0x7355534400000000000000000000000000000000000000000000000000000000;
389395
freeRateForexBytes['EUR'] = 0x7345555200000000000000000000000000000000000000000000000000000000;
390396
freeRateForexBytes['CHF'] = 0x7343484600000000000000000000000000000000000000000000000000000000;
391397
freeRateForexBytes['JPY'] = 0x734a505900000000000000000000000000000000000000000000000000000000;
392398
freeRateForexBytes['GBP'] = 0x7347425000000000000000000000000000000000000000000000000000000000;
399+
freeRateForexBytes['sETH'] = 0x7345544800000000000000000000000000000000000000000000000000000000;
400+
393401

394402
//when returning rates they will be first divided by and then multiplied by these rates
395403
rateDivide1 = 100;
@@ -406,15 +414,15 @@ contract orfeed {
406414

407415
//erc20 price oracle address. Can be changed by DAO
408416
tokenPriceOracleAddress = 0xFd9304Db24009694c680885e6aa0166C639727D6;
409-
synthetixExchangeAddress = 0x22a67ecd108f7a6fc52da9e2655ddfe88eccd9ca;
417+
synthetixExchangeAddress = 0xE95Ef4e7a04d2fB05cb625c62CA58da10112c605;
410418

411419
tokenPriceOracleAddress2 = 0xe9Cf7887b93150D4F2Da7dFc6D502B216438F244;
412420

413421
//forex price oracle address. Can be changed by DAO
414422
forexPriceOracleAddress = 0xE86C848De6e4457720A1eb7f37B519010CD26d35;
415423

416424
//premium price oracle address. Can be changed by DAO
417-
premiumSubPriceOracleAddress = 0x5e00a16eb51157fb192bd4fcaef4f79a4f16f480;
425+
premiumSubPriceOracleAddress = 0xbf2e5dc9b5c25911c68edcebd57438da1abd7ed6;
418426

419427
//arb proxy contract address. Can be cahnged... will be changed by DAO
420428
arbContractAddress = 0x0;
@@ -449,15 +457,15 @@ contract orfeed {
449457
uint256 ethAmount = kyber.getOutputAmount(token, ethToken, inputAmount);
450458
uniswap = Uniswap(tokenPriceOracleAddress2);
451459
uint256 sethAmount = uniswap.getEthToTokenInputPrice(ethAmount);
452-
synthetix = Synthetix(forexPriceOracleAddress);
453-
uint256 outputAmount = synthetix.getOutputAmount('sETH', synth, sethAmount);
460+
se = SynthetixExchange(synthetixExchangeAddress);
461+
uint256 outputAmount = se.effectiveValue(freeRateForexBytes['sETH'], sethAmount, synth);
454462
return outputAmount;
455463
}
456464

457465
function getSynthToTokenOutputAmount(bytes32 synth, ERC20 token, uint256 inputAmount) returns(uint256) {
458466
kyber = Kyber(tokenPriceOracleAddress);
459-
synthetix = Synthetix(forexPriceOracleAddress);
460-
uint256 sethAmount = synthetix.getOutputAmount(synth, 'sETH', inputAmount);
467+
se = SynthetixExchange(synthetixExchangeAddress);
468+
uint256 sethAmount = se.effectiveValue(synth, inputAmount, freeRateForexBytes['sETH']);
461469
uniswap = Uniswap(tokenPriceOracleAddress2);
462470
uint256 ethAmount = uniswap.getTokenToEthInputPrice(sethAmount);
463471
uint256 outputAmount = kyber.getOutputAmount(ethToken, token, ethAmount);
@@ -520,6 +528,13 @@ contract orfeed {
520528
}
521529

522530

531+
function updateSynthAddress(address newOracle) onlyOwner external returns(bool) {
532+
synthetixExchangeAddress = newOracle;
533+
return true;
534+
}
535+
536+
537+
523538
//this will go to a DAO
524539
function updatePremiumSubOracleAddress(address newOracle) onlyOwner external returns(bool) {
525540
premiumSubPriceOracleAddress = newOracle;
@@ -745,13 +760,21 @@ contract orfeed {
745760
//token to forex
746761
else if (freeRateTokenSymbols[fromSymb] != 0x0 && freeRateTokenSymbols[toSymb] == 0x0) {
747762

763+
if(equal(fromSymb,"ETH")){
764+
fromSymb = "ETH2";
765+
}
766+
748767
uint256 toRate2 = getTokenToSynthOutputAmount(ERC20(freeRateTokenSymbols[fromSymb]), freeRateForexBytes[toSymb], amount);
749768
return toRate2.mul(rateMultiply2).div(rateDivide2);
750769
}
751770

752771
//forex to token
753772
else if (freeRateTokenSymbols[fromSymb] == 0x0 && freeRateTokenSymbols[toSymb] != 0x0) {
754773

774+
if(equal(toSymb,"ETH")){
775+
toSymb = "ETH2";
776+
}
777+
755778
uint256 toRate3 = getSynthToTokenOutputAmount(freeRateForexBytes[fromSymb], ERC20(freeRateTokenSymbols[toSymb]), amount);
756779
return toRate3.mul(rateMultiply3).div(rateDivide3);
757780
}
@@ -760,7 +783,8 @@ contract orfeed {
760783
//forex to forex
761784

762785
else if (freeRateTokenSymbols[fromSymb] == 0x0 && freeRateTokenSymbols[toSymb] == 0x0) {
763-
786+
787+
se = SynthetixExchange(synthetixExchangeAddress);
764788
uint256 toRate4 = se.effectiveValue(freeRateForexBytes[fromSymb], amount, freeRateForexBytes[toSymb]);
765789
return toRate4.mul(rateMultiply4).div(rateDivide4);
766790
}
@@ -780,6 +804,58 @@ contract orfeed {
780804
result := mload(add(source, 32))
781805
}
782806
}
807+
808+
function compare(string _a, string _b) returns (int) {
809+
bytes memory a = bytes(_a);
810+
bytes memory b = bytes(_b);
811+
uint minLength = a.length;
812+
if (b.length < minLength) minLength = b.length;
813+
//@todo unroll the loop into increments of 32 and do full 32 byte comparisons
814+
for (uint i = 0; i < minLength; i ++)
815+
if (a[i] < b[i])
816+
return -1;
817+
else if (a[i] > b[i])
818+
return 1;
819+
if (a.length < b.length)
820+
return -1;
821+
else if (a.length > b.length)
822+
return 1;
823+
else
824+
return 0;
825+
}
826+
827+
function equal(string _a, string _b) returns (bool) {
828+
return compare(_a, _b) == 0;
829+
}
830+
831+
function indexOf(string _haystack, string _needle) returns (int)
832+
{
833+
bytes memory h = bytes(_haystack);
834+
bytes memory n = bytes(_needle);
835+
if(h.length < 1 || n.length < 1 || (n.length > h.length))
836+
return -1;
837+
else if(h.length > (2**128 -1)) // since we have to be able to return -1 (if the char isn't found or input error), this function must return an "int" type with a max length of (2^128 - 1)
838+
return -1;
839+
else
840+
{
841+
uint subindex = 0;
842+
for (uint i = 0; i < h.length; i ++)
843+
{
844+
if (h[i] == n[0]) // found the first char of b
845+
{
846+
subindex = 1;
847+
while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) // search until the chars don't match or until we reach the end of a or b
848+
{
849+
subindex++;
850+
}
851+
if(subindex == n.length)
852+
return int(i);
853+
}
854+
}
855+
return -1;
856+
}
857+
}
858+
783859

784860

785861
//end contract

tests/orfeed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ contract('OrFeed', async accounts => {
77

88
before(async () => {
99
if (NETWORK === 'mainnet') {
10-
contractInstance = await Orfeed.at("0x73f5022bec0e01c0859634b0c7186301c5464b46")
10+
contractInstance = await Orfeed.at("0x8316b082621cfedab95bf4a44a1d4b64a6ffc336")
1111
} else {
1212
contractInstance = await OrFeed.deployed()
1313
}

0 commit comments

Comments
 (0)