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

Set default validator OFA share to 50% #22

Merged
merged 5 commits into from
Jan 24, 2024
Merged
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
19 changes: 13 additions & 6 deletions contracts/auction-handler/FastLaneAuctionHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ contract FastLaneAuctionHandler is FastLaneAuctionHandlerEvents {
/// @notice The scale for validator refund share
uint256 internal constant VALIDATOR_REFUND_SCALE = 10_000; // 1 = 0.01%

/// @notice The default refund share for validators
int256 internal constant DEFAULT_VALIDATOR_REFUND_SHARE = 5000; // 50%
jj1980a marked this conversation as resolved.
Show resolved Hide resolved

/// @notice Mapping to Validator Data Struct
mapping(address => ValidatorData) internal validatorsDataMap;

Expand All @@ -147,11 +150,11 @@ contract FastLaneAuctionHandler is FastLaneAuctionHandlerEvents {
/// @notice Map key is block.number
mapping(uint256 => PGAData) public fulfilledPGAMap;

/// @notice Map[validator] = % payment to validator in a bid with refund
mapping(address => uint256) public validatorsRefundShareMap;

uint256 public validatorsTotal;

/// @notice Map[validator] = % payment to validator in a bid with refund
mapping(address => int256) private validatorsRefundShareMap;
jj1980a marked this conversation as resolved.
Show resolved Hide resolved

bytes32 private constant UNLOCKED = bytes32(uint256(1));
bytes32 private constant LOCKED = bytes32(uint256(2));

Expand Down Expand Up @@ -214,7 +217,7 @@ contract FastLaneAuctionHandler is FastLaneAuctionHandlerEvents {
bytes memory searcherCallData
) external payable checkBid(oppTxHash, bidAmount) onlyEOA nonReentrant {
if (searcherToAddress == address(0)) revert RelaySearcherWrongParams();
if (validatorsRefundShareMap[block.coinbase] > VALIDATOR_REFUND_SCALE) {
if (getValidatorRefundShare(block.coinbase) > VALIDATOR_REFUND_SCALE) {
revert RelayValidatorNotAcceptingRefundBids();
}

Expand Down Expand Up @@ -481,7 +484,7 @@ contract FastLaneAuctionHandler is FastLaneAuctionHandlerEvents {
}

// Calculate the split of payment
uint256 validatorShare = (validatorsRefundShareMap[block.coinbase] * bidAmount) / VALIDATOR_REFUND_SCALE;
uint256 validatorShare = (getValidatorRefundShare(block.coinbase) * bidAmount) / VALIDATOR_REFUND_SCALE;
uint256 refundAmount = bidAmount - validatorShare; // subtract to ensure no overflow

// Update balance and make payment
Expand Down Expand Up @@ -651,7 +654,11 @@ contract FastLaneAuctionHandler is FastLaneAuctionHandlerEvents {
// ensure that validators can't insert txs to boost their refund rates during their own blocks
if (validator == block.coinbase) revert RelayImmutableBlockAuthorRate();

validatorsRefundShareMap[validator] = refundShare;
validatorsRefundShareMap[validator] = int256(refundShare) - DEFAULT_VALIDATOR_REFUND_SHARE;
}

function getValidatorRefundShare(address validator) public view returns (uint256) {
return uint256(validatorsRefundShareMap[validator] + DEFAULT_VALIDATOR_REFUND_SHARE);
}

/**
Expand Down
Loading