Skip to content
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

Merge feature-branch RFQ fixedpoint commits into main #1155

Merged
merged 31 commits into from
Oct 21, 2024

Conversation

ffranr
Copy link
Contributor

@ffranr ffranr commented Oct 19, 2024

This PR will merge approved commits from approved-rfq-fixedpoint into main.

The commits in this PR have already been approved and reviewed here:

#1136
#1141

ffranr and others added 30 commits October 14, 2024 16:31
This commit introduces the `BigInt.String` method, which can be used to
safely (without overflow) export a `BigInt` to RPC or JSON.
This commit introduces a type alias for a fixed-point type where the
coefficient is a `big.Int`.
This commit introduces a `big.Int` fixed-point constant representing the
number of milli-satoshis in one BTC.
This commit updates the RFQ price oracle's `QueryRateTick` endpoint to
return asset-to-BTC conversion rates as fixed-point numbers.
This commit replaces the BuyRequest.BipPrice field with
SuggestedAssetRate, changing a `uint64` price to an asset-to-BTC rate
represented as a fixed-point number.
This commit replaces the BuyAccept.AskPrice field with
AssetRate, changing a `uint64` price to an asset-to-BTC rate
represented as a fixed-point number.
This commit changes the PeerAcceptedBuyQuote.AskPrice field from a
`uint64` to a fixed-point representation for the asset-to-BTC rate.

It also updates the invoice milli-sat calculation to use the newly
introduced fixed-point field.
This commit modifies the AssetSalePolicy struct to carry the
asset-to-BTC rate instead of a "price". It also updates the policy check
equations to use the new rate field.
This commit replaces the SellRequest.AskPrice field with
SuggestedAssetRate, changing a `uint64` price to an asset-to-BTC rate
represented as a fixed-point number.
This commit replaces the SellAccept.BidPrice field with
AssetRate, changing a `uint64` price to an asset-to-BTC rate
represented as a fixed-point number.
This test ensures that converting an asset amount to fixed-point values
with different scales produces the same result when used in
`UnitsToMilliSatoshi`. The test confirms that the absence of a decimal
display value (scale) does not affect the final result.
Add a unit test demonstrating how a price oracle returns a TAP
asset-to-BTC rate and how that rate is used to convert an asset amount
into msats.
This commit modifies the AssetPurchasePolicy struct to carry the
asset-to-BTC rate instead of a "price". It also updates the policy check
equations to use the new rate field.
Introduce `BigInt.Bytes` and `BigInt.FromBytes` methods for encoding
and decoding `BigInt` in RFQ wire messages.
This will be used for serializing fixed-points in wire messages.
This commit updates the RFQ request wire message, renaming the
`SuggestedRateTick` field to `SuggestedAssetRate` and changing its type
to a fixed-point representation.
This commit replaces the RFQ accept wire message fields
InOutRateTick and OutInRateTick with InAssetRate and OutAssetRate.

The new fields represent the incoming asset-to-BTC rate and the
outgoing asset-to-BTC rate, respectively.
Modify TLV type integers to match the latest BLIP state.
Update the minimum supported accept wire message version to 1. Adjust
the version check logic to ensure that only version 1 is accepted, and
not any version greater than 0.
…mple

rfqmath: simplify price oracle rate example
Update TLV type integers to align with the latest BLIP state. Some
integer values are intentionally skipped to reserve space for new
fields defined in the BLIP.
Update the minimum supported request wire message version to 1. Adjust
the version check logic to ensure that only version 1 is accepted, and
not any version greater than 0.
@ffranr ffranr requested a review from Roasbeef October 19, 2024 00:18
# Conflicts:
#	docs/examples/basic-price-oracle/go.sum
#	docs/examples/basic-price-oracle/main.go
@coveralls
Copy link

coveralls commented Oct 19, 2024

Pull Request Test Coverage Report for Build 11440857483

Details

  • 127 of 560 (22.68%) changed or added relevant lines in 17 files are covered.
  • 38 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.04%) to 40.432%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapcfg/server.go 0 1 0.0%
rfqmsg/messages.go 22 28 78.57%
tapchannel/aux_traffic_shaper.go 0 12 0.0%
rfqmsg/records.go 30 43 69.77%
tapchannel/aux_invoice_manager.go 0 14 0.0%
rfqmsg/buy_accept.go 0 21 0.0%
rfqmsg/sell_accept.go 0 23 0.0%
rfq/order.go 0 26 0.0%
rfq/oracle.go 34 63 53.97%
rfqmsg/buy_request.go 0 31 0.0%
Files with Coverage Reduction New Missed Lines %
rfq/oracle.go 1 59.85%
tapchannel/aux_traffic_shaper.go 1 0.0%
commitment/tap.go 1 84.17%
rfqmsg/buy_accept.go 1 4.76%
rfqmsg/accept.go 2 29.66%
rfqmsg/sell_request.go 2 0.0%
rfqmsg/buy_request.go 2 0.0%
tappsbt/create.go 2 53.22%
rfq/negotiator.go 2 0.0%
tapgarden/caretaker.go 4 68.5%
Totals Coverage Status
Change from base Build 11399533526: -0.04%
Covered Lines: 24375
Relevant Lines: 60286

💛 - Coveralls

@dstadulis dstadulis changed the title Merge approved RFQ fixedpoint changes Merge feature-branch RFQ fixedpoint commits into main Oct 21, 2024
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

I think we should rebase the branch though, instead of merging main into it.

@dstadulis dstadulis added the rfq label Oct 21, 2024
@dstadulis dstadulis added this to the v0.4.2 milestone Oct 21, 2024
@ffranr ffranr force-pushed the approved-rfq-fixedpoint branch 2 times, most recently from f6b3711 to 0bdc03f Compare October 21, 2024 13:10
@dstadulis
Copy link
Collaborator

Will merge once @Roasbeef reviews

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎽

@Roasbeef Roasbeef merged commit 36a85b6 into main Oct 21, 2024
36 checks passed
@guggero guggero deleted the approved-rfq-fixedpoint branch October 21, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants