Skip to content

feat(payout): add withdraw function (Only withdraw with latest main)#674

Closed
NicoSerranoP wants to merge 1 commit into
mainfrom
feat/nico/withdraw
Closed

feat(payout): add withdraw function (Only withdraw with latest main)#674
NicoSerranoP wants to merge 1 commit into
mainfrom
feat/nico/withdraw

Conversation

@NicoSerranoP

Copy link
Copy Markdown
Member

Description

This is a clone of #673

Additionals

  1. We keep the pause feature for the moment (I could not find a discuss where we needed to delete it)
  2. withdraw uses the afterDepositWindow modifier because there should not be a cool down period anymore according to latest main
  3. claim still callable afterDepositWindow according to latest main

Confirmation

Important

We do not accept minor grammatical fixes (e.g., correcting typos, rewording sentences) unless they significantly improve clarity in technical documentation. These contributions, while appreciated, are not a priority for merging. If there is a grammatical error feel free to message the team.

Copilot AI review requested due to automatic review settings October 3, 2025 17:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a withdraw function to the Tally contract that allows the owner to withdraw all remaining funds to a designated custodian address after the deposit window has closed. The implementation includes proper access controls and modifier checks.

  • Introduces a custodian field in the StrategyInit struct and Tally contract
  • Adds a withdraw function with owner-only and post-deposit-window restrictions
  • Updates deployment configuration and tests to support the new custodian functionality

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/contracts/contracts/interfaces/IPayoutStrategy.sol Adds custodian field to StrategyInit struct and withdraw function to interface
packages/contracts/contracts/maci/Tally.sol Implements withdraw function and custodian storage variable
packages/contracts/tests/Tally.test.ts Adds comprehensive test coverage for withdraw functionality
packages/contracts/tasks/deploy/poll/01-poll.ts Updates deployment task to include custodian parameter
packages/contracts/deploy-config-example.json Adds custodian configuration field across all network examples

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +169 to +171
uint256 totalFunds = token.balanceOf(address(this));

token.safeTransfer(custodian, totalFunds);

Copilot AI Oct 3, 2025

Copy link

Choose a reason for hiding this comment

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

The withdraw function doesn't update the contract's internal state after transferring funds. Consider setting totalAmount to 0 or adding an event to track the withdrawal.

Copilot uses AI. Check for mistakes.
interface IPayoutStrategy {
/// @notice Strategy initialization params
struct StrategyInit {
/// @notice The custodian address who should receive leftover funds if voting period is over

Copilot AI Oct 3, 2025

Copy link

Choose a reason for hiding this comment

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

The comment mentions 'voting period' but the actual implementation uses 'deposit window'. Update to 'if deposit window is over' for consistency with the contract logic.

Suggested change
/// @notice The custodian address who should receive leftover funds if voting period is over
/// @notice The custodian address who should receive leftover funds if deposit window is over

Copilot uses AI. Check for mistakes.
}

/// @inheritdoc IPayoutStrategy
function withdraw() public override isInitialized onlyOwner afterDepositWindow {

Copilot AI Oct 3, 2025

Copy link

Choose a reason for hiding this comment

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

The withdraw function lacks input validation for the custodian address. Consider adding a check to ensure custodian is not the zero address before allowing withdrawal.

Suggested change
function withdraw() public override isInitialized onlyOwner afterDepositWindow {
function withdraw() public override isInitialized onlyOwner afterDepositWindow {
require(custodian != address(0), "Tally: custodian address is zero");

Copilot uses AI. Check for mistakes.
uint256 public voiceCreditFactor;

/// @notice The custodian address who should receive leftover funds if tallying and cooldown period are over
address public custodian;

Check failure

Code scanning / Slither

Uninitialized state variables High

Tally.custodian is never initialized. It is used in:
- Tally.withdraw()
uint256 public voiceCreditFactor;

/// @notice The custodian address who should receive leftover funds if tallying and cooldown period are over
address public custodian;

Check warning

Code scanning / Slither

State variables that could be declared constant Warning

Tally.custodian should be constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants