dynamically select default acceleration bid

This commit is contained in:
Mononaut 2025-05-15 22:32:47 +00:00
parent cba4308447
commit a81fcff752
No known key found for this signature in database
GPG key ID: A3F058E41374C04E

View file

@ -311,7 +311,15 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
index
}));
this.defaultBid = this.maxRateOptions[1].fee;
// if the difference in cost between the first two options is more than 20% of the base fee, default to the cheaper one
if (this.maxRateOptions.length > 2) {
const costDiff = this.maxRateOptions[1].fee - this.maxRateOptions[0].fee;
if (costDiff >= (this.estimate.mempoolBaseFee + this.estimate.vsizeFee) * 0.2) {
this.selectFeeRateIndex = 0;
}
}
this.defaultBid = this.maxRateOptions[this.selectFeeRateIndex].fee;
this.userBid = this.defaultBid;
this.cost = this.userBid + this.estimate.mempoolBaseFee + this.estimate.vsizeFee;