Skip to content

Aidar/com 6385 re build wallet demo with v2#78

Merged
royalnine merged 9 commits intomainfrom
aidar/com-6385-re-build-wallet-demo-with-v2
Nov 17, 2025
Merged

Aidar/com 6385 re build wallet demo with v2#78
royalnine merged 9 commits intomainfrom
aidar/com-6385-re-build-wallet-demo-with-v2

Conversation

@royalnine
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Nov 17, 2025

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

Project Deployment Preview Comments Updated (UTC)
wallet-demo Ready Ready Preview Comment Nov 17, 2025 10:49am

Copy link
Contributor

Copilot AI left a comment

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 upgrades the wallet-earn demo from Compass API SDK v1 to v2, introducing significant architectural changes in how vault and position data are fetched and managed.

  • Updated @compass-labs/api-sdk from v1.0.23 to v2.0.1
  • Separated vault listing and user positions into distinct API endpoints
  • Replaced transaction bundler pattern with simplified earnManage API
  • Introduced COMPASS_WALLET_ADDRESS environment variable for wallet address management

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
wallet-earn/package.json Updated Compass API SDK dependency to v2.0.1
wallet-earn/utils/utils.ts Added getWalletAddress() helper and updated type references to v2 models
wallet-earn/components/WalletScreen.tsx Simplified to show only wallet balances, removed vault position calculations
wallet-earn/components/TokenScreen.tsx Added position merging logic and introduced EnrichedVaultData type
wallet-earn/components/Screens.tsx Refactored data fetching to use separate vaults and positions endpoints
wallet-earn/components/EarnItem.tsx Updated to use v2 vault metrics (CAGR, lifetime returns) and simplified form logic
wallet-earn/app/page.tsx Replaced private key derivation with getWalletAddress() helper
wallet-earn/app/api/vaults/route.ts New endpoint for fetching vault list with USDC filtering
wallet-earn/app/api/positions/route.ts New endpoint for fetching user earn positions
wallet-earn/app/api/vault/[address]/route.ts Updated to use getWalletAddress() helper
wallet-earn/app/api/token/[token]/route.ts Updated to use getWalletAddress() helper
wallet-earn/app/api/deposit/route.ts Simplified to use earnManage API instead of manual allowance + deposit
wallet-earn/app/api/withdraw/route.ts Simplified to use earnManage API instead of transaction bundler
wallet-earn/README.md Added COMPASS_WALLET_ADDRESS to environment variables list
wallet-earn/.env.example Added COMPASS_WALLET_ADDRESS placeholder
Comments suppressed due to low confidence (2)

wallet-earn/utils/utils.ts:70

  • The addTotalBalance function is still exported but is no longer used after the refactoring. It was replaced with inline calculations in WalletScreen.tsx. Consider removing this unused export to keep the codebase clean.
export const addTotalBalance = (
  tokenData: TokenData[],
  vaultData: EnrichedVaultData[]
) =>
  tokenData.reduce((sum, token) => {
    const tokenSingle = tokenData?.find(
      (tD) => tD.tokenSymbol == token.tokenSymbol
    ) as TokenData;
    const tokenTotal = addTokenTotal(tokenSingle, vaultData);
    return sum + tokenTotal * Number(token.price);
  }, 0);

wallet-earn/utils/utils.ts:57

  • The addTokenTotal function is still exported but appears to no longer be used anywhere in the codebase after the refactoring. This function was previously used in WalletScreen.tsx and TokenScreen.tsx but has been replaced with inline calculations. Consider removing this unused export to keep the codebase clean.
export const addTokenTotal = (tokenData: TokenData, vaultData: EnrichedVaultData[]) =>
  vaultData
    .filter((vD) => vD.denomination === tokenData.tokenSymbol)
    .reduce(
      (sum, vD) => sum + Number(vD?.userPosition?.amountInUnderlyingToken) || 0,
      0
    ) + Number(tokenData.amount);

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

Comment on lines 248 to +271
<Slider
value={[amount]}
max={
Number(token.amount) +
Number(vaultData.userPosition?.amountInUnderlyingToken)
}
step={
(Number(token.amount) +
Number(vaultData.userPosition?.amountInUnderlyingToken)) /
400
}
max={Number(token.amount)}
step={Number(token.amount) / 400}
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

The slider allows users to select amounts between 0 and their wallet balance (Number(token.amount)), but the current position might already exceed the wallet balance if funds are staked. This means users cannot increase positions beyond their wallet balance, which is correct, but they also cannot see or adjust to positions higher than their current wallet balance if they have existing stakes. The UX is confusing because the slider max doesn't represent the user's total manageable position. Consider using Number(token.amount) + Number(vaultData.userPosition?.amountInUnderlyingToken || 0) as the max to allow full position management.

Copilot uses AI. Check for mistakes.
@royalnine royalnine merged commit 782f993 into main Nov 17, 2025
5 of 7 checks passed
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