From 0c2402f14332ae6dc307f6576c5096c8fbff1a90 Mon Sep 17 00:00:00 2001 From: chrismaree Date: Fri, 17 May 2024 12:02:07 +0200 Subject: [PATCH] chris format & licence update Signed-off-by: chrismaree --- .../ImmutableOvalChainlinkFactory.sol | 33 ++++++++++++++ src/factories/MutableUnlockersFactory.sol | 43 ------------------- .../MutableUnlockersOvalChainlinkFactory.sol | 39 +++++++++++++++++ 3 files changed, 72 insertions(+), 43 deletions(-) create mode 100644 src/factories/ImmutableOvalChainlinkFactory.sol delete mode 100644 src/factories/MutableUnlockersFactory.sol create mode 100644 src/factories/MutableUnlockersOvalChainlinkFactory.sol diff --git a/src/factories/ImmutableOvalChainlinkFactory.sol b/src/factories/ImmutableOvalChainlinkFactory.sol new file mode 100644 index 0000000..5f10512 --- /dev/null +++ b/src/factories/ImmutableOvalChainlinkFactory.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.17; + +import {ImmutableController} from "../controllers/ImmutableController.sol"; +import {ChainlinkSourceAdapter} from "../adapters/source-adapters/ChainlinkSourceAdapter.sol"; +import {ChainlinkDestinationAdapter} from "../adapters/destination-adapters/ChainlinkDestinationAdapter.sol"; +import {IAggregatorV3Source} from "../interfaces/chainlink/IAggregatorV3Source.sol"; + +contract OvalChainlinkImmutable is ImmutableController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { + constructor( + IAggregatorV3Source source, + address[] memory unlockers, + uint256 _lockWindow, + uint256 _maxTraversal, + address owner + ) + ChainlinkSourceAdapter(source) + ImmutableController(_lockWindow, _maxTraversal, unlockers) + ChainlinkDestinationAdapter(source.decimals()) + {} +} + +contract MutableUnlockersOvalChainlinkFactory { + function createImmutableOvalChainlink( + IAggregatorV3Source source, + uint256 lockWindow, + uint256 maxTraversal, + address owner, + address[] memory unlockers + ) external returns (address) { + return address(new OvalChainlinkImmutable(source, unlockers, lockWindow, maxTraversal, owner)); + } +} diff --git a/src/factories/MutableUnlockersFactory.sol b/src/factories/MutableUnlockersFactory.sol deleted file mode 100644 index afdc9a0..0000000 --- a/src/factories/MutableUnlockersFactory.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.17; - -import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol"; -import {MutableUnlockersController} from "../controllers/MutableUnlockersController.sol"; -import {ChainlinkSourceAdapter} from "../adapters/source-adapters/ChainlinkSourceAdapter.sol"; -import {ChainlinkDestinationAdapter} from "../adapters/destination-adapters/ChainlinkDestinationAdapter.sol"; -import {IAggregatorV3Source} from "../interfaces/chainlink/IAggregatorV3Source.sol"; - -contract OvalChainlink is MutableUnlockersController, ChainlinkSourceAdapter, ChainlinkDestinationAdapter { - constructor(IAggregatorV3Source source, address[] memory unlockers, uint256 _lockWindow, uint256 _maxTraversal, address owner) - ChainlinkSourceAdapter(source) - MutableUnlockersController(_lockWindow, _maxTraversal, unlockers) - ChainlinkDestinationAdapter(source.decimals()) - { - _transferOwnership(owner); - } -} - -contract MutableUnlockersFactory { - uint256 public immutable LOCK_WINDOW; - uint256 public immutable MAX_TRAVERSAL; - address public immutable OWNER; - address[] public unlockers; - - constructor(uint256 lockWindow, uint256 maxTraversal, address owner, address[] memory _unlockers) { - LOCK_WINDOW = lockWindow; - MAX_TRAVERSAL = maxTraversal; - OWNER = owner; - - for (uint256 i = 0; i < _unlockers.length; i++) { - unlockers.push(_unlockers[i]); - } - } - - function createChainlink(IAggregatorV3Source source) external returns (address) { - return address(new OvalChainlink(source, unlockers, LOCK_WINDOW, MAX_TRAVERSAL, OWNER)); - } - - // Add other create functions here. - // Open question: is there an alternative setup where these contracts call out to do the actual construction, - // allowing dynamic additions of new Oval contract types? -} diff --git a/src/factories/MutableUnlockersOvalChainlinkFactory.sol b/src/factories/MutableUnlockersOvalChainlinkFactory.sol new file mode 100644 index 0000000..9c3c0b6 --- /dev/null +++ b/src/factories/MutableUnlockersOvalChainlinkFactory.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.17; + +import {MutableUnlockersController} from "../controllers/MutableUnlockersController.sol"; +import {ChainlinkSourceAdapter} from "../adapters/source-adapters/ChainlinkSourceAdapter.sol"; +import {ChainlinkDestinationAdapter} from "../adapters/destination-adapters/ChainlinkDestinationAdapter.sol"; +import {IAggregatorV3Source} from "../interfaces/chainlink/IAggregatorV3Source.sol"; + +contract OvalChainlinkMutableUnlocker is + MutableUnlockersController, + ChainlinkSourceAdapter, + ChainlinkDestinationAdapter +{ + constructor( + IAggregatorV3Source source, + address[] memory unlockers, + uint256 _lockWindow, + uint256 _maxTraversal, + address owner + ) + ChainlinkSourceAdapter(source) + MutableUnlockersController(_lockWindow, _maxTraversal, unlockers) + ChainlinkDestinationAdapter(source.decimals()) + { + _transferOwnership(owner); + } +} + +contract MutableUnlockersOvalChainlinkFactory { + function createMutableUnlockerOvalChainlink( + IAggregatorV3Source source, + uint256 lockWindow, + uint256 maxTraversal, + address owner, + address[] memory unlockers + ) external returns (address) { + return address(new OvalChainlinkMutableUnlocker(source, unlockers, lockWindow, maxTraversal, owner)); + } +}