Skip to content

Conversation

@TaprootFreak
Copy link
Collaborator

Summary

  • Add new swap command to DfxDexAdapter for cross-asset liquidity acquisition via DEX
  • Unlike purchase (same asset), swap allows converting one asset to another (e.g., USDC → EURC)
  • Enables automatic EURC liquidity provisioning using USDC via Uniswap

Changes

  • Add SWAP = 'swap' to DfxDexAdapterCommands enum
  • Implement swap() method that:
    • Takes sourceAsset from action params (e.g., "USDC")
    • Uses targetAsset from rule (e.g., "EURC")
    • Checks available source liquidity before swap
    • Calls dexService.purchaseLiquidity() with different reference/target assets
  • Add param validation for sourceAsset parameter
  • Reuse checkSellPurchaseCompletion for order tracking

Usage

Action params: {"sourceAsset": "USDC"}

Example LiquidityManagementAction:

INSERT INTO liquidity_management_action (system, command, params)
VALUES ('DfxDex', 'swap', '{"sourceAsset":"USDC"}');

Example LiquidityManagementRule for EURC:

INSERT INTO liquidity_management_rule (
  status, context, targetAssetId, minimal, optimal, maximal,
  deficitStartActionId, redundancyStartActionId, delayActivation
) VALUES ('Active', 'Ethereum', 169, 1000, 5000, 20000,
  <new_action_id>, 99, 1);

Test plan

  • Deploy to dev environment
  • Create test action with {"sourceAsset": "USDC"}
  • Create test rule for EURC with deficit action
  • Verify swap executes correctly via Uniswap pool
  • Check order completion tracking works

Add new 'swap' command for cross-asset liquidity acquisition via DEX.
Unlike 'purchase' (same asset), 'swap' allows converting one asset to
another, e.g., USDC → EURC via Uniswap.

- Add SWAP to DfxDexAdapterCommands enum
- Implement swap() method with source asset from params
- Add param validation for sourceAsset parameter
- Reuse checkSellPurchaseCompletion for order tracking

Usage: Action params {"sourceAsset": "USDC"} with rule targetAsset EURC
will swap available USDC to EURC via the configured DEX pool.
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🤖 PR Review Bot

⚠️ Security: 0 critical, 67 high vulnerabilities


This is an automated review. Please address the issues above.

Comment on lines 20 to +23
PURCHASE = 'purchase',
SELL = 'sell',
WITHDRAW = 'withdraw',
SWAP = 'swap',
Copy link
Member

Choose a reason for hiding this comment

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

Use purchase/sell instead of swap (same functionality), add a trade asset parameter

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.

3 participants