From 5919e8b221445c1e1d956554f2b6e138ddd0af1f Mon Sep 17 00:00:00 2001 From: Carter Carlson Date: Tue, 20 Sep 2022 16:47:50 -0700 Subject: [PATCH] refactor: mainnet cleanup --- contracts/Diamond.sol | 21 +- contracts/DiamondInit.sol | 6 +- contracts/facets/CurveFacet.sol | 1 + contracts/facets/DiamondCutFacet.sol | 11 +- contracts/facets/FeesFacet.sol | 2 +- contracts/facets/FoundryFacet.sol | 14 +- contracts/facets/HubFacet.sol | 25 +- contracts/facets/MeTokenRegistryFacet.sol | 50 +- contracts/facets/OwnershipFacet.sol | 29 +- contracts/interfaces/ICurveFacet.sol | 3 +- contracts/interfaces/IDiamondCut.sol | 2 +- contracts/interfaces/IFeesFacet.sol | 5 +- contracts/interfaces/IFoundryFacet.sol | 11 +- contracts/interfaces/IHubFacet.sol | 34 +- contracts/interfaces/IMeToken.sol | 2 +- .../interfaces/IMeTokenRegistryFacet.sol | 49 +- contracts/interfaces/IMigrationRegistry.sol | 2 +- contracts/interfaces/IOwnershipFacet.sol | 60 + contracts/interfaces/IVaultRegistry.sol | 2 +- contracts/libs/LibAppStorage.sol | 10 - contracts/libs/LibCurve.sol | 2 - contracts/libs/LibDiamond.sol | 22 +- contracts/libs/LibFoundry.sol | 39 +- contracts/libs/LibHub.sol | 1 + contracts/libs/LibMeToken.sol | 1 - contracts/mocks/LibAppStorageMock.sol | 10 - contracts/registries/MigrationRegistry.sol | 9 +- contracts/registries/VaultRegistry.sol | 6 +- scripts/MeTokensDiamond.json | 2030 +++++++++++++++++ scripts/deploy.ts | 5 +- scripts/temp.ts | 16 + tasks/deployUpgrade.ts | 6 +- test/contracts/facets/OwnershipFacet.ts | 41 - test/integration/Diamond/Upgrade.ts | 8 +- test/integration/Hub/UpdateCurve.ts | 2 +- test/utils/hubSetup.ts | 5 +- 36 files changed, 2351 insertions(+), 191 deletions(-) create mode 100644 contracts/interfaces/IOwnershipFacet.sol create mode 100644 scripts/MeTokensDiamond.json create mode 100644 scripts/temp.ts diff --git a/contracts/Diamond.sol b/contracts/Diamond.sol index eca95c03..6f31f4fd 100644 --- a/contracts/Diamond.sol +++ b/contracts/Diamond.sol @@ -1,28 +1,25 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; -/******************************************************************************\ -* Author: Nick Mudge (https://twitter.com/mudgen) -* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 -* -* Implementation of a diamond. -/******************************************************************************/ - -import {IDiamondCut} from "./interfaces/IDiamondCut.sol"; +import {IDiamondCutFacet} from "./interfaces/IDiamondCutFacet.sol"; import {LibAppStorage} from "./libs/LibAppStorage.sol"; import {LibDiamond} from "./libs/LibDiamond.sol"; +/// @title MeTokens protocol Diamond +/// @author Nick Mudge (https://twitter.com/mudgen) +/// @notice The meTokens protocol core proxy contract. contract Diamond { constructor(address firstController, address diamondCutFacet) payable { LibAppStorage.initControllers(firstController); // Add the diamondCut external function from the diamondCutFacet - IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1); + IDiamondCutFacet.FacetCut[] + memory cut = new IDiamondCutFacet.FacetCut[](1); bytes4[] memory functionSelectors = new bytes4[](1); - functionSelectors[0] = IDiamondCut.diamondCut.selector; - cut[0] = IDiamondCut.FacetCut({ + functionSelectors[0] = IDiamondCutFacet.diamondCut.selector; + cut[0] = IDiamondCutFacet.FacetCut({ facetAddress: diamondCutFacet, - action: IDiamondCut.FacetCutAction.Add, + action: IDiamondCutFacet.FacetCutAction.Add, functionSelectors: functionSelectors }); LibDiamond.diamondCut(cut, address(0), ""); diff --git a/contracts/DiamondInit.sol b/contracts/DiamondInit.sol index 8dc856e5..d48d052d 100644 --- a/contracts/DiamondInit.sol +++ b/contracts/DiamondInit.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.9; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {IDiamondCut} from "./interfaces/IDiamondCut.sol"; +import {IDiamondCutFacet} from "./interfaces/IDiamondCutFacet.sol"; import {IDiamondLoupeFacet} from "./interfaces/IDiamondLoupeFacet.sol"; import {IMigrationRegistry} from "./interfaces/IMigrationRegistry.sol"; import {IVaultRegistry} from "./interfaces/IVaultRegistry.sol"; @@ -13,7 +13,7 @@ import {LibCurve} from "./libs/LibCurve.sol"; import {ABDKMathQuad} from "./utils/ABDKMathQuad.sol"; /// @title Diamond Init -/// @author Carter Carlson (@cartercarlson), @zgorizzo69 +/// @author Carter Carlson (@cartercarlson), @zgorizzo69, @mudgen /// @notice Contract to initialize state variables, similar to OZ's initialize() contract DiamondInit { using ABDKMathQuad for uint256; @@ -55,7 +55,7 @@ contract DiamondInit { LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); // Adding erc165 data - ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondCutFacet).interfaceId] = true; ds.supportedInterfaces[type(IDiamondLoupeFacet).interfaceId] = true; ds.supportedInterfaces[type(IERC165).interfaceId] = true; diff --git a/contracts/facets/CurveFacet.sol b/contracts/facets/CurveFacet.sol index b935ad57..3362c9a1 100644 --- a/contracts/facets/CurveFacet.sol +++ b/contracts/facets/CurveFacet.sol @@ -8,6 +8,7 @@ import {ICurveFacet} from "../interfaces/ICurveFacet.sol"; /// @title MeTokens Curve Facet /// @author @cartercarlson, @zgorizzo69, @cbobrobison, @parv3213 +/// @notice This contract provides direct views to the meTokens Protocol curve. contract CurveFacet is Modifiers, ICurveFacet { /// @inheritdoc ICurveFacet function viewMeTokensMinted( diff --git a/contracts/facets/DiamondCutFacet.sol b/contracts/facets/DiamondCutFacet.sol index bfe4d2f8..755df13d 100644 --- a/contracts/facets/DiamondCutFacet.sol +++ b/contracts/facets/DiamondCutFacet.sol @@ -6,17 +6,12 @@ pragma solidity 0.8.9; * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ -import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; +import {IDiamondCutFacet} from "../interfaces/IDiamondCutFacet.sol"; import {LibDiamond} from "../libs/LibDiamond.sol"; import {Modifiers} from "../libs/LibAppStorage.sol"; -contract DiamondCutFacet is IDiamondCut, Modifiers { - /// @notice Add/replace/remove any number of functions and optionally execute - /// a function with delegatecall - /// @param cut Contains the facet addresses and function selectors - /// @param init The address of the contract or facet to execute calldata - /// @param data A function call, including function selector and arguments - /// calldata is executed with delegatecall on init +contract DiamondCutFacet is IDiamondCutFacet, Modifiers { + /// @inheritdoc IDiamondCutFacet function diamondCut( FacetCut[] calldata cut, address init, diff --git a/contracts/facets/FeesFacet.sol b/contracts/facets/FeesFacet.sol index 44d57181..00177f0c 100644 --- a/contracts/facets/FeesFacet.sol +++ b/contracts/facets/FeesFacet.sol @@ -6,7 +6,7 @@ import {Modifiers} from "../libs/LibAppStorage.sol"; /// @title meTokens Fees Facet /// @author @cartercarlson, @parv3213 -/// @notice This contract defines the fee structure for meTokens protocol +/// @notice This contract defines the fee structure for meTokens Protocol contract FeesFacet is IFeesFacet, Modifiers { /// @inheritdoc IFeesFacet function setMintFee(uint256 rate) external override onlyFeesController { diff --git a/contracts/facets/FoundryFacet.sol b/contracts/facets/FoundryFacet.sol index a9782667..700d4b6d 100644 --- a/contracts/facets/FoundryFacet.sol +++ b/contracts/facets/FoundryFacet.sol @@ -11,15 +11,15 @@ import {IVault} from "../interfaces/IVault.sol"; /// @title meTokens Foundry Facet /// @author @cartercarlson, @parv3213 -/// @notice This contract manages all minting / burning for meTokens protocol +/// @notice This contract manages all minting / burning for meTokens Protocol contract FoundryFacet is IFoundryFacet, Modifiers { /// @inheritdoc IFoundryFacet function mint( address meToken, uint256 assetsDeposited, address recipient - ) external override { - LibFoundry.mint(meToken, assetsDeposited, recipient); + ) external override returns (uint256 meTokensMinted) { + meTokensMinted = LibFoundry.mint(meToken, assetsDeposited, recipient); } /// @inheritdoc IFoundryFacet @@ -31,8 +31,8 @@ contract FoundryFacet is IFoundryFacet, Modifiers { uint8 vSig, bytes32 rSig, bytes32 sSig - ) external override { - LibFoundry.mintWithPermit( + ) external override returns (uint256 meTokensMinted) { + meTokensMinted = LibFoundry.mintWithPermit( meToken, assetsDeposited, recipient, @@ -48,8 +48,8 @@ contract FoundryFacet is IFoundryFacet, Modifiers { address meToken, uint256 meTokensBurned, address recipient - ) external override { - LibFoundry.burn(meToken, meTokensBurned, recipient); + ) external override returns (uint256 assetsReturned) { + assetsReturned = LibFoundry.burn(meToken, meTokensBurned, recipient); } /// @inheritdoc IFoundryFacet diff --git a/contracts/facets/HubFacet.sol b/contracts/facets/HubFacet.sol index da7665b0..aaed7507 100644 --- a/contracts/facets/HubFacet.sol +++ b/contracts/facets/HubFacet.sol @@ -12,7 +12,7 @@ import {Modifiers} from "../libs/LibAppStorage.sol"; /// @title meTokens Hub Facet /// @author @cartercarlson, @zgorizzo69, @parv3213 -/// @notice This contract manages all hub configurations for meTokens protocol +/// @notice This contract manages all hub configurations for meTokens Protocol contract HubFacet is IHubFacet, Modifiers { /// @inheritdoc IHubFacet function register( @@ -198,6 +198,29 @@ contract HubFacet is IHubFacet, Modifiers { s.hubCooldown = cooldown; } + /// @inheritdoc IHubFacet + function getBasicHubInfo(uint256 id) + external + view + override + returns ( + uint256 refundRatio, + address owner, + address vault, + address asset, + bool updating, + bool active + ) + { + HubInfo storage hubInfo = s.hubs[id]; + refundRatio = hubInfo.refundRatio; + owner = hubInfo.owner; + vault = hubInfo.vault; + asset = hubInfo.asset; + updating = hubInfo.updating; + active = hubInfo.active; + } + /// @inheritdoc IHubFacet function getHubInfo(uint256 id) external diff --git a/contracts/facets/MeTokenRegistryFacet.sol b/contracts/facets/MeTokenRegistryFacet.sol index c78f49bb..42694655 100644 --- a/contracts/facets/MeTokenRegistryFacet.sol +++ b/contracts/facets/MeTokenRegistryFacet.sol @@ -3,23 +3,20 @@ pragma solidity 0.8.9; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {IHubFacet} from "../interfaces/IHubFacet.sol"; import {IMeToken} from "../interfaces/IMeToken.sol"; import {IMeTokenFactory} from "../interfaces/IMeTokenFactory.sol"; import {IMeTokenRegistryFacet} from "../interfaces/IMeTokenRegistryFacet.sol"; import {IMigration} from "../interfaces/IMigration.sol"; -import {IMigrationRegistry} from "../interfaces/IMigrationRegistry.sol"; import {IVault} from "../interfaces/IVault.sol"; import {LibCurve} from "../libs/LibCurve.sol"; -import {LibDiamond} from "../libs/LibDiamond.sol"; -import {LibHub, HubInfo} from "../libs/LibHub.sol"; +import {HubInfo} from "../libs/LibHub.sol"; import {LibMeta} from "../libs/LibMeta.sol"; import {LibMeToken, MeTokenInfo} from "../libs/LibMeToken.sol"; import {Modifiers} from "../libs/LibAppStorage.sol"; /// @title meTokens Registry Facet /// @author @cbobrobison, @cartercarlson, @zgorizzo69, @parv3213 -/// @notice This contract tracks info about a meToken within meTokens protocol +/// @notice This contract tracks info about a meToken within meTokens Protocol contract MeTokenRegistryFacet is IMeTokenRegistryFacet, Modifiers { using SafeERC20 for IERC20; @@ -243,29 +240,50 @@ contract MeTokenRegistryFacet is IMeTokenRegistryFacet, Modifiers { } /// @inheritdoc IMeTokenRegistryFacet - function setMeTokenWarmup(uint256 warmup) external onlyDurationsController { - require(warmup != s.meTokenWarmup, "same warmup"); - require(warmup + s.meTokenDuration < s.hubWarmup, "too long"); - s.meTokenWarmup = warmup; + function setMeTokenWarmup(uint256 period) external onlyDurationsController { + require(period != s.meTokenWarmup, "same warmup"); + require(period + s.meTokenDuration < s.hubWarmup, "too long"); + s.meTokenWarmup = period; } /// @inheritdoc IMeTokenRegistryFacet - function setMeTokenDuration(uint256 duration) + function setMeTokenDuration(uint256 period) external onlyDurationsController { - require(duration != s.meTokenDuration, "same duration"); - require(s.meTokenWarmup + duration < s.hubWarmup, "too long"); - s.meTokenDuration = duration; + require(period != s.meTokenDuration, "same duration"); + require(s.meTokenWarmup + period < s.hubWarmup, "too long"); + s.meTokenDuration = period; } /// @inheritdoc IMeTokenRegistryFacet - function setMeTokenCooldown(uint256 cooldown) + function setMeTokenCooldown(uint256 period) external onlyDurationsController { - require(cooldown != s.meTokenCooldown, "same cooldown"); - s.meTokenCooldown = cooldown; + require(period != s.meTokenCooldown, "same cooldown"); + s.meTokenCooldown = period; + } + + /// @inheritdoc IMeTokenRegistryFacet + function getBasicMeTokenInfo(address meToken) + external + view + override + returns ( + address owner, + uint256 hubId, + uint256 balancePooled, + uint256 balanceLocked, + address migration + ) + { + MeTokenInfo storage meTokenInfo = s.meTokens[meToken]; + owner = meTokenInfo.owner; + hubId = meTokenInfo.hubId; + balancePooled = meTokenInfo.balancePooled; + balanceLocked = meTokenInfo.balanceLocked; + migration = meTokenInfo.migration; } /// @inheritdoc IMeTokenRegistryFacet diff --git a/contracts/facets/OwnershipFacet.sol b/contracts/facets/OwnershipFacet.sol index d642f217..b2ac2dc4 100644 --- a/contracts/facets/OwnershipFacet.sol +++ b/contracts/facets/OwnershipFacet.sol @@ -3,11 +3,13 @@ pragma solidity 0.8.9; import {LibDiamond} from "../libs/LibDiamond.sol"; import {Modifiers} from "../libs/LibAppStorage.sol"; +import {IOwnershipFacet} from "../interfaces/IOwnershipFacet.sol"; /// @title meTokens Ownership Facet /// @author @cartercarlson, @zgorizzo69, @parv3213 -/// @notice This contract provides access control for meTokens protocol -contract OwnershipFacet is Modifiers { +/// @notice This contract provides access control for meTokens Protocol +contract OwnershipFacet is Modifiers, IOwnershipFacet { + /// @inheritdoc IOwnershipFacet function setDiamondController(address newController) external onlyDiamondController @@ -16,6 +18,7 @@ contract OwnershipFacet is Modifiers { s.diamondController = newController; } + /// @inheritdoc IOwnershipFacet function setTrustedForwarder(address forwarder) external onlyDiamondController @@ -24,6 +27,7 @@ contract OwnershipFacet is Modifiers { s.trustedForwarder = forwarder; } + /// @inheritdoc IOwnershipFacet function setFeesController(address newController) external onlyFeesController @@ -32,6 +36,7 @@ contract OwnershipFacet is Modifiers { s.feesController = newController; } + /// @inheritdoc IOwnershipFacet function setDurationsController(address newController) external onlyDurationsController @@ -40,14 +45,7 @@ contract OwnershipFacet is Modifiers { s.durationsController = newController; } - function setMeTokenRegistryController(address newController) - external - onlyMeTokenRegistryController - { - _sameAsPreviousError(s.meTokenRegistryController, newController); - s.meTokenRegistryController = newController; - } - + /// @inheritdoc IOwnershipFacet function setRegisterController(address newController) external onlyRegisterController @@ -56,6 +54,7 @@ contract OwnershipFacet is Modifiers { s.registerController = newController; } + /// @inheritdoc IOwnershipFacet function setDeactivateController(address newController) external onlyDeactivateController @@ -64,30 +63,32 @@ contract OwnershipFacet is Modifiers { s.deactivateController = newController; } + /// @inheritdoc IOwnershipFacet function trustedForwarder() external view returns (address) { return s.trustedForwarder; } + /// @inheritdoc IOwnershipFacet function diamondController() external view returns (address) { return s.diamondController; } + /// @inheritdoc IOwnershipFacet function feesController() external view returns (address) { return s.feesController; } + /// @inheritdoc IOwnershipFacet function durationsController() external view returns (address) { return s.durationsController; } - function meTokenRegistryController() external view returns (address) { - return s.meTokenRegistryController; - } - + /// @inheritdoc IOwnershipFacet function registerController() external view returns (address) { return s.registerController; } + /// @inheritdoc IOwnershipFacet function deactivateController() external view returns (address) { return s.deactivateController; } diff --git a/contracts/interfaces/ICurveFacet.sol b/contracts/interfaces/ICurveFacet.sol index 43e9e1be..b73b078c 100644 --- a/contracts/interfaces/ICurveFacet.sol +++ b/contracts/interfaces/ICurveFacet.sol @@ -3,7 +3,8 @@ pragma solidity 0.8.9; import {LibCurve} from "../libs/LibCurve.sol"; -/// @title Curve Facet interface +/// @title meTokens Protocol Curve Facet interface +/// @author Carter Carlson (@cartercarlson), @zgorizzo69 interface ICurveFacet { /// @notice Get curveInfo for a hub /// @param hubId Unique hub identifier diff --git a/contracts/interfaces/IDiamondCut.sol b/contracts/interfaces/IDiamondCut.sol index 10459a88..55b474d9 100644 --- a/contracts/interfaces/IDiamondCut.sol +++ b/contracts/interfaces/IDiamondCut.sol @@ -6,7 +6,7 @@ pragma solidity 0.8.9; * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ -interface IDiamondCut { +interface IDiamondCutFacet { enum FacetCutAction { Add, Replace, diff --git a/contracts/interfaces/IFeesFacet.sol b/contracts/interfaces/IFeesFacet.sol index 30dfbc19..3fce96ec 100644 --- a/contracts/interfaces/IFeesFacet.sol +++ b/contracts/interfaces/IFeesFacet.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; -/// @title MeTokens fee interface +/// @title meTokens Protocol Fees Facet interface /// @author Carter Carlson (@cartercarlson) interface IFeesFacet { /// @notice Event of setting the Mint fee for meTokens protocol @@ -17,14 +17,17 @@ interface IFeesFacet { event SetBurnOwnerFee(uint256 rate); /// @notice Set Mint fee for meTokens protocol + /// @dev Only callable by FeesController /// @param rate New fee rate function setMintFee(uint256 rate) external; /// @notice Set BurnBuyer fee for meTokens protocol + /// @dev Only callable by FeesController /// @param rate New fee rate function setBurnBuyerFee(uint256 rate) external; /// @notice Set BurnOwner fee for meTokens protocol + /// @dev Only callable by FeesController /// @param rate New fee rate function setBurnOwnerFee(uint256 rate) external; diff --git a/contracts/interfaces/IFoundryFacet.sol b/contracts/interfaces/IFoundryFacet.sol index 39f2019c..68e80a12 100644 --- a/contracts/interfaces/IFoundryFacet.sol +++ b/contracts/interfaces/IFoundryFacet.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; -/// @title MeTokens foundry interface +/// @title meTokens Protocol Foundry Facet interface /// @author Carter Carlson (@cartercarlson), Parv Garg (@parv3213) interface IFoundryFacet { /// @notice Event of minting a meToken @@ -52,11 +52,12 @@ interface IFoundryFacet { /// @param meToken Address of meToken to mint /// @param assetsDeposited Amount of assets to deposit /// @param recipient Address to receive minted meTokens + /// @return meTokensMinted Amount of meTokens minted function mint( address meToken, uint256 assetsDeposited, address recipient - ) external; + ) external returns (uint256 meTokensMinted); /// @notice Mint a meToken by depositing a EIP compliant asset /// @param meToken Address of meToken to mint @@ -66,6 +67,7 @@ interface IFoundryFacet { /// @param v v of the signature /// @param r r of the signature /// @param s s of the signature + /// @return meTokensMinted Amount of meTokens minted function mintWithPermit( address meToken, uint256 assetsDeposited, @@ -74,17 +76,18 @@ interface IFoundryFacet { uint8 v, bytes32 r, bytes32 s - ) external; + ) external returns (uint256 meTokensMinted); /// @notice Burn a meToken to receive the underlying asset /// @param meToken Address of meToken to burn /// @param meTokensBurned Amount of meTokens to burn /// @param recipient Address to receive the underlying assets + /// @return assetsReturned Amount of assets returned function burn( address meToken, uint256 meTokensBurned, address recipient - ) external; + ) external returns (uint256 assetsReturned); /// @notice Donate a meToken's underlying asset to its owner /// @param meToken Address of meToken to donate diff --git a/contracts/interfaces/IHubFacet.sol b/contracts/interfaces/IHubFacet.sol index b9d29c7c..d945d6a3 100644 --- a/contracts/interfaces/IHubFacet.sol +++ b/contracts/interfaces/IHubFacet.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.9; import {IVault} from "./IVault.sol"; import {HubInfo} from "../libs/LibHub.sol"; -/// @title MeTokens hub interface +/// @title meTokens Protocol Hub Facet interface /// @author Carter Carlson (@cartercarlson) interface IHubFacet { /// @notice Event of registering a hub @@ -35,8 +35,7 @@ interface IHubFacet { /// @param id Unique hub identifier /// @param targetRefundRatio Target rate to refund burners /// @param targetRefundRatio curve target RefundRatio - /// @param reconfigure Boolean to show if we're changing the - /// curveInfo but not the curve address + /// @param reconfigure Boolean to show if we're updating the CurveInfo /// @param startTime Timestamp to start updating /// @param endTime Timestamp to end updating /// @param endCooldown Timestamp to allow another update @@ -64,6 +63,7 @@ interface IHubFacet { event FinishUpdate(uint256 id); /// @notice Register a new hub + /// @dev Only callable by RegisterController /// @param owner Address to own hub /// @param asset Address of vault asset /// @param vault Address of vault @@ -83,10 +83,12 @@ interface IHubFacet { /// @notice Deactivate a hub, which prevents a meToken from subscribing /// to it + /// @dev Only callable by hub owner or DeactivateController /// @param id Unique hub identifier function deactivate(uint256 id) external; /// @notice Intialize a hub update + /// @dev Only callable by hub owner /// @param id Unique hub identifier /// @param targetRefundRatio Target rate to refund burners /// @param targetReserveWeight Target curve reserveWeight @@ -98,14 +100,17 @@ interface IHubFacet { /// @notice Cancel a hub update /// @dev Can only be called before startTime + /// @dev Only callable by hub owner /// @param id Unique hub identifier function cancelUpdate(uint256 id) external; /// @notice Finish updating a hub + /// @dev Callable by anyone /// @param id Unique hub identifier function finishUpdate(uint256 id) external; /// @notice Transfer the ownership of a hub + /// @dev Only callable by hub owner /// @param id Unique hub identifier /// @param newOwner Address to own the hub function transferHubOwnership(uint256 id, address newOwner) external; @@ -113,21 +118,44 @@ interface IHubFacet { /// @notice Get the time period for a hub to warmup, which is the time /// difference between initUpdate() is called and when the update /// is live + /// @dev Only callable by DurationsController /// @param amount Amount of time, in seconds function setHubWarmup(uint256 amount) external; /// @notice Set the time period for a hub to update, which is the time /// difference between when the update is live and when finishUpdate() /// can be called + /// @dev Only callable by DurationsController /// @param amount Amount of time, in seconds function setHubDuration(uint256 amount) external; /// @notice Set the time period for a hub to cooldown, which is the time /// difference between when finishUpdate() can be called and when initUpdate() /// can be called again + /// @dev Only callable by DurationsController /// @param amount Amount of time, in seconds function setHubCooldown(uint256 amount) external; + /// @notice View to get basic information for a hub - reducing gas if called on-chain + /// @param id Unique hub identifier + /// @return refundRatio Rate to refund burners + /// @return owner Address which owns hub + /// @return vault Address of vault + /// @return asset Address of vault asset + /// @return updating Boolean to show if hub is in state of updating + /// @return active Boolean to show if hub is live and usable + function getBasicHubInfo(uint256 id) + external + view + returns ( + uint256 refundRatio, + address owner, + address vault, + address asset, + bool updating, + bool active + ); + /// @notice View to get information for a hub /// @param id Unique hub identifier /// @return Information of hub diff --git a/contracts/interfaces/IMeToken.sol b/contracts/interfaces/IMeToken.sol index b1af26ff..97326f60 100644 --- a/contracts/interfaces/IMeToken.sol +++ b/contracts/interfaces/IMeToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; -/// @title MeToken erc20 interface +/// @title MeToken ERC20 interface /// @author Carter Carlson (@cartercarlson) /// @dev Required for all meTokens interface IMeToken { diff --git a/contracts/interfaces/IMeTokenRegistryFacet.sol b/contracts/interfaces/IMeTokenRegistryFacet.sol index d66dadbd..bafa103d 100644 --- a/contracts/interfaces/IMeTokenRegistryFacet.sol +++ b/contracts/interfaces/IMeTokenRegistryFacet.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.9; import {MeTokenInfo} from "../libs/LibMeToken.sol"; -/// @title MeToken registry interface +/// @title meTokens Protocol MeToken Registry interface /// @author Carter Carlson (@cartercarlson) interface IMeTokenRegistryFacet { /// @notice Event of subscribing (creating) a new meToken @@ -93,6 +93,7 @@ interface IMeTokenRegistryFacet { ) external; /// @notice Initialize a meToken resubscription to a new hub + /// @dev Only callable by meToken owner /// @param meToken Address of meToken /// @param targetHubId Hub which meToken is resubscribing to /// @param migration Address of migration vault @@ -106,10 +107,12 @@ interface IMeTokenRegistryFacet { /// @notice Cancel a meToken resubscription /// @dev Can only be done during the warmup period + /// @dev Only callable by meToken owner /// @param meToken Address of meToken function cancelResubscribe(address meToken) external; /// @notice Finish a meToken's resubscription to a new hub + /// @dev Callable by anyone /// @param meToken Address of meToken /// @return Details of meToken function finishResubscribe(address meToken) @@ -117,35 +120,63 @@ interface IMeTokenRegistryFacet { returns (MeTokenInfo memory); /// @notice Update a meToken's balanceLocked and balancePooled + /// @dev Only callable by migration contract /// @param meToken Address of meToken - /// @param newBalance Rate to multiply balances by + /// @param newBalance Resulting balance from migration vault function updateBalances(address meToken, uint256 newBalance) external; /// @notice Transfer meToken ownership to a new owner + /// @dev Only callable by meToken owner /// @param newOwner Address to claim meToken ownership of msg.sender function transferMeTokenOwnership(address newOwner) external; /// @notice Cancel the transfer of meToken ownership + /// @dev Only callable by meToken owner function cancelTransferMeTokenOwnership() external; /// @notice Claim the transfer of meToken ownership + /// @dev Only callable by recipient /// @param from Address of current meToken owner function claimMeTokenOwnership(address from) external; - /// @notice Get the time period for a meToken to warmup, which is the time + /// @notice Set the time period for a meToken to warmup, which is the time /// difference between when initResubscribe() is called and when the /// resubscription is live - function setMeTokenWarmup(uint256 amount) external; + /// @dev Only callable by DurationsController + /// @param period Period of the meToken resubscribe warmup, in seconds + function setMeTokenWarmup(uint256 period) external; - /// @notice Get the time period for a meToken to resubscribe, which is the time + /// @notice Set the time period for a meToken to resubscribe, which is the time /// difference between when the resubscription is live and when /// finishResubscription() can be called - function setMeTokenDuration(uint256 amount) external; + /// @dev Only callable by DurationsController + /// @param period Period of the meToken resubscribe duration, in seconds + function setMeTokenDuration(uint256 period) external; - /// @notice Get the time period for a meToken to cooldown, which is the time + /// @notice Set the time period for a meToken to cooldown, which is the time /// difference between when finishResubscription can be called and when /// initResubscribe() can be called again - function setMeTokenCooldown(uint256 amount) external; + /// @dev Only callable by DurationsController + /// @param period Period of the meToken resubscribe cooldown, in seconds + function setMeTokenCooldown(uint256 period) external; + + /// @notice View to get basic information for a meToken - reducing gas if called on-chain + /// @param meToken Address of meToken queried + /// @return owner Address of meToken owner + /// @return hubId Unique hub identifier + /// @return balancePooled Amount of balance pooled + /// @return balanceLocked Amount of balance locked + /// @return migration Address of migration vault + function getBasicMeTokenInfo(address meToken) + external + view + returns ( + address owner, + uint256 hubId, + uint256 balancePooled, + uint256 balanceLocked, + address migration + ); /// @notice View to get information for a meToken /// @param meToken Address of meToken queried @@ -166,7 +197,7 @@ interface IMeTokenRegistryFacet { function getPendingOwner(address from) external view returns (address); /// @notice Get the meToken resubscribe warmup period - /// @return Period of meToken warmup, in seconds + /// @return Period of meToken resubscribe warmup, in seconds function meTokenWarmup() external view returns (uint256); /// @notice Get the meToken resubscribe duration period diff --git a/contracts/interfaces/IMigrationRegistry.sol b/contracts/interfaces/IMigrationRegistry.sol index e75b1926..7fa19add 100644 --- a/contracts/interfaces/IMigrationRegistry.sol +++ b/contracts/interfaces/IMigrationRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; -/// @title MeToken migration registry interface +/// @title meTokens Protocol Migration Registry interface /// @author Carter Carlson (@cartercarlson) interface IMigrationRegistry { /// @notice Event of approving a meToken migration route diff --git a/contracts/interfaces/IOwnershipFacet.sol b/contracts/interfaces/IOwnershipFacet.sol new file mode 100644 index 00000000..6afd2b17 --- /dev/null +++ b/contracts/interfaces/IOwnershipFacet.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.9; + +/// @title meTokens Protocol Ownership Facet interface +/// @author Carter Carlson (@cartercarlson) +interface IOwnershipFacet { + /// @notice Set Diamond Controller + /// @dev Only callable by DiamondController + /// @param newController Address of new DiamondController + function setDiamondController(address newController) external; + + /// @notice Set trusted forwarder for meta transactions + /// @dev Only callable by DiamondController + /// @param forwarder Address of new trusted forwarder + function setTrustedForwarder(address forwarder) external; + + /// @notice Set Fees Controller + /// @dev Only callable by FeesController + /// @param newController Address of new FeesController + function setFeesController(address newController) external; + + /// @notice Set Durations Controller + /// @dev Only callable by DurationsController + /// @param newController Address of new DurationsController + function setDurationsController(address newController) external; + + /// @notice Set Register Controller + /// @dev Only callable by RegisterController + /// @param newController Address of new RegisterController + function setRegisterController(address newController) external; + + /// @notice Set Deactivate Controller + /// @dev Only callable by DeactivateController + /// @param newController Address of new DeactivateController + function setDeactivateController(address newController) external; + + /// @notice Get trustedForwarder + /// @return address trustedForwarder + function trustedForwarder() external view returns (address); + + /// @notice Get diamondController + /// @return address diamondController + function diamondController() external view returns (address); + + /// @notice Get feesController + /// @return address feesController + function feesController() external view returns (address); + + /// @notice Get durationsController + /// @return address durationsController + function durationsController() external view returns (address); + + /// @notice Get registerController + /// @return address registerController + function registerController() external view returns (address); + + /// @notice Get deactivateController + /// @return address deactivateController + function deactivateController() external view returns (address); +} diff --git a/contracts/interfaces/IVaultRegistry.sol b/contracts/interfaces/IVaultRegistry.sol index 6e2efe95..80da3acd 100644 --- a/contracts/interfaces/IVaultRegistry.sol +++ b/contracts/interfaces/IVaultRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; -/// @title Vault registry interface for meTokens protocol. +/// @title meTokens Protocol Vault Registry interface /// @author Carter Carlson (@cartercarlson) interface IVaultRegistry { /// @notice Event of approving an address diff --git a/contracts/libs/LibAppStorage.sol b/contracts/libs/LibAppStorage.sol index 5099e025..b2288a5f 100644 --- a/contracts/libs/LibAppStorage.sol +++ b/contracts/libs/LibAppStorage.sol @@ -45,7 +45,6 @@ struct AppStorage { address trustedForwarder; address feesController; address durationsController; - address meTokenRegistryController; address registerController; address deactivateController; } @@ -62,7 +61,6 @@ library LibAppStorage { s.diamondController = _firstController; s.feesController = _firstController; s.durationsController = _firstController; - s.meTokenRegistryController = _firstController; s.registerController = _firstController; s.deactivateController = _firstController; } @@ -119,14 +117,6 @@ contract Modifiers { _; } - modifier onlyMeTokenRegistryController() { - require( - LibMeta.msgSender() == s.meTokenRegistryController, - "!meTokenRegistryController" - ); - _; - } - modifier onlyRegisterController() { require( LibMeta.msgSender() == s.registerController, diff --git a/contracts/libs/LibCurve.sol b/contracts/libs/LibCurve.sol index 86a29b40..29b1a224 100644 --- a/contracts/libs/LibCurve.sol +++ b/contracts/libs/LibCurve.sol @@ -3,8 +3,6 @@ pragma solidity 0.8.9; import {ABDKMathQuad} from "../utils/ABDKMathQuad.sol"; -//import {LibAppStorage, AppStorage} from "./LibAppStorage.sol"; - library LibCurve { using ABDKMathQuad for uint256; using ABDKMathQuad for bytes16; diff --git a/contracts/libs/LibDiamond.sol b/contracts/libs/LibDiamond.sol index 3065716d..5c2b6605 100644 --- a/contracts/libs/LibDiamond.sol +++ b/contracts/libs/LibDiamond.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.9; -/******************************************************************************\ -* Author: Nick Mudge (https://twitter.com/mudgen) -* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 -/******************************************************************************/ -import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; +import {IDiamondCutFacet} from "../interfaces/IDiamondCutFacet.sol"; +/// @title meTokens Protocol diamond library +/// @author Nick Mudge (https://twitter.com/mudgen) +/// @notice Diamond library to enable library storage of meTokens protocol. +/// @dev EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 library LibDiamond { struct FacetAddressAndPosition { address facetAddress; @@ -35,30 +35,30 @@ library LibDiamond { keccak256("diamond.standard.diamond.storage"); event DiamondCut( - IDiamondCut.FacetCut[] diamondCut, + IDiamondCutFacet.FacetCut[] diamondCut, address init, bytes data ); // Internal function version of diamondCut function diamondCut( - IDiamondCut.FacetCut[] memory cut, + IDiamondCutFacet.FacetCut[] memory cut, address init, bytes memory data ) internal { for (uint256 facetIndex; facetIndex < cut.length; facetIndex++) { - IDiamondCut.FacetCutAction action = cut[facetIndex].action; - if (action == IDiamondCut.FacetCutAction.Add) { + IDiamondCutFacet.FacetCutAction action = cut[facetIndex].action; + if (action == IDiamondCutFacet.FacetCutAction.Add) { addFunctions( cut[facetIndex].facetAddress, cut[facetIndex].functionSelectors ); - } else if (action == IDiamondCut.FacetCutAction.Replace) { + } else if (action == IDiamondCutFacet.FacetCutAction.Replace) { replaceFunctions( cut[facetIndex].facetAddress, cut[facetIndex].functionSelectors ); - } else if (action == IDiamondCut.FacetCutAction.Remove) { + } else if (action == IDiamondCutFacet.FacetCutAction.Remove) { removeFunctions( cut[facetIndex].facetAddress, cut[facetIndex].functionSelectors diff --git a/contracts/libs/LibFoundry.sol b/contracts/libs/LibFoundry.sol index 00aad019..93c0c81f 100644 --- a/contracts/libs/LibFoundry.sol +++ b/contracts/libs/LibFoundry.sol @@ -55,7 +55,8 @@ library LibFoundry { address meToken, uint256 assetsDeposited, address recipient - ) internal { + ) internal returns (uint256) { + require(assetsDeposited > 0, "assetsDeposited==0"); (address asset, address sender, uint256 meTokensMinted) = handleMint( meToken, assetsDeposited @@ -71,6 +72,7 @@ library LibFoundry { assetsDeposited, meTokensMinted ); + return meTokensMinted; } function handleMint(address meToken, uint256 assetsDeposited) @@ -134,7 +136,8 @@ library LibFoundry { uint8 vSig, bytes32 rSig, bytes32 sSig - ) internal { + ) internal returns (uint256) { + require(assetsDeposited > 0, "assetsDeposited==0"); ( address asset, uint256[2] memory amounts // 0-meTokensMinted 1-assetsDepositedAfterFees @@ -158,6 +161,7 @@ library LibFoundry { assetsDeposited, amounts[0] ); + return amounts[0]; } // BURN FLOW CHART @@ -195,7 +199,8 @@ library LibFoundry { address meToken, uint256 meTokensBurned, address recipient - ) internal { + ) internal returns (uint256) { + require(meTokensBurned > 0, "meTokensBurned==0"); AppStorage storage s = LibAppStorage.diamondStorage(); address sender = LibMeta.msgSender(); MeTokenInfo memory meTokenInfo = s.meTokens[meToken]; @@ -255,6 +260,7 @@ library LibFoundry { meTokensBurned, assetsReturned ); + return assetsReturned; } function calculateMeTokensMinted(address meToken, uint256 assetsDeposited) @@ -275,32 +281,33 @@ library LibFoundry { meTokenInfo.balancePooled ); - // Logic for if we're switching to a new curve type // reconfiguring - if (hubInfo.reconfigure) { - uint256 targetMeTokensMinted = LibCurve.viewTargetMeTokensMinted( + if (meTokenInfo.targetHubId != 0) { + // Calculate return for a resubscribing meToken + uint256 targetMeTokensMinted = LibCurve.viewMeTokensMinted( assetsDeposited, - meTokenInfo.hubId, + meTokenInfo.targetHubId, totalSupply, meTokenInfo.balancePooled ); meTokensMinted = LibWeightedAverage.calculate( meTokensMinted, targetMeTokensMinted, - hubInfo.startTime, - hubInfo.endTime + meTokenInfo.startTime, + meTokenInfo.endTime ); - } else if (meTokenInfo.targetHubId != 0) { - uint256 targetMeTokensMinted = LibCurve.viewMeTokensMinted( + } else if (hubInfo.reconfigure) { + // Calculate return for a hub which is updating its' curveInfo + uint256 targetMeTokensMinted = LibCurve.viewTargetMeTokensMinted( assetsDeposited, - meTokenInfo.targetHubId, + meTokenInfo.hubId, totalSupply, meTokenInfo.balancePooled ); meTokensMinted = LibWeightedAverage.calculate( meTokensMinted, targetMeTokensMinted, - meTokenInfo.startTime, - meTokenInfo.endTime + hubInfo.startTime, + hubInfo.endTime ); } } @@ -325,7 +332,7 @@ library LibFoundry { ); if (meTokenInfo.targetHubId != 0) { - // Calculate return assuming meToken is resubscribing + // Calculate return for a resubscribing meToken uint256 targetAssetsReturned = LibCurve.viewAssetsReturned( meTokensBurned, meTokenInfo.targetHubId, @@ -339,7 +346,7 @@ library LibFoundry { meTokenInfo.endTime ); } else if (hubInfo.reconfigure) { - // Must mean we're updating curveInfo + // Calculate return for a hub which is updating its' curveInfo uint256 targetAssetsReturned = LibCurve.viewTargetAssetsReturned( meTokensBurned, meTokenInfo.hubId, diff --git a/contracts/libs/LibHub.sol b/contracts/libs/LibHub.sol index 7002f3ee..a125aa0c 100644 --- a/contracts/libs/LibHub.sol +++ b/contracts/libs/LibHub.sol @@ -24,6 +24,7 @@ library LibHub { function finishUpdate(uint256 id) internal { HubInfo storage hubInfo = LibAppStorage.diamondStorage().hubs[id]; + require(hubInfo.updating, "Not updating"); require(block.timestamp > hubInfo.endTime, "Still updating"); if (hubInfo.targetRefundRatio != 0) { diff --git a/contracts/libs/LibMeToken.sol b/contracts/libs/LibMeToken.sol index 4d277ce8..99272a98 100644 --- a/contracts/libs/LibMeToken.sol +++ b/contracts/libs/LibMeToken.sol @@ -73,7 +73,6 @@ library LibMeToken { block.timestamp > meTokenInfo.endTime, "block.timestamp < endTime" ); - // Update balancePooled / balanceLocked IMigration(meTokenInfo.migration).finishMigration(meToken); diff --git a/contracts/mocks/LibAppStorageMock.sol b/contracts/mocks/LibAppStorageMock.sol index d717676b..1530b95c 100644 --- a/contracts/mocks/LibAppStorageMock.sol +++ b/contracts/mocks/LibAppStorageMock.sol @@ -44,7 +44,6 @@ struct AppStorageMock { address trustedForwarder; address feesController; address durationsController; - address meTokenRegistryController; address registerController; address deactivateController; // NOTE: This is the upgraded value for AppStorage @@ -67,7 +66,6 @@ library LibAppStorageMock { s.diamondController = _firstController; s.feesController = _firstController; s.durationsController = _firstController; - s.meTokenRegistryController = _firstController; s.registerController = _firstController; s.deactivateController = _firstController; } @@ -97,14 +95,6 @@ contract ModifiersMock { _; } - modifier onlyMeTokenRegistryController() { - require( - LibMeta.msgSender() == s.meTokenRegistryController, - "!meTokenRegistryController" - ); - _; - } - modifier onlyRegisterController() { require( LibMeta.msgSender() == s.registerController, diff --git a/contracts/registries/MigrationRegistry.sol b/contracts/registries/MigrationRegistry.sol index 46016495..bb72ff82 100644 --- a/contracts/registries/MigrationRegistry.sol +++ b/contracts/registries/MigrationRegistry.sol @@ -4,15 +4,16 @@ pragma solidity 0.8.9; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IMigrationRegistry} from "../interfaces/IMigrationRegistry.sol"; -/// @title Migration Registry +/// @title meTokens Protocol Migration Registry /// @author Carter Carlson (@cartercarlson) /// @notice Contract which manages all migration routes for when a meToken -/// changes its' base asset +/// changes its' base asset. contract MigrationRegistry is Ownable, IMigrationRegistry { - // Initial vault, target vault, migration vault, approved status + // Initial vault => target vault => migration vault => approved status mapping(address => mapping(address => mapping(address => bool))) private _migrations; + /// @inheritdoc IMigrationRegistry function approve( address initialVault, address targetVault, @@ -26,6 +27,7 @@ contract MigrationRegistry is Ownable, IMigrationRegistry { emit Approve(initialVault, targetVault, migration); } + /// @inheritdoc IMigrationRegistry function unapprove( address initialVault, address targetVault, @@ -39,6 +41,7 @@ contract MigrationRegistry is Ownable, IMigrationRegistry { emit Unapprove(initialVault, targetVault, migration); } + /// @inheritdoc IMigrationRegistry function isApproved( address initialVault, address targetVault, diff --git a/contracts/registries/VaultRegistry.sol b/contracts/registries/VaultRegistry.sol index f1fd5848..b52fc3ab 100644 --- a/contracts/registries/VaultRegistry.sol +++ b/contracts/registries/VaultRegistry.sol @@ -4,11 +4,11 @@ pragma solidity 0.8.9; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IVaultRegistry} from "../interfaces/IVaultRegistry.sol"; -/// @title Registry +/// @title meTokens Protocol Vault Registry /// @author Carter Carlson (@cartercarlson) -/// @notice Keeps track of approved addresses for a given Registry +/// @notice Approved vaults to be used within meTokens Protocol. contract VaultRegistry is IVaultRegistry, Ownable { - // NOTE: approved vault factories could be for + // NOTE: approved vault factories could be for: // Vanilla erc20 vaults, Uniswap-LP vaults, Balancer LP vaults, etc. mapping(address => bool) private _approved; diff --git a/scripts/MeTokensDiamond.json b/scripts/MeTokensDiamond.json new file mode 100644 index 00000000..d50c9208 --- /dev/null +++ b/scripts/MeTokensDiamond.json @@ -0,0 +1,2030 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "MeTokensDiamond", + "sourceName": "hardhat-diamond-abi/HardhatDiamondABI.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + } + ], + "name": "getCurveInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "baseY", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetBaseY", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "reserveWeight", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "targetReserveWeight", + "type": "uint32" + } + ], + "internalType": "struct LibCurve.CurveInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "meTokensBurned", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + } + ], + "name": "viewAssetsReturned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + } + ], + "name": "viewMeTokensMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "meTokensBurned", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + } + ], + "name": "viewTargetAssetsReturned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supply", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + } + ], + "name": "viewTargetMeTokensMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + }, + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + } + ], + "indexed": false, + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "diamondCut", + "type": "tuple[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "DiamondCut", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + }, + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum IDiamondCut.FacetCutAction", + "name": "action", + "type": "uint8" + } + ], + "internalType": "struct IDiamondCut.FacetCut[]", + "name": "cut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "facetFunctionSelectors_", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct IDiamondLoupeFacet.Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "SetBurnBuyerFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "SetBurnOwnerFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "SetMintFee", + "type": "event" + }, + { + "inputs": [], + "name": "burnBuyerFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "burnOwnerFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "setBurnBuyerFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "setBurnOwnerFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "setMintFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "burner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "meTokensBurned", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assetsReturned", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "donor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + } + ], + "name": "Donate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "meTokensMinted", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "meTokensBurned", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "meTokensBurned", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "calculateAssetsReturned", + "outputs": [ + { + "internalType": "uint256", + "name": "assetsReturned", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + } + ], + "name": "calculateMeTokensMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "meTokensMinted", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + } + ], + "name": "donate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "vSig", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "rSig", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "sSig", + "type": "bytes32" + } + ], + "name": "mintWithPermit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "CancelUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "Deactivate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "FinishUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "targetRefundRatio", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "targetReserveWeight", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bool", + "name": "reconfigure", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endCooldown", + "type": "uint256" + } + ], + "name": "InitUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "refundRatio", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "baseY", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "reserveWeight", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "encodedVaultArgs", + "type": "bytes" + } + ], + "name": "Register", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "TransferHubOwnership", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "cancelUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "count", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "deactivate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "finishUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "getHubInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endCooldown", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "refundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetRefundRatio", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "bool", + "name": "updating", + "type": "bool" + }, + { + "internalType": "bool", + "name": "reconfigure", + "type": "bool" + }, + { + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "internalType": "struct HubInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hubCooldown", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hubDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hubWarmup", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetRefundRatio", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "targetReserveWeight", + "type": "uint32" + } + ], + "name": "initUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "uint256", + "name": "refundRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseY", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "reserveWeight", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "encodedVaultArgs", + "type": "bytes" + } + ], + "name": "register", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cooldown", + "type": "uint256" + } + ], + "name": "setHubCooldown", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "setHubDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "warmup", + "type": "uint256" + } + ], + "name": "setHubWarmup", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferHubOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "CancelResubscribe", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "CancelTransferMeTokenOwnership", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "ClaimMeTokenOwnership", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "FinishResubscribe", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "targetHubId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "migration", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "encodedMigrationArgs", + "type": "bytes" + } + ], + "name": "InitResubscribe", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minted", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + } + ], + "name": "Subscribe", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "TransferMeTokenOwnership", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "add", + "type": "bool" + }, + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "UpdateBalanceLocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "add", + "type": "bool" + }, + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "UpdateBalancePooled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "UpdateBalances", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "cancelResubscribe", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cancelTransferMeTokenOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldOwner", + "type": "address" + } + ], + "name": "claimMeTokenOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "finishResubscribe", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceLocked", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endCooldown", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetHubId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "migration", + "type": "address" + } + ], + "internalType": "struct MeTokenInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + } + ], + "name": "getMeTokenInfo", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balancePooled", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceLocked", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endCooldown", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetHubId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "migration", + "type": "address" + } + ], + "internalType": "struct MeTokenInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getOwnerMeToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldOwner", + "type": "address" + } + ], + "name": "getPendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "targetHubId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "migration", + "type": "address" + }, + { + "internalType": "bytes", + "name": "encodedMigrationArgs", + "type": "bytes" + } + ], + "name": "initResubscribe", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "isOwner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "meTokenCooldown", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "meTokenDuration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "meTokenWarmup", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cooldown", + "type": "uint256" + } + ], + "name": "setMeTokenCooldown", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "duration", + "type": "uint256" + } + ], + "name": "setMeTokenDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "warmup", + "type": "uint256" + } + ], + "name": "setMeTokenWarmup", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "uint256", + "name": "hubId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetsDeposited", + "type": "uint256" + } + ], + "name": "subscribe", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferMeTokenOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "meToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "updateBalances", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "deactivateController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "diamondController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "durationsController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feesController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "meTokenRegistryController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "registerController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setDeactivateController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setDiamondController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setDurationsController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setFeesController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setMeTokenRegistryController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newController", + "type": "address" + } + ], + "name": "setRegisterController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forwarder", + "type": "address" + } + ], + "name": "setTrustedForwarder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "trustedForwarder", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "deployedBytecode": "", + "bytecode": "", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 26ae1568..7397201a 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -173,7 +173,10 @@ async function main() { // Upgrade diamond w/ facets console.log("\nDiamond Cut successful"); - const diamondCut = await ethers.getContractAt("IDiamondCut", diamond.address); + const diamondCut = await ethers.getContractAt( + "IDiamondCutFacet", + diamond.address + ); let tx; let receipt; let args: any = [ diff --git a/scripts/temp.ts b/scripts/temp.ts new file mode 100644 index 00000000..8f3b2be5 --- /dev/null +++ b/scripts/temp.ts @@ -0,0 +1,16 @@ +import { ethers } from "hardhat"; +import j from "./MeTokensDiamond.json"; + +async function main() { + const diamondAddr = "0x357d636c40A8E3FbFC983D960292D9fEf56104cb"; + + const diamond = await ethers.getContractAt( + "IMeTokenRegistryFacet", + diamondAddr + ); + await diamond.claimMeTokenOwnership( + "0x00000000005dbcB0d0513FcDa746382Fe8a53468" + ); +} + +main(); diff --git a/tasks/deployUpgrade.ts b/tasks/deployUpgrade.ts index d6e261cb..f98071e8 100644 --- a/tasks/deployUpgrade.ts +++ b/tasks/deployUpgrade.ts @@ -8,7 +8,7 @@ import { } from "@ethersproject/contracts"; import { Signer } from "@ethersproject/abstract-signer"; -import { OwnershipFacet, IDiamondCut } from "../artifacts/types"; +import { OwnershipFacet, IDiamondCutFacet } from "../artifacts/types"; import { getSelectors, getSighashes } from "../scripts/libraries/helpers"; import { HardhatRuntimeEnvironment } from "hardhat/types"; @@ -220,10 +220,10 @@ task( //Execute the Cut const diamondCut = (await hre.ethers.getContractAt( - "IDiamondCut", + "IDiamondCutFacet", diamondAddress, signer - )) as IDiamondCut; + )) as IDiamondCutFacet; if (testing) { console.log("Diamond cut"); diff --git a/test/contracts/facets/OwnershipFacet.ts b/test/contracts/facets/OwnershipFacet.ts index 07321af8..5fc61875 100644 --- a/test/contracts/facets/OwnershipFacet.ts +++ b/test/contracts/facets/OwnershipFacet.ts @@ -187,47 +187,6 @@ const setup = async () => { }); }); - describe("setMeTokenRegistryController", () => { - let oldMTRController: SignerWithAddress; - let newMTRController: SignerWithAddress; - before(async () => { - oldMTRController = account0; - newMTRController = account1; - expect(await ownershipFacet.meTokenRegistryController()).to.equal( - oldMTRController.address - ); - }); - it("should revert when caller is not meToken registry controller", async () => { - await expect( - ownershipFacet - .connect(newMTRController) - .setMeTokenRegistryController(newMTRController.address) - ).to.be.revertedWith("!meTokenRegistryController"); - }); - it("should revert when new meToken registry controller is same as old", async () => { - await expect( - ownershipFacet.setMeTokenRegistryController(oldMTRController.address) - ).to.be.revertedWith("same"); - }); - it("should be able to set new meToken registry controller", async () => { - await ownershipFacet.setMeTokenRegistryController( - newMTRController.address - ); - expect(await ownershipFacet.meTokenRegistryController()).to.equal( - newMTRController.address - ); - }); - after(async () => { - // set back original meToken registry controller - await ownershipFacet - .connect(account1) - .setMeTokenRegistryController(oldMTRController.address); - expect(await ownershipFacet.meTokenRegistryController()).to.equal( - oldMTRController.address - ); - }); - }); - describe("setRegisterController", () => { let oldRegisterController: SignerWithAddress; let newRegisterController: SignerWithAddress; diff --git a/test/integration/Diamond/Upgrade.ts b/test/integration/Diamond/Upgrade.ts index 81a0e67e..97b57008 100644 --- a/test/integration/Diamond/Upgrade.ts +++ b/test/integration/Diamond/Upgrade.ts @@ -12,7 +12,7 @@ import { Diamond, DiamondLoupeFacet, FeesFacetMock, - IDiamondCut, + IDiamondCutFacet, FeesFacet, OwnershipFacet, DiamondInit, @@ -29,7 +29,7 @@ const setup = async () => { let whale: Signer; let account2: SignerWithAddress; let account3: SignerWithAddress; - let diamondCut: IDiamondCut; + let diamondCut: IDiamondCutFacet; let updatedFeesFacet: FeesFacetMock; const one = ethers.utils.parseEther("1"); const FacetCutAction = { Add: 0, Replace: 1, Remove: 2 }; @@ -62,8 +62,8 @@ const setup = async () => { account3, meTokenRegistry, } = await hubSetup(baseY, reserveWeight, encodedVaultArgs, refundRatio)); - diamondCut = await getContractAt( - "IDiamondCut", + diamondCut = await getContractAt( + "IDiamondCutFacet", diamond.address ); diff --git a/test/integration/Hub/UpdateCurve.ts b/test/integration/Hub/UpdateCurve.ts index 87081c49..7a7b0a0b 100644 --- a/test/integration/Hub/UpdateCurve.ts +++ b/test/integration/Hub/UpdateCurve.ts @@ -1037,7 +1037,7 @@ const setup = async () => { .connect(account2) .burn( meToken.address, - await meToken.balanceOf(account1.address), + await meToken.balanceOf(account2.address), account2.address ); }); diff --git a/test/utils/hubSetup.ts b/test/utils/hubSetup.ts index 778f12f5..e849b95e 100644 --- a/test/utils/hubSetup.ts +++ b/test/utils/hubSetup.ts @@ -249,7 +249,10 @@ export async function hubSetupWithoutRegister(fees?: number[]): Promise<{ }); } // upgrade diamond w/ facets - const diamondCut = await ethers.getContractAt("IDiamondCut", diamond.address); + const diamondCut = await ethers.getContractAt( + "IDiamondCutFacet", + diamond.address + ); let args: any = [ { mintFee: feeInitialization[0],