Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(orderly-network): implement plugin for Orderly with deposit, withdrawal, order creation, and close position functionality #442

Merged
merged 19 commits into from
Mar 25, 2025

Conversation

wolfcito
Copy link
Contributor

@wolfcito wolfcito commented Mar 23, 2025

Relates to:

Background

This PR implements the Orderly plugin and introduces several new features and improvements:

  • Deposit Logic: Enhanced plugin functionality with multi-chain support and refactored deposit logic.
  • Withdrawal Functionality: Added the withdrawOrderly method for facilitating USDC withdrawals, along with improved helper methods for key management and signing requests.
  • Order Creation: Implemented the createOrderOrderly method with new parameters (order_amount, visible_quantity, and client_order_id) and improved error handling.
  • Close Position Functionality: Added the closePositionOrderly method to allow users to close positions, along with new parameter validation (ClosePositionOrderlyParams) and the getPosition helper function for retrieving current position details.

What does this PR do?

  • Implements the Orderly plugin with support for deposit, withdrawal, order creation, and position closing.
  • Adds new parameter classes for robust validation and better parameter handling.
  • Enhances helper functions for network interactions, key management, and cryptographic operations.
  • Provides improved error handling and user feedback for deposit, withdrawal, and order-related methods.

Testing

  1. Clone the repository and checkout this branch.
  2. Build the plugin.
  3. Navigate to the examples directory and choose an example to test the plugin functionality.
  4. Test each action:
    • Deposit USDC.
    • Withdraw USDC.
    • Create an order.
    • Close a position.
  5. Verify that the outputs, screenshots, and transaction links match expected behavior.

Detailed testing results

Method Prompt Screenshot Transaction Link
Deposit USDC "deposit 1 usdc to orderly network" image txn
Withdraw USDC "withdraw 1 usdc from orderly network" image N/A
Create Order "create a market order to buy 0.005 ETH at $2000" image N/A
Close Position "Close the position PERP_ETH_USDC" image N/A

Docs

My changes do not require a change to the project documentation.

Checklist

  • I have tested this change and added the relevant screenshots to the PR description
  • I updated the README if necessary to include the new plugin, wallet, chain, etc.

…r methods

- Introduced `withdrawOrderly` method to facilitate USDC withdrawals from the Orderly Network.
- Updated `DepositOrderlyParams` and added `WithdrawOrderlyParams` for better parameter handling.
- Enhanced helper functions for key management and network interactions, including public key retrieval and signing requests.
- Added new utility functions for handling cryptographic operations.
- Updated package dependencies to support new features.
… handling

- Added `createOrderOrderly` method to facilitate order creation at the Orderly Network.
- Introduced new parameters for order creation, including `order_amount`, `visible_quantity`, and `client_order_id`.
- Enhanced error handling in withdrawal and deposit methods for better user feedback.
- Added utility functions to fetch allowed symbols and USDC token information based on network.
- Updated `CreateOrderOrderlyParams` and added new parameter classes for improved validation.
…arameter validation

- Implemented `closePositionOrderly` method to allow users to close positions on the Orderly Network.
- Introduced `ClosePositionOrderlyParams` for better parameter handling, ensuring position quantity is validated.
- Added `getPosition` helper function to retrieve current position details based on network and account ID.
- Updated existing parameter classes to improve clarity and maintainability.
- Added new dependencies for `@orderly.network/types`, `tweetnacl`, and updated existing ones in the `orderly-network` plugin.
- Improved the structure of `package.json` for better readability.
- Updated `pnpm-lock.yaml` to reflect changes in package versions and dependencies, including the removal of unnecessary dependencies.
- Ensured compatibility with the latest versions of TypeScript and other related packages.
Copy link

changeset-bot bot commented Mar 23, 2025

⚠️ No Changeset found

Latest commit: 754b02f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…ce parameter handling

- Introduced `getBalanceHoldingsOrderly` method to retrieve user token holdings in Orderly Network.
- Added `GetUSDCBalanceHoldingsOrderlyParams` for improved parameter validation.
- Refactored existing methods to utilize pattern matching for better error handling and code clarity.
- Updated utility functions for fetching USDC addresses and vault addresses using pattern matching.
… handling

- Added checks to ensure a position exists and has a non-zero quantity before attempting to close it.
- Updated the order creation logic to use the position details directly instead of parameters for better accuracy.
- Removed redundant validation from `ClosePositionOrderlyParams` to streamline parameter handling.
…mount restrictions

- Added validation to prevent the use of order_amount for BUY orders in Futures mode, prompting users to use order_quantity instead.
- Updated parameter descriptions to clarify usage for order_quantity and order_amount in the context of MARKET orders.
@wolfcito wolfcito changed the title feat(orderly-network): implement plugin for Orderly with deposit, withdrawal, order creation, and close position functionality [WIP] feat(orderly-network): implement plugin for Orderly with deposit, withdrawal, order creation, and close position functionality Mar 24, 2025
wolfcito and others added 9 commits March 24, 2025 12:54
- Added advanced usage section in README for integrating with the ERC20 plugin.
- Updated tools list in README to include specific USDC operations.
- Introduced package-lock.json for the vercel-ai example to manage dependencies effectively.
…nges

- Replaced the import of modeGovernance with orderlynetwork in the README example for better clarity on plugin usage.
- Ensured the documentation aligns with the latest integration practices for the ERC20 plugin.
- Added new address mappings for chain ID 34443 in both getEvmUSDCAddress and getEvmVaultAddress functions.
- Updated the default address returned for both functions to ensure consistency for the specified chain.
@0xaguspunk 0xaguspunk merged commit 94b1285 into goat-sdk:main Mar 25, 2025
2 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.

2 participants