Skip to content

fix(sdk-coin-flrp): subtract minImportToCFee from ExportInP outputAmount#9183

Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
masterfrom
CECHO-1518-flrp-export-amount
Draft

fix(sdk-coin-flrp): subtract minImportToCFee from ExportInP outputAmount#9183
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
masterfrom
CECHO-1518-flrp-export-amount

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown

What

  • Add minImportToCFee field to the FlareNetwork interface and set it to 2850000 nFLR (250 nFLR/gas × ~11400 gas, the minimum EVM import fee) in both FlareP and FlarePTestnet network classes
  • Update Flrp.explainTransaction to subtract minImportToCFee from outputAmount and output amounts for P→C exports (ExportInP), mirroring the existing minImportToPFee subtraction for C→P exports (ExportInC, CECHO-1450)
  • Add test coverage verifying that ExportInP outputAmount and outputs[0].amount are adjusted by minImportToCFee

Why

  • The TFLR export confirmation UI displays - TFLR instead of the correct send amount for P→C exports. The root cause is that ExportInP's exported UTXO amount is the gross value (user-requested amount + C-chain import fee), not the net amount the user will receive on C-chain. When the platform reads this gross outputAmount and applies its own import-fee adjustment, the resulting amount becomes inconsistent, causing the confirmation UI to display a dash instead of the correct value.
  • Subtracting minImportToCFee from outputAmount in explainTransaction aligns the displayed amount with the minimum expected net C-chain receipt, consistent with how ExportInC subtracts minImportToPFee to show the correct pending P-chain receipt (CECHO-1450).

Test plan

  • sdk-coin-flrp unit tests: 363 passing — existing ExportInP explain tests still pass, new test verifies outputAmount and outputs[0].amount are adjusted by minImportToCFee
  • statics unit tests: 30821 passing — FlareNetwork interface change is valid
  • verifyTransaction tests: 9 passing — verifyTransaction uses tx.explainTransaction() (transaction-level, unadjusted) so existing validation logic is unaffected

Ticket: CECHO-1518

For P→C exports (ExportInP), the exported UTXO amount includes the
C-chain import fee that is added by the platform during transaction
building (amount = userAmount + importToCFee). Without adjusting the
outputAmount, the confirmation UI reads the gross UTXO amount as the
displayed send amount. When the platform additionally applies its own
import-fee subtraction from the same gross value, the resulting
spendAmount can appear as 0 or be misinterpreted, causing the export
confirmation UI to display "- TFLR" instead of the correct amount.

Fix: in Flrp.explainTransaction, when the transaction is a P-chain
export (ExportInP, !isTransactionForCChain), subtract minImportToCFee
from outputAmount and each output's amount. This yields the minimum
expected net C-chain receipt, aligning the confirmation display with
the amount the user will actually receive after ImportInC, consistent
with how ExportInC subtracts minImportToPFee (CECHO-1450).

Add minImportToCFee to the FlareNetwork interface and set it to
2850000 nFLR (250 nFLR/gas × ~11400 gas, the minimum EVM import fee).
Add test coverage verifying ExportInP outputAmount is adjusted.

Ticket: CECHO-1518
Session-Id: 6f2ea6bd-01d6-4a82-a82f-0af0974e5165
Task-Id: 65e37cf1-5c7c-4605-8126-070b8d699a02
@linear-code

linear-code Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

CECHO-1518

@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot force-pushed the CECHO-1518-flrp-export-amount branch from fb69c69 to dd4c74a Compare July 3, 2026 09:07
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.

1 participant