From 028e791d3da16680d3fae06c1e330fbedc3621d0 Mon Sep 17 00:00:00 2001 From: livingrockrises <90545960+livingrockrises@users.noreply.github.com> Date: Tue, 9 Apr 2024 03:45:55 +0530 Subject: [PATCH] new chain integrations --- .../test/helpers/MockChainlinkAggregator.sol | 113 ------------------ hardhat.config.ts | 59 +++++++++ lib/openzeppelin-contracts | 1 + package.json | 5 +- scripts/1-deploy-token-paymaster.ts | 9 ++ scripts/2-deploy-oracle-aggregator.ts | 4 + scripts/utils/index.ts | 3 +- yarn.lock | 28 ++++- 8 files changed, 101 insertions(+), 121 deletions(-) delete mode 100644 contracts/test/helpers/MockChainlinkAggregator.sol create mode 160000 lib/openzeppelin-contracts diff --git a/contracts/test/helpers/MockChainlinkAggregator.sol b/contracts/test/helpers/MockChainlinkAggregator.sol deleted file mode 100644 index 323b5b6..0000000 --- a/contracts/test/helpers/MockChainlinkAggregator.sol +++ /dev/null @@ -1,113 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.17; - -import "@openzeppelin/contracts/access/Ownable.sol"; -import "../../token/oracles/IOracleAggregator.sol"; -import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; -import "hardhat/console.sol"; - -/** - * @title Mock Oracle Aggregator contract - * @notice DO NOT use this in any environment for use - */ -contract MockChainlinkOracleAggregator is Ownable, IOracleAggregator { - struct TokenInfo { - /* Number of decimals represents the precision of the price returned by the feed. For example, - a price of $100.50 might be represented as 100500000000 in the contract, with 9 decimal places - of precision */ - uint8 decimals; - bool dataSigned; - address callAddress; - bytes callData; - } - - mapping(address => TokenInfo) internal tokensInfo; - - constructor(address _owner) { - _transferOwnership(_owner); - } - - /** - * @dev set price feed information for specific feed - * @param callAddress price feed / derived price feed address to call - * @param decimals decimals (precision) defined in this price feed - * @param callData function selector which will be used to query price data - * @param signed if the feed may return result as signed integrer - */ - function setTokenOracle( - address token, - address callAddress, - uint8 decimals, - bytes calldata callData, - bool signed - ) external onlyOwner { - require( - callAddress != address(0), - "ChainlinkOracleAggregator:: call address can not be zero" - ); - require( - token != address(0), - "ChainlinkOracleAggregator:: token address can not be zero" - ); - tokensInfo[token].callAddress = callAddress; - tokensInfo[token].decimals = decimals; - tokensInfo[token].callData = callData; - tokensInfo[token].dataSigned = signed; - } - - /** - * @dev query deciamls used by set feed for specific token - * @param token ERC20 token address - */ - function getTokenOracleDecimals( - address token - ) external view returns (uint8 _tokenOracleDecimals) { - _tokenOracleDecimals = tokensInfo[token].decimals; - } - - /** - * @dev query price feed - * @param token ERC20 token address - */ - function getTokenPrice( - address token - ) external view returns (uint256 tokenPrice) { - // usually token / native (depends on price feed) - tokenPrice = _getTokenPrice(token); - } - - /** - * @dev exchangeRate : each aggregator implements this method based on how it sources the quote/price - * @notice here it is token / native sourced from chainlink so in order to get defined exchangeRate we inverse the feed - * @param token ERC20 token address - */ - function getTokenValueOfOneNativeToken( - address token - ) external view virtual returns (uint256 exchangeRate) { - // we'd actually want eth / token - uint256 tokenPriceUnadjusted = _getTokenPrice(token); - uint8 _tokenOracleDecimals = tokensInfo[token].decimals; - exchangeRate = - ((10 ** _tokenOracleDecimals) * - (10 ** IERC20Metadata(token).decimals())) / - tokenPriceUnadjusted; - } - - // Making explicit revert or make use of stale price feed which reverts - // like done in below function and the test case - - function _getTokenPrice( - address token - ) internal view returns (uint256 tokenPriceUnadjusted) { - (bool success, bytes memory ret) = tokensInfo[token] - .callAddress - .staticcall(tokensInfo[token].callData); - - require(success, "ChainlinkOracleAggregator:: query failed"); - if (tokensInfo[token].dataSigned) { - tokenPriceUnadjusted = uint256(abi.decode(ret, (int256))); - } else { - tokenPriceUnadjusted = abi.decode(ret, (uint256)); - } - } -} diff --git a/hardhat.config.ts b/hardhat.config.ts index 82b0711..bdf8d4e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -7,6 +7,7 @@ import "@typechain/hardhat"; import "hardhat-gas-reporter"; import "solidity-coverage"; import "@nomiclabs/hardhat-etherscan"; +// import "@nomicfoundation/hardhat-verify"; const walletUtils = require("./walletUtils"); @@ -271,6 +272,28 @@ const config: HardhatUserConfig = { chainId: 245022926, // gasPrice: 6400000 }, + blastMainnet: { + url: process.env.BLAST_MAINNET_URL || "", + accounts: hardhatAccounts, + chainId: 81457, + }, + degenChain: { + url: process.env.DEGEN_CHAIN_MAINNET || "https://rpc.degen.tips", + accounts: hardhatAccounts, + chainId: 666666666, + }, + oliveTestnet: { + url: + process.env.OLIVE_TESTNET || + "https://olive-network-testnet.rpc.caldera.xyz/http", + accounts: hardhatAccounts, + chainId: 8101902, + }, + cardonaTestnet: { + url: process.env.OLIVE_TESTNET || "https://rpc.cardona.zkevm-rpc.com", + accounts: hardhatAccounts, + chainId: 2442, + }, opBNBMainnet: { url: process.env.OP_BNB_MAINNET_URL || "", accounts: hardhatAccounts, @@ -327,6 +350,10 @@ const config: HardhatUserConfig = { opBNBMainnet: process.env.OP_BNB_API_KEY || "", mantleTestnet: "PLACEHOLDER_STRING", mantleMainnet: "PLACEHOLDER_STRING", + blastMainnet: process.env.BLAST_API_KEY || "", + degenChain: "PLACEHOLDER_STRING", + oliveTestnet: "PLACEHOLDER_STRING", + cardonaTestnet: "PLACEHOLDER_STRING", comboTestnet: process.env.COMBO_API_KEY || "", zkEVMMainnet: process.env.ZKEVM_API_KEY || "", zkEVMGoerli: process.env.ZKEVM_API_KEY || "", @@ -341,6 +368,38 @@ const config: HardhatUserConfig = { browserURL: "https://goerli.lineascan.build", }, }, + { + network: "blastMainnet", + chainId: 81457, + urls: { + apiURL: "https://api.blastscan.io/api", + browserURL: "https://blastscan.io/", + }, + }, + { + network: "degenChain", + chainId: 666666666, + urls: { + apiURL: "https://explorer.degen.tips/api", + browserURL: "https://explorer.degen.tips", + }, + }, + { + network: "oliveTestnet", + chainId: 8101902, + urls: { + apiURL: "https://olive-network-testnet.explorer.caldera.xyz/api", + browserURL: "https://olive-network-testnet.explorer.caldera.xyz/", + }, + }, + { + network: "cardonaTestnet", + chainId: 2442, + urls: { + apiURL: "https://cardona-zkevm.polygonscan.com/api", + browserURL: "https://cardona-zkevm.polygonscan.com/", + }, + }, { network: "linea-mainnet", chainId: 59144, diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts new file mode 160000 index 0000000..fd81a96 --- /dev/null +++ b/lib/openzeppelin-contracts @@ -0,0 +1 @@ +Subproject commit fd81a96f01cc42ef1c9a5399364968d0e07e9e90 diff --git a/package.json b/package.json index c1a39e3..e5f350b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nomicfoundation/hardhat-network-helpers": "^1.0.8", "@nomicfoundation/hardhat-toolbox": "^2.0.2", "@nomiclabs/hardhat-ethers": "^2.2.3", - "@nomiclabs/hardhat-etherscan": "^3.1.7", + "@nomiclabs/hardhat-etherscan": "^3.1.8", "@nomiclabs/hardhat-waffle": "^2.0.1", "@typechain/ethers-v5": "^10.2.0", "@typechain/hardhat": "^6.1.5", @@ -94,6 +94,7 @@ "@ethersproject/abstract-signer": "^5.6.2", "@ethersproject/constants": "^5.6.1", "@mean-finance/uniswap-v3-oracle": "^1.0.3", + "@nomicfoundation/hardhat-verify": "^2.0.5", "@openzeppelin/contracts": "4.8.1", "@openzeppelin/contracts-upgradeable": "4.8.1", "@pimlico/erc20-paymaster": "^0.0.1", @@ -112,4 +113,4 @@ "solidity-bytes-utils": "^0.8.0", "source-map-support": "^0.5.19" } -} \ No newline at end of file +} diff --git a/scripts/1-deploy-token-paymaster.ts b/scripts/1-deploy-token-paymaster.ts index 77db8bf..fbdd571 100644 --- a/scripts/1-deploy-token-paymaster.ts +++ b/scripts/1-deploy-token-paymaster.ts @@ -74,6 +74,15 @@ async function deployTokenPaymasterContract( tokenPaymasterComputedAddr ); } + + await run(`verify:verify`, { + address: tokenPaymasterComputedAddr, + constructorArguments: [ + earlyOwnerAddress, + entryPointAddress, + verifyingSigner, + ], + }); return tokenPaymasterComputedAddr; } catch (err) { console.log(err); diff --git a/scripts/2-deploy-oracle-aggregator.ts b/scripts/2-deploy-oracle-aggregator.ts index 1f0a83e..f6e6ccb 100644 --- a/scripts/2-deploy-oracle-aggregator.ts +++ b/scripts/2-deploy-oracle-aggregator.ts @@ -67,6 +67,10 @@ async function deployChainlinkOracleAggregatorContract( oracleAggregatorComputedAddr ); } + await run(`verify:verify`, { + address: oracleAggregatorComputedAddr, + constructorArguments: [earlyOwnerAddress], + }); return oracleAggregatorComputedAddr; } catch (err) { console.log(err); diff --git a/scripts/utils/index.ts b/scripts/utils/index.ts index 629be36..420e974 100644 --- a/scripts/utils/index.ts +++ b/scripts/utils/index.ts @@ -271,8 +271,7 @@ export const deployContract = async ( // TODO // Review gas price const { hash, wait } = await deployerInstance.deploy(salt, contractByteCode, { - maxFeePerGas: 3e9, - maxPriorityFeePerGas: 2e9, + gasPrice: 2e9, }); console.log(`Submitted transaction ${hash} for deployment`); diff --git a/yarn.lock b/yarn.lock index cfe90ff..7eab89d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1174,6 +1174,21 @@ resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-toolbox/-/hardhat-toolbox-2.0.2.tgz#ec95f23b53cb4e71a1a7091380fa223aad18f156" integrity sha512-vnN1AzxbvpSx9pfdRHbUzTRIXpMLPXnUlkW855VaDk6N1pwRaQ2gNzEmFAABk4lWf11E00PKwFd/q27HuwYrYg== +"@nomicfoundation/hardhat-verify@^2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.5.tgz#dcc2cb5e5c55a39704c7d492436f80f05a4ca5a3" + integrity sha512-Tg4zu8RkWpyADSFIgF4FlJIUEI4VkxcvELsmbJn2OokbvH2SnUrqKmw0BBfDrtvP0hhmx8wsnrRKP5DV/oTyTA== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^8.1.0" + chalk "^2.4.2" + debug "^4.1.1" + lodash.clonedeep "^4.5.0" + semver "^6.3.0" + table "^6.8.0" + undici "^5.14.0" + "@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz#4c858096b1c17fe58a474fe81b46815f93645c15" @@ -1245,10 +1260,10 @@ resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0" integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg== -"@nomiclabs/hardhat-etherscan@^3.1.7": - version "3.1.7" - resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.1.7.tgz#72e3d5bd5d0ceb695e097a7f6f5ff6fcbf062b9a" - integrity sha512-tZ3TvSgpvsQ6B6OGmo1/Au6u8BrAkvs1mIC/eURA3xgIfznUZBhmpne8hv7BXUzw9xNL3fXdpOYgOQlVMTcoHQ== +"@nomiclabs/hardhat-etherscan@^3.1.8": + version "3.1.8" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.1.8.tgz#3c12ee90b3733e0775e05111146ef9418d4f5a38" + integrity sha512-v5F6IzQhrsjHh6kQz4uNrym49brK9K5bYCq2zQZ729RYRaifI9hHbtmK+KkIVevfhut7huQFEQ77JLRMAzWYjQ== dependencies: "@ethersproject/abi" "^5.1.2" "@ethersproject/address" "^5.0.2" @@ -6153,6 +6168,11 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== + lodash.debounce@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"