generated from LooksRare/solidity-template
-
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
a6dbdc6
commit b93db9e
Showing
6 changed files
with
174 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; | ||
import {IBlast, YieldMode as IBlast__YieldMode, GasMode as IBlast__GasMode} from "./interfaces/IBlast.sol"; | ||
import {IBlastPoints} from "./interfaces/IBlastPoints.sol"; | ||
import {IERC20Rebasing, YieldMode as IERC20Rebasing__YieldMode} from "./interfaces/IERC20Rebasing.sol"; | ||
|
||
/** | ||
* @title BlastYield | ||
* @notice This contract is a base contract for future contracts that wish to claim Blast WETH or USDB yield to inherit from. | ||
* @author LooksRare protocol team (👀,💎) | ||
*/ | ||
contract BlastYield is AccessControl { | ||
address public immutable WETH; | ||
address public immutable USDB; | ||
|
||
/** | ||
* @param _blast Blast precompile | ||
* @param _blastPoints Blast points | ||
* @param _blastPointsOperator Blast points operator | ||
* @param _owner Owner of the contract | ||
* @param _usdb USDB address | ||
* @param _weth WETH address | ||
*/ | ||
constructor( | ||
address _blast, | ||
address _blastPoints, | ||
address _blastPointsOperator, | ||
address _owner, | ||
address _usdb, | ||
address _weth | ||
) { | ||
_grantRole(DEFAULT_ADMIN_ROLE, _owner); | ||
|
||
WETH = _weth; | ||
USDB = _usdb; | ||
|
||
IBlast(_blast).configure(IBlast__YieldMode.CLAIMABLE, IBlast__GasMode.CLAIMABLE, _owner); | ||
IBlastPoints(_blastPoints).configurePointsOperator(_blastPointsOperator); | ||
IERC20Rebasing(_weth).configure(IERC20Rebasing__YieldMode.CLAIMABLE); | ||
IERC20Rebasing(_usdb).configure(IERC20Rebasing__YieldMode.CLAIMABLE); | ||
} | ||
|
||
/** | ||
* @notice Claim Blast yield. Only callable by contract owner. | ||
* @param wethReceiver The receiver of WETH. | ||
* @param usdbReceiver The receiver of USDB. | ||
*/ | ||
function claim(address wethReceiver, address usdbReceiver) external virtual onlyRole(DEFAULT_ADMIN_ROLE) { | ||
uint256 claimableWETH = IERC20Rebasing(WETH).getClaimableAmount(address(this)); | ||
if (claimableWETH != 0) { | ||
IERC20Rebasing(WETH).claim(wethReceiver, claimableWETH); | ||
} | ||
|
||
uint256 claimableUSDB = IERC20Rebasing(USDB).getClaimableAmount(address(this)); | ||
if (claimableUSDB != 0) { | ||
IERC20Rebasing(USDB).claim(usdbReceiver, claimableUSDB); | ||
} | ||
} | ||
} |
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,77 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
enum YieldMode { | ||
AUTOMATIC, | ||
VOID, | ||
CLAIMABLE | ||
} | ||
|
||
enum GasMode { | ||
VOID, | ||
CLAIMABLE | ||
} | ||
|
||
interface IBlast { | ||
// configure | ||
function configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external; | ||
|
||
function configure(YieldMode _yield, GasMode gasMode, address governor) external; | ||
|
||
// base configuration options | ||
function configureClaimableYield() external; | ||
|
||
function configureClaimableYieldOnBehalf(address contractAddress) external; | ||
|
||
function configureAutomaticYield() external; | ||
|
||
function configureAutomaticYieldOnBehalf(address contractAddress) external; | ||
|
||
function configureVoidYield() external; | ||
|
||
function configureVoidYieldOnBehalf(address contractAddress) external; | ||
|
||
function configureClaimableGas() external; | ||
|
||
function configureClaimableGasOnBehalf(address contractAddress) external; | ||
|
||
function configureVoidGas() external; | ||
|
||
function configureVoidGasOnBehalf(address contractAddress) external; | ||
|
||
function configureGovernor(address _governor) external; | ||
|
||
function configureGovernorOnBehalf(address _newGovernor, address contractAddress) external; | ||
|
||
// claim yield | ||
function claimYield(address contractAddress, address recipientOfYield, uint256 amount) external returns (uint256); | ||
|
||
function claimAllYield(address contractAddress, address recipientOfYield) external returns (uint256); | ||
|
||
// claim gas | ||
function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint256); | ||
|
||
function claimGasAtMinClaimRate( | ||
address contractAddress, | ||
address recipientOfGas, | ||
uint256 minClaimRateBips | ||
) external returns (uint256); | ||
|
||
function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint256); | ||
|
||
function claimGas( | ||
address contractAddress, | ||
address recipientOfGas, | ||
uint256 gasToClaim, | ||
uint256 gasSecondsToConsume | ||
) external returns (uint256); | ||
|
||
// read functions | ||
function readClaimableYield(address contractAddress) external view returns (uint256); | ||
|
||
function readYieldConfiguration(address contractAddress) external view returns (uint8); | ||
|
||
function readGasParams( | ||
address contractAddress | ||
) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, GasMode); | ||
} |
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,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
interface IBlastPoints { | ||
function configurePointsOperator(address operator) external; | ||
} |
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,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
enum YieldMode { | ||
AUTOMATIC, | ||
VOID, | ||
CLAIMABLE | ||
} | ||
|
||
interface IERC20Rebasing { | ||
// changes the yield mode of the caller and update the balance | ||
// to reflect the configuration | ||
function configure(YieldMode) external returns (uint256); | ||
|
||
// "claimable" yield mode accounts can call this this claim their yield | ||
// to another address | ||
function claim(address recipient, uint256 amount) external returns (uint256); | ||
|
||
// read the claimable amount for an account | ||
function getClaimableAmount(address account) external view returns (uint256); | ||
} |
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