fix(blockchain): use amountFormatted to rebuild TokenAmount from DB
Previously used amount (raw) with hardcoded 18 decimals, which caused incorrect formatting for USDT (6 decimals). Now uses amountFormatted which is already correctly formatted during deposit detection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
db3e0ba1bd
commit
8532bf6945
|
|
@ -17,6 +17,11 @@ export class DepositTransactionMapper {
|
|||
throw new Error(`DepositTransaction ${prisma.id} missing accountSequence or userId`);
|
||||
}
|
||||
|
||||
// 使用 amountFormatted 重建 TokenAmount
|
||||
// amountFormatted 已经是正确的人类可读格式(如 1000000.00000000)
|
||||
// 用 decimals=8 与 toFixed(8) 保持一致,确保 toFixed(8) 返回相同的值
|
||||
const amount = TokenAmount.fromFormatted(prisma.amountFormatted.toString(), 8);
|
||||
|
||||
const props: DepositTransactionProps = {
|
||||
id: prisma.id,
|
||||
chainType: ChainType.create(prisma.chainType),
|
||||
|
|
@ -24,7 +29,7 @@ export class DepositTransactionMapper {
|
|||
fromAddress: EvmAddress.fromUnchecked(prisma.fromAddress),
|
||||
toAddress: EvmAddress.fromUnchecked(prisma.toAddress),
|
||||
tokenContract: EvmAddress.fromUnchecked(prisma.tokenContract),
|
||||
amount: TokenAmount.fromDecimal(prisma.amount, 18),
|
||||
amount,
|
||||
blockNumber: BlockNumber.create(prisma.blockNumber),
|
||||
blockTimestamp: prisma.blockTimestamp,
|
||||
logIndex: prisma.logIndex,
|
||||
|
|
|
|||
Loading…
Reference in New Issue