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

chore: add blast gas fees utils to Automate #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions contracts/Automate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Gelatofied} from "./vendor/gelato/Gelatofied.sol";
import {GelatoBytes} from "./vendor/gelato/GelatoBytes.sol";
import {Proxied} from "./vendor/proxy/EIP173/Proxied.sol";
import {BlastGasFees} from "./vendor/blast/BlastGasFees.sol";
import {AutomateStorage} from "./AutomateStorage.sol";
import {LibDataTypes} from "./libraries/LibDataTypes.sol";
import {LibEvents} from "./libraries/LibEvents.sol";
Expand All @@ -22,7 +22,7 @@ import {IAutomate} from "./interfaces/IAutomate.sol";
*/
//solhint-disable function-max-lines
//solhint-disable no-empty-blocks
contract Automate is Gelatofied, Proxied, AutomateStorage, IAutomate {
contract Automate is Gelatofied, BlastGasFees, AutomateStorage, IAutomate {
using GelatoBytes for bytes;
using EnumerableSet for EnumerableSet.Bytes32Set;

Expand Down
22 changes: 22 additions & 0 deletions contracts/vendor/blast/BlastGasFees.sol
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);
}
}
111 changes: 111 additions & 0 deletions contracts/vendor/blast/interfaces/IBlast.sol
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
);
}
80 changes: 64 additions & 16 deletions deployments/blast/Automate_Implementation.json

Large diffs are not rendered by default.

227 changes: 227 additions & 0 deletions deployments/blast/solcInputs/a453e7a18519fd07c1a882fb1953995f.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions scripts/blast/dev-blast-configure-claimable-gas.ts
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();
24 changes: 24 additions & 0 deletions scripts/blast/dev-blast-read-gas-params.ts
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();