Skip to content

Conversation

@gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Dec 2, 2025

Description

Does what it says on the box

TODO:

  • TRX sends
  • TRC sends
  • TRC receives
  • TRX receives

Issue (if applicable)

closes #11264

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

⚠️ FOR TRC-20s, make sure your account is well-funded in TRX (say, 20 or more). Gas estimates in the TRON domain are not properly done yet, and many TRC-20 Txs will either fail at broadcast time, or will broadcast but burn gas and fail (happens in app atm if you try to send an ERC-20 with an account without enough TRX, you'll just burn gas, or in the case of THOR broadcast will fail)

  • Able to trade from TRX, supported TRON tokens
  • Able to trade to TRX, supported TRON tokens (basically only USDT)
  • Able to interact with TRON Pool in LP

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

  • Able to trade to TRX, supported TRON tokens

  • Able to trade from TRX, supported TRON tokens

  • Able to interact with TRON Pool in LP

Summary by CodeRabbit

  • New Features

    • Added TRON support to Thorchain swapper (TRX and TRC20): unsigned transaction creation, fee estimation, and execution flow.
    • Exposed TRON-specific endpoints and executeTronTransaction path.
    • Added memo support for TRON transactions.
  • Configuration

    • New TRON node URL configuration option for the swapper.
  • Documentation

    • Comprehensive TRON integration docs detailing fee-estimation caveats, known issues, and integration guidance.
  • Assets

    • Updated tradable asset map to include TRON assets (TRX, TRC20).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

📝 Walkthrough

Walkthrough

Adds TRON support to Thorchain swapper: unsigned TRON tx construction (with memo), fee estimation (TRC20 energy, TRX bandwidth + memo), new tron utils and endpoints, minor Tron adapter/type changes, asset map updates, config entry, and documentation on TRON fee-estimation issues.

Changes

Cohort / File(s) Summary
Documentation
packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md
New doc describing TRON fee-estimation problems, real-world cost breakdowns, evidence, and a prioritized TODO to fix estimation, UX, and error handling.
Chain adapter & types
packages/chain-adapters/src/tron/TronChainAdapter.ts, packages/chain-adapters/src/tron/types.ts
Add memo?: string to build input; reuse single TronWeb instance; attach memo to built tx when present; keep TRC20 feeLimit; add TODOs for improved fee estimation.
ThorchainSwapper core & endpoints
packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts, packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
Add executeTronTransaction delegating to sign-and-broadcast; expose getUnsignedTronTransaction and getTronTransactionFees via endpoints; import tron utils.
Thorchain-utils: TRON modules
packages/swapper/src/thorchain-utils/tron/*
packages/swapper/src/thorchain-utils/tron/getThorTxData.ts, .../getUnsignedTronTransaction.ts, .../getTronTransactionFees.ts, .../index.ts
New modules: fetch Thor inbound vault (getThorTxData); compose unsigned TRON tx with memo and protocol fees (getUnsignedTronTransaction); estimate TRON fees (energy for TRC20, bandwidth+memo for TRX) with conservative fallbacks (getTronTransactionFees); barrel export.
Route quoting
packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
Replace TRON hard-fail with per-route Promise.allSettled construction of route quotes (placeholder network fee), filter successful routes, and consolidate errors when none succeed.
Exports & config
packages/swapper/src/thorchain-utils/index.ts, packages/swapper/src/types.ts
Export tron from thorchain-utils index; add VITE_TRON_NODE_URL: string to SwapperConfig.
Build utilities / assets
scripts/generateTradableAssetMap/utils.ts, generated assets
Add TRON to Chain enum and mappings, support TRC20 token standard and TRON fee-asset resolution for generated tradable assets.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Swapper as ThorchainSwapper
    participant Utils as Tron Utils
    participant Daemon as Thor Daemon
    participant Adapter as TronChainAdapter
    participant TronWeb as TronWeb

    rect rgb(223,242,225)
    Note over Client,Swapper: Build unsigned TRON transaction
    Client->>Swapper: getUnsignedTronTransaction(trade)
    Swapper->>Utils: getUnsignedTronTransaction(...)
    Utils->>Daemon: getInboundAddressDataForChain(sellAsset)
    Daemon-->>Utils: { vault }
    Utils->>Adapter: buildSendApiTransaction({ to:vault, value, memo?, contractAddress? })
    Adapter-->>Utils: unsigned TronSignTx
    Utils-->>Swapper: TronSignTx
    Swapper-->>Client: unsigned transaction
    end

    rect rgb(232,230,255)
    Note over Client,Swapper: Estimate TRON fees
    Client->>Swapper: getTronTransactionFees(trade)
    Swapper->>Utils: getTronTransactionFees(...)
    Utils->>TronWeb: getChainParameters()
    TronWeb-->>Utils: energyPrice, bandwidthPrice
    alt TRC20 transfer (contractAddress)
        Utils->>TronWeb: triggerConstantContract(transfer ABI) → energyUsed
        TronWeb-->>Utils: energyUsed
        Utils->>Utils: fee = energyUsed * energyPrice
    else TRX transfer (no contract)
        Utils->>Adapter: build sample transfer + addUpdateData(memo) → txBytes
        Adapter-->>Utils: txBytes
        Utils->>Utils: fee = txBytes * bandwidthPrice
    end
    Utils-->>Swapper: fee (Sun)
    Swapper-->>Client: fee estimate
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Files/areas needing extra attention:
    • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts — dual-path fee estimation, TronWeb calls, fallbacks, and unit conversions.
    • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts — assembling amounts, protocol fees, memo validation, contractAddress logic.
    • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts — changed control flow to Promise.allSettled and consolidated error reporting.
    • packages/chain-adapters/src/tron/TronChainAdapter.ts — TronWeb instance reuse and memo attachment to tx raw data.
    • Config/types and exports: packages/swapper/src/types.ts, packages/swapper/src/thorchain-utils/index.ts.

Possibly related PRs

  • feat: sun.io swapper #11261 — touches TRON integration surface (fee estimation and unsigned transaction utilities); likely overlapping logic and tests.
  • feat: support tron #11217 — related TRON adapter and type changes (memo handling, fee-estimation notes); likely direct code-level overlap.

Suggested reviewers

  • gomesalexandre

Poem

"🐰 I hopped through bytes to find a vault,

Memos tucked in hex, never at fault.
Energy and bandwidth I weigh,
Fees and bytes mark the way,
A happy rabbit says: TRON, let's vault!"

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: thorchain tron support' clearly and concisely summarizes the main change—adding TRON support to Thorchain integration.
Linked Issues check ✅ Passed The pull request successfully implements THORChain TRON support as required by issue #11264, adding TRX/TRC20 send/receive functionality with fee estimation and memo support.
Out of Scope Changes check ✅ Passed All changes are directly related to TRON-Thorchain integration. No unrelated or out-of-scope modifications detected in the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat_thor_tron

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f37fd68 and c63f0b0.

📒 Files selected for processing (1)
  • packages/swapper/src/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/swapper/src/types.ts

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • TRC-20: Entity not found: Issue - Could not find referenced Issue.
  • ERC-20: Entity not found: Issue - Could not find referenced Issue.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

gomesalexandre and others added 7 commits December 3, 2025 01:27
- Add executeTronTransaction method to ThorchainSwapper for transaction execution
- Implement proper TRON fee estimation using real-time network prices:
  * TRC20: triggerConstantContract for energy calculation (~27 TRX)
  * TRX: actual bandwidth calculation with memo overhead (~0.3-0.5 TRX)
- Add VITE_TRON_NODE_URL to SwapperConfig
- Set networkFeeCryptoBaseUnit to undefined for rate quotes (calculated at execution time)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Reuse single TronWeb instance for transaction building
- Remove manual fee_limit restoration (addUpdateData preserves it)
- Clean up transaction flow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…t address extraction

- Increase feeLimit to 150 TRX for TRC20 transfers with memo (covers energy + bandwidth)
- Use contractAddressOrUndefined utility consistently across tron utils
- Research shows feeLimit only covers energy, bandwidth is burned separately

Note: TRC20 transfers require ~64k-130k energy + ~345 bandwidth
With memo, bandwidth increases. Account needs TRX to burn for bandwidth if
free daily bandwidth (600 units) is exhausted.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Critical fix for TRC20 bandwidth error:
- Add txLocal: true to addUpdateData() call
- This preserves fee_limit field (150 TRX for TRC20 with memo)
- Without txLocal, addUpdateData calls wallet/getsignweight API which
  returns transaction WITHOUT fee_limit, causing "Account resource insufficient" error

Root cause: TronWeb's addUpdateData() loses fee_limit when using remote API.
Solution: txLocal: true forces local transaction recreation that preserves all fields.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…sues

Testing theory: txLocal: true might cause transaction validation issues.
Successful Thorchain TRC20 txs on-chain have both fee_limit and memo preserved,
suggesting addUpdateData() works correctly without txLocal option.

On-chain evidence:
- TX 78055EA7: fee_limit 100 TRX, has memo, SUCCESS
- TX BD77F95E: fee_limit 15.6 TRX, has memo, SUCCESS

If this doesn't work, need to investigate wallet balance or other issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
After analyzing SwapKit's TRON implementation and successful Thorchain TRC20 txs:
- Standard feeLimit is 100 TRX (not 150)
- addUpdateData() without txLocal is correct
- Transaction structure matches working implementations

Root cause of BANDWIDTH_ERROR confirmed:
- Account has 0.25 TRX liquid (frozen TRX cannot pay fees)
- Transaction needs ~7-8 TRX liquid for energy + memo fee
- Error is misleading - it's insufficient liquid TRX, not bandwidth

Code is correct. Issue is account balance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created TRON_FEE_ESTIMATION_ISSUES.md documenting critical problems:
- getFeeData() returns fixed 0.268 TRX for ALL transactions
- TRC20 transfers actually cost 6-15 TRX (24-56x underestimate)
- Causes misleading UI fees and on-chain transaction failures
- Users lose TRX in partial execution before OUT_OF_ENERGY errors

Added TODO comments in TronChainAdapter.getFeeData() with:
- Detect TRC20 vs TRX using contractAddress
- Use existing estimateTRC20TransferFee() method
- Account for memo overhead (1 TRX memo fee + bandwidth)
- Build actual transaction for accurate size estimation

Evidence includes failed txs and cost analysis.
Priority: HIGH - users losing funds on failed transactions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gomesalexandre gomesalexandre marked this pull request as ready for review December 2, 2025 23:44
@gomesalexandre gomesalexandre requested a review from a team as a code owner December 2, 2025 23:44
Created THORCHAIN_TRON_INTEGRATION.md covering:
- Architecture (UTXO-style pattern, not EVM)
- Implementation details for all components
- Memo handling via addUpdateData()
- Cost breakdown (energy, bandwidth, memo fee)
- Successful on-chain transaction examples
- Common issues and solutions
- Testing checklist
- Comparison with SwapKit implementation

Documents that implementation is correct and matches working integrations.
Main issue is inherited getFeeData() returning wrong fees for TRC20.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/chain-adapters/src/tron/TronChainAdapter.ts (1)

358-387: TRC20 fee estimation in getFeeData() remains critically inaccurate

getFeeData() delegates entirely to this.providers.http.getPriorityFees() (which returns a fixed ~0.268 TRX for all transactions) and ignores the _input payload, making it unable to distinguish TRX transfers from TRC20 transfers or account for memos. Real TRC20 transfers with memos cost 7.8–14.4 TRX, resulting in a 30–56x underestimation that leads to failed on-chain transactions and users losing TRX.

The necessary helpers already exist in unchained-client (estimateTRC20TransferFee(), estimateFees(), getChainPrices()) and a correct implementation has been built in getTronTransactionFees (used by THORChain swaps). getFeeData() should either adopt that approach or be updated to use the existing helpers to detect TRC20 transfers and build accurate transactions with memo support.

Given that TRON is now exposed via THORChain flows and the detailed analysis in TRON_FEE_ESTIMATION_ISSUES.md documents real failed transactions and user losses, this should be prioritized as a follow-up to prevent further transaction failures.

🧹 Nitpick comments (3)
packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md (1)

160-201: Tidy up markdown to satisfy linters

To clear the current markdown/language lint warnings:

  • Line 169: add a language to the fenced code block, e.g. ```text instead of plain ``` to satisfy MD040.
  • Lines 198–200: consider wrapping the bare URLs in markdown links (e.g. [TRON Resource Model](https://developers.tron.network/docs/resource-model)) to satisfy MD034.
  • Around line 160: you can make the “Should be:” section a complete sentence (“Error message should be:”) if you want to silence the style warning.

Purely cosmetic, but will keep the docs lint‑clean.

packages/chain-adapters/src/tron/TronChainAdapter.ts (1)

175-191: Memo-aware TRON transaction building looks good

The refactor to destructure memo from chainSpecific, create a single TronWeb instance per call, and then conditionally apply addUpdateData(txData, memo, 'utf8') after building either TRC20 or TRX transactions is sound. It centralizes memo handling and should correctly trigger the network’s memo fee behavior for THORChain swaps.

If this path becomes hot, you might eventually consider promoting the TronWeb instance to a class-level dependency instead of re‑instantiating it per transaction, but that’s an optimization, not a blocker.

Also applies to: 195-207, 236-239

packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts (1)

444-463: Consider simplifying the synchronous route mapping.

The route creation is entirely synchronous (no await needed), yet it's wrapped in Promise.allSettled. While this maintains consistency with EVM/UTXO cases, it adds unnecessary async overhead.

The current approach works correctly and maintains pattern consistency. If you prefer simplifying:

-      const maybeRoutes = await Promise.allSettled(
-        perRouteValues.map((route): Promise<T> => {
-          const memo = getMemo(route)
-
-          // For rate quotes (no wallet), we can't calculate fees
-          // Actual fees will be calculated in getTronTransactionFees when executing
-          const networkFeeCryptoBaseUnit = undefined
-
-          return Promise.resolve(
-            makeThorTradeRateOrQuote<ThorUtxoOrCosmosTradeRateOrQuote>({
-              route,
-              allowanceContract: '0x0', // not applicable to TRON
-              memo,
-              feeData: {
-                networkFeeCryptoBaseUnit,
-                protocolFees: getProtocolFees(route.quote),
-              },
-            }),
-          )
+      const routes = perRouteValues.map((route): T => {
+        const memo = getMemo(route)
+
+        return makeThorTradeRateOrQuote<ThorUtxoOrCosmosTradeRateOrQuote>({
+          route,
+          allowanceContract: '0x0', // not applicable to TRON
+          memo,
+          feeData: {
+            networkFeeCryptoBaseUnit: undefined,
+            protocolFees: getProtocolFees(route.quote),
+          },
         })
-      )
-
-      const routes = maybeRoutes.filter(isFulfilled).map(maybeRoute => maybeRoute.value)
-
-      if (!routes.length)
-        return Err(
-          makeSwapErrorRight({
-            message: 'Unable to create any routes',
-            code: TradeQuoteError.UnsupportedTradePair,
-            cause: maybeRoutes.filter(isRejected).map(maybeRoute => maybeRoute.reason),
-          }),
-        )
+      })
+
+      if (!routes.length)
+        return Err(
+          makeSwapErrorRight({
+            message: 'Unable to create any routes',
+            code: TradeQuoteError.UnsupportedTradePair,
+          }),
+        )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 10350b0 and ac80cfb.

⛔ Files ignored due to path filters (1)
  • packages/swapper/src/swappers/ThorchainSwapper/generated/generatedTradableAssetMap.json is excluded by !**/generated/**
📒 Files selected for processing (13)
  • packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md (1 hunks)
  • packages/chain-adapters/src/tron/TronChainAdapter.ts (4 hunks)
  • packages/chain-adapters/src/tron/types.ts (1 hunks)
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts (1 hunks)
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts (2 hunks)
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts (1 hunks)
  • packages/swapper/src/thorchain-utils/index.ts (1 hunks)
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts (1 hunks)
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1 hunks)
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts (1 hunks)
  • packages/swapper/src/thorchain-utils/tron/index.ts (1 hunks)
  • packages/swapper/src/types.ts (1 hunks)
  • scripts/generateTradableAssetMap/utils.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/chain-adapters/src/tron/types.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/chain-adapters/src/tron/TronChainAdapter.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/chain-adapters/src/tron/types.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/chain-adapters/src/tron/TronChainAdapter.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
**/swapper{s,}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

ALWAYS use makeSwapErrorRight for swapper errors with TradeQuoteError enum for error codes and provide detailed error information

Files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/chain-adapters/src/tron/types.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/chain-adapters/src/tron/TronChainAdapter.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
packages/swapper/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/**/*.ts: Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system
Use camelCase for variable and function names in the Swapper system
Use PascalCase for types, interfaces, and enums in the Swapper system
Use kebab-case for filenames in the Swapper system

Files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
packages/swapper/src/swappers/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/src/swappers/**/*.ts: Adhere to the Swapper directory structure: each swapper resides in packages/swapper/src/swappers// with required files (SwapperName.ts, endpoints.ts, types.ts, utils/constants.ts, utils/helpers.ts)
Validate inputs and log errors for debugging in Swapper system implementations
Swapper files must be located in packages/swapper/src/swappers/ directory structure and not placed outside this location
Avoid side effects in swap logic; ensure swap methods are deterministic and stateless

Files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
packages/swapper/src/swappers/*/*.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/src/swappers/*/*.ts: All swappers must implement the Swapper interface from packages/swapper/src/types.ts
Implement filterAssetIdsBySellable method to filter assets by supported chain IDs in the sell property
Implement filterBuyAssetsBySellAssetId method to filter assets by supported chain IDs in the buy property
Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution

Files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
packages/swapper/src/swappers/*/endpoints.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/src/swappers/*/endpoints.ts: All swapper API implementations must implement the SwapperApi interface from packages/swapper/src/types.ts
Reuse checkEvmSwapStatus utility for checking EVM swap status instead of implementing custom status checks

Files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
🧠 Learnings (37)
📓 Common learnings
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/ContractInteractionBreakdown.tsx:0-0
Timestamp: 2025-09-13T16:45:18.813Z
Learning: gomesalexandre prefers aggressively deleting unused/obsolete code files ("ramboing") rather than fixing technical issues in code that won't be used, demonstrating his preference for keeping codebases clean and PR scope focused.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/types.ts:7-7
Timestamp: 2025-09-10T15:34:29.604Z
Learning: gomesalexandre is comfortable relying on transitive dependencies (like abitype through ethers/viem) rather than explicitly declaring them in package.json, preferring to avoid package.json bloat when the transitive dependency approach works reliably in practice.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10503
File: .env:56-56
Timestamp: 2025-09-16T13:17:02.938Z
Learning: gomesalexandre prefers to enable feature flags globally in the base .env file when the intent is to activate features everywhere, even when there are known issues like crashes, demonstrating his preference for intentional global feature rollouts over cautious per-environment enablement.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10249
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:447-503
Timestamp: 2025-08-13T17:07:10.763Z
Learning: gomesalexandre prefers relying on TypeScript's type system for validation rather than adding defensive runtime null checks when types are properly defined. They favor a TypeScript-first approach over defensive programming with runtime validations.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/hooks/useActionCenterSubscribers/useThorchainLpDepositActionSubscriber.tsx:61-66
Timestamp: 2025-08-14T17:51:47.556Z
Learning: gomesalexandre is not concerned about structured logging and prefers to keep console.error usage as-is rather than implementing structured logging patterns, even when project guidelines suggest otherwise.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10413
File: src/components/Modals/FiatRamps/fiatRampProviders/onramper/utils.ts:29-55
Timestamp: 2025-09-02T14:26:19.028Z
Learning: gomesalexandre prefers to keep preparatory/reference code simple until it's actively consumed, rather than implementing comprehensive error handling, validation, and robustness improvements upfront. They prefer to add these improvements when the code is actually being used in production.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:396-402
Timestamp: 2025-08-14T17:55:57.490Z
Learning: gomesalexandre is comfortable with functions/variables that return undefined or true (tri-state) when only the truthy case matters, preferring to rely on JavaScript's truthy/falsy behavior rather than explicitly returning boolean values.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10783
File: src/context/ModalStackProvider/useModalRegistration.ts:30-41
Timestamp: 2025-10-16T11:14:40.657Z
Learning: gomesalexandre prefers to add lint rules (like typescript-eslint/strict-boolean-expressions for truthiness checks on numbers) to catch common issues project-wide rather than relying on code review to catch them.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.ts : Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/chain-adapters/src/tron/types.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/chain-adapters/src/tron/TronChainAdapter.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : All swappers must implement the Swapper interface from packages/swapper/src/types.ts

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/constants.ts : Register new swappers in packages/swapper/src/constants.ts with an entry in the swappers registry mapping SwapperName enum to swapper implementation

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.ts : Use PascalCase for types, interfaces, and enums in the Swapper system

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/**/*.ts : Adhere to the Swapper directory structure: each swapper resides in packages/swapper/src/swappers/<SwapperName>/ with required files (SwapperName.ts, endpoints.ts, types.ts, utils/constants.ts, utils/helpers.ts)

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/utils/constants.ts : Define supported chain IDs for each swapper in utils/constants.ts with both 'sell' and 'buy' properties following the pattern: SupportedChainIds type

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/endpoints.ts : All swapper API implementations must implement the SwapperApi interface from packages/swapper/src/types.ts

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/**/*.ts : Avoid side effects in swap logic; ensure swap methods are deterministic and stateless

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/index.ts : Export unique functions and types from packages/swapper/src/index.ts only if needed for external consumption

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution

Applied to files:

  • packages/swapper/src/types.ts
  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
  • packages/chain-adapters/src/tron/TronChainAdapter.ts
  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.ts : Use camelCase for variable and function names in the Swapper system

Applied to files:

  • packages/swapper/src/thorchain-utils/index.ts
📚 Learning: 2025-09-04T10:18:34.140Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10427
File: src/hooks/useActionCenterSubscribers/useSwapActionSubscriber.tsx:40-40
Timestamp: 2025-09-04T10:18:34.140Z
Learning: In the shapeshift/web codebase, src/state/slices/selectors.ts uses wildcard exports (`export * from './[sliceName]/selectors'`) to re-export all selectors from individual slice selector files, making them available through the barrel import. This means selectors like selectTxByFilter from txHistorySlice/selectors are properly accessible via '@/state/slices/selectors' even though they don't appear in explicit named exports.

Applied to files:

  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/index.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Implement filterBuyAssetsBySellAssetId method to filter assets by supported chain IDs in the buy property

Applied to files:

  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Implement filterAssetIdsBySellable method to filter assets by supported chain IDs in the sell property

Applied to files:

  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-12-01T22:01:37.982Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11240
File: packages/swapper/src/swappers/CetusSwapper/endpoints.ts:56-58
Timestamp: 2025-12-01T22:01:37.982Z
Learning: In packages/swapper/src/swappers/CetusSwapper/endpoints.ts, gomesalexandre is comfortable with mutating the shared Cetus SDK singleton instance (sdk.senderAddress = from) when required by the SDK API, preferring pragmatic working code over theoretical statelessness concerns.

Applied to files:

  • packages/swapper/src/thorchain-utils/index.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-08-13T17:10:05.685Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10249
File: src/state/slices/actionSlice/types.ts:91-94
Timestamp: 2025-08-13T17:10:05.685Z
Learning: In the ActionGenericTransactionMetadata type in src/state/slices/actionSlice/types.ts, the thorMemo field is typed as `string | null` (rather than the more common `string | undefined` pattern) because it receives its value from the memo field returned by useSendThorTx(), which is also typed as `string | null`. This maintains type consistency across the data flow.

Applied to files:

  • packages/chain-adapters/src/tron/types.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/**/*.ts : Validate inputs and log errors for debugging in Swapper system implementations

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/index.ts
📚 Learning: 2025-09-12T13:43:19.770Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/EIP155RequestHandlerUtil.ts:94-103
Timestamp: 2025-09-12T13:43:19.770Z
Learning: gomesalexandre has implemented a reliable gasLimit flow in WalletConnect dApps where Tenderly simulation provides gas estimates that get written to the form via setValue in GasSelectionMenu.tsx, making customTransactionData.gasLimit the primary reliable source. The sendTransaction.gasLimit fallback is kept as "paranoia" but may rarely be hit in practice due to this simulation-based architecture.

Applied to files:

  • packages/chain-adapters/src/tron/TronChainAdapter.ts
📚 Learning: 2025-09-12T13:43:19.770Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/EIP155RequestHandlerUtil.ts:94-103
Timestamp: 2025-09-12T13:43:19.770Z
Learning: gomesalexandre has implemented a sophisticated gasLimit management system in WalletConnect dApps using Tenderly simulation. The GasSelectionMenu component automatically adjusts gasLimit via setValue when simulation shows higher gas usage than currently set, handling edge cases like dApps that enforce low gas limits (e.g., 21000) when actual usage is higher (e.g., 23322). This makes customTransactionData.gasLimit highly reliable as the primary source.

Applied to files:

  • packages/chain-adapters/src/tron/TronChainAdapter.ts
📚 Learning: 2025-11-24T21:20:17.804Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/error-handling.mdc:0-0
Timestamp: 2025-11-24T21:20:17.804Z
Learning: Applies to **/swapper{s,}/**/*.{ts,tsx} : ALWAYS use `makeSwapErrorRight` for swapper errors with `TradeQuoteError` enum for error codes and provide detailed error information

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
📚 Learning: 2025-11-03T22:31:30.786Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10985
File: packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.ts:0-0
Timestamp: 2025-11-03T22:31:30.786Z
Learning: In packages/swapper/src/swappers/PortalsSwapper, the rate and quote files intentionally use different approaches for calculating buyAmountBeforeSlippageCryptoBaseUnit: getPortalsTradeRate.tsx uses minOutputAmount / (1 - buffer) for conservative estimates, while getPortalsTradeQuote.ts uses outputAmount / (1 - buffer) for final quote display. This difference is validated by on-chain simulation testing and is intentional.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
📚 Learning: 2025-08-04T16:02:27.360Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10171
File: src/components/MultiHopTrade/components/TradeConfirm/components/ExpandedStepperSteps.tsx:458-458
Timestamp: 2025-08-04T16:02:27.360Z
Learning: In multi-hop swap transactions, last hop sell transactions might not be detected by the swapper (unlike buy transactions which are always known immediately). The conditional stepSource logic for last hop buy transactions (`isLastHopSellTxSeen ? stepSource : undefined`) serves as defensive programming for future multi-hop support with intermediate chains, even though multi-hop functionality is not currently supported in production.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.test.ts : Write unit tests for swapper methods and API endpoints

Applied to files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/endpoints.ts : Reuse checkEvmSwapStatus utility for checking EVM swap status instead of implementing custom status checks

Applied to files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
📚 Learning: 2025-08-04T15:36:25.122Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10171
File: src/components/MultiHopTrade/components/TradeConfirm/components/ExpandedStepperSteps.tsx:458-458
Timestamp: 2025-08-04T15:36:25.122Z
Learning: In swap transaction handling, buy transaction hashes should always use the swapper's explorer (stepSource) because they are known by the swapper immediately upon swap execution. The conditional logic for using default explorers applies primarily to sell transactions which need to be detected/indexed by external systems like Thorchain or ViewBlock.

Applied to files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
📚 Learning: 2025-11-12T12:18:00.863Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-145
Timestamp: 2025-11-12T12:18:00.863Z
Learning: NEAR Intents swapper: The NEAR 1Click API does not provide gas limit estimation logic like other swappers (e.g., magic gasLimit fields). For ERC20 token swaps in getTradeQuote, accurate fee estimation requires token approval and sufficient balance; without these prerequisites, fees may display as 0 or use inaccurate native transfer estimates. This is a known limitation of the NEAR Intents integration.

Applied to files:

  • packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
  • packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md
📚 Learning: 2025-11-12T12:49:17.895Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-125
Timestamp: 2025-11-12T12:49:17.895Z
Learning: In packages/chain-adapters/src/evm/utils.ts, the getErc20Data function already includes a guard that returns an empty string when contractAddress is undefined (line 8: `if (!contractAddress) return ''`). This built-in handling means callers don't need to conditionally invoke getErc20Data—it safely handles both ERC20 tokens and native assets.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getThorTxData.ts
📚 Learning: 2025-08-17T21:53:03.806Z
Learnt from: 0xApotheosis
Repo: shapeshift/web PR: 10290
File: scripts/generateAssetData/color-map.json:41-47
Timestamp: 2025-08-17T21:53:03.806Z
Learning: In the ShapeShift web codebase, native assets (using CAIP-19 slip44 namespace like eip155:1/slip44:60, bip122:.../slip44:..., cosmos:.../slip44:...) are manually hardcoded and not generated via the automated asset generation script. Only ERC20/BEP20 tokens go through the asset generation process. The validation scripts should only validate generated assets, not manually added native assets.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-11-24T21:20:04.979Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T21:20:04.979Z
Learning: Applies to **/*.{ts,tsx} : Import types from `shapeshiftoss/caip` for chain/account/asset IDs

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-10-23T14:27:19.073Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10857
File: src/plugins/walletConnectToDapps/eventsManager/useWalletConnectEventsHandler.ts:101-104
Timestamp: 2025-10-23T14:27:19.073Z
Learning: In WalletConnect wallet_switchEthereumChain and wallet_addEthereumChain requests, the chainId parameter is always present as per the protocol spec. Type guards checking for missing chainId in these handlers (like `if (!evmNetworkIdHex) return`) are solely for TypeScript compiler satisfaction, not real runtime edge cases.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-08-05T23:36:13.214Z
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10187
File: src/state/slices/preferencesSlice/selectors.ts:21-25
Timestamp: 2025-08-05T23:36:13.214Z
Learning: The AssetId type from 'shapeshiftoss/caip' package is a string type alias, so it can be used directly as a return type for cache key resolvers in re-reselect selectors without needing explicit string conversion.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-09-08T15:53:09.362Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10442
File: src/components/TradeAssetSearch/components/GroupedAssetList/GroupedAssetList.tsx:34-35
Timestamp: 2025-09-08T15:53:09.362Z
Learning: In DefaultAssetList.tsx, the GroupedAssetList component already receives the activeChainId prop correctly on line ~58, contrary to automated analysis that may flag it as missing.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-09-04T17:29:59.479Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx:28-33
Timestamp: 2025-09-04T17:29:59.479Z
Learning: In shapeshift/web, the useGetPopularAssetsQuery function in src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx intentionally uses primaryAssets[assetId] instead of falling back to assets[assetId]. The design distributes primary assets across chains by iterating through their related assets and adding the primary asset to each related asset's chain. This ensures primary assets appear in all chains where they have related assets, supporting the grouped asset system.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-09-12T10:15:10.389Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/EIP712MessageDisplay.tsx:133-137
Timestamp: 2025-09-12T10:15:10.389Z
Learning: gomesalexandre has identified that EIP-712 domain chainId should be preferred over request context chainId for accuracy in WalletConnect dApps structured signing flows. The domain chainId from the parsed message is more specific and accurate than the general request context, especially for asset resolution and network-specific operations.

Applied to files:

  • scripts/generateTradableAssetMap/utils.ts
📚 Learning: 2025-11-03T05:46:24.190Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10985
File: packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx:130-141
Timestamp: 2025-11-03T05:46:24.190Z
Learning: In packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeRate/getPortalsTradeRate.tsx, gomesalexandre prefers "let it crash" approach when Portals returns zero outputAmount or 100% buffer causing division by zero, rather than adding defensive guards to surface zero quotes. He wants to fail fast with exceptions that bubble up to the try/catch wrapper, surfacing upstream data issues rather than masking them with defensive programming.

Applied to files:

  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
📚 Learning: 2025-11-24T21:20:17.804Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/error-handling.mdc:0-0
Timestamp: 2025-11-24T21:20:17.804Z
Learning: Applies to **/*.{ts,tsx} : Use `Result<T, E>` pattern for error handling in swappers and APIs; ALWAYS use `Ok()` and `Err()` from `sniptt/monads`; AVOID throwing within swapper API implementations

Applied to files:

  • packages/swapper/src/thorchain-utils/getL1RateOrQuote.ts
🧬 Code graph analysis (6)
packages/chain-adapters/src/tron/TronChainAdapter.ts (1)
packages/chain-adapters/src/types.ts (2)
  • GetFeeDataInput (325-332)
  • FeeDataEstimate (107-111)
packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts (7)
packages/swapper/src/types.ts (1)
  • GetUnsignedTronTransactionArgs (579-581)
packages/chain-adapters/src/tron/types.ts (1)
  • TronSignTx (46-48)
packages/swapper/src/utils.ts (2)
  • isExecutableTradeQuote (308-309)
  • getExecutableTradeStep (314-324)
packages/swapper/src/thorchain-utils/types.ts (1)
  • ThorTradeQuote (236-236)
packages/swapper/src/thorchain-utils/tron/getThorTxData.ts (1)
  • getThorTxData (17-30)
src/lib/utils/tron.ts (1)
  • assertGetTronChainAdapter (18-27)
packages/utils/src/index.ts (1)
  • contractAddressOrUndefined (46-47)
packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts (1)
packages/utils/src/assetData/baseAssets.ts (1)
  • tron (339-353)
packages/swapper/src/thorchain-utils/tron/getThorTxData.ts (3)
packages/swapper/src/types.ts (1)
  • SwapperConfig (41-73)
packages/swapper/src/thorchain-utils/index.ts (1)
  • getDaemonUrl (58-67)
packages/swapper/src/thorchain-utils/getInboundAddressDataForChain.ts (1)
  • getInboundAddressDataForChain (12-56)
scripts/generateTradableAssetMap/utils.ts (1)
packages/caip/src/constants.ts (2)
  • tronChainId (80-80)
  • ASSET_NAMESPACE (120-129)
packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts (4)
packages/chain-adapters/src/evm/EvmBaseAdapter.ts (1)
  • signAndBroadcastTransaction (450-476)
packages/chain-adapters/src/utxo/UtxoBaseAdapter.ts (1)
  • signAndBroadcastTransaction (479-500)
packages/chain-adapters/src/solana/SolanaChainAdapter.ts (1)
  • signAndBroadcastTransaction (371-397)
packages/chain-adapters/src/cosmossdk/thorchain/ThorchainChainAdapter.ts (1)
  • signAndBroadcastTransaction (320-344)
🪛 LanguageTool
packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md

[style] ~161-~161: To form a complete sentence, be sure to include a subject.
Context: ...esource insufficient error"(cryptic) Should be: -"Insufficient TRX for TRC20 tran...

(MISSING_IT_THERE)

🪛 markdownlint-cli2 (0.18.1)
packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md

169-169: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


198-198: Bare URL used

(MD034, no-bare-urls)


199-199: Bare URL used

(MD034, no-bare-urls)


200-200: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Call / Static
🔇 Additional comments (12)
packages/chain-adapters/src/tron/TRON_FEE_ESTIMATION_ISSUES.md (1)

1-205: Excellent, actionable documentation of TRON fee issues

This write‑up clearly captures the TRC20 fee underestimation problem, real‑world cost ranges, and a concrete TODO plan (including unchained helpers and memo costs). It’s a solid reference for anyone touching TRON fees and aligns with the in‑code TODOs in TronChainAdapter.getFeeData. No blocking changes from my side here.

packages/chain-adapters/src/tron/types.ts (1)

19-22: Memo field addition looks correct; just double‑check upstream typing

Adding memo?: string to BuildTxInput is consistent with how memo is typed in GetFeeDataInput and matches how TronChainAdapter now destructures chainSpecific.memo. Just ensure any upstream sources that produce string | null normalize to string | undefined before passing into this type.

packages/swapper/src/thorchain-utils/index.ts (1)

36-39: Consistent tron namespace export

The export * as tron from './tron' addition matches the existing cosmossdk, evm, and utxo patterns and cleanly surfaces the new TRON helpers via the thorchain‑utils barrel. Looks good.

packages/swapper/src/types.ts (2)

40-73: Required VITE_TRON_NODE_URL is fine; ensure all configs are updated

Adding VITE_TRON_NODE_URL: string as a required field on SwapperConfig is consistent with the existing pattern of mandatory URLs and the fail‑fast env style. Please just verify that all places constructing SwapperConfig (including tests and scripts) are updated to provide this value so you don’t hit type or runtime config errors.


220-227: Tron trade, deps, and execution wiring mirrors existing patterns

The new TRON types (GetTronTradeQuoteInput*, GetTronTradeRateInput, TronSwapperDeps, GetUnsignedTronTransactionArgs, TronTransactionExecutionProps/Input, and the executeTronTransaction/getUnsignedTronTransaction/getTronTransactionFees hooks on Swapper and SwapperApi) cleanly mirror the existing Cosmos/Solana/Sui patterns and look type‑sound.

Two small things to keep in mind:

  • Make sure all Swapper implementations that care about TRON are actually wired to these new optional methods, so you don’t accidentally fall back to generic executeTrade paths.
  • If, in the future, you want TRON‑specific fee breakdowns surfaced in QuoteFeeData.chainSpecific, you’ll likely want to extend that union to include a Tron‑specific shape (e.g., bandwidth/energy/memo), but that can be deferred.

Nothing blocking for this PR.

Also applies to: 232-235, 289-307, 546-548, 579-581, 689-698, 736-739

packages/swapper/src/swappers/ThorchainSwapper/ThorchainSwapper.ts (1)

4-15: executeTronTransaction implementation is consistent with other chains

The new executeTronTransaction simply delegates to the provided signAndBroadcastTransaction callback, in line with the Cosmos and UTXO implementations. That’s the right level of abstraction for the swapper and should integrate cleanly with the TRON chain‑adapter execution flow.

scripts/generateTradableAssetMap/utils.ts (1)

17-18: TRON chain and TRC20 standard wiring looks correct

Adding Chain.TRON, mapping it to tronChainId, and returning ASSET_NAMESPACE.trc20 for KnownChainIds.TronMainnet aligns with how other L1 chains and their token standards are handled. This should allow getAssetIdPairFromPool to correctly resolve TRON.USDT-… style pool assets into CAIP TRC20 asset IDs, and fall back to the TRON fee asset when there’s no contract suffix.

Just confirm that the THORChain pool asset strings for TRON actually use the TRON.* prefix so the enum mapping is hit as expected.

Also applies to: 25-55, 61-76

packages/swapper/src/thorchain-utils/tron/index.ts (1)

1-3: Clean tron barrel exports

This tron index cleanly re‑exports getThorTxData, getUnsignedTronTransaction, and getTronTransactionFees, making them available via the thorchain-utils tron namespace. Consistent with the rest of the utility structure.

packages/swapper/src/swappers/ThorchainSwapper/endpoints.ts (1)

10-10: LGTM! Clean integration following established patterns.

The TRON API methods are correctly added following the same delegation pattern used for EVM and UTXO chains. The import and method signatures are consistent with the existing codebase structure.

Also applies to: 28-29

packages/swapper/src/thorchain-utils/tron/getThorTxData.ts (1)

1-30: LGTM! Clean vault address retrieval utility.

The implementation correctly leverages existing utilities (getDaemonUrl, getInboundAddressDataForChain) and follows the established error handling pattern by throwing the unwrapped error on failure.

packages/swapper/src/thorchain-utils/tron/getUnsignedTronTransaction.ts (1)

9-45: LGTM! Well-structured transaction builder.

The function correctly:

  • Validates the trade quote is executable
  • Extracts necessary data from the trade step
  • Fetches the vault address via getThorTxData
  • Handles both TRX native transfers and TRC20 token transfers via contractAddressOrUndefined
  • Passes memo through chainSpecific for THORChain routing
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1)

