diff --git a/apps/landing/package.json b/apps/landing/package.json index f64faa219..5fc9a9bd3 100644 --- a/apps/landing/package.json +++ b/apps/landing/package.json @@ -5,7 +5,7 @@ "version": "0.0.1", "scripts": { "dev": "vite", - "build": "vue-tsc --noEmit && vite build", + "build": "vite build", "preview": "vite preview" }, "dependencies": { diff --git a/common/env/src/index.ts b/common/env/src/index.ts index b093f6058..2d7e74aa9 100644 --- a/common/env/src/index.ts +++ b/common/env/src/index.ts @@ -1,30 +1,41 @@ -const ETHEREUM_CONTRACT_ADDRESSES = { +const ETHEREUM_CONTRACTS = { TESTNET: { - FunctionsOracleFactory: '0xfA2D8643D87E625004bcA263Bcd2002255fDD4BB', - FunctionsOracle: '0xF89a8DDFdb39C6BB3125bBeA3BB356B40A99b46f', - FunctionsBillingRegistry: '0x6310Cc8288aE5f70E914363c72F7d2e1D1C8533d', - CasimirPoolBeacon: '0x98A6f99c1bD042b4B1B5C03755805a7FFac902e1', - CasimirRegistryBeacon: '0x3FB35C4de1a1AeA102B192d28391227C93305cA5', - CasimirUpkeepBeacon: '0x12CCBd11A592Bc7ad0405c15c90c8419b390E814', - CasimirManager: '0x813aA99639F77A275b5bD5E12904cCd48826C19F', - CasimirRegistry: '0x97d5b6F9801D2CdCB492e567b1246a837Cd8d2D4', - CasimirUpkeep: '0x1A4f46e5209b71C11aeb6776fD161B80174B2a63', - CasimirViews: '0xc9F69bD5F43153FB485cBF1DB907EE1eb28c9B29' - } -} + MANAGER_ADDRESS: '0x813aA99639F77A275b5bD5E12904cCd48826C19F', + REGISTRY_ADDRESS: '0x97d5b6F9801D2CdCB492e567b1246a837Cd8d2D4', + UPKEEP_ADDRESS: '0x1A4f46e5209b71C11aeb6776fD161B80174B2a63', + VIEWS_ADDRESS: '0xc9F69bD5F43153FB485cBF1DB907EE1eb28c9B29', -enum ETHEREUM_FORK_URL { - MAINNET = 'https://mainnet.infura.io/v3/46a379ac6895489f812f33beb726b03b', - TESTNET = 'https://goerli.infura.io/v3/46a379ac6895489f812f33beb726b03b' + FUNCTIONS_ORACLE_FACTORY_ADDRESS: '0xfA2D8643D87E625004bcA263Bcd2002255fDD4BB', + FUNCTIONS_ORACLE_ADDRESS: '0xF89a8DDFdb39C6BB3125bBeA3BB356B40A99b46f', + FUNCTIONS_BILLING_REGISTRY_ADDRESS: '0x6310Cc8288aE5f70E914363c72F7d2e1D1C8533d', + + POOL_BEACON_ADDRESS: '0x98A6f99c1bD042b4B1B5C03755805a7FFac902e1', + REGISTRY_BEACON_ADDRESS: '0x3FB35C4de1a1AeA102B192d28391227C93305cA5', + UPKEEP_BEACON_ADDRESS: '0x12CCBd11A592Bc7ad0405c15c90c8419b390E814', + + BEACON_DEPOSIT_ADDRESS: '0x07b39F4fDE4A38bACe212b546dAc87C58DfE3fDC', + DAO_ORACLE_ADDRESS: '', + LINK_ETH_FEED_ADDRESS: '0xb4c4a493AB6356497713A78FFA6c60FB53517c63', + KEEPER_REGISTRAR_ADDRESS: '0x57A4a13b35d25EE78e084168aBaC5ad360252467', + KEEPER_REGISTRY_ADDRESS: '0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2', + LINK_TOKEN_ADDRESS: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB', + SSV_NETWORK_ADDRESS: '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D', + SSV_VIEWS_ADDRESS: '0xAE2C84c48272F5a1746150ef333D5E5B51F68763', + SSV_TOKEN_ADDRESS: '0x3a9f01091C446bdE031E39ea8354647AFef091E7', + SWAP_FACTORY_ADDRESS: '0x1F98431c8aD98523631AE4a59f267346ea31F984', + SWAP_ROUTER_ADDRESS: '0xE592427A0AEce92De3Edee1F18E0157C05861564', + WETH_TOKEN_ADDRESS: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6' + } } enum ETHEREUM_NETWORK_NAME { MAINNET = 'mainnet', TESTNET = 'goerli' } -enum ETHEREUM_NETWORK_URL { + +enum ETHEREUM_RPC_URL { MAINNET = 'https://mainnet.infura.io/v3/46a379ac6895489f812f33beb726b03b', TESTNET = 'https://goerli.infura.io/v3/46a379ac6895489f812f33beb726b03b' } -export { ETHEREUM_CONTRACT_ADDRESSES, ETHEREUM_FORK_URL, ETHEREUM_NETWORK_NAME, ETHEREUM_NETWORK_URL } \ No newline at end of file +export { ETHEREUM_CONTRACTS, ETHEREUM_NETWORK_NAME, ETHEREUM_RPC_URL } \ No newline at end of file diff --git a/contracts/ethereum/hardhat.config.ts b/contracts/ethereum/hardhat.config.ts index 460528e2e..950ac3d99 100644 --- a/contracts/ethereum/hardhat.config.ts +++ b/contracts/ethereum/hardhat.config.ts @@ -7,6 +7,7 @@ import '@nomiclabs/hardhat-ethers' import '@nomicfoundation/hardhat-toolbox' import '@openzeppelin/hardhat-upgrades' import 'hardhat-abi-exporter' +import { ETHEREUM_CONTRACTS } from '@casimir/env' // Seed is provided const mnemonic = process.env.BIP39_SEED as string @@ -47,23 +48,23 @@ const externalEnv = { WETH_TOKEN_ADDRESS: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' }, goerli: { - BEACON_DEPOSIT_ADDRESS: '0x07b39F4fDE4A38bACe212b546dAc87C58DfE3fDC', + BEACON_DEPOSIT_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.BEACON_DEPOSIT_ADDRESS, DAO_ORACLE_ADDRESS: '', FUNCTIONS_BILLING_REGISTRY_ADDRESS: '', FUNCTIONS_ORACLE_ADDRESS: '', - LINK_ETH_FEED_ADDRESS: '0xb4c4a493AB6356497713A78FFA6c60FB53517c63', - KEEPER_REGISTRAR_ADDRESS: '0x57A4a13b35d25EE78e084168aBaC5ad360252467', - KEEPER_REGISTRY_ADDRESS: '0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2', - LINK_TOKEN_ADDRESS: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB', + LINK_ETH_FEED_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.LINK_ETH_FEED_ADDRESS, + KEEPER_REGISTRAR_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.KEEPER_REGISTRAR_ADDRESS, + KEEPER_REGISTRY_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.KEEPER_REGISTRY_ADDRESS, + LINK_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.LINK_TOKEN_ADDRESS, POOL_BEACON_ADDRESS: '', REGISTRY_BEACON_ADDRESS: '', - SSV_NETWORK_ADDRESS: '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D', - SSV_VIEWS_ADDRESS: '0xAE2C84c48272F5a1746150ef333D5E5B51F68763', - SSV_TOKEN_ADDRESS: '0x3a9f01091C446bdE031E39ea8354647AFef091E7', - SWAP_FACTORY_ADDRESS: '0x1F98431c8aD98523631AE4a59f267346ea31F984', - SWAP_ROUTER_ADDRESS: '0xE592427A0AEce92De3Edee1F18E0157C05861564', + SSV_NETWORK_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_NETWORK_ADDRESS, + SSV_VIEWS_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_VIEWS_ADDRESS, + SSV_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_TOKEN_ADDRESS, + SWAP_FACTORY_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SWAP_FACTORY_ADDRESS, + SWAP_ROUTER_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SWAP_ROUTER_ADDRESS, UPKEEP_BEACON_ADDRESS: '', - WETH_TOKEN_ADDRESS: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6' + WETH_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.WETH_TOKEN_ADDRESS } } diff --git a/contracts/ethereum/helpers/oracle.ts b/contracts/ethereum/helpers/oracle.ts index 003ede839..57e7a6e09 100644 --- a/contracts/ethereum/helpers/oracle.ts +++ b/contracts/ethereum/helpers/oracle.ts @@ -14,7 +14,7 @@ const ssvViewsAddress = process.env.SSV_VIEWS_ADDRESS as string if (!ssvViewsAddress) throw new Error('No ssv views address provided') const ssvTokenAddress = process.env.SSV_TOKEN_ADDRESS as string if (!ssvTokenAddress) throw new Error('No ssv token address provided') -const uniswapV3FactoryAddress = process.env.UNISWAP_V3_FACTORY_ADDRESS as string +const uniswapV3FactoryAddress = process.env.SWAP_FACTORY_ADDRESS as string if (!uniswapV3FactoryAddress) throw new Error('No uniswap v3 factory address provided') const wethTokenAddress = process.env.WETH_TOKEN_ADDRESS as string if (!wethTokenAddress) throw new Error('No weth token address provided') diff --git a/scripts/cdk/deploy.ts b/scripts/cdk/deploy.ts index 52f919949..44d3494b5 100755 --- a/scripts/cdk/deploy.ts +++ b/scripts/cdk/deploy.ts @@ -1,4 +1,5 @@ import { getSecret, loadCredentials } from '@casimir/aws' +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { run } from '@casimir/shell' /** @@ -12,15 +13,27 @@ void async function () { await loadCredentials() process.env.AWS_ACCOUNT = await getSecret('casimir-aws-account') - process.env.ETHEREUM_RPC_URL = 'https://nodes.casimir.co/eth/hardhat' process.env.USERS_URL = `https://users.${process.env.STAGE}.casimir.co` - - process.env.PUBLIC_MANAGER_ADDRESS = '0x5d35a44Db8a390aCfa997C9a9Ba3a2F878595630' - process.env.PUBLIC_VIEWS_ADDRESS = '0xC88C4022347305336E344e624E5Fa4fB8e61c21E' - process.env.PUBLIC_REGISTRY_ADDRESS = '0xB567C0E87Ec176177E44C91577704267C24Fbd83' - process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL + process.env.CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key') + + const networkKey = process.env.NETWORK?.toUpperCase() || process.env.FORK?.toUpperCase() || 'TESTNET' + process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[networkKey] + process.env.MANAGER_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.MANAGER_ADDRESS + process.env.REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.REGISTRY_ADDRESS + process.env.UPKEEP_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.UPKEEP_ADDRESS + process.env.VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.VIEWS_ADDRESS + process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_NETWORK_ADDRESS + process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_VIEWS_ADDRESS + process.env.PUBLIC_USERS_URL = process.env.USERS_URL - process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key') + process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = process.env.CRYPTO_COMPARE_API_KEY + process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL + process.env.PUBLIC_MANAGER_ADDRESS = process.env.MANAGER_ADDRESS + process.env.PUBLIC_REGISTRY_ADDRESS = process.env.REGISTRY_ADDRESS + process.env.PUBLIC_UPKEEP_ADDRESS = process.env.UPKEEP_ADDRESS + process.env.PUBLIC_VIEWS_ADDRESS = process.env.VIEWS_ADDRESS + process.env.PUBLIC_SSV_NETWORK_ADDRESS = process.env.SSV_NETWORK_ADDRESS + process.env.PUBLIC_SSV_VIEWS_ADDRESS = process.env.SSV_VIEWS_ADDRESS await run('npm run build --workspace @casimir/ethereum') await run('npm run build:docs --workspace @casimir/ethereum') diff --git a/scripts/cdk/test.ts b/scripts/cdk/test.ts index 9aa32f458..2648f8aa0 100644 --- a/scripts/cdk/test.ts +++ b/scripts/cdk/test.ts @@ -11,17 +11,8 @@ void async function () { await loadCredentials() process.env.AWS_ACCOUNT = await getSecret('casimir-aws-account') - - process.env.ETHEREUM_RPC_URL = 'https://nodes.casimir.co/eth/hardhat' process.env.USERS_URL = `https://users.${process.env.STAGE}.casimir.co` - process.env.PUBLIC_MANAGER_ADDRESS = '0x5d35a44Db8a390aCfa997C9a9Ba3a2F878595630' - process.env.PUBLIC_VIEWS_ADDRESS = '0xC88C4022347305336E344e624E5Fa4fB8e61c21E' - process.env.PUBLIC_REGISTRY_ADDRESS = '0xB567C0E87Ec176177E44C91577704267C24Fbd83' - process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL - process.env.PUBLIC_USERS_URL = process.env.USERS_URL - process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key') - await run('npm run build --workspace @casimir/ethereum') await run('npm run build:docs --workspace @casimir/ethereum') await run('npm run build --workspace @casimir/landing') diff --git a/scripts/ethereum/deploy.ts b/scripts/ethereum/deploy.ts index 5bd164eea..4c2397d67 100644 --- a/scripts/ethereum/deploy.ts +++ b/scripts/ethereum/deploy.ts @@ -1,5 +1,5 @@ import { loadCredentials, getSecret } from '@casimir/aws' -import { ETHEREUM_NETWORK_NAME, ETHEREUM_NETWORK_URL } from '@casimir/env' +import { ETHEREUM_NETWORK_NAME, ETHEREUM_RPC_URL } from '@casimir/env' import { run } from '@casimir/shell' /** @@ -15,7 +15,7 @@ void async function () { console.log(`Your mnemonic seed is ${process.env.BIP39_SEED}`) process.env.NETWORK = process.env.NETWORK || 'testnet' - process.env.ETHEREUM_RPC_URL = ETHEREUM_NETWORK_URL[process.env.NETWORK.toUpperCase()] + process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[process.env.NETWORK.toUpperCase()] const networkName = ETHEREUM_NETWORK_NAME[process.env.NETWORK.toUpperCase()] console.log(`Using ${networkName} network from ${process.env.ETHEREUM_RPC_URL}`) diff --git a/scripts/ethereum/dev.ts b/scripts/ethereum/dev.ts index dbc221d09..9d522a240 100644 --- a/scripts/ethereum/dev.ts +++ b/scripts/ethereum/dev.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { loadCredentials, getSecret } from '@casimir/aws' -import { ETHEREUM_FORK_URL } from '@casimir/env' +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { run } from '@casimir/shell' /** @@ -20,7 +20,7 @@ void async function () { process.env.MINING_INTERVAL = '12' process.env.ETHEREUM_RPC_URL = 'http://127.0.0.1:8545' - process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_FORK_URL[process.env.FORK.toUpperCase()] + process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_RPC_URL[process.env.FORK.toUpperCase()] if (!process.env.ETHEREUM_FORK_RPC_URL) { throw new Error(`Ethereum ${process.env.FORK} is not supported`) } @@ -44,13 +44,6 @@ void async function () { }) } - if (!process.env.VIEWS_ADDRESS) { - process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ - from: wallet.address, - nonce: walletNonce + 2 - }) - } - if (!process.env.REGISTRY_ADDRESS) { process.env.REGISTRY_ADDRESS = ethers.utils.getContractAddress({ from: process.env.MANAGER_ADDRESS, @@ -65,9 +58,16 @@ void async function () { }) } - process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D' - process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763' - process.env.UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984' + if (!process.env.VIEWS_ADDRESS) { + process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ + from: wallet.address, + nonce: walletNonce + 2 + }) + } + + process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_NETWORK_ADDRESS + process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_VIEWS_ADDRESS + process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SWAP_FACTORY_ADDRESS run('npm run node --workspace @casimir/ethereum') const hardhatWaitTime = 2500 diff --git a/scripts/ethereum/test.ts b/scripts/ethereum/test.ts index 64153754d..95d06515b 100755 --- a/scripts/ethereum/test.ts +++ b/scripts/ethereum/test.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { loadCredentials, getSecret } from '@casimir/aws' -import { ETHEREUM_FORK_URL } from '@casimir/env' +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { run } from '@casimir/shell' /** @@ -17,7 +17,7 @@ void async function () { process.env.FORK = process.env.FORK || 'testnet' - process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_FORK_URL[process.env.FORK.toUpperCase()] + process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_RPC_URL[process.env.FORK.toUpperCase()] if (!process.env.ETHEREUM_FORK_RPC_URL) { throw new Error(`Ethereum ${process.env.FORK} is not supported`) } @@ -38,13 +38,6 @@ void async function () { }) } - if (!process.env.VIEWS_ADDRESS) { - process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ - from: wallet.address, - nonce: walletNonce + 2 - }) - } - if (!process.env.REGISTRY_ADDRESS) { process.env.REGISTRY_ADDRESS = ethers.utils.getContractAddress({ from: process.env.MANAGER_ADDRESS, @@ -59,9 +52,16 @@ void async function () { }) } - process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D' - process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763' - process.env.UNISWAP_V3_FACTORY_ADDRESS = process.env.UNISWAP_V3_FACTORY_ADDRESS || '0x1F98431c8aD98523631AE4a59f267346ea31F984' + if (!process.env.VIEWS_ADDRESS) { + process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ + from: wallet.address, + nonce: walletNonce + 2 + }) + } + + process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_NETWORK_ADDRESS + process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_VIEWS_ADDRESS + process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SWAP_FACTORY_ADDRESS await run('npm run generate --workspace @casimir/oracle') run('npm run test --workspace @casimir/ethereum') diff --git a/scripts/root/dev.ts b/scripts/root/dev.ts index e0df878bc..55dd84c18 100644 --- a/scripts/root/dev.ts +++ b/scripts/root/dev.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { loadCredentials, getSecret } from '@casimir/aws' -import { ETHEREUM_FORK_URL } from '@casimir/env' +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { run, runSync } from '@casimir/shell' /** @@ -28,9 +28,6 @@ void async function () { process.env.FORK = process.env.FORK || 'testnet' process.env.MOCK_SERVICES = process.env.MOCK_SERVICES || 'true' process.env.BUILD_PREVIEW = process.env.BUILD_PREVIEW || 'false' - process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D' - process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763' - process.env.UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984' if (process.env.BUILD_PREVIEW === 'true') { process.env.WEB_URL = process.env.WEB_URL || 'http://localhost:4173' @@ -51,26 +48,39 @@ void async function () { } } + const networkKey = process.env.NETWORK?.toUpperCase() || process.env.FORK?.toUpperCase() || 'TESTNET' + process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_NETWORK_ADDRESS + process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_VIEWS_ADDRESS + process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SWAP_FACTORY_ADDRESS if (process.env.NETWORK) { - + process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[networkKey] if (!process.env.ETHEREUM_RPC_URL) { - process.env.ETHEREUM_RPC_URL = ETHEREUM_FORK_URL[process.env.NETWORK.toUpperCase()] - if (!process.env.ETHEREUM_RPC_URL) { - throw new Error(`Ethereum ${process.env.NETWORK} is not supported`) - } + throw new Error(`Ethereum ${process.env.NETWORK} is not supported`) } + process.env.MANAGER_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.MANAGER_ADDRESS if (!process.env.MANAGER_ADDRESS) { throw new Error(`No manager address provided for ${process.env.NETWORK} ethereum network.`) } + process.env.REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.REGISTRY_ADDRESS + if (!process.env.REGISTRY_ADDRESS) { + throw new Error(`No registry address provided for ${process.env.NETWORK} ethereum network.`) + } + + process.env.UPKEEP_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.UPKEEP_ADDRESS + if (!process.env.UPKEEP_ADDRESS) { + throw new Error(`No upkeep address provided for ${process.env.NETWORK} ethereum network.`) + } + + process.env.VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.VIEWS_ADDRESS if (!process.env.VIEWS_ADDRESS) { throw new Error(`No views address provided for ${process.env.NETWORK} ethereum network.`) } } else { - process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_FORK_URL[process.env.FORK.toUpperCase()] + process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_RPC_URL[networkKey] if (!process.env.ETHEREUM_FORK_RPC_URL) { throw new Error(`Ethereum ${process.env.FORK} is not supported`) } @@ -92,13 +102,6 @@ void async function () { }) } - if (!process.env.VIEWS_ADDRESS) { - process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ - from: wallet.address, - nonce: walletNonce + 2 - }) - } - if (!process.env.REGISTRY_ADDRESS) { process.env.REGISTRY_ADDRESS = ethers.utils.getContractAddress({ from: process.env.MANAGER_ADDRESS, @@ -113,6 +116,13 @@ void async function () { }) } + if (!process.env.VIEWS_ADDRESS) { + process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({ + from: wallet.address, + nonce: walletNonce + 2 + }) + } + run('npm run dev:ethereum') } @@ -137,11 +147,11 @@ void async function () { process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL process.env.PUBLIC_MANAGER_ADDRESS = process.env.MANAGER_ADDRESS process.env.PUBLIC_VIEWS_ADDRESS = process.env.VIEWS_ADDRESS - process.env.PUBLIC_SSV_NETWORK_ADDRESS = process.env.SSV_NETWORK_ADDRESS - process.env.PUBLIC_SSV_VIEWS_ADDRESS = process.env.SSV_VIEWS_ADDRESS - process.env.PUBLIC_UNISWAP_V3_FACTORY_ADDRESS = process.env.UNISWAP_V3_FACTORY_ADDRESS process.env.PUBLIC_REGISTRY_ADDRESS = process.env.REGISTRY_ADDRESS process.env.PUBLIC_UPKEEP_ADDRESS = process.env.UPKEEP_ADDRESS + process.env.PUBLIC_SSV_NETWORK_ADDRESS = process.env.SSV_NETWORK_ADDRESS + process.env.PUBLIC_SSV_VIEWS_ADDRESS = process.env.SSV_VIEWS_ADDRESS + process.env.PUBLIC_SWAP_FACTORY_ADDRESS = process.env.SWAP_FACTORY_ADDRESS process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = process.env.CRYPTO_COMPARE_API_KEY process.env.PUBLIC_LEDGER_APP = process.env.LEDGER_APP process.env.PUBLIC_SPECULOS_URL = process.env.SPECULOS_URL diff --git a/services/functions/scripts/dev.ts b/services/functions/scripts/dev.ts index f1e033c35..f98ea1d62 100644 --- a/services/functions/scripts/dev.ts +++ b/services/functions/scripts/dev.ts @@ -1,3 +1,4 @@ +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { run } from '@casimir/shell' /** @@ -5,10 +6,19 @@ import { run } from '@casimir/shell' */ void async function() { process.env.BIP39_SEED = process.env.BIP39_SEED || 'inflict ball claim confirm cereal cost note dad mix donate traffic patient' - process.env.ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL || 'http://127.0.0.1:8545' - process.env.ETHEREUM_BEACON_RPC_URL = process.env.ETHEREUM_BEACON_RPC_URL || 'http://127.0.0.1:5052' - if (!process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS) throw new Error('No functions billing registry address provided') + const networkKey = process.env.NETWORK?.toUpperCase() || process.env.FORK?.toUpperCase() || 'TESTNET' + if (process.env.NETWORK) { + process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[networkKey] + process.env.UPKEEP_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.UPKEEP_ADDRESS + process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.FUNCTIONS_BILLING_REGISTRY_ADDRESS + process.env.FUNCTIONS_ORACLE_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.FUNCTIONS_ORACLE_ADDRESS + } + if (!process.env.ETHEREUM_RPC_URL) throw new Error(`No ethereum rpc url provided for ${networkKey}`) + if (!process.env.UPKEEP_ADDRESS) throw new Error(`No upkeep address provided for ${networkKey}`) + if (!process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS) throw new Error(`No functions billing registry address provided for ${networkKey}`) if (!process.env.FUNCTIONS_ORACLE_ADDRESS) throw new Error('No functions oracle address provided') + + process.env.ETHEREUM_BEACON_RPC_URL = process.env.ETHEREUM_BEACON_RPC_URL || 'http://127.0.0.1:5002' process.env.USE_LOGS = process.env.USE_LOGS || 'false' run(`npx esno -r dotenv/config src/index.ts${process.env.USE_LOGS === 'true' ? ' >> .log/functions.log' : ''}`) diff --git a/services/oracle/scripts/dev.ts b/services/oracle/scripts/dev.ts index b75f382eb..de8632b22 100644 --- a/services/oracle/scripts/dev.ts +++ b/services/oracle/scripts/dev.ts @@ -1,3 +1,4 @@ +import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' import { fetchRetry } from '@casimir/fetch' import { run } from '@casimir/shell' @@ -13,17 +14,34 @@ void async function () { process.env.USE_HARDCODED_OPERATORS = 'false' process.env.BIP39_SEED = process.env.BIP39_SEED || 'inflict ball claim confirm cereal cost note dad mix donate traffic patient' - if (!process.env.MANAGER_ADDRESS) throw new Error('No manager address provided') - if (!process.env.VIEWS_ADDRESS) throw new Error('No views address provided') - if (!process.env.REGISTRY_ADDRESS) throw new Error('No registry address provided') - if (!process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS) throw new Error('No functions billing registry address provided') - if (!process.env.KEEPER_REGISTRY_ADDRESS) throw new Error('No link registry address provided') - process.env.LINK_TOKEN_ADDRESS = '0x326C977E6efc84E512bB9C30f76E30c160eD06FB' - process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D' - process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763' - process.env.SSV_TOKEN_ADDRESS = '0x3a9f01091C446bdE031E39ea8354647AFef091E7' - process.env.UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984' - process.env.WETH_TOKEN_ADDRESS = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6' + + const networkKey = process.env.NETWORK?.toUpperCase() || process.env.FORK?.toUpperCase() || 'TESTNET' + if (process.env.NETWORK) { + process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[networkKey] + process.env.MANAGER_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.MANAGER_ADDRESS + process.env.REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.REGISTRY_ADDRESS + process.env.UPKEEP_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.UPKEEP_ADDRESS + process.env.VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.VIEWS_ADDRESS + process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.FUNCTIONS_BILLING_REGISTRY_ADDRESS + } + process.env.KEEPER_REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.KEEPER_REGISTRY_ADDRESS + process.env.LINK_TOKEN_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.LINK_TOKEN_ADDRESS + process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_NETWORK_ADDRESS + process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_VIEWS_ADDRESS + process.env.SSV_TOKEN_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_TOKEN_ADDRESS + process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SWAP_FACTORY_ADDRESS + process.env.WETH_TOKEN_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.WETH_TOKEN_ADDRESS + if (!process.env.ETHEREUM_RPC_URL) throw new Error(`No ethereum rpc url provided for ${networkKey}`) + if (!process.env.MANAGER_ADDRESS) throw new Error(`No manager address provided for ${networkKey}`) + if (!process.env.VIEWS_ADDRESS) throw new Error(`No views address provided for ${networkKey}`) + if (!process.env.REGISTRY_ADDRESS) throw new Error(`No registry address provided for ${networkKey}`) + if (!process.env.FUNCTIONS_BILLING_REGISTRY_ADDRESS) throw new Error(`No functions billing registry address provided for ${networkKey}`) + if (!process.env.KEEPER_REGISTRY_ADDRESS) throw new Error(`No keeper registry address provided for ${networkKey}`) + if (!process.env.LINK_TOKEN_ADDRESS) throw new Error(`No link token address provided for ${networkKey}`) + if (!process.env.SSV_NETWORK_ADDRESS) throw new Error(`No ssv network address provided for ${networkKey}`) + if (!process.env.SSV_VIEWS_ADDRESS) throw new Error(`No ssv views address provided for ${networkKey}`) + if (!process.env.SSV_TOKEN_ADDRESS) throw new Error(`No ssv token address provided for ${networkKey}`) + if (!process.env.SWAP_FACTORY_ADDRESS) throw new Error(`No uniswap v3 factory address provided for ${networkKey}`) const dkg = await run(`which ${process.env.CLI_PATH}`) as string if (!dkg || dkg.includes('not found')) { diff --git a/services/oracle/scripts/generate.ts b/services/oracle/scripts/generate.ts index 1930574d9..28ff7965b 100644 --- a/services/oracle/scripts/generate.ts +++ b/services/oracle/scripts/generate.ts @@ -21,12 +21,6 @@ void async function () { process.env.BIP39_SEED = process.env.BIP39_SEED || 'inflict ball claim confirm cereal cost note dad mix donate traffic patient' if (!process.env.MANAGER_ADDRESS) throw new Error('No manager address set') if (!process.env.VIEWS_ADDRESS) throw new Error('No views address set') - process.env.LINK_TOKEN_ADDRESS = '0x326C977E6efc84E512bB9C30f76E30c160eD06FB' - process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D' - process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763' - process.env.SSV_TOKEN_ADDRESS = '0x3a9f01091C446bdE031E39ea8354647AFef091E7' - process.env.UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984' - process.env.WETH_TOKEN_ADDRESS = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6' const preregisteredOperatorIds = process.env.PREREGISTERED_OPERATOR_IDS?.split(',').map(id => parseInt(id)) || [156, 157, 158, 159] if (preregisteredOperatorIds.length < 4) throw new Error('Not enough operator ids provided') diff --git a/services/oracle/src/providers/config.ts b/services/oracle/src/providers/config.ts index b425ce8c2..046ff22a0 100644 --- a/services/oracle/src/providers/config.ts +++ b/services/oracle/src/providers/config.ts @@ -34,7 +34,7 @@ export function getConfig() { if (!ssvViewsAddress) throw new Error('No ssv network views address provided') const ssvTokenAddress = process.env.SSV_TOKEN_ADDRESS if (!ssvTokenAddress) throw new Error('No ssv token address provided') - const uniswapV3FactoryAddress = process.env.UNISWAP_V3_FACTORY_ADDRESS + const uniswapV3FactoryAddress = process.env.SWAP_FACTORY_ADDRESS if (!uniswapV3FactoryAddress) throw new Error('No uniswap v3 factory address provided') const wethTokenAddress = process.env.WETH_TOKEN_ADDRESS if (!wethTokenAddress) throw new Error('No weth token address provided')