-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e5d8eb
commit 056e521
Showing
4 changed files
with
59 additions
and
86 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// Gearbox Protocol. Generalized leverage for DeFi protocols | ||
// (c) Gearbox Foundation, 2023. | ||
pragma solidity ^0.8.23; | ||
|
||
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; | ||
|
||
import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol"; | ||
import {ControlledTrait} from "@gearbox-protocol/core-v3/contracts/traits/ControlledTrait.sol"; | ||
import {ContractsRegisterTrait} from "@gearbox-protocol/core-v3/contracts/traits/ContractsRegisterTrait.sol"; | ||
import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol"; | ||
|
||
import {IZapper} from "../../interfaces/zappers/IZapper.sol"; | ||
|
||
contract ZapperRegister is IVersion, ControlledTrait, ContractsRegisterTrait, SanityCheckTrait { | ||
using EnumerableSet for EnumerableSet.AddressSet; | ||
|
||
event AddZapper(address indexed zapper); | ||
event RemoveZapper(address indexed zapper); | ||
|
||
uint256 public constant version = 3_10; | ||
bytes32 public constant contractType = "ZR"; | ||
|
||
mapping(address => EnumerableSet.AddressSet) internal _zappersMap; | ||
|
||
constructor(address acl_, address contractsRegister_) | ||
ControlledTrait(acl_) | ||
ContractsRegisterTrait(contractsRegister_) | ||
{} | ||
|
||
function zappers(address pool) external view returns (address[] memory) { | ||
return _zappersMap[pool].values(); | ||
} | ||
|
||
function addZapper(address zapper) external nonZeroAddress(zapper) controllerOrConfiguratorOnly { | ||
address pool = IZapper(zapper).pool(); | ||
_ensureRegisteredPool(pool); | ||
|
||
EnumerableSet.AddressSet storage zapperSet = _zappersMap[pool]; | ||
if (!zapperSet.contains(zapper)) { | ||
zapperSet.add(zapper); | ||
emit AddZapper(zapper); | ||
} | ||
} | ||
|
||
function removeZapper(address zapper) external nonZeroAddress(zapper) controllerOrConfiguratorOnly { | ||
EnumerableSet.AddressSet storage zapperSet = _zappersMap[IZapper(zapper).pool()]; | ||
if (zapperSet.contains(zapper)) { | ||
zapperSet.remove(zapper); | ||
emit RemoveZapper(zapper); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.