Skip to content

Commit cd78770

Browse files
author
xgram
committed
Add Xgram swap support
1 parent c60b647 commit cd78770

36 files changed

+5546
-1505
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: review-api-requirements
3+
description: Reviews exchange plugins for compliance with provider API requirements. Use when reviewing swap or fiat plugin implementations.
4+
---
5+
6+
Review the branch/pull request for compliance with Edge exchange provider API requirements.
7+
8+
## Context Expected
9+
10+
You will receive:
11+
- Repository name (edge-exchange-plugins)
12+
- Branch name
13+
- List of changed files to review
14+
15+
## How to Review
16+
17+
1. Read the API requirements document: `docs/API_REQUIREMENTS.md`
18+
2. Read the changed plugin files provided in context
19+
3. For each requirement in the API doc, verify the plugin implementation meets it (where applicable)
20+
4. Report findings with specific file:line references
21+
22+
## Key Areas to Check
23+
24+
- Chain and token identification (using identifiers, not just ticker symbols)
25+
- Order ID extraction and status page URI
26+
- Error handling (all errors returned at once, processed in priority order)
27+
- Bi-directional quoting support (from, to, max)
28+
- Transaction status API integration
29+
- Account activation handling (XRP, HBAR, etc.)
30+
- Limit error amounts in correct denomination
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: review-chain-mapping
3+
description: Reviews exchange plugins for correct chain mapping implementation. Use when reviewing plugins that add or modify chain support.
4+
---
5+
6+
Review the branch/pull request for correct chain mapping implementation.
7+
8+
## Context Expected
9+
10+
You will receive:
11+
- Repository name (edge-exchange-plugins)
12+
- Branch name
13+
- List of changed files to review
14+
15+
## How to Review
16+
17+
1. Read the chain mapping documentation: `docs/CHAIN_MAPPING_SYNCHRONIZERS.md`
18+
2. Read the changed plugin and mapping files provided in context
19+
3. Verify the mapping implementation follows the documented patterns
20+
4. Report findings with specific file:line references
21+
22+
## Key Areas to Check
23+
24+
- Source mappings in `scripts/mappings/` (provider code → Edge plugin ID)
25+
- Generated runtime mappings in `src/mappings/` (Edge plugin ID → provider code)
26+
- Synchronizer implementation if adding a new provider
27+
- New chains mapped correctly (not left as `null` without reason)
28+
- EVM chains using `chainId` where applicable
29+
- Mapping file imported and used correctly in plugin code
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: review-edge-exchange-plugins
3+
description: Orchestrator that launches exchange plugin review subagents. Use when reviewing exchange plugin implementations.
4+
---
5+
6+
Review the branch/pull request for compliance with Edge exchange plugin conventions.
7+
8+
## Context Expected
9+
10+
You will receive:
11+
- Repository name (edge-exchange-plugins)
12+
- Branch name
13+
- List of changed files to review
14+
15+
## Orchestration
16+
17+
Launch ALL FOUR sub-agents in parallel, passing them the full context you received:
18+
19+
1. **review-api-requirements** - Reviews for compliance with `docs/API_REQUIREMENTS.md`
20+
2. **review-chain-mapping** - Reviews chain mapping with `docs/CHAIN_MAPPING_SYNCHRONIZERS.md`
21+
3. **review-plugin-creation** - Reviews plugin structure with `docs/CREATING_AN_EXCHANGE_PLUGIN.md`
22+
4. **review-exchange-bugs** - Reviews for common bugs and poor patterns
23+
24+
## Output
25+
26+
Collect findings from all sub-agents and consolidate into a single report organized by category:
27+
28+
- **API Requirements Issues** - From review-api-requirements
29+
- **Chain Mapping Issues** - From review-chain-mapping
30+
- **Plugin Structure Issues** - From review-plugin-creation
31+
- **Bug Patterns** - From review-exchange-bugs
32+
33+
For each finding, include specific file:line references. Omit categories with no findings.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
name: review-exchange-bugs
3+
description: Reviews exchange plugins for common bugs and poor patterns. Use when reviewing any exchange plugin changes.
4+
---
5+
6+
Review the branch/pull request for common bugs and poor patterns specific to Edge exchange plugins.
7+
8+
## Context Expected
9+
10+
You will receive:
11+
- Repository name (edge-exchange-plugins)
12+
- Branch name
13+
- List of changed files to review
14+
15+
## How to Review
16+
17+
1. Read the changed plugin files provided in context
18+
2. Check for each bug pattern listed below
19+
3. Report findings with specific file:line references
20+
21+
---
22+
23+
## Separate Handlers for Different Asset Types
24+
25+
When adding support for a new asset type (like Zcash), create a separate handler block rather than extending existing UTXO logic:
26+
27+
```typescript
28+
// Incorrect - mixing ZEC with general UTXO handling
29+
} else {
30+
// UTXO block
31+
if (fromWallet.currencyInfo.pluginId === 'zcash') {
32+
// ZEC-specific code mixed in
33+
}
34+
// ... rest of UTXO handling
35+
}
36+
37+
// Correct - separate block for ZEC
38+
} else if (fromWallet.currencyInfo.pluginId === 'zcash') {
39+
// ZEC-specific handling with all necessary checks
40+
if (thorAddress == null) throw new SwapCurrencyError(...)
41+
if (fromTokenId != null) throw new SwapCurrencyError(...)
42+
// ... ZEC-specific logic
43+
} else {
44+
// General UTXO handling
45+
}
46+
```
47+
48+
While Zcash is UTXO-based under the hood, Edge treats it differently. Keeping handlers separate makes code easier to maintain and reduces the chance of missing required checks.
49+
50+
---
51+
52+
## Include All Validation Checks in New Handlers
53+
54+
When creating a new asset handler by copying from an existing one, copy ALL validation checks:
55+
56+
```typescript
57+
// UTXO block has token rejection check
58+
} else {
59+
if (fromTokenId != null) {
60+
throw new SwapCurrencyError(swapInfo, request)
61+
}
62+
// ... rest of UTXO logic
63+
}
64+
65+
// New ZEC block - MUST include the same check
66+
} else if (fromWallet.currencyInfo.pluginId === 'zcash') {
67+
if (fromTokenId != null) {
68+
throw new SwapCurrencyError(swapInfo, request) // Don't forget this!
69+
}
70+
// ... ZEC logic
71+
}
72+
```
73+
74+
Missing validation checks can allow unsupported swap types to proceed.
75+
76+
---
77+
78+
## Remove Invalid Destination When Adding Support
79+
80+
If a previous commit blocked swaps to an asset, remove that block when adding destination support:
81+
82+
```typescript
83+
// Previous state: ZEC swaps blocked
84+
INVALID_CURRENCY_CODES.to.zcash = ['ZEC']
85+
86+
// Adding ZEC receive support but forgetting to remove the block:
87+
// New ZEC receive handler (lines 388-392) NEVER RUNS because
88+
// checkInvalidCodes throws SwapCurrencyError first (lines 129-135)
89+
90+
// Correct: Remove the invalid code entry when adding support
91+
// Delete: INVALID_CURRENCY_CODES.to.zcash = ['ZEC']
92+
```
93+
94+
Always trace the swap flow to ensure new handlers are actually reachable.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: review-plugin-creation
3+
description: Reviews exchange plugins for correct structure and conventions. Use when reviewing new plugins or significant plugin modifications.
4+
---
5+
6+
Review the branch/pull request for correct plugin structure and conventions.
7+
8+
## Context Expected
9+
10+
You will receive:
11+
- Repository name (edge-exchange-plugins)
12+
- Branch name
13+
- List of changed files to review
14+
15+
## How to Review
16+
17+
1. Read the plugin creation guide: `docs/CREATING_AN_EXCHANGE_PLUGIN.md`
18+
2. Read the changed plugin files provided in context
19+
3. Verify the plugin follows the documented structure and conventions
20+
4. Report findings with specific file:line references
21+
22+
## Key Areas to Check
23+
24+
- Plugin metadata (`swapInfo` with correct fields)
25+
- Init options with cleaners
26+
- Quote fetching (address retrieval, quote directions, error mapping)
27+
- Amount conversions using `denominationToNative`/`nativeToDenomination`
28+
- Transaction info (`EdgeSpendInfo` or `MakeTxParams`)
29+
- API response validation with cleaners
30+
- Plugin registration in `src/index.ts`
31+
- Correct plugin location (`src/swap/central/` vs `src/swap/defi/`)

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Unreleased
44

5+
## 2.40.4 (2026-01-15)
6+
7+
- fixed: Fix Rango EVM approval address
8+
9+
## 2.40.3 (2025-12-29)
10+
11+
- fixed: Fix Rango EVM approval address
12+
- fixed: Add pendingTxs to createEvmApprovalEdgeTransactions
13+
514
## 2.40.2 (2025-12-10)
615

716
- added: Added new mappings to all swap providers.

0 commit comments

Comments
 (0)