-
Notifications
You must be signed in to change notification settings - Fork 127
client: order options #1170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client: order options #1170
Conversation
I definitely agree with using an options map like you have here. I also think there should be a new request type that returns which order options each asset supports. I'll start by updating #1164 to use this instead of how I have it there and adding this new request. Then add in these other options (feebump/splittx) in subsequent PRs. Does that sound good? |
The way forward that I see for this PR and #1164 is just for this PR to be pared down to just the backend pieces and merged as the basis for other options as well as the frontend work to use it all. I'm not sure I see a clean way to rework 1164 on this basis short of just starting over with this one, but it's already here. Let's clean this one up and see how it forms a basis for continuing on the order options feature.
We'll have to think this through some more as applicable options will vary depending on the wallet settings and other things we'd likely get from an order estimate. @martonp Please work this out with @buck54321, but it seems simplest to get this on in. I think we are starting on a feature that is going to involve several iterations with plenty of room for improvement. In any case, these are not for 0.3, so not top priority. |
I've been working on some changes since this PR assumes that the options will not need to be used in |
Maybe you could explain more, but we shouldn't be reasoning about these options in core. |
Why shouldn't we be reasoning about order options in core? |
var highestFeeRate uint64
for i, match := range matches {
...
}
if t.metaData.MinSwapFeeRate != nil && *t.metaData.MinSwapFeeRate > highestFeeRate {
highestFeeRate = *t.metaData.MinSwapFeeRate
} and that operation can trivially be moved to the asset backend's
|
Yeah, I agree with that assessment. While this particular change is not at the top of our priorities, I think this PR should get out of draft soon so we can more clearly evaluate next steps and what if anything should come out of #1164. Whichever way we go, I think this entire initiative is important as it gives flexibility to the user, and in this PR's framework it keeps Core logic only concerned with logic that only it can/must handle while allowing backends to decide about the relevance and details of particular options on their own. |
You're right, it seems there doesn't need to be logic in core that deals with The issue I see with the current solution is that each of the options are defined separately in each asset's code, but when making the UI or the rpc client, there needs to be a unified set of options that are exposed. The My idea was to have the full set of options be defined separately, and then each asset would just specify which of these options it supports. This technique will preserve all of the benefits that you described, but it would also provide consistency, and it would also give us the option to use these options in Here is a rough draft, let me know what you guys think: |
4ed0375
to
50551e2
Compare
50551e2
to
11ba297
Compare
1aacd2e
to
0176478
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks super cool!
I ran into a problem swapping, just using random values. Unfortunately I have not been able to reproduce, but here was the error I saw. Was with a fresh simnet dex and client.
[ERR] CORE: 127.0.0.1:17273 tick: {swapMatches order 36e26c2efb664116d4a4ce7aa1852a879b58356c8223dcb3d6b46cd223a565df - {error sending swap transaction: not enough funds to cover minimum fee rate. 0.0000428 < 0.0000251}}
I'll try a few more times though.
edit:
It seems to happen pretty consistently when I trade with myself with one lot and turning the three options on. Let me know if you are unable to reproduce.
client/asset/btc/btc.go
Outdated
if feeBump > 1.01 { | ||
bumpedMaxRate = uint64(math.Round(float64(bumpedMaxRate) * feeBump)) | ||
bumpedNetRate = uint64(math.Round(float64(bumpedNetRate) * feeBump)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feeBump > 1.0
would indicate a fee bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of setting an informal minimum bump of 1% here, but there's not real reason it has to be that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greater than 1% looks like. But I don't see a downside to blindly multiplying by feeBump
as long as it is >1.
More fundamentally, the units and meaning of FeeBump
all the way back to swapOptions
and redeemOptions
is not perfectly clear. It could conceivable be a percent added e.g. 0.01 instead of a multiplier like 1.01, or it could even be an integer that is an absolute sat/vB to add, or an integer that represents steps of say 0.1%.
Just depends on the definition of calcBumpedRate
I suppose.
client/asset/btc/btc.go
Outdated
if fee > totalIn { | ||
return nil, nil, 0, fmt.Errorf("redeem tx not worth the fees") | ||
} | ||
btc.log.Warnf("Ignoring fee bump (%v) resulting in fees > redemption", customCfg.FeeBump) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only prints the pointer value as well, so not very useful. Maybe you want the float value.
// is used, the fee rate used should be at least the suggested fee, else | ||
// zero-conf coins might be rejected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see the reasoning for the TODO now.
0176478
to
64f8008
Compare
userBump := *bump | ||
if userBump > 2.0 { | ||
return baseRate, fmt.Errorf("fee bump %f is higher than the 2.0 limit", userBump) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, normally this is quite sensible. But when fees are generally low, like 1 or 2 sat/vB, I'd really want to bump in absolute units of sat/vB. Applying a multiplier bump of 2.0 to a 1.0 sat/vB is fairly insignificant, and provides little buffer in the event rising fees. This is fine, just thinking for another scale option in the future.
Outside of DEX, I often pick a rate that is a only a few sat/vB higher than the current recommended, but still several times higher. A percentage is obviously the most robust for dealing with a wide range of fee rates over time, and good for higher rates, so this is sensible. I just wonder if we'll end up wanting an absolute bump options at some point, or maybe a percent limit that scales with current fee rate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this. An absolute bump would be preferred in some cases, but a multiplier has a wider range of applicability and also provides a natural upper limit to the bump size without hard-coded max values. Can re-visit as needed, of course.
client/asset/dcr/dcr.go
Outdated
reason = fmt.Sprintf("+%d%% fees, -%s DCR overlock", int(math.Round(pctChange)), amount(overlock)) | ||
} else { | ||
reason = fmt.Sprintf("+%.1f%% fees, -%s DCR overlock", pctChange, amount(overlock)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the negative amount overlock a bit confusing. We are trying to say that they are paying more in fees because of the added transaction, but doing that eliminates/avoids the over locking of %s DCR.
Is there are clearer way to express this within the constraints of this ui dialog?
Add order-time wallet options. The options are returned as part of a pre-order estimate, and are persisted as part of order metadata so that they can be passed to FundOrder, Swap, and Redeem. BTC, clones, and DCR all get two swap options (fee bump, split) and 1 redemption option (fee bump). Define two different option types, boolean and xy-range. Each input type corresponds to a different UI input widget, with boolean being a simple checkbox while xy-range offers a slider and text inputs. The types are intentionally generic for reusability.
8812be4
to
0f74bb4
Compare
Related to #1164, this work allows wallet-defined, user-selected, per-order options that affect how swaps and redemptions are processed by the wallet.
This PR is barely roughed out, but is presented for discussion in contrast with #1164. The primary benefits of this approach over that of #1164, imo, are
Options
is completely optional. Developers of new assets can ignore them, or add them in piecemeal as demand requires.Ignore the front-end stuff for now, and btc (and clones) is the only asset done so far.Ready for review