Skip to content

feat: request-withdraw, complete-withdraw#464

Merged
awisniew207 merged 6 commits into
mainfrom
feat/withdrawal-api-endpoint
Jan 30, 2026
Merged

feat: request-withdraw, complete-withdraw#464
awisniew207 merged 6 commits into
mainfrom
feat/withdrawal-api-endpoint

Conversation

@awisniew207

@awisniew207 awisniew207 commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Description

Add withdrawal endpoints for users to withdraw tokens from their agent smart accounts

registry-backend:

  • Add POST /user/:appId/request-withdraw endpoint to prepare unsigned UserOperations for withdrawing tokens
  • Add POST /user/:appId/complete-withdraw endpoint to submit signed UserOperations and execute withdrawals
  • Add SPONSOR_WITHDRAW_GAS env var to optionally sponsor gas fees via ZeroDev paymaster
  • Add Alchemy utility for fetching token balances with metadata
  • Refactor chainConfig into utils with network-specific bundler URL support
  • Add integration tests for withdrawal flow

registry-sdk:

  • Add POST /user/:appId/request-withdraw endpoint schema
  • Add POST /user/:appId/complete-withdraw endpoint schema
  • Add withdraw types: Asset, RequestWithdrawRequest, RequestWithdrawResponse, SignedWithdrawal, CompleteWithdrawRequest, CompleteWithdrawResponse
  • Regenerate RTK clients

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

A withdraw.spec.ts integration test exists, which test both endpoints sending 0.1 USDC on Base Sepolia to the user's EOA controller address. It has been tested both with and without gas sponsorship

Checklist:

  • I created a release plan (nx release plan) describing my changes and the version bump
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@vercel

vercel Bot commented Jan 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vincent-app-dashboard Ready Ready Preview, Comment Jan 30, 2026 10:17pm
vincent-dashboard-2.0 Ready Ready Preview, Comment Jan 30, 2026 10:17pm

Request Review

Comment thread packages/apps/registry-backend/src/lib/completeWithdraw.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 withdrawal functionality enabling users to withdraw tokens from their agent smart accounts back to their controller wallets. The implementation follows a two-step flow: request-withdraw prepares unsigned UserOperations, and complete-withdraw submits the signed operations to the blockchain.

Changes:

  • Added two new REST API endpoints for initiating and completing token withdrawals from agent smart accounts
  • Implemented optional gas sponsorship via ZeroDev paymaster controlled by SPONSOR_WITHDRAW_GAS environment variable
  • Created reusable utilities for chain configuration and Alchemy token balance fetching

Reviewed changes

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

Show a summary per file
File Description
packages/libs/registry-sdk/src/lib/schemas/withdraw.ts Defines Zod schemas and TypeScript types for withdrawal request/response structures
packages/libs/registry-sdk/src/lib/openApi/user.ts Registers OpenAPI endpoint definitions for request-withdraw and complete-withdraw
packages/libs/registry-sdk/src/index.ts Exports withdrawal schemas and types for public API consumption
packages/libs/registry-sdk/src/generated/vincentApiClientReact.ts Auto-generated React RTK Query hooks for withdrawal endpoints
packages/libs/registry-sdk/src/generated/vincentApiClientNode.ts Auto-generated Node.js RTK Query client for withdrawal endpoints
packages/libs/registry-sdk/src/generated/openapi.json Auto-generated OpenAPI specification including withdrawal schemas
packages/apps/registry-backend/src/lib/requestWithdraw.ts Implements UserOperation preparation logic with balance validation and optional paymaster
packages/apps/registry-backend/src/lib/completeWithdraw.ts Handles UserOperation submission to bundler with polling for transaction confirmation
packages/apps/registry-backend/src/lib/utils/chainConfig.ts Provides network configuration mapping and RPC URL resolution utilities
packages/apps/registry-backend/src/lib/utils/alchemy.ts Abstracts Alchemy Portfolio API calls for token balance fetching
packages/apps/registry-backend/src/lib/getAgentFunds.ts Minor formatting fix (newline)
packages/apps/registry-backend/src/lib/express/user/routes.ts Registers Express routes for withdrawal endpoints with middleware
packages/apps/registry-backend/src/env.ts Adds SPONSOR_WITHDRAW_GAS boolean environment variable
packages/apps/registry-backend/package.json Updates registry-sdk to workspace reference for local development
packages/apps/registry-backend/jest.config.js Includes withdraw.spec.ts in test file patterns
packages/apps/registry-backend/test/integration/withdraw.spec.ts Comprehensive integration tests covering validation and full withdrawal flow
packages/apps/registry-backend/test/integration/global-setup.ts Adds withdrawal-related environment variables to test setup
docs/wallet-providers/request-withdraw.mdx Documents request-withdraw API endpoint with examples
docs/wallet-providers/complete-withdraw.mdx Documents complete-withdraw API endpoint with examples
docs/wallet-providers/introduction.mdx Adds withdrawal endpoints to wallet provider API overview
docs/docs.json Adds "Withdraw Funds" section to documentation navigation
pnpm-lock.yaml Updates registry-sdk reference from published version to workspace link
.nx/version-plans/version-plan-1768873657320.md Version plan documenting minor version bumps for both packages
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/wallet-providers/complete-withdraw.mdx
Comment thread packages/apps/registry-backend/src/lib/requestWithdraw.ts
Comment thread packages/libs/registry-sdk/src/lib/openApi/user.ts
@awisniew207 awisniew207 merged commit d0bb608 into main Jan 30, 2026
6 checks passed
@Spacesai1or Spacesai1or deleted the feat/withdrawal-api-endpoint branch January 30, 2026 22:27
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