Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completely remove the flash loan logic #779

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
604 changes: 295 additions & 309 deletions .gas-snapshot

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ it is explained in depth [here](https://github.com/sablier-labs/v2-core/wiki/Tes
The list of all deployment addresses can be found [here](https://docs.sablier.com). For guidance on the deploy scripts,
see the [Deployments wiki](https://github.com/sablier-labs/v2-core/wiki/Deployments).

It is worth noting that not every file in this repository is included in the current deployments. For instance, the
`SablierV2FlashLoan` abstract is not inherited by any contract on the `main` branch, but we have kept it in version
control because we may decide to use it in the future.

## Security

The codebase has undergone rigorous audits by leading security experts from Cantina, as well as independent auditors.
Expand Down
14 changes: 0 additions & 14 deletions script/Init.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ud60x18 } from "@prb/math/src/UD60x18.sol";

import { Solarray } from "solarray/src/Solarray.sol";

import { ISablierV2Comptroller } from "../src/interfaces/ISablierV2Comptroller.sol";
import { ISablierV2LockupDynamic } from "../src/interfaces/ISablierV2LockupDynamic.sol";
import { ISablierV2LockupLinear } from "../src/interfaces/ISablierV2LockupLinear.sol";
import { Broker, LockupDynamic, LockupLinear } from "../src/types/DataTypes.sol";
Expand All @@ -21,7 +20,6 @@ interface IERC20Mint {
/// @notice Initializes the protocol by setting up the comptroller and creating some streams.
contract Init is BaseScript {
function run(
ISablierV2Comptroller comptroller,
ISablierV2LockupLinear lockupLinear,
ISablierV2LockupDynamic lockupDynamic,
IERC20 asset
Expand All @@ -32,18 +30,6 @@ contract Init is BaseScript {
address sender = broadcaster;
address recipient = vm.addr(vm.deriveKey({ mnemonic: mnemonic, index: 1 }));

/*//////////////////////////////////////////////////////////////////////////
COMPTROLLER
//////////////////////////////////////////////////////////////////////////*/

// Enable the ERC-20 asset for flash loaning.
if (!comptroller.isFlashAsset(asset)) {
comptroller.toggleFlashAsset(asset);
}

// Set the flash fee to 0.05%.
comptroller.setFlashFee({ newFlashFee: ud60x18(0.0005e18) });

/*//////////////////////////////////////////////////////////////////////////
LOCKUP-LINEAR
//////////////////////////////////////////////////////////////////////////*/
Expand Down
26 changes: 0 additions & 26 deletions src/SablierV2Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ contract SablierV2Comptroller is
PUBLIC STORAGE
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2Comptroller
UD60x18 public override flashFee;

/// @inheritdoc ISablierV2Comptroller
mapping(IERC20 asset => bool supported) public override isFlashAsset;

/// @inheritdoc ISablierV2Comptroller
mapping(IERC20 asset => UD60x18 fee) public override protocolFees;

Expand All @@ -60,16 +54,6 @@ contract SablierV2Comptroller is
USER-FACING NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc ISablierV2Comptroller
function setFlashFee(UD60x18 newFlashFee) external override onlyAdmin {
// Effects: set the new flash fee.
UD60x18 oldFlashFee = flashFee;
flashFee = newFlashFee;

// Log the change of the flash fee.
emit ISablierV2Comptroller.SetFlashFee({ admin: msg.sender, oldFlashFee: oldFlashFee, newFlashFee: newFlashFee });
}

/// @inheritdoc ISablierV2Comptroller
function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external override onlyAdmin {
// Effects: set the new global fee.
Expand All @@ -84,14 +68,4 @@ contract SablierV2Comptroller is
newProtocolFee: newProtocolFee
});
}

/// @inheritdoc ISablierV2Comptroller
function toggleFlashAsset(IERC20 asset) external override onlyAdmin {
// Effects: enable the ERC-20 asset for flash loaning.
bool oldFlag = isFlashAsset[asset];
isFlashAsset[asset] = !oldFlag;

// Log the change of the flash asset flag.
emit ISablierV2Comptroller.ToggleFlashAsset({ admin: msg.sender, asset: asset, newFlag: !oldFlag });
}
}
174 changes: 0 additions & 174 deletions src/abstracts/SablierV2FlashLoan.sol

This file was deleted.

47 changes: 0 additions & 47 deletions src/interfaces/ISablierV2Comptroller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,17 @@ interface ISablierV2Comptroller is IAdminable {
EVENTS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Emitted when the admin sets a new flash fee.
/// @param admin The address of the contract admin.
/// @param oldFlashFee The old flash fee, denoted as a fixed-point number.
/// @param newFlashFee The new flash fee, denoted as a fixed-point number.
event SetFlashFee(address indexed admin, UD60x18 oldFlashFee, UD60x18 newFlashFee);

/// @notice Emitted when the admin sets a new protocol fee for the provided ERC-20 asset.
/// @param admin The address of the contract admin.
/// @param asset The contract address of the ERC-20 asset the new protocol fee has been set for.
/// @param oldProtocolFee The old protocol fee, denoted as a fixed-point number.
/// @param newProtocolFee The new protocol fee, denoted as a fixed-point number.
event SetProtocolFee(address indexed admin, IERC20 indexed asset, UD60x18 oldProtocolFee, UD60x18 newProtocolFee);

/// @notice Emitted when the admin enables or disables an ERC-20 asset for flash loaning.
/// @param admin The address of the contract admin.
/// @param asset The contract address of the ERC-20 asset to toggle.
/// @param newFlag Whether the ERC-20 asset can be flash loaned.
event ToggleFlashAsset(address indexed admin, IERC20 indexed asset, bool newFlag);

/*//////////////////////////////////////////////////////////////////////////
CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Retrieves the global flash fee, denoted as a fixed-point number where 1e18 is 100%.
///
/// @dev Notes:
/// - This fee represents a percentage, not an amount. Do not confuse it with {IERC3156FlashLender.flashFee},
/// which calculates the fee amount for a specified flash loan amount.
/// - Unlike the protocol fee, this is a global fee applied to all flash loans, not a per-asset fee.
function flashFee() external view returns (UD60x18 fee);

/// @notice Retrieves a flag indicating whether the provided ERC-20 asset can be flash loaned.
/// @param token The contract address of the ERC-20 asset to check.
function isFlashAsset(IERC20 token) external view returns (bool result);

/// @notice Retrieves the protocol fee for all streams created with the provided ERC-20 asset.
/// @param asset The contract address of the ERC-20 asset to query.
/// @return fee The protocol fee denoted as a fixed-point number where 1e18 is 100%.
Expand All @@ -58,19 +34,6 @@ interface ISablierV2Comptroller is IAdminable {
NON-CONSTANT FUNCTIONS
//////////////////////////////////////////////////////////////////////////*/

/// @notice Updates the flash fee charged on all flash loans made with any ERC-20 asset.
///
/// @dev Emits a {SetFlashFee} event.
///
/// Notes:
/// - Does not revert if the fee is the same.
///
/// Requirements:
/// - `msg.sender` must be the contract admin.
///
/// @param newFlashFee The new flash fee to set, denoted as a fixed-point number where 1e18 is 100%.
function setFlashFee(UD60x18 newFlashFee) external;

/// @notice Sets a new protocol fee that will be charged on all streams created with the provided ERC-20 asset.
///
/// @dev Emits a {SetProtocolFee} event.
Expand All @@ -86,14 +49,4 @@ interface ISablierV2Comptroller is IAdminable {
/// @param asset The contract address of the ERC-20 asset to update the fee for.
/// @param newProtocolFee The new protocol fee, denoted as a fixed-point number where 1e18 is 100%.
function setProtocolFee(IERC20 asset, UD60x18 newProtocolFee) external;

/// @notice Toggles the flash loanability of an ERC-20 asset.
///
/// @dev Emits a {ToggleFlashAsset} event.
///
/// Requirements:
/// - `msg.sender` must be the admin.
///
/// @param asset The address of the ERC-20 asset to toggle.
function toggleFlashAsset(IERC20 asset) external;
}
17 changes: 0 additions & 17 deletions src/interfaces/erc3156/IERC3156FlashBorrower.sol

This file was deleted.

22 changes: 0 additions & 22 deletions src/interfaces/erc3156/IERC3156FlashLender.sol

This file was deleted.

Loading