Skip to content

Add TRON vault swap for Chainflip #413

@0xh3rman

Description

@0xh3rman

Context

Chainflip has added Tron support (native TRX and USDT-TRC20 as source assets), currently live on the Perseverance testnet. Add Tron as a Chainflip swap source in the swap provider layer.

Key difference from EVM

Tron vault swaps are not a Vault contract call (no xSwapNative / xSwapToken). Instead:

  • Direct transfer of TRX/USDT to the Chainflip Vault address.
  • Encoded swap parameters attached as the transaction note (the data / memo field).
  • No TRC-20 approval needed — it's a transfer, not transferFrom.
  • Cheaper: no protocol fetch tx, so no ingress fee. Recommended swap method on Tron.

Conceptually closer to the Bitcoin deposit-with-data model than the EVM contract-call model.

Flow

  1. Request encoding via broker_request_swap_parameter_encoding with "chain": "Tron" in both source_asset and extra_parameters; refund address must be a valid Tron address.
  2. Response: { chain, calldata, value, to, note, source_token_address? }.
  3. Build tx → attach note to the data field → sign → broadcast.

Tasks

  • Add Tron as a Chainflip source asset (TRX + USDT-TRC20) in provider config
  • Wire broker_request_swap_parameter_encoding request for chain: Tron
  • Parse response fields (value, to, note, calldata, source_token_address)
  • TRX path: build TransferContract to Vault, value in sun, set note as tx data
  • USDT-TRC20 path: build TriggerSmartContracttransfer(address,uint256) to Vault, set note as tx data (no approval step)
  • Handle Tron address encoding (base58 T… ↔ 21-byte 0x41… hex) — RPC returns to in hex
  • Encode broker commission + affiliates (g1) via broker_commission in the request → lands in note cfParameters
  • Reuse existing Tron tx-building / signing in the Rust core
  • Test on Perseverance with the testnet Vault address; verify the swap is witnessed and egresses

⚠️ Do not hand-roll

Don't hand-encode the note / cfParameters — incorrectly encoded params can lose funds. Always use the broker RPC to produce it.

Links

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions