diff --git a/scripts/check-token.js b/scripts/check-token.js index eca7ec06..2fd3dfd2 100644 --- a/scripts/check-token.js +++ b/scripts/check-token.js @@ -16,7 +16,6 @@ async function main () { const OffchainOracle = await ethers.getContractFactory('OffchainOracle'); const offchainOracleInDeployments = require(`../deployments/${networkName}/OffchainOracle.json`); const deployedOffchainOracle = OffchainOracle.attach(offchainOracleInDeployments.address); - const isDeployedOracleWithFilter = !!offchainOracleInDeployments.devdoc.methods['getRateToEthWithThreshold(address,bool,uint256)']; const weth = offchainOracleInDeployments.args[4]; const connectors = await deployedOffchainOracle.connectors(); @@ -37,24 +36,13 @@ async function main () { } catch {} console.log('======================'); - const getRateToEthDeployedOracle = isDeployedOracleWithFilter - ? () => deployedOffchainOracle.getRateToEthWithThreshold(token, true, thresholdFilter) - : () => deployedOffchainOracle.getRateToEth(token, true); + console.log('Current state\'s price =', usdPrice(await deployedOffchainOracle.getRateToEthWithThreshold(token, true, thresholdFilter) / 10 ** (18 - decimals))); - console.log('Current state\'s price =', usdPrice(await getRateToEthDeployedOracle() / 10 ** (18 - decimals))); - - const getRateToEth = isDeployedOracleWithFilter - ? offchainOracle.getRateToEthWithThreshold - : offchainOracle.getRateToEth; const oracles = await deployedOffchainOracle.oracles(); for (let i = 0; i < oracles.allOracles.length; i++) { await offchainOracle.addOracle(oracles.allOracles[i], oracles.oracleTypes[i]); - const getRateParams = [token, true]; - if (isDeployedOracleWithFilter) { - getRateParams.push(thresholdFilter); - } - const price = usdPrice(await getRateToEth(...getRateParams) / 10 ** (18 - decimals)); + const price = usdPrice(await offchainOracle.getRateToEthWithThreshold(token, true, thresholdFilter) / 10 ** (18 - decimals)); if (parseFloat(price) !== 0) { console.log(oracles.allOracles[i], 'oracle\'s price =', price); @@ -68,7 +56,7 @@ async function main () { else if (tokens.EEE === connectors[j]) symbol = 'EEE'; else symbol = await (await ethers.getContractAt('IERC20Metadata', connectors[j])).symbol(); - const { rate, weight } = await oracle.getRate(token, weth, connectors[j]); + const { rate, weight } = await oracle.getRate(token, weth, connectors[j], thresholdFilter); pricesViaConnector.push({ connector: symbol, rate: parseFloat(usdPrice(rate / 10 ** (18 - decimals))).toFixed(2), weight: weight.toString() }); } catch {} } diff --git a/scripts/check-tokens-prices.js b/scripts/check-tokens-prices.js index 9cd63097..4b9445fc 100644 --- a/scripts/check-tokens-prices.js +++ b/scripts/check-tokens-prices.js @@ -21,7 +21,6 @@ async function main () { const OffchainOracle = await ethers.getContractFactory('OffchainOracle'); const offchainOracleInDeployments = require(`../deployments/${networkName}/OffchainOracle.json`); const deployedOffchainOracle = OffchainOracle.attach(offchainOracleInDeployments.address); - const isDeployedOracleWithFilter = !!offchainOracleInDeployments.devdoc.methods['getRateToEthWithThreshold(address,bool,uint256)']; const weth = offchainOracleInDeployments.args[4]; const connectors = await deployedOffchainOracle.connectors(); @@ -68,10 +67,7 @@ async function main () { } catch {} clearAndPrint(`Progress: ${i} / ${tokenlist.length}`); - const getRateToEthDeployedOracle = isDeployedOracleWithFilter - ? () => deployedOffchainOracle.getRateToEthWithThreshold(token.address, true, thresholdFilter) - : () => deployedOffchainOracle.getRateToEth(token.address, true); - const deployedOraclePrice = await getRateToEthDeployedOracle(); + const deployedOraclePrice = await deployedOffchainOracle.getRateToEthWithThreshold(token.address, true, thresholdFilter); const currentImplPrice = await offchainOracle.getRateToEthWithThreshold(token.address, true, thresholdFilter); const currentImplPriceUsd = parseFloat(usdPrice(currentImplPrice / 10 ** (18 - tokenDecimals))).toFixed(2);