From 3cdf76b4cd0c37bfcbb8f9cf160c7e206fbf2e27 Mon Sep 17 00:00:00 2001 From: lazaralex98 Date: Fri, 25 Feb 2022 18:31:37 +0200 Subject: [PATCH] mumbai doesn't have certain contracts so I created a polygon fork --- .env.example | 8 +++++--- contracts/OffsetHelperStorage.sol | 14 +++++++------- hardhat.config.ts | 17 +++++++++++++++-- test/index.ts | 5 ++--- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.env.example b/.env.example index 861d3b1..25d2e80 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ -ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1 -ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/ -PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 +MUMBAI_URL=https://polygon-mumbai.g.alchemy.com/v2/abc123abc123abc123abc123abc123abc123abc +MUMBAI_PRIVATE_KEY=abc123abc123abc123abc123abc123abc123abc + +POLYGON_URL=https://polygon-mainnet.g.alchemy.com/v2/abc123abc123abc123abc123abc123abc123abc +POLYGON_PRIVATE_KEY=abc123abc123abc123abc123abc123abc123abc \ No newline at end of file diff --git a/contracts/OffsetHelperStorage.sol b/contracts/OffsetHelperStorage.sol index 8d05a85..c8e8a01 100644 --- a/contracts/OffsetHelperStorage.sol +++ b/contracts/OffsetHelperStorage.sol @@ -11,30 +11,30 @@ import "./CO2KEN_contracts/IToucanContractRegistry.sol"; contract OffsetHelperStorage is OwnableUpgradeable { mapping(string => address) public eligibleTokenAddresses; address public contractRegistryAddress = - 0x6739D490670B2710dc7E79bB12E455DE33EE1cb6; + 0x263fA1c180889b3a3f46330F32a4a23287E99FC9; address public sushiRouterAddress = - 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; // this is polygon, not mumbai + 0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506; constructor() { eligibleTokenAddresses[ "BCT" - ] = 0xf2438A14f668b1bbA53408346288f3d7C71c10a1; + ] = 0x2F800Db0fdb5223b3C3f354886d907A671414A7F; eligibleTokenAddresses[ "NCT" - ] = 0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E; + ] = 0xD838290e877E0188a4A44700463419ED96c16107; eligibleTokenAddresses[ "USDC" - ] = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; // this is polygon, not mumbai + ] = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; eligibleTokenAddresses[ "WETH" - ] = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619; // this is polygon, not mumbai + ] = 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619; eligibleTokenAddresses[ "WMATIC" - ] = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // this is polygon, not mumbai + ] = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; } // @description you can use this to change or add eligible tokens and their addresses if needed diff --git a/hardhat.config.ts b/hardhat.config.ts index 453e037..1941d1c 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -23,7 +23,7 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { // Go to https://hardhat.org/config/ to learn more const config: HardhatUserConfig = { - defaultNetwork: "hardhat", + defaultNetwork: "polygonFork", solidity: { version: "0.8.4", settings: { @@ -34,6 +34,13 @@ const config: HardhatUserConfig = { }, }, networks: { + polygon: { + url: process.env.POLYGON_URL || "", + accounts: + process.env.POLYGON_PRIVATE_KEY !== undefined + ? [process.env.POLYGON_PRIVATE_KEY] + : [], + }, mumbai: { url: process.env.MUMBAI_URL || "", accounts: @@ -41,7 +48,13 @@ const config: HardhatUserConfig = { ? [process.env.MUMBAI_PRIVATE_KEY] : [], }, - hardhat: { + polygonFork: { + forking: { + url: process.env.POLYGON_URL || "", + blockNumber: 25276448, + }, + }, + mumbaiFork: { forking: { url: process.env.MUMBAI_URL || "", blockNumber: 25276448, diff --git a/test/index.ts b/test/index.ts index 0390c29..f2808f7 100644 --- a/test/index.ts +++ b/test/index.ts @@ -14,9 +14,8 @@ import { const addresses: any = { myAddress: "0x721F6f7A29b99CbdE1F18C4AA7D7AEb31eb2923B", - tco2Address: "0xa5831eb637dff307395b5183c86B04c69C518681", - bctAddress: "0xf2438A14f668b1bbA53408346288f3d7C71c10a1", - nctAddress: "0x7beCBA11618Ca63Ead5605DE235f6dD3b25c530E", + bctAddress: "0x2F800Db0fdb5223b3C3f354886d907A671414A7F", + nctAddress: "0xD838290e877E0188a4A44700463419ED96c16107", usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", wethAddress: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", wmaticAddress: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",