Skip to content

Integrate USDC Withdrawal from VotingEngine #11

Description

@Mrwicks00

Description

Allow users to withdraw their staked USDC from the VotingEngine contract after a battle is finalized.

Tasks

  • Create a custom hook useWithdraw() that calls VotingEngine.withdraw(battleId) via wagmi
  • Check if withdrawals are enabled using VotingEngine.withdrawalsEnabled(battleId)
  • Display user's withdrawable amount from VotingEngine.votes(battleId, userAddress).amount
  • Add withdraw button on battle detail page and profile page
  • Show withdraw button only when battle is FINALIZED and withdrawals are enabled
  • Display transaction status (pending, success, error)
  • Handle errors (withdrawals not enabled, no staked amount, etc.)

Contract Functions Used

  • VotingEngine.withdraw(uint256 battleId) - Withdraw staked USDC
  • VotingEngine.withdrawalsEnabled(uint256) - Check if withdrawals are enabled
  • VotingEngine.votes(uint256, address) - Get user's vote info (amount to withdraw)

Files to Modify

  • frontend/app/battles/[id]/page.tsx
  • frontend/app/profile/page.tsx
  • frontend/hooks/useWithdraw.ts (new file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersnot-paidThis issue or pull request already exists

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions