Skip to content

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

Open
0xble wants to merge 1 commit into
old-mainfrom
feat/gasless-voting
Open

feat(Party): add gas refunds for voting#234
0xble wants to merge 1 commit into
old-mainfrom
feat/gasless-voting

Conversation

@0xble

@0xble 0xble commented Jun 25, 2023

Copy link
Copy Markdown
Contributor

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

height Bot commented Jun 25, 2023

Copy link
Copy Markdown

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.

Comment thread contracts/party/PartyGovernance.sol
@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