Skip to content

Orderly deposit#416

Open
aqt-dev wants to merge 6 commits intomainfrom
orderly-deposit
Open

Orderly deposit#416
aqt-dev wants to merge 6 commits intomainfrom
orderly-deposit

Conversation

@aqt-dev
Copy link
Contributor

@aqt-dev aqt-dev commented Dec 23, 2025

Summary

This PR introduces a comprehensive integration of the Orderly Network's deposit functionality into the AnySpend application, enabling users to deposit tokens across multiple chains seamlessly. It includes new components, hooks, and constants to facilitate deposits and manage fees.

Changes

• Added AnySpendOrderlyDepositButton and OrderlyDepositButton components for initiating deposits to the Orderly Network from the UI.
• Introduced AnySpendOrderlyDeposit and OrderlyDeposit components to handle the deposit logic, including user interactions and transaction management.
• Implemented useOrderlyDepositFee hook to fetch and calculate the deposit fees dynamically based on the selected chain and deposit amount.
• Created constants for Orderly Network configurations, including supported chains and their respective contract addresses.

@aqt-dev aqt-dev requested a review from a team as a code owner December 23, 2025 21:37
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aqt-dev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the AnySpend application by integrating the Orderly Network's deposit capabilities. The changes allow users to perform cross-chain token deposits, converting various tokens into USDC and depositing them directly into the Orderly vault. This integration provides a streamlined and efficient way for users to manage their assets across different blockchain networks within the AnySpend ecosystem.

Highlights

  • Orderly Network Integration: Introduced comprehensive integration of Orderly Network's deposit functionality, enabling users to deposit tokens across multiple chains seamlessly into the Orderly vault.
  • New UI Components: Added AnySpendOrderlyDepositButton and OrderlyDepositButton for initiating deposits, and AnySpendOrderlyDeposit and OrderlyDeposit components to manage the deposit logic and user interactions.
  • Dynamic Fee Calculation: Implemented a useOrderlyDepositFee hook to dynamically fetch and calculate deposit fees based on the selected chain and deposit amount.
  • Orderly Network Configuration: Created new constants for Orderly Network configurations, including supported chains, their respective contract addresses, and utility functions for account and broker hash computation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of integrating Orderly Network's deposit functionality into the AnySpend application. The changes are well-structured, with new components for the UI, SDK components for the core logic, a dedicated hook for fee calculation, and a comprehensive set of constants for chain configurations. My review includes a few points to enhance the implementation. I've identified a critical security vulnerability related to a hardcoded secret that should be addressed immediately. I also found a high-severity correctness issue in the transaction handling logic that could lead to failed deposits. Additionally, I've suggested a couple of medium-severity improvements for better maintainability and configuration flexibility. Overall, this is a solid contribution, and addressing these points will make it even more robust and secure.

Comment on lines +12 to +13
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET || "k1c4Ep6agmoejiBinKE70B6bzb8vSdm8",
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

A potentially sensitive shared secret is hardcoded as a default value. Hardcoding secrets in source code is a critical security vulnerability, as it exposes them to anyone with access to the repository. Additionally, the NEXT_PUBLIC_ prefix makes this variable accessible on the client-side, increasing the risk. Secrets should be loaded exclusively from environment variables, and the application should be configured to fail at build time if a required secret is missing in production environments.

Suggested change
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET || "k1c4Ep6agmoejiBinKE70B6bzb8vSdm8",
NEXT_PUBLIC_DEVMODE_SHARED_SECRET:
process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET,

Comment on lines +165 to +175
await sendTransactionAsync({
to: chainConfig.usdcAddress,
data: encodeFunctionData({
abi: erc20Abi,
functionName: "approve",
args: [chainConfig.vaultAddress, amountInUnits],
}),
});

// Small delay to ensure approval is mined
await new Promise(resolve => setTimeout(resolve, 2000));
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using a fixed setTimeout to wait for a transaction to be mined is unreliable. Network congestion can cause transaction times to vary significantly, and a 2-second delay may not be sufficient, leading to the subsequent deposit transaction failing because the approval has not yet been confirmed. You should explicitly wait for the approval transaction to be confirmed before proceeding.

To fix this, you should:

  1. Import usePublicClient from wagmi and get a client instance: const publicClient = usePublicClient({ chainId });
  2. Capture the transaction hash from the sendTransactionAsync call for the approval.
  3. Use publicClient.waitForTransactionReceipt to wait for the approval transaction to be confirmed.
  4. Add publicClient to the useCallback dependency array for executeDeposit.
Suggested change
await sendTransactionAsync({
to: chainConfig.usdcAddress,
data: encodeFunctionData({
abi: erc20Abi,
functionName: "approve",
args: [chainConfig.vaultAddress, amountInUnits],
}),
});
// Small delay to ensure approval is mined
await new Promise(resolve => setTimeout(resolve, 2000));
const approvalTxHash = await sendTransactionAsync({
to: chainConfig.usdcAddress,
data: encodeFunctionData({
abi: erc20Abi,
functionName: "approve",
args: [chainConfig.vaultAddress, amountInUnits],
}),
});
// Wait for approval to be mined
await publicClient.waitForTransactionReceipt({ hash: approvalTxHash });

Comment on lines +348 to +351
metadata: {
logoURI:
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logoURI for the USDC token is hardcoded to the Ethereum mainnet USDC logo for all chains. This can be inaccurate, as different chains may have distinct logos for their native or bridged USDC versions (e.g., USDC.e). For better accuracy and maintainability, consider adding a usdcLogoUri property to the OrderlyChainConfig interface and populating it for each chain.

Comment on lines 20 to 39
const ORDERLY_DEPOSIT_ABI = JSON.stringify([
{
name: "deposit",
type: "function",
stateMutability: "payable",
inputs: [
{
name: "depositData",
type: "tuple",
components: [
{ name: "accountId", type: "bytes32" },
{ name: "brokerHash", type: "bytes32" },
{ name: "tokenHash", type: "bytes32" },
{ name: "tokenAmount", type: "uint128" },
],
},
],
outputs: [],
},
]);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The ORDERLY_DEPOSIT_ABI is a hardcoded duplicate of the deposit function's ABI, which is already defined within ORDERLY_VAULT_ABI in constants/orderly.ts. This code duplication is a maintenance risk. To avoid potential inconsistencies, you should import ORDERLY_VAULT_ABI and derive ORDERLY_DEPOSIT_ABI from it by filtering for the 'deposit' function.

const ORDERLY_DEPOSIT_ABI = JSON.stringify(ORDERLY_VAULT_ABI.filter(item => item.name === "deposit"));

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.

1 participant