Skip to content

Commit 7e13214

Browse files
committed
fix: prevent negative value when subtracting fee from max amount
1 parent 426321f commit 7e13214

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/hooks/src/tx/amount.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ export class AmountConfig extends TxChainSetter implements IAmountConfig {
110110
const subFee = this.feeConfig.fees[0].mul(
111111
new Dec(this._fractionSubFeeWeight)
112112
);
113-
return maxValue.sub(subFee).toString();
113+
const finalValue = maxValue.sub(subFee);
114+
115+
if (finalValue.toDec().lte(new Dec(0))) {
116+
return "0";
117+
}
118+
119+
return finalValue.toString();
114120
}
115121

116122
return maxValue.toString();

0 commit comments

Comments
 (0)