From 2ccddb0ceab043fcd4f57023604262c0b038fc57 Mon Sep 17 00:00:00 2001 From: TaprootFreak <142087526+TaprootFreak@users.noreply.github.com> Date: Tue, 13 Jan 2026 17:21:08 +0100 Subject: [PATCH] fix: round amount to asset decimals in bridgeToDeuro (#2923) EURC has only 6 decimal places, but the amount from liquidity balance can have more (e.g. 12). This caused ethers.parseUnits() to throw NUMERIC_FAULT underflow when the fractional component exceeded the token's decimals. Use EvmUtil.toWeiAmount() which correctly rounds to the specified decimals before calling parseUnits. --- src/integration/blockchain/deuro/deuro-client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/integration/blockchain/deuro/deuro-client.ts b/src/integration/blockchain/deuro/deuro-client.ts index 451cc5fa61..7b1da7b67b 100644 --- a/src/integration/blockchain/deuro/deuro-client.ts +++ b/src/integration/blockchain/deuro/deuro-client.ts @@ -9,6 +9,7 @@ import { } from '@deuro/eurocoin'; import { Contract, ethers } from 'ethers'; import { gql, request } from 'graphql-request'; +import { EvmUtil } from '../shared/evm/evm.util'; import { Config } from 'src/config/config'; import { Asset } from 'src/shared/models/asset/asset.entity'; import { EvmClient } from '../shared/evm/evm-client'; @@ -209,7 +210,7 @@ export class DEuroClient { if (!asset.decimals) throw new Error(`Asset ${asset.name} has no decimals`); if (!asset.chainId) throw new Error(`Asset ${asset.name} has no chainId`); - const weiAmount = ethers.utils.parseUnits(amount.toString(), asset.decimals); + const weiAmount = EvmUtil.toWeiAmount(amount, asset.decimals); const remainingCapacity = await this.getBridgeRemainingCapacity(asset.name); if (remainingCapacity.lt(weiAmount)) {