-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
8 changed files
with
209 additions
and
38 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Gearbox Protocol. Generalized leverage for DeFi protocols | ||
// (c) Gearbox Holdings, 2022 | ||
pragma solidity ^0.8.10; | ||
|
||
/// @title IBotList | ||
interface IBotList { | ||
/// @dev Emits when a borrower enables or disables a bot for their account | ||
event BotApprovalChanged( | ||
address indexed borrower, | ||
address indexed bot, | ||
bool status | ||
); | ||
|
||
/// @dev Emits when a bot is forbidden system-wide | ||
event BotForbiddenStatusChanged(address indexed bot, bool status); | ||
|
||
/// @dev Sets approval from msg.sender to bot | ||
function setBotStatus(address bot, bool status) external; | ||
|
||
/// @dev Returns whether the bot is approved by the borrower | ||
function approvedBot(address borrower, address bot) | ||
external | ||
view | ||
returns (bool); | ||
|
||
/// @dev Returns whether the bot is forbidden by the borrower | ||
function forbiddenBot(address bot) external view returns (bool); | ||
} |
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
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,52 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
// Gearbox. Generalized leverage protocol that allows to take leverage and then use it across other DeFi protocols and platforms in a composable way. | ||
// (c) Gearbox Holdings, 2022 | ||
pragma solidity ^0.8.10; | ||
|
||
import { Address } from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
import { ACLTrait } from "../core/ACLTrait.sol"; | ||
import { IBotList } from "../interfaces/IBotList.sol"; | ||
|
||
import { ZeroAddressException, AddressIsNotContractException } from "../interfaces/IErrors.sol"; | ||
|
||
/// @title BotList | ||
/// @dev Used to store a mapping of borrowers => bots. A separate contract is used for transferability when | ||
/// changing Credit Facades | ||
contract BotList is ACLTrait, IBotList { | ||
using Address for address; | ||
|
||
/// @dev Mapping from (borrower, bot) to bot approval status | ||
mapping(address => mapping(address => bool)) public approvedBot; | ||
|
||
/// @dev Whether the bot is forbidden system-wide | ||
mapping(address => bool) public forbiddenBot; | ||
|
||
constructor(address _addressProvider) ACLTrait(_addressProvider) {} | ||
|
||
/// @dev Adds or removes allowance for a bot to execute multicalls on behalf of sender | ||
/// @param bot Bot address | ||
/// @param status Whether allowance is added or removed | ||
function setBotStatus(address bot, bool status) external { | ||
if (bot == address(0)) { | ||
revert ZeroAddressException(); | ||
} | ||
|
||
if (!bot.isContract() && status) { | ||
revert AddressIsNotContractException(bot); | ||
} | ||
|
||
approvedBot[msg.sender][bot] = status; | ||
|
||
emit BotApprovalChanged(msg.sender, bot, status); | ||
} | ||
|
||
/// @dev Forbids the bot system-wide if it is known to be compromised | ||
function setBotForbiddenStatus(address bot, bool status) | ||
external | ||
configuratorOnly | ||
{ | ||
forbiddenBot[bot] = status; | ||
emit BotForbiddenStatusChanged(bot, status); | ||
} | ||
} |
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
Oops, something went wrong.