Add offchain oracle contract

This commit is contained in:
Tornado Contrib 2024-04-27 23:16:04 +00:00
parent 28508ef299
commit 8f656af0ac
Signed by: tornadocontrib
GPG Key ID: 60B4DF1A076C64B1
2 changed files with 27 additions and 17 deletions

@ -85,9 +85,9 @@ import {
TreeCache, TreeCache,
} from './services'; } from './services';
const DEFAULT_GAS_LIMIT = 600_000; const DEFAULT_GAS_LIMIT = Number(process.env.DEFAULT_GAS_LIMIT) || 600_000;
const RELAYER_NETWORK = 1;
const TOKEN_PRICE_ORACLE = '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8'; const RELAYER_NETWORK = Number(process.env.RELAYER_NETWORK) || 1;
// Where cached events, trees, circuits, and key is saved // Where cached events, trees, circuits, and key is saved
const STATIC_DIR = process.env.CACHE_DIR || path.join(__dirname, '../static'); const STATIC_DIR = process.env.CACHE_DIR || path.join(__dirname, '../static');
@ -280,7 +280,7 @@ export async function getProgramRelayer({
const netConfig = getConfig(netId); const netConfig = getConfig(netId);
const ethConfig = getConfig('1'); const ethConfig = getConfig(RELAYER_NETWORK);
const subdomains = getSubdomains(); const subdomains = getSubdomains();
@ -291,7 +291,7 @@ export async function getProgramRelayer({
constants: { REGISTRY_BLOCK }, constants: { REGISTRY_BLOCK },
} = ethConfig; } = ethConfig;
const provider = getProgramProvider(1, ethRpc, ethConfig, { const provider = getProgramProvider(RELAYER_NETWORK, ethRpc, ethConfig, {
...fetchDataOptions, ...fetchDataOptions,
}); });
@ -791,6 +791,7 @@ export function tornadoProgram() {
nativeCurrency, nativeCurrency,
multicallContract, multicallContract,
routerContract, routerContract,
offchainOracleContract,
ovmGasPriceOracleContract, ovmGasPriceOracleContract,
tokens: { [currency]: currencyConfig }, tokens: { [currency]: currencyConfig },
} = config; } = config;
@ -833,10 +834,11 @@ export function tornadoProgram() {
? OvmGasPriceOracle__factory.connect(ovmGasPriceOracleContract, provider) ? OvmGasPriceOracle__factory.connect(ovmGasPriceOracleContract, provider)
: undefined, : undefined,
); );
const tokenPriceOracle = new TokenPriceOracle( const tokenPriceOracle = new TokenPriceOracle(
provider, provider,
Multicall, Multicall,
OffchainOracle__factory.connect(TOKEN_PRICE_ORACLE, provider), offchainOracleContract ? OffchainOracle__factory.connect(offchainOracleContract, provider) : undefined,
); );
const depositsServiceConstructor = { const depositsServiceConstructor = {

@ -54,11 +54,12 @@ export type Config = {
rpcUrls: RpcUrls; rpcUrls: RpcUrls;
multicallContract: string; multicallContract: string;
routerContract: string; routerContract: string;
echoContract: string;
offchainOracleContract?: string;
tornContract?: string; tornContract?: string;
governanceContract?: string; governanceContract?: string;
stakingRewardsContract?: string; stakingRewardsContract?: string;
registryContract?: string; registryContract?: string;
echoContract: string;
aggregatorContract?: string; aggregatorContract?: string;
reverseRecordsContract?: string; reverseRecordsContract?: string;
gasPriceOracleContract?: string; gasPriceOracleContract?: string;
@ -147,11 +148,12 @@ export const defaultConfig: networkConfig = {
}, },
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
routerContract: '0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b', routerContract: '0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b',
echoContract: '0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
tornContract: '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C', tornContract: '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
governanceContract: '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce', governanceContract: '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce',
stakingRewardsContract: '0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29', stakingRewardsContract: '0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29',
registryContract: '0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2', registryContract: '0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2',
echoContract: '0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42',
aggregatorContract: '0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49', aggregatorContract: '0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49',
reverseRecordsContract: '0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C', reverseRecordsContract: '0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C',
tornadoSubgraph: 'tornadocash/mainnet-tornado-subgraph', tornadoSubgraph: 'tornadocash/mainnet-tornado-subgraph',
@ -258,8 +260,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Binance Smart Chain', networkName: 'Binance Smart Chain',
deployedBlock: 8158799, deployedBlock: 8158799,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
tornadoSubgraph: 'tornadocash/bsc-tornado-subgraph', tornadoSubgraph: 'tornadocash/bsc-tornado-subgraph',
subgraphs: { subgraphs: {
tornado, tornado,
@ -322,8 +325,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Polygon (Matic) Network', networkName: 'Polygon (Matic) Network',
deployedBlock: 16257962, deployedBlock: 16257962,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
gasPriceOracleContract: '0xF81A8D8D3581985D3969fe53bFA67074aDFa8F3C', gasPriceOracleContract: '0xF81A8D8D3581985D3969fe53bFA67074aDFa8F3C',
tornadoSubgraph: 'tornadocash/matic-tornado-subgraph', tornadoSubgraph: 'tornadocash/matic-tornado-subgraph',
subgraphs: { subgraphs: {
@ -379,8 +383,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Optimism', networkName: 'Optimism',
deployedBlock: 2243689, deployedBlock: 2243689,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
ovmGasPriceOracleContract: '0x420000000000000000000000000000000000000F', ovmGasPriceOracleContract: '0x420000000000000000000000000000000000000F',
tornadoSubgraph: 'tornadocash/optimism-tornado-subgraph', tornadoSubgraph: 'tornadocash/optimism-tornado-subgraph',
subgraphs: { subgraphs: {
@ -444,8 +449,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Arbitrum One', networkName: 'Arbitrum One',
deployedBlock: 3430648, deployedBlock: 3430648,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
tornadoSubgraph: 'tornadocash/arbitrum-tornado-subgraph', tornadoSubgraph: 'tornadocash/arbitrum-tornado-subgraph',
subgraphs: { subgraphs: {
tornado, tornado,
@ -508,8 +514,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Gnosis Chain', networkName: 'Gnosis Chain',
deployedBlock: 17754561, deployedBlock: 17754561,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
tornadoSubgraph: 'tornadocash/xdai-tornado-subgraph', tornadoSubgraph: 'tornadocash/xdai-tornado-subgraph',
subgraphs: { subgraphs: {
tornado, tornado,
@ -572,8 +579,9 @@ export const defaultConfig: networkConfig = {
networkName: 'Avalanche Mainnet', networkName: 'Avalanche Mainnet',
deployedBlock: 4429818, deployedBlock: 4429818,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17', routerContract: '0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
offchainOracleContract: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
tornadoSubgraph: 'tornadocash/avalanche-tornado-subgraph', tornadoSubgraph: 'tornadocash/avalanche-tornado-subgraph',
subgraphs: { subgraphs: {
theGraph, theGraph,
@ -627,11 +635,11 @@ export const defaultConfig: networkConfig = {
deployedBlock: 5594395, deployedBlock: 5594395,
multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11', multicallContract: '0xcA11bde05977b3631167028862bE2a173976CA11',
routerContract: '0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee', routerContract: '0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee',
echoContract: '0xa75BF2815618872f155b7C4B0C81bF990f5245E4',
tornContract: '0x3AE6667167C0f44394106E197904519D808323cA', tornContract: '0x3AE6667167C0f44394106E197904519D808323cA',
governanceContract: '0xe5324cD7602eeb387418e594B87aCADee08aeCAD', governanceContract: '0xe5324cD7602eeb387418e594B87aCADee08aeCAD',
stakingRewardsContract: '0x6d0018890751Efd31feb8166711B16732E2b496b', stakingRewardsContract: '0x6d0018890751Efd31feb8166711B16732E2b496b',
registryContract: '0x1428e5d2356b13778A13108b10c440C83011dfB8', registryContract: '0x1428e5d2356b13778A13108b10c440C83011dfB8',
echoContract: '0xcDD1fc3F5ac2782D83449d3AbE80D6b7B273B0e5',
aggregatorContract: '0x4088712AC9fad39ea133cdb9130E465d235e9642', aggregatorContract: '0x4088712AC9fad39ea133cdb9130E465d235e9642',
reverseRecordsContract: '0xEc29700C0283e5Be64AcdFe8077d6cC95dE23C23', reverseRecordsContract: '0xEc29700C0283e5Be64AcdFe8077d6cC95dE23C23',
tornadoSubgraph: 'tornadocash/sepolia-tornado-subgraph', tornadoSubgraph: 'tornadocash/sepolia-tornado-subgraph',