feat: perpetuals using orderly #11589
Draft
+105,759
−433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds perpetuals trading functionality to ShapeShift using Orderly Network's SDK.
Key Implementation Details
Broker-Specific Accounts
Orderly Network uses broker-specific accounts. Each
(wallet_address + broker_id)pair creates a unique, isolated account:keccak256(wallet_address + keccak256(broker_id))The broker ID is configured via
VITE_ORDERLY_BROKER_ID(default:"shapeshift").Wallet Adapter Architecture
The
OrderlyWalletAdapterbridges ShapeShift's wallet system to Orderly's SDK:NativeWalletProviderEIP-1193 adapterrdnsidentifier to find the correct providerBug Fix: MIPD Provider Selection
Fixed an issue where MetaMask (and other MIPD wallets) would fail with
"error getting address from wallet"errors.Root Cause: The original code grabbed the first available MIPD provider instead of the specific wallet the user connected with.
Fix: Now uses the
rdns(Reverse Domain Name System identifier likeio.metamask) stored during wallet connection to find the exact provider.Files Changed
src/pages/Perpetuals/PerpetualsPage.tsx- Main perpetuals trading page using Orderly SDKsrc/pages/Perpetuals/OrderlyWalletAdapter.tsx- Bridges ShapeShift wallet to Orderly SDKsrc/pages/Perpetuals/NativeWalletProvider.ts- EIP-1193 provider adapter for native/mobile walletsIssue (if applicable)
closes #
Risk
Medium Risk - New feature behind
VITE_FEATURE_ORDERLY_PERPETUALSfeature flag.Testing
Engineering
VITE_FEATURE_ORDERLY_PERPETUALS=trueVITE_ORDERLY_BROKER_ID=shapeshift(or your test broker)/perpetuals[Orderly] Wallet state updatedwith correct accountsOperations
Screenshots (if applicable)