fix(sdk-coin-flrp): subtract minImportToCFee from ExportInP outputAmount#9183
Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Draft
fix(sdk-coin-flrp): subtract minImportToCFee from ExportInP outputAmount#9183bitgo-ai-agent-dev[bot] wants to merge 1 commit into
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
Conversation
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
Contributor
fb69c69 to
dd4c74a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
minImportToCFeefield to theFlareNetworkinterface and set it to2850000nFLR (250 nFLR/gas × ~11400 gas, the minimum EVM import fee) in bothFlarePandFlarePTestnetnetwork classesFlrp.explainTransactionto subtractminImportToCFeefromoutputAmountand output amounts for P→C exports (ExportInP), mirroring the existingminImportToPFeesubtraction for C→P exports (ExportInC, CECHO-1450)ExportInPoutputAmountandoutputs[0].amountare adjusted byminImportToCFeeWhy
- TFLRinstead of the correct send amount for P→C exports. The root cause is thatExportInP'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 grossoutputAmountand applies its own import-fee adjustment, the resulting amount becomes inconsistent, causing the confirmation UI to display a dash instead of the correct value.minImportToCFeefromoutputAmountinexplainTransactionaligns the displayed amount with the minimum expected net C-chain receipt, consistent with howExportInCsubtractsminImportToPFeeto show the correct pending P-chain receipt (CECHO-1450).Test plan
sdk-coin-flrpunit tests: 363 passing — existing ExportInP explain tests still pass, new test verifiesoutputAmountandoutputs[0].amountare adjusted byminImportToCFeestaticsunit tests: 30821 passing —FlareNetworkinterface change is validverifyTransactiontests: 9 passing —verifyTransactionusestx.explainTransaction()(transaction-level, unadjusted) so existing validation logic is unaffectedTicket: CECHO-1518