From fa7799789688073a1ab4b0c38e34dbc19d7ed54e Mon Sep 17 00:00:00 2001 From: nikdementev Date: Sat, 19 Jun 2021 23:03:18 +0300 Subject: [PATCH] fix: prices oracle --- abis/OffchainOracle.abi.json | 171 ++++++++++++++++++++++++++++++++++- package.json | 2 +- src/config.js | 2 +- src/priceWatcher.js | 2 +- 4 files changed, 173 insertions(+), 4 deletions(-) diff --git a/abis/OffchainOracle.abi.json b/abis/OffchainOracle.abi.json index e5b971d..57b2d2a 100644 --- a/abis/OffchainOracle.abi.json +++ b/abis/OffchainOracle.abi.json @@ -1,12 +1,181 @@ [ + { + "inputs": [ + { "internalType": "contract MultiWrapper", "name": "_multiWrapper", "type": "address" }, + { "internalType": "contract IOracle[]", "name": "existingOracles", "type": "address[]" }, + { "internalType": "enum OffchainOracle.OracleType[]", "name": "oracleTypes", "type": "uint8[]" }, + { "internalType": "contract IERC20[]", "name": "existingConnectors", "type": "address[]" }, + { "internalType": "contract IERC20", "name": "wBase", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "contract IERC20", "name": "connector", "type": "address" } + ], + "name": "ConnectorAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "contract IERC20", "name": "connector", "type": "address" } + ], + "name": "ConnectorRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "contract MultiWrapper", "name": "multiWrapper", "type": "address" } + ], + "name": "MultiWrapperUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "contract IOracle", "name": "oracle", "type": "address" }, + { + "indexed": false, + "internalType": "enum OffchainOracle.OracleType", + "name": "oracleType", + "type": "uint8" + } + ], + "name": "OracleAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "contract IOracle", "name": "oracle", "type": "address" }, + { + "indexed": false, + "internalType": "enum OffchainOracle.OracleType", + "name": "oracleType", + "type": "uint8" + } + ], + "name": "OracleRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [{ "internalType": "contract IERC20", "name": "connector", "type": "address" }], + "name": "addConnector", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IOracle", "name": "oracle", "type": "address" }, + { "internalType": "enum OffchainOracle.OracleType", "name": "oracleKind", "type": "uint8" } + ], + "name": "addOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "connectors", + "outputs": [{ "internalType": "contract IERC20[]", "name": "allConnectors", "type": "address[]" }], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "contract IERC20", "name": "srcToken", "type": "address" }, - { "internalType": "contract IERC20", "name": "dstToken", "type": "address" } + { "internalType": "contract IERC20", "name": "dstToken", "type": "address" }, + { "internalType": "bool", "name": "useWrappers", "type": "bool" } ], "name": "getRate", "outputs": [{ "internalType": "uint256", "name": "weightedRate", "type": "uint256" }], "stateMutability": "view", "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "srcToken", "type": "address" }, + { "internalType": "bool", "name": "useSrcWrappers", "type": "bool" } + ], + "name": "getRateToEth", + "outputs": [{ "internalType": "uint256", "name": "weightedRate", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "multiWrapper", + "outputs": [{ "internalType": "contract MultiWrapper", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracles", + "outputs": [ + { "internalType": "contract IOracle[]", "name": "allOracles", "type": "address[]" }, + { "internalType": "enum OffchainOracle.OracleType[]", "name": "oracleTypes", "type": "uint8[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "contract IERC20", "name": "connector", "type": "address" }], + "name": "removeConnector", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IOracle", "name": "oracle", "type": "address" }, + { "internalType": "enum OffchainOracle.OracleType", "name": "oracleKind", "type": "uint8" } + ], + "name": "removeOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "contract MultiWrapper", "name": "_multiWrapper", "type": "address" }], + "name": "setMultiWrapper", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" } ] diff --git a/package.json b/package.json index 104c935..86e8fdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "relay", - "version": "4.0.15", + "version": "4.0.16", "description": "Relayer for Tornado.cash privacy solution. https://tornado.cash", "scripts": { "server": "node src/server.js", diff --git a/src/config.js b/src/config.js index 6e579c4..e0cc365 100644 --- a/src/config.js +++ b/src/config.js @@ -8,7 +8,7 @@ module.exports = { httpRpcUrl: process.env.HTTP_RPC_URL, wsRpcUrl: process.env.WS_RPC_URL, oracleRpcUrl: process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/', - offchainOracleAddress: '0x080AB73787A8B13EC7F40bd7d00d6CC07F9b24d0', + offchainOracleAddress: '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb', aggregatorAddress: process.env.AGGREGATOR, minerMerkleTreeHeight: 20, privateKey: process.env.PRIVATE_KEY, diff --git a/src/priceWatcher.js b/src/priceWatcher.js index 923f97c..9f95204 100644 --- a/src/priceWatcher.js +++ b/src/priceWatcher.js @@ -22,7 +22,7 @@ async function main() { for (let i = 0; i < tokenAddresses.length; i++) { try { const price = await offchainOracle.methods - .getRate(tokenAddresses[i], '0x0000000000000000000000000000000000000000') + .getRate(tokenAddresses[i], '0x0000000000000000000000000000000000000000', false) .call() const numerator = toBN(oneUintAmount[i]) const denominator = toBN(10).pow(toBN(18)) // eth decimals