From 6ff7f8ba34bdbacf4dae6b864d74520456cc8145 Mon Sep 17 00:00:00 2001 From: Memo Khoury Date: Thu, 14 Oct 2021 23:26:26 -0400 Subject: [PATCH 1/3] added poly and mainnet diamond extensions --- contracts/shared/interfaces/IMainnetDiamond.sol | 14 ++++++++++++++ contracts/shared/interfaces/IPolygonDiamond.sol | 6 ++++++ contracts/shared/interfaces/ITellerDiamond.sol | 4 ---- deploy/protocol.ts | 17 +++++++++++++++-- test/integration/poly-bridge.test.ts | 7 ++++++- 5 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 contracts/shared/interfaces/IMainnetDiamond.sol create mode 100644 contracts/shared/interfaces/IPolygonDiamond.sol diff --git a/contracts/shared/interfaces/IMainnetDiamond.sol b/contracts/shared/interfaces/IMainnetDiamond.sol new file mode 100644 index 000000000..0849d7fac --- /dev/null +++ b/contracts/shared/interfaces/IMainnetDiamond.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { ITellerDiamond } from "./ITellerDiamond.sol"; +import { MainnetNFTFacet } from "../../nft/mainnet/MainnetNFTFacet.sol"; +import { + NFTMainnetBridgingToPolygonFacet +} from "../../nft/mainnet/NFTMainnetBridgingToPolygonFacet.sol"; + +abstract contract IMainnetDiamond is + ITellerDiamond, + MainnetNFTFacet, + NFTMainnetBridgingToPolygonFacet +{} diff --git a/contracts/shared/interfaces/IPolygonDiamond.sol b/contracts/shared/interfaces/IPolygonDiamond.sol new file mode 100644 index 000000000..5ce327646 --- /dev/null +++ b/contracts/shared/interfaces/IPolygonDiamond.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { ITellerDiamond } from "./ITellerDiamond.sol"; + +abstract contract IPolyDiamond is ITellerDiamond {} diff --git a/contracts/shared/interfaces/ITellerDiamond.sol b/contracts/shared/interfaces/ITellerDiamond.sol index 07a61887e..696835476 100644 --- a/contracts/shared/interfaces/ITellerDiamond.sol +++ b/contracts/shared/interfaces/ITellerDiamond.sol @@ -29,9 +29,6 @@ import { NFTFacet } from "../../nft/NFTFacet.sol"; import { MainnetNFTInterestFacet } from "../../nft/mainnet/MainnetNFTInterestFacet.sol"; -import { - NFTMainnetBridgingToPolygonFacet -} from "../../nft/mainnet/NFTMainnetBridgingToPolygonFacet.sol"; import { CollateralFacet } from "../../market/CollateralFacet.sol"; import { CompoundFacet } from "../../escrow/dapps/CompoundFacet.sol"; import { @@ -58,7 +55,6 @@ abstract contract ITellerDiamond is SignersFacet, NFTFacet, MainnetNFTInterestFacet, - NFTMainnetBridgingToPolygonFacet, CompoundFacet, CompoundClaimCompFacet, AaveFacet, diff --git a/deploy/protocol.ts b/deploy/protocol.ts index e2ec384c9..1e60d7a81 100644 --- a/deploy/protocol.ts +++ b/deploy/protocol.ts @@ -5,6 +5,7 @@ import { getDappAddresses, getNativeToken, isEtheremNetwork } from '../config' import { ICollateralEscrow, ILoansEscrow, + IMainnetDiamond, ITellerDiamond, ITToken, UpgradeableBeaconFactory, @@ -222,15 +223,27 @@ const deployProtocol: DeployFunction = async (hre) => { owner: deployer, execute, } + + const mainnetDiamondArgs: DeployDiamondArgs = { + hre, + name: 'MainnetDiamond', + facets, + owner: deployer, + execute, + } const diamond = await deployDiamond(tellerDiamondArgs) + const mainnetDiamond = await deployDiamond( + mainnetDiamondArgs + ) await addAuthorizedAddresses(hre, diamond) + await addAuthorizedAddresses(hre, mainnetDiamond) const ERC1155_PREDICATE = `0x0B9020d4E32990D67559b1317c7BF0C15D6EB88f` // set approval for all tokens to be transfered by ERC1155 Predicate if ( isEtheremNetwork(network, true) && - nftV2.isApprovedForAll(diamond.address, ERC1155_PREDICATE) + nftV2.isApprovedForAll(mainnetDiamond.address, ERC1155_PREDICATE) ) { - await diamond.initNFTBridge() + await mainnetDiamond.initNFTBridge() } } diff --git a/test/integration/poly-bridge.test.ts b/test/integration/poly-bridge.test.ts index 165f9b6f4..782e3e911 100644 --- a/test/integration/poly-bridge.test.ts +++ b/test/integration/poly-bridge.test.ts @@ -13,6 +13,8 @@ import hre, { import { getMarkets, isEtheremNetwork } from '../../config' import { Market } from '../../types/custom/config-types' import { + IMainnetDiamond, + IPolyDiamond, ITellerDiamond, MainnetNFTFacet, MainnetNFTFacetMock, @@ -42,7 +44,10 @@ if (isEtheremNetwork(hre.network)) { const { log } = hre // define needed variablez let deployer: Signer - let diamond: ITellerDiamond & MainnetNFTFacet & MainnetNFTFacetMock + let diamond: ITellerDiamond & + IMainnetDiamond & + IPolyDiamond & + MainnetNFTFacetMock let nftV1: TellerNFT let nftV2: TellerNFTV2 & MainnetTellerNFT let tellerDictionary: TellerNFTDictionary From 219d9941d81df6653e440f92c3a85ead163e84e5 Mon Sep 17 00:00:00 2001 From: Memo Khoury Date: Fri, 15 Oct 2021 11:12:32 -0400 Subject: [PATCH 2/3] added poly deploy --- deploy/protocol.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/deploy/protocol.ts b/deploy/protocol.ts index 1e60d7a81..8a9e9c443 100644 --- a/deploy/protocol.ts +++ b/deploy/protocol.ts @@ -6,6 +6,7 @@ import { ICollateralEscrow, ILoansEscrow, IMainnetDiamond, + IPolyDiamond, ITellerDiamond, ITToken, UpgradeableBeaconFactory, @@ -231,12 +232,24 @@ const deployProtocol: DeployFunction = async (hre) => { owner: deployer, execute, } + + const polygonDiamondArgs: DeployDiamondArgs = { + hre, + name: 'PolyDiamond', + facets, + owner: deployer, + execute, + } + const diamond = await deployDiamond(tellerDiamondArgs) const mainnetDiamond = await deployDiamond( mainnetDiamondArgs ) + const polyDiamond = await deployDiamond(polygonDiamondArgs) + await addAuthorizedAddresses(hre, diamond) await addAuthorizedAddresses(hre, mainnetDiamond) + await addAuthorizedAddresses(hre, polyDiamond) const ERC1155_PREDICATE = `0x0B9020d4E32990D67559b1317c7BF0C15D6EB88f` // set approval for all tokens to be transfered by ERC1155 Predicate if ( From a224e76fc4d1ecb72ae246885d2e7cccdc8b301c Mon Sep 17 00:00:00 2001 From: Memo Khoury Date: Fri, 15 Oct 2021 16:24:31 -0400 Subject: [PATCH 3/3] remove deployments to polydiamond and mainnetdiamond --- deploy/protocol.ts | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/deploy/protocol.ts b/deploy/protocol.ts index 8a9e9c443..b9a98bc19 100644 --- a/deploy/protocol.ts +++ b/deploy/protocol.ts @@ -225,38 +225,15 @@ const deployProtocol: DeployFunction = async (hre) => { execute, } - const mainnetDiamondArgs: DeployDiamondArgs = { - hre, - name: 'MainnetDiamond', - facets, - owner: deployer, - execute, - } - - const polygonDiamondArgs: DeployDiamondArgs = { - hre, - name: 'PolyDiamond', - facets, - owner: deployer, - execute, - } - const diamond = await deployDiamond(tellerDiamondArgs) - const mainnetDiamond = await deployDiamond( - mainnetDiamondArgs - ) - const polyDiamond = await deployDiamond(polygonDiamondArgs) - await addAuthorizedAddresses(hre, diamond) - await addAuthorizedAddresses(hre, mainnetDiamond) - await addAuthorizedAddresses(hre, polyDiamond) const ERC1155_PREDICATE = `0x0B9020d4E32990D67559b1317c7BF0C15D6EB88f` // set approval for all tokens to be transfered by ERC1155 Predicate if ( isEtheremNetwork(network, true) && - nftV2.isApprovedForAll(mainnetDiamond.address, ERC1155_PREDICATE) + nftV2.isApprovedForAll(diamond.address, ERC1155_PREDICATE) ) { - await mainnetDiamond.initNFTBridge() + await (diamond as IMainnetDiamond).initNFTBridge() } }