-
Notifications
You must be signed in to change notification settings - Fork 42
Sam/docs #400
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
base: master
Are you sure you want to change the base?
Conversation
docs/guides/adding-new-exchange.md
Outdated
| ```typescript | ||
| async fetchSwapQuote(request: EdgeSwapRequest): Promise<EdgeSwapQuote> { | ||
| // 1. Validate supported currencies | ||
| const { fromCurrencyCode, toCurrencyCode } = request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pluginId,tokenId not currencyCode
| if (lt(quote.fromAmount, MIN_AMOUNT)) { | ||
| throw new SwapBelowLimitError(swapInfo, MIN_AMOUNT) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The below and above limit errors should come from the API call, not hard coded.
| throw new SwapBelowLimitError(swapInfo, MIN_AMOUNT) | ||
| } | ||
|
|
||
| // 5. Return EdgeSwapQuote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also validate region and supported assets. All should be validated via API response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API should return all errors in an array and errors should be surfaced with this priority.
- region restriction
- asset support
- min/max amount
docs/guides/adding-new-exchange.md
Outdated
| ```typescript | ||
| const currencyMap: StringMap = { | ||
| USDT: "USDT20", // Your API code | ||
| BTC: "BTC", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO. do not even mention allowing currency codes. all plugins should use pluginId, tokenId. show example of a hard coded mapping of partner chain identifiers to edge pluginIds.
Note, partners will also be required to support EVM chainIds so include an example of how to find the Edge pluginId based on an EVM chain id.
| ### Currency Code Validation | ||
|
|
||
| ```typescript | ||
| // Check supported currencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use pluginId, tokenId. do not even mention currency codes
|
|
||
| This document tracks deprecated APIs in edge-core-js that are still used in the codebase. These should be migrated when possible. | ||
|
|
||
| ## Deprecated APIs Currently in Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of currencyCode is deprecated as well
| request.fromWallet.currencyInfo.defaultSettings?.otherSettings?.chainId; | ||
|
|
||
| // Convert tokenId to contract address | ||
| const contractAddress = request.fromTokenId; // tokenId IS the contract address for EVM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not always, provide a helper function for converstion to/from based on pluginId type. evm vs cosmos vs tron, etc.
|
|
||
| // For XRP, XLM, etc. | ||
| if (tag != null) { | ||
| spendInfo.spendTargets[0].uniqueIdentifier = tag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the convention is now .memos[]
|
|
||
| // Insufficient liquidity | ||
| if (response.error === "INSUFFICIENT_LIQUIDITY") { | ||
| throw new InsufficientLiquidityError(swapInfo, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hallucination?
| expirationDate?: Date; // Required for fixed quotes | ||
|
|
||
| // For fixed quotes | ||
| guaranteedAmount?: string; // The guaranteed output amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hallucination?
- Create AGENTS.md with build commands and code style guidelines - Add TypeScript style guide covering imports, types, and conventions - Document swap plugin architecture patterns and best practices - Capture critical business rules for DEX wallet requirements - Create step-by-step guide for adding new exchanges - Track deprecated APIs that need migration - Reference Edge company-wide conventions - Update README with quick links to key documentation This documentation provides a knowledge base for both human developers and AI coding assistants working on the edge-exchange-plugins project.
- Document DEBUG_EXCHANGE env setting in edge-react-gui - Present debug server as recommended development approach - Clarify difference between debug server and direct linking methods - Update debugging tips to emphasize hot-reload benefits
- Document chain support mapping and parameter access patterns - Emphasize critical fee estimation via transaction creation - Add destination tag/memo handling requirements - Clarify fixed vs variable quote specifications - Document reverse quote implementation - Expand error handling requirements with specific examples - Add tokenId to contract address mapping explanation - Include best practices for all new requirements
- Remove incorrect usage of deprecated defaultSettings for chain ID - Clarify that pluginId uniquely identifies the network - Update type annotations to use proper Edge types (EdgeTokenId) - Explain that tokenId is null for native/mainnet tokens - Document EdgeCurrencyWallet structure with currencyInfo/currencyConfig - Emphasize pluginId as the primary chain identifier
- Remove EVM-specific references for tokenId - Clarify tokenId applies to any chain with tokens - Explain tokenId format varies by chain type - Use more generic language (native currency vs tokens)
- Add comprehensive plugin system fundamentals section - Document how plugins attach to edge-core-js via factory pattern - Explain EdgeCorePluginOptions and plugin lifecycle - Correct API usage based on actual Edge types: - Fix currency code access (must be derived from wallet/tokenId) - Update to use networkFees array instead of networkFee - Correct memo API to use memos array - Fix EdgeSwapQuote interface properties - Add getCurrencyCode helper function example - Clarify factory function signatures and registration
- Update fetchSwapQuote to use pluginId/tokenId → symbol mapping - Add comprehensive mapping examples for chains and tokens - Include EVM chain ID mapping for exchanges that need it - Emphasize API-driven validation over hardcoded values - Fix duplicate section in prerequisites - Update error handling to reference assets instead of currencies
- Add comprehensive error handling section with priority order - Show API-driven validation instead of hardcoded values - Document error priority: region → asset support → limits - Update quote request pattern to use API validation - Replace currency validation with asset validation via API
- Add explicit section on API-driven validation - Show BAD vs GOOD examples of hardcoded vs API validation - Update best practices to prioritize API validation - Clarify what exchange APIs should return - Reinforce no hardcoded limits or asset lists
- Replace currency code helpers with exchange symbol mapping - Update error throwing examples to use request object - Fix deprecated currencyCode field in networkFee - Ensure consistent use of pluginId/tokenId terminology
- Remove fictional apiResponse properties that don't exist - Add real examples from SideShift, ChangeNow, and LetsExchange - Emphasize that each exchange has unique API response formats - Show actual error handling patterns from existing plugins - Update testing guide to reflect API-specific validation Addresses PR feedback about 'hallucination' in documentation
|
|
||
| ### DEX Same-Wallet Requirement | ||
|
|
||
| - DEX swaps happen in a single transaction on-chain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true. Most DEXs can have different source and dest addresses. Only the XRP DEX and the Fantom/Sonic bridge require this
| async fetchSwapQuote(request: EdgeSwapRequest): Promise<EdgeSwapQuote> { | ||
| // Validate same wallet requirement for DEX | ||
| if (request.fromWallet !== request.toWallet) { | ||
| throw new Error(`${swapInfo.displayName} requires same wallet for swap`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a new swap error specifically for this. See SwapAddressError in fantomSonicUpgrade.ts
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneDescription
none