Skip to content

Commit

Permalink
Merge branch 'master' into @chris/stop-dropdown-after-fill
Browse files Browse the repository at this point in the history
  • Loading branch information
derHowie authored Sep 13, 2024
2 parents f0d8bf9 + 0b0f08e commit a5f1de6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/core/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ const parseFees = (
const feeValue = FixedNumber.from(
formatUnits(BigInt(fee.value) + rollupFee, nativeAssetDecimals),
);
const feePrice = FixedNumber.fromString(fee.price.toString());
const feePrice = FixedNumber.fromString(
fee.price.toFixed(nativeAssetDecimals).toString(),
nativeAssetDecimals,
);

return {
fee: feeValue.toString(),
Expand Down Expand Up @@ -278,19 +281,23 @@ export function parseTransaction({
const description = getDescription(asset, type, meta);

const nativeAsset = changes.find((change) => change?.asset.isNativeAsset);
const nativeAssetPrice = FixedNumber.fromString(
nativeAsset?.price?.toString() || '0',
);

const value = FixedNumber.fromValue(
BigNumber.from(nativeAsset?.value || 0),
nativeAsset?.asset.decimals || 0,
);

const valueInNative = value.mulUnsafe(nativeAssetPrice).toString();

const nativeAssetDecimals = 18; // we only support networks with 18 decimals native assets rn, backend will change when we support more

const nativeAssetPrice = FixedNumber.fromString(
typeof nativeAsset?.price === 'number'
? nativeAsset.price.toFixed(nativeAssetDecimals).toString()
: '0',
nativeAssetDecimals,
);

const valueInNative = value.mulUnsafe(nativeAssetPrice).toString();

const { feeInNative, ...fee } = parseFees(tx.fee, nativeAssetDecimals);

const native = {
Expand Down

0 comments on commit a5f1de6

Please sign in to comment.