Skip to content

Breakout and test NativePasswordRequired logic#68

Merged
bootsboogie merged 19 commits intodevelopfrom
WEB-20
Sep 9, 2021
Merged

Breakout and test NativePasswordRequired logic#68
bootsboogie merged 19 commits intodevelopfrom
WEB-20

Conversation

@bootsboogie
Copy link
Contributor

@bootsboogie bootsboogie commented Sep 7, 2021

Notice

Before submitting a pull request, please make sure you have answered the following:

  • Have you followed the guidelines in our Contributing guide?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Do all new and existing tests pass? Does the linter pass?

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

closes #20

Description

Pull the business logic from the view and test

@bootsboogie bootsboogie requested a review from a team as a code owner September 7, 2021 22:08
Copy link
Contributor

@cjthompson cjthompson left a comment

Choose a reason for hiding this comment

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

This is fantastic and establishes a very good pattern. Thanks for doing this.

Approved with a few nit picks.

@bootsboogie bootsboogie merged commit 9b88892 into develop Sep 9, 2021
@bootsboogie bootsboogie deleted the WEB-20 branch September 9, 2021 18:57
gomesalexandre added a commit that referenced this pull request Dec 3, 2025
CRITICAL: Fixes 24-50x fee underestimation causing OUT_OF_ENERGY failures

Previously returned fixed 0.268 TRX for all transactions.
Now returns accurate estimates validated against real transactions:
- TRC20 transfers: 6.7-13.3 TRX (without memo)
- TRC20 with memo: 7.8-14.4 TRX
- TRX transfers: 0.198 TRX (without memo)
- TRX with memo: 1.231 TRX

Validation Results (Real Thorchain USDT swaps + User transaction):
- User tx: 6.77 TRX actual, 9.92 TRX estimated (1.46x = conservative ✅)
- Thor tx 1: 7.84 TRX actual, 10.92 TRX estimated (1.39x = conservative ✅)
- Thor tx 2: 7.82 TRX actual, 10.92 TRX estimated (1.40x = conservative ✅)
- Old estimate: 0.268 TRX (0.034x actual = 29x underestimate ❌)
- Improvement: 41x more accurate

Implementation:
- Detects TRC20 vs TRX via contractAddress in chainSpecific
- Calls estimateTRC20TransferFee() with actual recipient address
- Applies 1.5x safety margin for dynamic energy spikes (max 3.4x)
- Builds real transactions to measure bandwidth accurately
- Adds 1 TRX memo fee when present (network parameter #68)
- Thor/TRON rates now show fees when wallet connected
- Send modal now passes contractAddress for TRC20 detection

Files Modified:
- TronChainAdapter.ts: Rewritten getFeeData() (85 lines)
- getL1RateOrQuote.ts: Thor rates with fee calculation (68 lines)
- api.ts: Realistic fallback (31→13 TRX)
- tron/types.ts: Added GetFeeDataInput type
- types.ts: Added TRON to ChainSpecificGetFeeDataInput
- Send/utils.ts: Pass contractAddress and memo to getFeeData
- NearIntentsSwapper: Added chainSpecific for TRON calls

Technical Details:
- Uses triggerConstantContract (estimateEnergy not available on TronGrid)
- SSTORE cost varies 2x based on recipient balance (20k vs 5k energy)
- Dynamic energy can spike up to 3.4x during congestion
- Memo fee confirmed via getChainParameters(): 1,000,000 SUN
- Energy price: 100 SUN/unit (mainnet), 210 SUN/unit (Shasta)
- Validated against NETTS article: 65k/131k energy for USDT

Fixes #11270

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

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai coderabbitai bot mentioned this pull request Dec 4, 2025
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.

NativePasswordRequired tests and refactor out business logic

4 participants