-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add blast gas fees utils to Automate
- Loading branch information
1 parent
d4ce8a0
commit 12d9a44
Showing
5 changed files
with
179 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.14; | ||
|
||
import {Proxied} from "../proxy/EIP173/Proxied.sol"; | ||
import {IBlast} from "./interfaces/IBlast.sol"; | ||
|
||
contract BlastGasFees is Proxied { | ||
IBlast public constant BLAST = | ||
IBlast(0x4300000000000000000000000000000000000002); | ||
|
||
function configureClaimableGas() external onlyProxyAdmin { | ||
BLAST.configureClaimableGas(); | ||
} | ||
|
||
function claimAllGas(address _recipient) external onlyProxyAdmin { | ||
BLAST.claimAllGas(address(this), _recipient); | ||
} | ||
|
||
function claimMaxGas(address _recipient) external onlyProxyAdmin { | ||
BLAST.claimMaxGas(address(this), _recipient); | ||
} | ||
} |
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,111 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
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,20 @@ | ||
import { ethers } from "hardhat"; | ||
import { Automate } from "../../typechain"; | ||
|
||
export const configureClaimableGas = async () => { | ||
const [owner] = await ethers.getSigners(); | ||
const ownerAddress = await owner.getAddress(); | ||
console.log("Owner: ", ownerAddress); | ||
|
||
const automateAddress = (await ethers.getContract("Automate")).address; | ||
const automate = <Automate>( | ||
await ethers.getContractAt("Automate", automateAddress) | ||
); | ||
|
||
const txn = await automate.configureClaimableGas(); | ||
const receipt = await txn.wait(); | ||
|
||
console.log(`Configured claimable gas in ${receipt.transactionHash}`); | ||
}; | ||
|
||
configureClaimableGas(); |
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,24 @@ | ||
import { ethers } from "hardhat"; | ||
|
||
export const readGasParams = async () => { | ||
const [owner] = await ethers.getSigners(); | ||
const ownerAddress = await owner.getAddress(); | ||
console.log("Owner: ", ownerAddress); | ||
|
||
const automateAddress = (await ethers.getContract("Automate")).address; | ||
|
||
const blastAbi = [ | ||
"function readGasParams(address contractAddress) external view returns (uint256 etherSeconds, uint256 etherBalance, uint256 lastUpdated, uint8)", | ||
]; | ||
const blastAddress = "0x4300000000000000000000000000000000000002"; | ||
|
||
const blast = await ethers.getContractAt(blastAbi, blastAddress); | ||
|
||
const result = await blast.readGasParams(automateAddress); | ||
|
||
console.log( | ||
`Balance: ${result.etherBalance.toString()}. LastUpdated: ${result.lastUpdated.toString()}` | ||
); | ||
}; | ||
|
||
readGasParams(); |