Merge pull request #4468 from mempool/mononaut/fix-liquid-fee-rounding
Fix liquid recommended fee rounding
This commit is contained in:
commit
1fe983a299
@ -15,11 +15,12 @@ class FeeApi {
|
|||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
defaultFee = Common.isLiquid() ? 0.1 : 1;
|
defaultFee = Common.isLiquid() ? 0.1 : 1;
|
||||||
|
minimumIncrement = Common.isLiquid() ? 0.1 : 1;
|
||||||
|
|
||||||
public getRecommendedFee(): RecommendedFees {
|
public getRecommendedFee(): RecommendedFees {
|
||||||
const pBlocks = projectedBlocks.getMempoolBlocks();
|
const pBlocks = projectedBlocks.getMempoolBlocks();
|
||||||
const mPool = mempool.getMempoolInfo();
|
const mPool = mempool.getMempoolInfo();
|
||||||
const minimumFee = Math.ceil(mPool.mempoolminfee * 100000);
|
const minimumFee = this.roundUpToNearest(mPool.mempoolminfee * 100000, this.minimumIncrement);
|
||||||
const defaultMinFee = Math.max(minimumFee, this.defaultFee);
|
const defaultMinFee = Math.max(minimumFee, this.defaultFee);
|
||||||
|
|
||||||
if (!pBlocks.length) {
|
if (!pBlocks.length) {
|
||||||
@ -58,7 +59,11 @@ class FeeApi {
|
|||||||
const multiplier = (pBlock.blockVSize - 500000) / 500000;
|
const multiplier = (pBlock.blockVSize - 500000) / 500000;
|
||||||
return Math.max(Math.round(useFee * multiplier), this.defaultFee);
|
return Math.max(Math.round(useFee * multiplier), this.defaultFee);
|
||||||
}
|
}
|
||||||
return Math.ceil(useFee);
|
return this.roundUpToNearest(useFee, this.minimumIncrement);
|
||||||
|
}
|
||||||
|
|
||||||
|
private roundUpToNearest(value: number, nearest: number): number {
|
||||||
|
return Math.ceil(value / nearest) * nearest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user