85-89: Fallback fee estimates align with PR testing notes.

The conservative fallback values (1 TRX for native, 10 TRX for TRC20) align with the PR description noting that TRON gas estimates are unreliable and recommending ~20 TRX funding for TRC20 transactions. The error is silently caught which is acceptable for fallback behavior.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md (2)

342-342: Add language identifier to fenced code block.

Line 342 has a bare fenced code block. Specify json for syntax highlighting:

-```
+```json

529-534: Wrap bare URLs in markdown link syntax.

Lines 529–534 use bare URLs which violate markdown linting rules. Wrap each in markdown link format:

-- **Thorchain TRON Pools:** https://thornode.ninerealms.com/thorchain/pools (search "TRON")
-- **Thorchain Dev Docs:** https://dev.thorchain.org/concepts/memo-length-reduction.html
-- **TRON Resource Model:** https://developers.tron.network/docs/resource-model
-- **TronWeb Docs:** https://tronweb.network/docu/docs/intro/
-- **SwapKit TRON:** https://github.com/swapkit/SwapKit/tree/develop/packages/toolboxes/src/tron
-- **On-Chain Explorer:** https://tronscan.org/
+- **Thorchain TRON Pools:** [https://thornode.ninerealms.com/thorchain/pools](https://thornode.ninerealms.com/thorchain/pools) (search "TRON")
+- **Thorchain Dev Docs:** [https://dev.thorchain.org/concepts/memo-length-reduction.html](https://dev.thorchain.org/concepts/memo-length-reduction.html)
+- **TRON Resource Model:** [https://developers.tron.network/docs/resource-model](https://developers.tron.network/docs/resource-model)
+- **TronWeb Docs:** [https://tronweb.network/docu/docs/intro/](https://tronweb.network/docu/docs/intro/)
+- **SwapKit TRON:** [https://github.com/swapkit/SwapKit/tree/develop/packages/toolboxes/src/tron](https://github.com/swapkit/SwapKit/tree/develop/packages/toolboxes/src/tron)
+- **On-Chain Explorer:** [https://tronscan.org/](https://tronscan.org/)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ac80cfb and 5870e6f.

📒 Files selected for processing (1)
  • packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/ContractInteractionBreakdown.tsx:0-0
Timestamp: 2025-09-13T16:45:18.813Z
Learning: gomesalexandre prefers aggressively deleting unused/obsolete code files ("ramboing") rather than fixing technical issues in code that won't be used, demonstrating his preference for keeping codebases clean and PR scope focused.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/types.ts:7-7
Timestamp: 2025-09-10T15:34:29.604Z
Learning: gomesalexandre is comfortable relying on transitive dependencies (like abitype through ethers/viem) rather than explicitly declaring them in package.json, preferring to avoid package.json bloat when the transitive dependency approach works reliably in practice.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10503
File: .env:56-56
Timestamp: 2025-09-16T13:17:02.938Z
Learning: gomesalexandre prefers to enable feature flags globally in the base .env file when the intent is to activate features everywhere, even when there are known issues like crashes, demonstrating his preference for intentional global feature rollouts over cautious per-environment enablement.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10249
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:447-503
Timestamp: 2025-08-13T17:07:10.763Z
Learning: gomesalexandre prefers relying on TypeScript's type system for validation rather than adding defensive runtime null checks when types are properly defined. They favor a TypeScript-first approach over defensive programming with runtime validations.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/hooks/useActionCenterSubscribers/useThorchainLpDepositActionSubscriber.tsx:61-66
Timestamp: 2025-08-14T17:51:47.556Z
Learning: gomesalexandre is not concerned about structured logging and prefers to keep console.error usage as-is rather than implementing structured logging patterns, even when project guidelines suggest otherwise.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10413
File: src/components/Modals/FiatRamps/fiatRampProviders/onramper/utils.ts:29-55
Timestamp: 2025-09-02T14:26:19.028Z
Learning: gomesalexandre prefers to keep preparatory/reference code simple until it's actively consumed, rather than implementing comprehensive error handling, validation, and robustness improvements upfront. They prefer to add these improvements when the code is actually being used in production.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:396-402
Timestamp: 2025-08-14T17:55:57.490Z
Learning: gomesalexandre is comfortable with functions/variables that return undefined or true (tri-state) when only the truthy case matters, preferring to rely on JavaScript's truthy/falsy behavior rather than explicitly returning boolean values.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10783
File: src/context/ModalStackProvider/useModalRegistration.ts:30-41
Timestamp: 2025-10-16T11:14:40.657Z
Learning: gomesalexandre prefers to add lint rules (like typescript-eslint/strict-boolean-expressions for truthiness checks on numbers) to catch common issues project-wide rather than relying on code review to catch them.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md
📚 Learning: 2025-11-12T12:18:00.863Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-145
Timestamp: 2025-11-12T12:18:00.863Z
Learning: NEAR Intents swapper: The NEAR 1Click API does not provide gas limit estimation logic like other swappers (e.g., magic gasLimit fields). For ERC20 token swaps in getTradeQuote, accurate fee estimation requires token approval and sufficient balance; without these prerequisites, fees may display as 0 or use inaccurate native transfer estimates. This is a known limitation of the NEAR Intents integration.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md
📚 Learning: 2025-11-03T22:31:30.786Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10985
File: packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.ts:0-0
Timestamp: 2025-11-03T22:31:30.786Z
Learning: In packages/swapper/src/swappers/PortalsSwapper, the rate and quote files intentionally use different approaches for calculating buyAmountBeforeSlippageCryptoBaseUnit: getPortalsTradeRate.tsx uses minOutputAmount / (1 - buffer) for conservative estimates, while getPortalsTradeQuote.ts uses outputAmount / (1 - buffer) for final quote display. This difference is validated by on-chain simulation testing and is intentional.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md
📚 Learning: 2025-08-04T15:36:25.122Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10171
File: src/components/MultiHopTrade/components/TradeConfirm/components/ExpandedStepperSteps.tsx:458-458
Timestamp: 2025-08-04T15:36:25.122Z
Learning: In swap transaction handling, buy transaction hashes should always use the swapper's explorer (stepSource) because they are known by the swapper immediately upon swap execution. The conditional logic for using default explorers applies primarily to sell transactions which need to be detected/indexed by external systems like Thorchain or ViewBlock.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md
🪛 LanguageTool
packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md

[grammar] ~541-~541: Ensure spelling is correct
Context: ...unt resource insufficient" 4. Dynamic FeeLimit Calculation - Adjust based on actual ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md

342-342: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


529-529: Bare URL used

(MD034, no-bare-urls)


530-530: Bare URL used

(MD034, no-bare-urls)


531-531: Bare URL used

(MD034, no-bare-urls)


532-532: Bare URL used

(MD034, no-bare-urls)


533-533: Bare URL used

(MD034, no-bare-urls)


534-534: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Call / Static
🔇 Additional comments (1)
packages/swapper/src/thorchain-utils/tron/THORCHAIN_TRON_INTEGRATION.md (1)

1-550: Comprehensive TRON integration documentation with strong technical depth.

This documentation successfully bridges the implementation and user-facing testing needs. The architecture comparison (EVM vs TRON), integration flow, real transaction verification, and known issues section are well-articulated and actionable. The cost analysis and fee breakdowns (energy/bandwidth/memo tiers) provide clear context for why minimum balance requirements exist. The transparent documentation of limitations (fee estimation TODO, minimum balances not enforced) aligns well with the PR's "high-risk" guidance and testing notes about pre-funding accounts.

Minor observation: The document references TRON_FEE_ESTIMATION_ISSUES.md multiple times for deeper fee estimation issues—ensure that companion doc is included in the PR or linked appropriately.

Fixed getTronTransactionFees to estimate from user's perspective:
- Use args.from instead of vault for triggerConstantContract issuerAddress
- Use args.from instead of vault for sendTrx from parameter
- Remove unnecessary Number() conversion (TronWeb accepts strings)

Why this matters:
- triggerConstantContract simulates execution from caller's perspective
- Using vault address estimated "vault→vault" cost, not "user→vault"
- Energy costs may vary based on sender's account state

Credit: coderabbitai review feedback

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (2)

23-33: Align error handling with swappers Result pattern instead of throwing

This helper throws plain Errors for non‑executable quotes and missing memos, which diverges from the swappers convention of using Result + makeSwapErrorRight and custom error classes. Consider refactoring this (or a thin wrapper) to return a Result instead of throwing so callers stay in the same error‑handling model as the rest of the Thorchain swapper.


85-89: Consider logging estimation failures before falling back to fixed fees

The catch block silently returns fixed conservative fees for all failures. For a high‑risk chain integration like TRON, adding at least a minimal log with context (asset, amount, chain params) before returning the fallback would make debugging fee issues much easier without changing behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5870e6f and 9947ff9.

📒 Files selected for processing (1)
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/swapper{s,}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

ALWAYS use makeSwapErrorRight for swapper errors with TradeQuoteError enum for error codes and provide detailed error information

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
packages/swapper/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/**/*.ts: Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system
Use camelCase for variable and function names in the Swapper system
Use PascalCase for types, interfaces, and enums in the Swapper system
Use kebab-case for filenames in the Swapper system

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
🧠 Learnings (14)
📓 Common learnings
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11170
File: patches/@shapeshiftoss+bitcoinjs-lib+7.0.0-shapeshift.0.patch:9-19
Timestamp: 2025-11-25T21:43:10.838Z
Learning: In shapeshift/web, gomesalexandre will not expand PR scope to fix latent bugs in unused API surface (like bitcoinjs-lib patch validation methods) when comprehensive testing proves the actual used code paths work correctly, preferring to avoid costly hdwallet/web verdaccio publish cycles and full regression testing for conceptual issues with zero runtime impact.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/ContractInteractionBreakdown.tsx:0-0
Timestamp: 2025-09-13T16:45:18.813Z
Learning: gomesalexandre prefers aggressively deleting unused/obsolete code files ("ramboing") rather than fixing technical issues in code that won't be used, demonstrating his preference for keeping codebases clean and PR scope focused.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/types.ts:7-7
Timestamp: 2025-09-10T15:34:29.604Z
Learning: gomesalexandre is comfortable relying on transitive dependencies (like abitype through ethers/viem) rather than explicitly declaring them in package.json, preferring to avoid package.json bloat when the transitive dependency approach works reliably in practice.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10503
File: .env:56-56
Timestamp: 2025-09-16T13:17:02.938Z
Learning: gomesalexandre prefers to enable feature flags globally in the base .env file when the intent is to activate features everywhere, even when there are known issues like crashes, demonstrating his preference for intentional global feature rollouts over cautious per-environment enablement.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10249
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:447-503
Timestamp: 2025-08-13T17:07:10.763Z
Learning: gomesalexandre prefers relying on TypeScript's type system for validation rather than adding defensive runtime null checks when types are properly defined. They favor a TypeScript-first approach over defensive programming with runtime validations.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/hooks/useActionCenterSubscribers/useThorchainLpDepositActionSubscriber.tsx:61-66
Timestamp: 2025-08-14T17:51:47.556Z
Learning: gomesalexandre is not concerned about structured logging and prefers to keep console.error usage as-is rather than implementing structured logging patterns, even when project guidelines suggest otherwise.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10413
File: src/components/Modals/FiatRamps/fiatRampProviders/onramper/utils.ts:29-55
Timestamp: 2025-09-02T14:26:19.028Z
Learning: gomesalexandre prefers to keep preparatory/reference code simple until it's actively consumed, rather than implementing comprehensive error handling, validation, and robustness improvements upfront. They prefer to add these improvements when the code is actually being used in production.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:396-402
Timestamp: 2025-08-14T17:55:57.490Z
Learning: gomesalexandre is comfortable with functions/variables that return undefined or true (tri-state) when only the truthy case matters, preferring to rely on JavaScript's truthy/falsy behavior rather than explicitly returning boolean values.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10783
File: src/context/ModalStackProvider/useModalRegistration.ts:30-41
Timestamp: 2025-10-16T11:14:40.657Z
Learning: gomesalexandre prefers to add lint rules (like typescript-eslint/strict-boolean-expressions for truthiness checks on numbers) to catch common issues project-wide rather than relying on code review to catch them.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
📚 Learning: 2025-11-03T22:31:30.786Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10985
File: packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.ts:0-0
Timestamp: 2025-11-03T22:31:30.786Z
Learning: In packages/swapper/src/swappers/PortalsSwapper, the rate and quote files intentionally use different approaches for calculating buyAmountBeforeSlippageCryptoBaseUnit: getPortalsTradeRate.tsx uses minOutputAmount / (1 - buffer) for conservative estimates, while getPortalsTradeQuote.ts uses outputAmount / (1 - buffer) for final quote display. This difference is validated by on-chain simulation testing and is intentional.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-12T12:18:00.863Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-145
Timestamp: 2025-11-12T12:18:00.863Z
Learning: NEAR Intents swapper: The NEAR 1Click API does not provide gas limit estimation logic like other swappers (e.g., magic gasLimit fields). For ERC20 token swaps in getTradeQuote, accurate fee estimation requires token approval and sufficient balance; without these prerequisites, fees may display as 0 or use inaccurate native transfer estimates. This is a known limitation of the NEAR Intents integration.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-24T21:20:17.804Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/error-handling.mdc:0-0
Timestamp: 2025-11-24T21:20:17.804Z
Learning: Applies to **/swapper{s,}/**/*.{ts,tsx} : ALWAYS use `makeSwapErrorRight` for swapper errors with `TradeQuoteError` enum for error codes and provide detailed error information

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T13:43:50.695Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/hooks/useSimulateEvmTransaction.ts:91-95
Timestamp: 2025-09-12T13:43:50.695Z
Learning: gomesalexandre dismissed gas calculation overflow validation in useSimulateEvmTransaction hook as "stale", preferring to trust Tenderly's simulation data without defensive validation checks, consistent with his established pattern of relying on external service quality over defensive programming in WalletConnect flows.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-15T15:57:39.956Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10810
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:212-0
Timestamp: 2025-10-15T15:57:39.956Z
Learning: gomesalexandre uses discriminated union patterns (e.g., `isEIP1559 ? { max_fee_per_gas, max_priority_fee_per_gas } : { gas_price }`) in WalletConnect flows without additional validation guards, trusting that the runtime data structure ensures mutual exclusivity between EIP-1559 and legacy gas pricing fields.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-21T17:11:18.087Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:11:18.087Z
Learning: In src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx, within the handleInputChange function, use .toFixed() without arguments (not .toString()) when converting BigNumber amounts for input field synchronization. This avoids exponential notation in the input while preserving precision for presentational components like <Amount.Crypto /> and <Amount.Fiat /> to format appropriately.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-05T16:39:58.598Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/Explore.tsx:56-56
Timestamp: 2025-08-05T16:39:58.598Z
Learning: In the ShapeShift web codebase, the established pattern for handling floating point numbers is to use BigNumber operations (bnOrZero, bn) for calculations and convert to strings using .toString() before passing to UI components like Amount.Fiat, Amount.Crypto, and Amount.Percent. This prevents JavaScript floating point precision issues and maintains consistency across the application.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-05T17:00:30.416Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/components/AssetSearchRow.tsx:78-78
Timestamp: 2025-08-05T17:00:30.416Z
Learning: In BigNumber operations within the ShapeShift codebase, floating point literals like 0.01 should always be passed as strings like '0.01' to maintain precision. This applies to all BigNumber methods including .times(), .div(), .plus(), and .minus().

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-21T17:12:47.282Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:12:47.282Z
Learning: In the ShapeShift web codebase, when converting bignumber.js BigNumber values, prefer using .toFixed() over .toString() unless there's a specific reason to use .toString(). The .toFixed() method avoids exponential notation while preserving precision, which is especially important for input field synchronization and display purposes.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: The ShapeShift codebase's fromBaseUnit function correctly handles hex strings (like WalletConnect transaction.value) without manual conversion because bnOrZero -> bn -> new BigNumber() automatically detects and parses hex strings starting with "0x". gomesalexandre confirmed this with concrete evidence showing hex value 0x176d1c49189db correctly converts to 0.000412118294825435 ETH.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: gomesalexandre confirmed that fromBaseUnit in the ShapeShift codebase correctly handles hex strings (like transaction.value from WalletConnect) without requiring manual hex-to-decimal conversion, as bnOrZero handles this automatically via BigNumber.js.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-13T15:52:25.116Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10272
File: src/context/WalletProvider/MobileWallet/mobileMessageHandlers.ts:61-0
Timestamp: 2025-08-13T15:52:25.116Z
Learning: In the ShapeShift web codebase, specifically in src/context/WalletProvider/MobileWallet/mobileMessageHandlers.ts, message variants in the Message union type do not include inline comments documenting their expected return types. The codebase follows a pattern of keeping these type definitions clean without such documentation comments.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Call / Static
🔇 Additional comments (2)
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (2)

1-3: Confirm TronWeb import style matches library export

TronWeb is typically exposed as a default export; import { TronWeb } from 'tronweb' may resolve to undefined at runtime unless you have a custom named export, which would break new TronWeb({ fullHost: rpcUrl }). If you are not intentionally using a named export, switch to a default import:

-import { TronWeb } from 'tronweb'
+import TronWeb from 'tronweb'

45-84: TRC20/TRX fee estimation logic looks consistent and conservative

The split between TRC20 (energy‑based via triggerConstantContract) and TRX (bandwidth + memo size via sendTrx + addUpdateData) with Sun‑denominated outputs and conservative defaults (energyUsed fallback, raw_data_hex length, signature size) looks reasonable for THORChain fee estimation.

gomesalexandre and others added 3 commits December 3, 2025 12:00
CodeRabbit was incorrect about sendTrx accepting strings.
TronWeb's TypeScript definition requires number for amount parameter:
  sendTrx(to: string, amount?: number, from?: string)

While implementation accepts strings internally, the type definition
enforces number, causing TS2345 error.

Kept the important fix: using args.from instead of vault for sender.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
More consistent with codebase patterns and safer for edge cases.
bnOrZero handles invalid inputs gracefully vs raw Number() cast.

Note: TronWeb's TypeScript definition requires number type for sendTrx amount,
so string is not an option (contrary to CodeRabbit's suggestion).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1)

68-72: Avoid .toNumber() here to prevent precision loss on large SUN amounts.

bnOrZero(...).toNumber() can lose precision for very large base‑unit values before passing them into sendTrx. While here the amount is only used to build a dummy transaction for size/fee estimation, it’s safer and more consistent with BigNumber usage in this codebase to keep the value as an integer string.

You can derive an integer string via bnOrZero(...).toFixed(0) and pass that directly to TronWeb:

-      let tx = await tronWeb.transactionBuilder.sendTrx(
-        vault,
-        bnOrZero(sellAmountIncludingProtocolFeesCryptoBaseUnit).toNumber(),
-        from,
-      )
+      const tx = await tronWeb.transactionBuilder.sendTrx(
+        vault,
+        bnOrZero(sellAmountIncludingProtocolFeesCryptoBaseUnit).toFixed(0),
+        from,
+      )

This avoids any JS Number rounding while still satisfying TronWeb’s integer amount requirement. As per coding guidelines, it also eliminates the unnecessary let in favor of const.

TronWeb transactionBuilder.sendTrx: does it accept the `amount` parameter as a decimal string as well as a number, and are there known precision issues when passing large SUN amounts as JavaScript Numbers?
🧹 Nitpick comments (1)
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1)

85-89: Log fee‑estimation failures before falling back to conservative defaults.

Right now the catch block silently returns a hard‑coded fallback fee. For a high‑risk on‑chain integration, having zero signal when estimation repeatedly fails will make debugging much harder.

Consider logging the error with relevant context (e.g. swapperName, sellAsset.assetId, contractAddress, rpcUrl) using the existing swapper/logger utility (or, minimally, console.error) before returning the fallback value:

-  } catch (err) {
-    // Fallback to conservative estimate if fee estimation fails
-    // TRX transfer: ~1 TRX, TRC20: ~10 TRX
-    return contractAddress ? '10000000' : '1000000'
-  }
+  } catch (err) {
+    // Fallback to conservative estimate if fee estimation fails
+    // TRX transfer: ~1 TRX, TRC20: ~10 TRX
+    console.error('getTronTransactionFees: failed to estimate TRON fee', {
+      err,
+      swapperName,
+      contractAddress,
+      rpcUrl,
+    })
+    return contractAddress ? '10000000' : '1000000'
+  }

This keeps the current behavior but aligns better with the guideline to always log errors with useful metadata.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 857d335 and f37fd68.

📒 Files selected for processing (1)
  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/swapper{s,}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

ALWAYS use makeSwapErrorRight for swapper errors with TradeQuoteError enum for error codes and provide detailed error information

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
packages/swapper/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/swapper.mdc)

packages/swapper/**/*.ts: Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system
Use camelCase for variable and function names in the Swapper system
Use PascalCase for types, interfaces, and enums in the Swapper system
Use kebab-case for filenames in the Swapper system

Files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
🧠 Learnings (24)
📓 Common learnings
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11170
File: patches/@shapeshiftoss+bitcoinjs-lib+7.0.0-shapeshift.0.patch:9-19
Timestamp: 2025-11-25T21:43:10.838Z
Learning: In shapeshift/web, gomesalexandre will not expand PR scope to fix latent bugs in unused API surface (like bitcoinjs-lib patch validation methods) when comprehensive testing proves the actual used code paths work correctly, preferring to avoid costly hdwallet/web verdaccio publish cycles and full regression testing for conceptual issues with zero runtime impact.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11171
File: src/components/MultiHopTrade/components/TradeConfirm/hooks/useTradeExecution.tsx:295-296
Timestamp: 2025-11-28T13:07:32.395Z
Learning: Tron is not supported on GridPlus, Trezor, or Ledger hardware wallets. Therefore, skipDeviceDerivation optimization (which only applies to these wallet types) is not needed in Tron adapter code paths.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/ContractInteractionBreakdown.tsx:0-0
Timestamp: 2025-09-13T16:45:18.813Z
Learning: gomesalexandre prefers aggressively deleting unused/obsolete code files ("ramboing") rather than fixing technical issues in code that won't be used, demonstrating his preference for keeping codebases clean and PR scope focused.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/types.ts:7-7
Timestamp: 2025-09-10T15:34:29.604Z
Learning: gomesalexandre is comfortable relying on transitive dependencies (like abitype through ethers/viem) rather than explicitly declaring them in package.json, preferring to avoid package.json bloat when the transitive dependency approach works reliably in practice.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10503
File: .env:56-56
Timestamp: 2025-09-16T13:17:02.938Z
Learning: gomesalexandre prefers to enable feature flags globally in the base .env file when the intent is to activate features everywhere, even when there are known issues like crashes, demonstrating his preference for intentional global feature rollouts over cautious per-environment enablement.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10249
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:447-503
Timestamp: 2025-08-13T17:07:10.763Z
Learning: gomesalexandre prefers relying on TypeScript's type system for validation rather than adding defensive runtime null checks when types are properly defined. They favor a TypeScript-first approach over defensive programming with runtime validations.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/hooks/useActionCenterSubscribers/useThorchainLpDepositActionSubscriber.tsx:61-66
Timestamp: 2025-08-14T17:51:47.556Z
Learning: gomesalexandre is not concerned about structured logging and prefers to keep console.error usage as-is rather than implementing structured logging patterns, even when project guidelines suggest otherwise.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10413
File: src/components/Modals/FiatRamps/fiatRampProviders/onramper/utils.ts:29-55
Timestamp: 2025-09-02T14:26:19.028Z
Learning: gomesalexandre prefers to keep preparatory/reference code simple until it's actively consumed, rather than implementing comprehensive error handling, validation, and robustness improvements upfront. They prefer to add these improvements when the code is actually being used in production.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10276
File: src/pages/ThorChainLP/components/ReusableLpStatus/TransactionRow.tsx:396-402
Timestamp: 2025-08-14T17:55:57.490Z
Learning: gomesalexandre is comfortable with functions/variables that return undefined or true (tri-state) when only the truthy case matters, preferring to rely on JavaScript's truthy/falsy behavior rather than explicitly returning boolean values.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10783
File: src/context/ModalStackProvider/useModalRegistration.ts:30-41
Timestamp: 2025-10-16T11:14:40.657Z
Learning: gomesalexandre prefers to add lint rules (like typescript-eslint/strict-boolean-expressions for truthiness checks on numbers) to catch common issues project-wide rather than relying on code review to catch them.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/lib/moralis.ts:47-85
Timestamp: 2025-08-07T11:22:16.983Z
Learning: gomesalexandre prefers console.error over structured logging for Moralis API integration debugging, as they find it more conventional and prefer to examine XHR requests directly rather than rely on structured logs for troubleshooting.
📚 Learning: 2025-11-03T22:31:30.786Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10985
File: packages/swapper/src/swappers/PortalsSwapper/getPortalsTradeQuote/getPortalsTradeQuote.ts:0-0
Timestamp: 2025-11-03T22:31:30.786Z
Learning: In packages/swapper/src/swappers/PortalsSwapper, the rate and quote files intentionally use different approaches for calculating buyAmountBeforeSlippageCryptoBaseUnit: getPortalsTradeRate.tsx uses minOutputAmount / (1 - buffer) for conservative estimates, while getPortalsTradeQuote.ts uses outputAmount / (1 - buffer) for final quote display. This difference is validated by on-chain simulation testing and is intentional.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/*.ts : Reuse executeEvmTransaction utility for EVM-based swappers instead of implementing custom transaction execution

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-24T21:20:17.804Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/error-handling.mdc:0-0
Timestamp: 2025-11-24T21:20:17.804Z
Learning: Applies to **/swapper{s,}/**/*.{ts,tsx} : ALWAYS use `makeSwapErrorRight` for swapper errors with `TradeQuoteError` enum for error codes and provide detailed error information

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-12T12:18:00.863Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-145
Timestamp: 2025-11-12T12:18:00.863Z
Learning: NEAR Intents swapper: The NEAR 1Click API does not provide gas limit estimation logic like other swappers (e.g., magic gasLimit fields). For ERC20 token swaps in getTradeQuote, accurate fee estimation requires token approval and sufficient balance; without these prerequisites, fees may display as 0 or use inaccurate native transfer estimates. This is a known limitation of the NEAR Intents integration.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T13:43:50.695Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/hooks/useSimulateEvmTransaction.ts:91-95
Timestamp: 2025-09-12T13:43:50.695Z
Learning: gomesalexandre dismissed gas calculation overflow validation in useSimulateEvmTransaction hook as "stale", preferring to trust Tenderly's simulation data without defensive validation checks, consistent with his established pattern of relying on external service quality over defensive programming in WalletConnect flows.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-15T15:57:39.956Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10810
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:212-0
Timestamp: 2025-10-15T15:57:39.956Z
Learning: gomesalexandre uses discriminated union patterns (e.g., `isEIP1559 ? { max_fee_per_gas, max_priority_fee_per_gas } : { gas_price }`) in WalletConnect flows without additional validation guards, trusting that the runtime data structure ensures mutual exclusivity between EIP-1559 and legacy gas pricing fields.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-12-01T22:01:37.982Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11240
File: packages/swapper/src/swappers/CetusSwapper/endpoints.ts:56-58
Timestamp: 2025-12-01T22:01:37.982Z
Learning: In packages/swapper/src/swappers/CetusSwapper/endpoints.ts, gomesalexandre is comfortable with mutating the shared Cetus SDK singleton instance (sdk.senderAddress = from) when required by the SDK API, preferring pragmatic working code over theoretical statelessness concerns.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T13:43:19.770Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/EIP155RequestHandlerUtil.ts:94-103
Timestamp: 2025-09-12T13:43:19.770Z
Learning: gomesalexandre has implemented a reliable gasLimit flow in WalletConnect dApps where Tenderly simulation provides gas estimates that get written to the form via setValue in GasSelectionMenu.tsx, making customTransactionData.gasLimit the primary reliable source. The sendTransaction.gasLimit fallback is kept as "paranoia" but may rarely be hit in practice due to this simulation-based architecture.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-29T07:07:49.332Z
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10386
File: src/components/MultiHopTrade/components/VerifyAddresses/VerifyAddresses.tsx:272-294
Timestamp: 2025-08-29T07:07:49.332Z
Learning: In UTXO sell address verification flow in VerifyAddresses.tsx, the user wants address verification to be marked as "verified/complete" before starting the change address fetch, not after. The verification step and change address fetch should be treated as separate sequential operations in the UI flow.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-21T17:11:18.087Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:11:18.087Z
Learning: In src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx, within the handleInputChange function, use .toFixed() without arguments (not .toString()) when converting BigNumber amounts for input field synchronization. This avoids exponential notation in the input while preserving precision for presentational components like <Amount.Crypto /> and <Amount.Fiat /> to format appropriately.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-05T16:39:58.598Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/Explore.tsx:56-56
Timestamp: 2025-08-05T16:39:58.598Z
Learning: In the ShapeShift web codebase, the established pattern for handling floating point numbers is to use BigNumber operations (bnOrZero, bn) for calculations and convert to strings using .toString() before passing to UI components like Amount.Fiat, Amount.Crypto, and Amount.Percent. This prevents JavaScript floating point precision issues and maintains consistency across the application.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-05T17:00:30.416Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/components/AssetSearchRow.tsx:78-78
Timestamp: 2025-08-05T17:00:30.416Z
Learning: In BigNumber operations within the ShapeShift codebase, floating point literals like 0.01 should always be passed as strings like '0.01' to maintain precision. This applies to all BigNumber methods including .times(), .div(), .plus(), and .minus().

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: The ShapeShift codebase's fromBaseUnit function correctly handles hex strings (like WalletConnect transaction.value) without manual conversion because bnOrZero -> bn -> new BigNumber() automatically detects and parses hex strings starting with "0x". gomesalexandre confirmed this with concrete evidence showing hex value 0x176d1c49189db correctly converts to 0.000412118294825435 ETH.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-21T17:12:47.282Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10871
File: src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx:426-428
Timestamp: 2025-10-21T17:12:47.282Z
Learning: In the ShapeShift web codebase, when converting bignumber.js BigNumber values, prefer using .toFixed() over .toString() unless there's a specific reason to use .toString(). The .toFixed() method avoids exponential notation while preserving precision, which is especially important for input field synchronization and display purposes.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: gomesalexandre confirmed that fromBaseUnit in the ShapeShift codebase correctly handles hex strings (like transaction.value from WalletConnect) without requiring manual hex-to-decimal conversion, as bnOrZero handles this automatically via BigNumber.js.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-10T15:34:54.593Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/components/modals/EIP712MessageDisplay.tsx:46-59
Timestamp: 2025-09-10T15:34:54.593Z
Learning: After extensive testing by gomesalexandre in PR #10458, dApps do not send EIP-712 domain.chainId as hex or bigint values in practice. The simple String(domain.chainId) conversion is sufficient for real-world usage in WalletConnect dApps structured signing.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-11-25T21:43:10.838Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11170
File: patches/@shapeshiftoss+bitcoinjs-lib+7.0.0-shapeshift.0.patch:9-19
Timestamp: 2025-11-25T21:43:10.838Z
Learning: In shapeshift/web, gomesalexandre will not expand PR scope to fix latent bugs in unused API surface (like bitcoinjs-lib patch validation methods) when comprehensive testing proves the actual used code paths work correctly, preferring to avoid costly hdwallet/web verdaccio publish cycles and full regression testing for conceptual issues with zero runtime impact.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-17T22:40:30.149Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10569
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.tsx:121-129
Timestamp: 2025-09-17T22:40:30.149Z
Learning: gomesalexandre maintains strict scope discipline even for style/UI PRs in shapeshift/web, declining functionally correct UX improvements (like keeping Cancel button enabled during gas simulation loading) when they fall outside the PR's stated styling objectives, demonstrating his consistent pattern of deferring valid but tangential improvements to separate efforts.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-08-08T15:00:22.321Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/MultiHopTrade/components/TradeInput/components/HighlightedTokens.tsx:14-14
Timestamp: 2025-08-08T15:00:22.321Z
Learning: In shapeshift/web reviews for NeOMakinG, avoid nitpicks to change deep-relative imports to '@/…' alias paths within feature/non-refactor PRs; defer such style-only changes to a dedicated follow-up refactor unless they fix an issue.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-10-13T11:55:57.439Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10751
File: src/Routes/RoutesCommon.tsx:190-190
Timestamp: 2025-10-13T11:55:57.439Z
Learning: In the shapeshift/web codebase, there are multiple independent claim systems: Arbitrum bridge claims (removed in PR #10751), RFOX claims (in src/pages/RFOX/components/Claim/), and TCY claims (in src/pages/TCY/). Each has its own routes, components, and logic. When reviewing claim-related changes, distinguish which system is being modified and avoid suggesting changes to unrelated claim systems.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-07-29T10:22:27.037Z
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10136
File: src/lib/asset-service/service/encodedRelatedAssetIndex.json:1-1
Timestamp: 2025-07-29T10:22:27.037Z
Learning: PRs with titles starting with "feat: regenerate asset data" are routine daily asset updates that don't need detailed code analysis. Users prefer to skip automated reviews for these maintenance PRs using coderabbitai ignore.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-12T11:56:19.437Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:0-0
Timestamp: 2025-09-12T11:56:19.437Z
Learning: gomesalexandre rejected verbose try/catch error handling for address validation in Tenderly integration (PR #10461), calling the approach "ugly" but still implemented safety measures in commit ad7e424b89, preferring cleaner safety implementations over defensive programming patterns.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
📚 Learning: 2025-09-11T22:53:19.837Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/EIP155TransactionConfirmation.tsx:27-31
Timestamp: 2025-09-11T22:53:19.837Z
Learning: gomesalexandre trusts Tenderly's data quality and doesn't want defensive validation for gas values (transaction?.gasLimit ?? transaction?.gas) in WalletConnect flows, preferring to rely on the external service providing valid hex values.

Applied to files:

  • packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts
🧬 Code graph analysis (1)
packages/swapper/src/thorchain-utils/tron/getTronTransactionFees.ts (6)
packages/unchained-client/src/tron/api.ts (1)
  • getChainPrices (188-201)
packages/swapper/src/types.ts (1)
  • GetUnsignedTronTransactionArgs (579-581)
packages/swapper/src/utils.ts (1)
  • isExecutableTradeQuote (308-309)
packages/swapper/src/thorchain-utils/types.ts (1)
  • ThorTradeQuote (236-236)
packages/swapper/src/thorchain-utils/tron/getThorTxData.ts (1)
  • getThorTxData (17-30)
packages/utils/src/index.ts (1)
  • contractAddressOrUndefined (46-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Call / Static

Copy link
Collaborator

@NeOMakinG NeOMakinG left a comment

Choose a reason for hiding this comment

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

@NeOMakinG NeOMakinG merged commit ac0fb48 into develop Dec 4, 2025
4 checks passed
@NeOMakinG NeOMakinG deleted the feat_thor_tron branch December 4, 2025 16:05
gomesalexandre added a commit that referenced this pull request Dec 4, 2025
Resolve merge conflicts after PR #11266 was squash merged. The original
PR had basic/placeholder Tron fee estimation, while this branch contains
the improved fee estimation logic. Kept the improvements from HEAD.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai coderabbitai bot mentioned this pull request Dec 5, 2025
1 task
@coderabbitai coderabbitai bot mentioned this pull request Jan 6, 2026
1 task
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.

THORChain - Tron support

3 participants