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

[Cleanup] Kept #76

Merged
merged 1 commit into from
Sep 1, 2023
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
1 change: 0 additions & 1 deletion contracts/attribute/Kept/Kept.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ abstract contract Kept is IKept, Initializable {

_;


uint256 gasUsed = startGas - gasleft();
UFixed18 keeperFee = UFixed18Lib.from(gasUsed)
.mul(multiplier)
Expand Down
10 changes: 6 additions & 4 deletions contracts/attribute/Kept/Kept_Arbitrum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ interface ArbGasInfo {
function getL1BaseFeeEstimate() external view returns (uint256);
}

contract Kept_Arbitrum is Kept {
/// @dev Arbitrum Kept implementation
abstract contract Kept_Arbitrum is Kept {
ArbGasInfo constant ARB_GAS = ArbGasInfo(0x000000000000000000000000000000000000006C);
uint256 public constant ARB_GAS_MULTIPLIER = 16;
uint256 public constant ARB_FIXED_OVERHEAD = 140;

// https://docs.arbitrum.io/devs-how-tos/how-to-estimate-gas#breaking-down-the-formula
// Tx Fee = block.baseFee * l2GasUsed + ArbGasInfo.getL1BaseFeeEstimate() * 16 * (calldataLength + fixedOverhead)
// Dynamic buffer = (ArbGasInfo.getL1BaseFeeEstimate() * 16 * (calldataLength + fixedOverhead))
function _calculateDynamicFee(bytes memory callData) internal view override returns (UFixed18) {
return
UFixed18.wrap(ARB_GAS.getL1BaseFeeEstimate() * ARB_GAS_MULTIPLIER * (callData.length + ARB_FIXED_OVERHEAD));
function _calculateDynamicFee(bytes memory callData) internal view virtual override returns (UFixed18) {
return UFixed18.wrap(
ARB_GAS.getL1BaseFeeEstimate() * ARB_GAS_MULTIPLIER * (callData.length + ARB_FIXED_OVERHEAD)
);
}
}
5 changes: 3 additions & 2 deletions contracts/attribute/Kept/Kept_Optimism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ interface OptGasInfo {
function getL1Fee(bytes memory) external view returns (uint256);
}

contract Kept_Optimism is Kept {
/// @dev Optimism Kept implementation
abstract contract Kept_Optimism is Kept {
// https://community.optimism.io/docs/developers/build/transaction-fees/#the-l1-data-fee
OptGasInfo constant OPT_GAS = OptGasInfo(0x420000000000000000000000000000000000000F);

// https://community.optimism.io/docs/developers/build/transaction-fees/#the-l1-data-fee
// The getL1Fee method takes into account L1 gas price, size, and overhead values
function _calculateDynamicFee(bytes memory callData) internal view override returns (UFixed18) {
function _calculateDynamicFee(bytes memory callData) internal view virtual override returns (UFixed18) {
return UFixed18.wrap(OPT_GAS.getL1Fee(callData));
}
}
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@equilibria/root",
"description": "Core library for DeFi",
"version": "2.0.0-rc1",
"version": "2.0.0-rc2",
"files": [
"**/*.sol",
"!/mocks/**/*"
Expand Down