Repository navigation
Price automatic fees at Coinset's fee tiers - #1028
Merged
Merged
Conversation
Automatic fees now pick a speed: Fast (about a minute), Standard (about 5 minutes) or Economy (within an hour), priced at the rate Coinset's get_fee_estimate gives for that target time, and never below the minimum of 5 mojos per cost. On a network Coinset doesn't serve, or when the estimate can't be fetched, every speed pays the recommended rate as before. A custom rate or a fixed amount can still be entered. - get_fee_rate returns the tiers, fastest first, and is async - The fee input picks a speed from a dropdown that shows each tier's rate, and the default fee setting uses the same control - Standard is the default tier, and an automatic fee stored before tiers is read as Standard - Fee rates are refreshed every minute while a fee input is shown
- Make the offer's coin split at the rate the confirmation showed, rather than a newer estimate fetched when the offer is made - Round tier rates up in whole mojos, so a rate that's already a whole hundredth isn't raised by another one - Share the network's Coinset client with the mempool source - Move the automatic fee input into its own component, and the tier labels and rate formatting into the fee helpers - Say only that estimates aren't available, since they can also fail to load on mainnet - Test the rate refresh, the fee rate cache keeping newer rates, the split fee confirmation, and that tests get no tiers
- Forget the fee rates when the wallet's state is cleared, so a network switch doesn't price transactions at the previous network's estimates - Show each speed's time until the rates load, rather than saying there are no estimates - Show an entered split rate as it was entered, and fix only a tier's rate when the offer is confirmed - Load the fee rates in the automatic fee input, so inputs showing an amount don't poll them - Derive the tiers' target times from the tiers - Test the speed captions without estimates and before the rates load, picking Custom again, the empty rate's placeholder, clearing the rates, and a response without a sync status
- Price the stand-in's estimates in whole hundredths of a mojo per cost, so a rate such as 5.11 isn't shown as 5.12 - Start the estimates state from the default estimates, rather than having a default with none - Drop a check for rates JSON can't express, and simplify choosing the fee estimate client - Test rejecting a negative standard or economy rate
The memo and clawback rows spanned two columns at every width, which gave the grid two content-sized columns below the breakpoint, so the amount and fee sat side by side and could run past the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automatic fees can now be priced at a speed using Coinset's fee estimates. Before, they always paid the minimum rate.
What changes
Speeds. An automatic fee picks Fast (about a minute), Standard (about 5 minutes) or Economy (within an hour). Each is priced at the rate Coinset's
get_fee_estimategives for that target time, for a transaction of typical cost.Floor of 5.
Fallback. Every speed pays the recommended rate of 5, as before, when:
The dropdown then says estimates aren't available.
Overrides. A custom rate in mojos per cost can still be entered from the same dropdown. The pencil button still switches to a fixed fee amount.
Default. The Default Fee setting uses the same control, and each transaction's fee starts from it.
auto) is read as Standard.Freshness.
Offer coin splits. Confirming an offer fixes an automatic split fee at the rate the confirmation dialog showed. That way, a newer estimate fetched while the offer is made can't change what's paid without the user seeing it.
Layout. The speed name is never cut off. In narrow fields, a long rate is shortened instead, and the custom rate drops the sparkle icon to make room. The Send page now uses one column on narrow screens. Before, its memo and clawback rows spanned two columns at every width, which put Amount and Network Fee side by side on phones and pushed the fee past the screen edge.
Coinset's
current_fee_rateisn't used as a floor. In live responses it equals the 1-minute estimate, so using it would price every tier as Fast.Sandbox
The sandbox runs on a simulator with no mempool, so the bridge now serves made-up estimates in place of Coinset's:
POST <bridge>/fee-estimateswith{"fast", "standard", "economy"}changes them, andnullturns them off to show the fallback.docs/sandbox.mdhas the commands.fee_estimatorclient override for this. It's used even in test mode, and only the sandbox sets it.API
get_fee_rateis now async and returnstiers: FeeTier[](name,target_time,fee_per_cost). The list is empty when there are no estimates.fee_per_cost.coinset_client(insage-wallet) now chooses the network's Coinset client for both the mempool source and the fee estimates.For you to decide
DEFAULT_FEE_TIERinsrc/lib/fees.ts.Testing
Rust unit tests cover turning estimate responses into tiers:
The
sage-rpcfee tests check that tests get no tiers. Tests never call Coinset (Sage::test).Frontend tests cover:
Sandbox tests go from the bridge's stand-in to
get_fee_rate:Checked in the sandbox:
Translation catalogs need
pnpm extractat the next release.Note
Medium Risk
This changes how every automatic fee is priced, and makes
get_fee_ratecall Coinset on mainnet and testnet11. A bad or high estimate raises fees. However, the confirmation dialog shows the fee (or, for an offer's coin split, the rate) before anything is submitted, and failures fall back to the old fixed rate of 5.sage/utils/fees.rs).get_fee_rateis async and returnstiers, with newFeeTierandFeeTierNameAPI types and regenerated bindings. There's a sharedcoinset_client.Sage::fee_estimatoroverride that only the sandbox sets.lib/fees.ts,state.ts)useFeeRates)AutoFeeInput, used byFeeAmountInputand the Default Fee setting