diff --git a/contracts/token/oracles/OracleAggregator.sol b/contracts/token/oracles/OracleAggregator.sol index ff636a9..5eabbc4 100644 --- a/contracts/token/oracles/OracleAggregator.sol +++ b/contracts/token/oracles/OracleAggregator.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.23; import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./IOracleAggregator.sol"; import "./FeedInterface.sol"; @@ -14,7 +15,6 @@ abstract contract OracleAggregator is Ownable, IOracleAggregator { function setTokenOracle( address token, - uint8 tokenDecimals, address tokenOracle, address nativeOracle, bool isDerivedFeed, @@ -28,7 +28,7 @@ abstract contract OracleAggregator is Ownable, IOracleAggregator { if (decimals1 != decimals2) revert MismatchInBaseAndQuoteDecimals(); tokensInfo[token].tokenOracle = tokenOracle; tokensInfo[token].nativeOracle = nativeOracle; - tokensInfo[token].tokenDecimals = tokenDecimals; + tokensInfo[token].tokenDecimals = ERC20(token).decimals(); tokensInfo[token].isDerivedFeed = isDerivedFeed; tokensInfo[token].priceUpdateThreshold = priceUpdateThreshold; } diff --git a/scripts/token-paymaster-v2/deploy-token-paymaster-mumbai.ts b/scripts/token-paymaster-v2/deploy-token-paymaster-mumbai.ts index 8df0ea5..5df02f5 100644 --- a/scripts/token-paymaster-v2/deploy-token-paymaster-mumbai.ts +++ b/scripts/token-paymaster-v2/deploy-token-paymaster-mumbai.ts @@ -11,7 +11,6 @@ import { BiconomyTokenPaymaster__factory, Deployer, Deployer__factory, - ERC20__factory, } from "../../typechain-types"; import { mumbaiConfigInfoProd } from "../configs"; import { TokenConfig } from "../utils/Types"; @@ -127,7 +126,6 @@ async function getPredeployedDeployerContractInstance(): Promise { async function setTokenOracle( tokenPaymasterInstance: BiconomyTokenPaymaster, tokenAddress: string, - tokenDecimals: number, tokenOracle: string, nativeOracle: string, isDerivedFeed: boolean, @@ -136,7 +134,6 @@ async function setTokenOracle( // Connect as the owner of the token paymaster const tx = await tokenPaymasterInstance.setTokenOracle( tokenAddress, - tokenDecimals, tokenOracle, nativeOracle, isDerivedFeed, @@ -173,11 +170,6 @@ async function getTokenPaymasterContractInstance( } } -async function getERC20TokenInstance(tokenAddress: string) { - const [signer] = await ethers.getSigners(); - return ERC20__factory.connect(tokenAddress, signer); -} - async function main() { const accounts = await ethers.getSigners(); const earlyOwner = await accounts[0].getAddress(); @@ -224,19 +216,13 @@ async function main() { priceUpdateThreshold = 172800; // 2 days default } - let tokenDecimals = 18; - - if (address) { - const tokenInstance = await getERC20TokenInstance(address); - tokenDecimals = await tokenInstance.decimals(); - } else { + if (!address) { throw new Error("token address can not be undefined"); } if (tokenPaymasterInstance) { await setTokenOracle( tokenPaymasterInstance, address, - tokenDecimals, nativeOracleAddress, tokenOracleAddress, derivedFeed, diff --git a/test/bundler-integration/token-paymaster/biconomy-token-paymaster-specs.ts b/test/bundler-integration/token-paymaster/biconomy-token-paymaster-specs.ts index db8fab0..811cf21 100644 --- a/test/bundler-integration/token-paymaster/biconomy-token-paymaster-specs.ts +++ b/test/bundler-integration/token-paymaster/biconomy-token-paymaster-specs.ts @@ -151,7 +151,6 @@ describe("Biconomy Token Paymaster (with Bundler)", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/bundler-integration/token-paymaster/btpm-undeployed-wallet.ts b/test/bundler-integration/token-paymaster/btpm-undeployed-wallet.ts index 5ff557c..5fbd2cb 100644 --- a/test/bundler-integration/token-paymaster/btpm-undeployed-wallet.ts +++ b/test/bundler-integration/token-paymaster/btpm-undeployed-wallet.ts @@ -153,7 +153,6 @@ describe("Biconomy Token Paymaster (with Bundler)", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/bundler-integration/token-paymaster/oracle-aggregator-specs.ts b/test/bundler-integration/token-paymaster/oracle-aggregator-specs.ts index 28fe465..55683df 100644 --- a/test/bundler-integration/token-paymaster/oracle-aggregator-specs.ts +++ b/test/bundler-integration/token-paymaster/oracle-aggregator-specs.ts @@ -139,7 +139,6 @@ describe("Biconomy Token Paymaster (With Bundler)", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/foundry/token-paymaster/TokenPaymaster.t.sol b/test/foundry/token-paymaster/TokenPaymaster.t.sol index eba71aa..34d6e0a 100644 --- a/test/foundry/token-paymaster/TokenPaymaster.t.sol +++ b/test/foundry/token-paymaster/TokenPaymaster.t.sol @@ -84,7 +84,7 @@ contract TokenPaymasterTest is SATestBase { vm.startPrank(alice.addr); // could also make a .call using selector and handle success // append 2 days price threshold - _btpm.setTokenOracle(address(usdc), usdc.decimals(), address(tokenOracle), address(nativeOracle), true, 172800); + _btpm.setTokenOracle(address(usdc), address(tokenOracle), address(nativeOracle), true, 172800); vm.stopPrank(); uint256 priceToLog = _btpm.getTokenValueOfOneNativeToken((address(usdc))); diff --git a/test/foundry/token-paymaster/TokenPaymasterMumbai.t.sol b/test/foundry/token-paymaster/TokenPaymasterMumbai.t.sol index b406369..154eabd 100644 --- a/test/foundry/token-paymaster/TokenPaymasterMumbai.t.sol +++ b/test/foundry/token-paymaster/TokenPaymasterMumbai.t.sol @@ -68,14 +68,12 @@ contract TokenPaymasterMumbaiTest is SATestBase { vm.startPrank(alice.addr); // could also make a .call using selector and handle success _btpm.setTokenOracle( - address(usdc), ERC20(address(usdc)).decimals(), address(tokenOracle), address(nativeOracle), true, 172800 + address(usdc), address(tokenOracle), address(nativeOracle), true, 172800 ); vm.stopPrank(); uint256 priceToLog = _btpm.getTokenValueOfOneNativeToken((address(usdc))); - // console2.log(priceToLog); - - address accountAddress = address(sa); + console2.log(priceToLog); vm.startPrank(charlie.addr); entryPoint.depositTo{value: 2 ether}(address(_btpm)); diff --git a/test/token-paymaster/biconomy-token-paymaster-specs.ts b/test/token-paymaster/biconomy-token-paymaster-specs.ts index ed06b78..21580df 100644 --- a/test/token-paymaster/biconomy-token-paymaster-specs.ts +++ b/test/token-paymaster/biconomy-token-paymaster-specs.ts @@ -147,7 +147,6 @@ describe("Biconomy Token Paymaster", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/token-paymaster/btpm-coverage-specs.ts b/test/token-paymaster/btpm-coverage-specs.ts index 46e8e78..bf52a9f 100644 --- a/test/token-paymaster/btpm-coverage-specs.ts +++ b/test/token-paymaster/btpm-coverage-specs.ts @@ -148,7 +148,6 @@ describe("Biconomy Token Paymaster", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/token-paymaster/btpm-undeployed-wallet.ts b/test/token-paymaster/btpm-undeployed-wallet.ts index 2b9d473..076fa6e 100644 --- a/test/token-paymaster/btpm-undeployed-wallet.ts +++ b/test/token-paymaster/btpm-undeployed-wallet.ts @@ -157,7 +157,6 @@ describe("Biconomy Token Paymaster", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, diff --git a/test/token-paymaster/oracle-aggregator-specs.ts b/test/token-paymaster/oracle-aggregator-specs.ts index ae4a4dc..5af9f20 100644 --- a/test/token-paymaster/oracle-aggregator-specs.ts +++ b/test/token-paymaster/oracle-aggregator-specs.ts @@ -147,7 +147,6 @@ describe("Biconomy Token Paymaster", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), tokenOracle.address, nativeOracle.address, true, @@ -338,7 +337,6 @@ describe("Biconomy Token Paymaster", function () { await sampleTokenPaymaster.setTokenOracle( token.address, - await token.decimals(), staleFeed.address, nativeOracle.address, true,