-
Notifications
You must be signed in to change notification settings - Fork 123
Minor asset loop out fixes #876
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
Conversation
hieblmi
left a comment
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.
LGTM, I think a unit test around the fixpoint conversion would make sense.
484d049 to
32647a5
Compare
starius
left a comment
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.
LGTM! 🏆
Added few comments.
| // | ||
| // * `F_s` is the scale component. It is an integer specifying how | ||
| // many decimal places `F_c` should be divided by to obtain the fractional | ||
| // representation. |
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.
This type is the same as github.com/lightninglabs/taproot-assets/taprpc/rfqrpc.FixedPoint
Can we include .proto file from taproot-assets?
If this is not possible, I propose to add TODO to deduplicate this in the future.
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.
It's not straightforward to include the proto files from other repos.
E.g. even within tap it's in multiple files:
https://github.com/lightninglabs/taproot-assets/blob/563efdc6c50b73cc9ea9d4fd77553c46948f6f01/taprpc/rfqrpc/rfq.proto#L112
https://github.com/lightninglabs/taproot-assets/blob/563efdc6c50b73cc9ea9d4fd77553c46948f6f01/taprpc/priceoraclerpc/price_oracle.proto#L48
|
|
||
| // unmarshalFixedPoint converts an RPC FixedPoint to a BigIntFixedPoint. | ||
| func unmarshalFixedPoint(fp *looprpc.FixedPoint) (*rfqmath.BigIntFixedPoint, | ||
| error) { |
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 propose to reuse https://pkg.go.dev/github.com/lightninglabs/taproot-assets/taprpc/rfqrpc#UnmarshalFixedPoint
looprpc.FixedPoint is the same type as rfqrpc.FixedPoint (has the same fields).
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.
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.
It is possible to create a struct manually filling the fields.
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.
created a rfqrpc.FixedPoint struct and called rfqrpc.UnmarshalFixedPoint
loopd/swapclient_server.go
Outdated
| SwapAssetRate: &looprpc.FixedPoint{ | ||
| Scale: uint32(quote.LoopOutRfq.SwapAssetRate.Scale), | ||
| Coefficient: quote.LoopOutRfq.SwapAssetRate.Coefficient.String(), | ||
| }, |
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 propose to factor out this transformation to a function, e.g. marshalFixedPoint.
It is used twice, for PrepayAssetRate and for SwapAssetRate.
SwapAssetRate: marshalFixedPoint(quote.LoopOutRfq.SwapAssetRate),We can also cover functions marshalFixedPoint and unmarshalFixedPoint with a unit test making sure everything is converted properly back and forth.
32647a5 to
9008b3b
Compare
9008b3b to
d0191d2
Compare

This PR adds some minor asset loop out fixes:
This is what a loop out quote will look like now:
