Skip to content

feat(Party): add gas refunds for voting #234

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

Open
wants to merge 1 commit into
base: old-main
Choose a base branch
from

Conversation

0xble
Copy link
Collaborator

@0xble 0xble commented Jun 25, 2023

Motivation

Needing to pay gas to vote on a proposal punishes active governance. It is especially insidious since voting against a proposal (i.e. not voting at all) does not cost gas while voting for a proposal does, which skews incentives toward inaction.

And just very simply, paying gas sucks.

Solution

If enabled by a host, voters will be refunded the cost of gas from the Party's balance of ETH for voting on proposals.

Here is the core logic for calculating refund amounts:

uint256 startGas = gasleft();

// ... Rest of logic for accepting proposals

// Only refund if the party has ETH.
uint256 balance = address(this).balance;
if (balance == 0) return;

// Calculate the refund amount.
uint256 baseFee = _min(block.basefee, maxBaseFee);
uint256 gasPrice = _min(tx.gasprice, baseFee + maxPriorityFee);
uint256 gasUsed = _min(startGas - gasleft() + baseGasUsed, maxGasUsed);
uint256 refund = _min(gasPrice * gasUsed, balance);

// Transfer the refund. Do not revert if it fails.
(bool wasRefundSent, ) = tx.origin.call{ value: refund }("");

emit GasRefunded(tx.origin, refund, wasRefundSent);

@height
Copy link

height bot commented Jun 25, 2023

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

unchecked {
// Only refund if the party has ETH.
uint256 balance = address(this).balance;
if (balance == 0) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we also check balance > refund?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If balance > refund it transfers the remaining ETH

@0xble 0xble added feature Add functionality governance Related to governance labels Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Add functionality governance Related to governance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants