Skip to content

Commit 2955081

Browse files
committed
looprpc: rename assetamt to max amt
1 parent bb35e03 commit 2955081

File tree

7 files changed

+568
-370
lines changed

7 files changed

+568
-370
lines changed

client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,11 @@ func (s *Client) LoopOutQuote(ctx context.Context,
703703
}
704704

705705
loopOutQuote.LoopOutRfq = &LoopOutRfq{
706-
PrepayRfqId: prepayRfq.Id,
707-
PrepayAssetAmt: prepayRfq.AssetAmount,
708-
SwapRfqId: swapRfq.Id,
709-
SwapAssetAmt: swapRfq.AssetAmount,
710-
AssetName: assetName,
706+
PrepayRfqId: prepayRfq.Id,
707+
MaxPrepayAssetAmt: prepayRfq.AssetAmount,
708+
SwapRfqId: swapRfq.Id,
709+
MaxSwapAssetAmt: swapRfq.AssetAmount,
710+
AssetName: assetName,
711711
}
712712
}
713713

cmd/loop/quote.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func printQuoteOutResp(req *looprpc.QuoteRequest,
269269

270270
if resp.AssetRfqInfo != nil {
271271
fmt.Printf(assetAmtFmt, "Send off-chain:",
272-
resp.AssetRfqInfo.SwapAssetAmt,
272+
resp.AssetRfqInfo.MaxSwapAssetAmt,
273273
resp.AssetRfqInfo.AssetName)
274274
} else {
275275
fmt.Printf(satAmtFmt, "Send off-chain:", req.Amt)
@@ -289,7 +289,7 @@ func printQuoteOutResp(req *looprpc.QuoteRequest,
289289
fmt.Println()
290290
if resp.AssetRfqInfo != nil {
291291
fmt.Printf(assetAmtFmt, "No show penalty (prepay):",
292-
resp.AssetRfqInfo.PrepayAssetAmt,
292+
resp.AssetRfqInfo.MaxPrepayAssetAmt,
293293
resp.AssetRfqInfo.AssetName)
294294
} else {
295295
fmt.Printf(satAmtFmt, "No show penalty (prepay):",

interface.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,16 @@ type LoopOutRfq struct {
224224
// PrepayRfqId is the ID of the prepay RFQ.
225225
PrepayRfqId []byte
226226

227-
// PrepayAssetAmt is the amount of the asset that will be used to pay
228-
// for the prepay invoice.
229-
PrepayAssetAmt uint64
227+
// MaxPrepayAssetAmt is the maximum amount of the asset that will be
228+
// used to pay for the prepay invoice.
229+
MaxPrepayAssetAmt uint64
230230

231231
// SwapRfqId is the ID of the swap RFQ.
232232
SwapRfqId []byte
233233

234-
// SwapAssetAmt is the amount of the asset that will be used to pay for
235-
// the swap invoice.
236-
SwapAssetAmt uint64
234+
// MaxSwapAssetAmt is the maxmimum amount of the asset that will be used
235+
// to pay for the swap invoice.
236+
MaxSwapAssetAmt uint64
237237

238238
// AssetName is the human readable name of the asset.
239239
AssetName string

loopd/swapclient_server.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,11 @@ func (s *swapClientServer) LoopOutQuote(ctx context.Context,
802802

803803
if quote.LoopOutRfq != nil {
804804
response.AssetRfqInfo = &looprpc.AssetRfqInfo{
805-
PrepayRfqId: quote.LoopOutRfq.PrepayRfqId,
806-
PrepayAssetAmt: quote.LoopOutRfq.PrepayAssetAmt,
807-
SwapRfqId: quote.LoopOutRfq.SwapRfqId,
808-
SwapAssetAmt: quote.LoopOutRfq.SwapAssetAmt,
809-
AssetName: quote.LoopOutRfq.AssetName,
805+
PrepayRfqId: quote.LoopOutRfq.PrepayRfqId,
806+
MaxPrepayAssetAmt: quote.LoopOutRfq.MaxPrepayAssetAmt,
807+
SwapRfqId: quote.LoopOutRfq.SwapRfqId,
808+
MaxSwapAssetAmt: quote.LoopOutRfq.MaxSwapAssetAmt,
809+
AssetName: quote.LoopOutRfq.AssetName,
810810
}
811811
}
812812

looprpc/client.pb.go

Lines changed: 474 additions & 344 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,26 +2066,71 @@ message AssetRfqInfo {
20662066
bytes prepay_rfq_id = 1;
20672067

20682068
/*
2069-
The actual asset amt to prepay for the swap invoice.
2069+
The maximum asset amt we'll pay for the prepay payment. This includes the
2070+
max limit multiplier that was set in the request.
20702071
*/
2071-
uint64 prepay_asset_amt = 2;
2072+
uint64 max_prepay_asset_amt = 2;
2073+
2074+
/*
2075+
The asset to BTC conversion rate for the prepay invoice.
2076+
*/
2077+
FixedPoint prepay_asset_rate = 6;
20722078

20732079
/*
20742080
The Swap RFQ ID to use to pay for the swap invoice.
20752081
*/
20762082
bytes swap_rfq_id = 3;
20772083

20782084
/*
2079-
The actual asset amt to swap for the swap invoice.
2085+
The maximum asset amt we'll pay for the swap payment. This includes the
2086+
max limit multiplier that was set in the request.
20802087
*/
2081-
uint64 swap_asset_amt = 4;
2088+
uint64 max_swap_asset_amt = 4;
2089+
2090+
/*
2091+
The asset to BTC conversion rate for the swap invoice.
2092+
*/
2093+
FixedPoint swap_asset_rate = 7;
20822094

20832095
/*
20842096
The name of the asset to swap.
20852097
*/
20862098
string asset_name = 5;
20872099
}
20882100

2101+
// FixedPoint is a scaled integer representation of a fractional number.
2102+
//
2103+
// This type consists of two integer fields: a coefficient and a scale.
2104+
// Using this format enables precise and consistent representation of fractional
2105+
// numbers while avoiding floating-point data types, which are prone to
2106+
// precision errors.
2107+
//
2108+
// The relationship between the fractional representation and its fixed-point
2109+
// representation is expressed as:
2110+
// ```
2111+
// V = F_c / (10^F_s)
2112+
// ```
2113+
// where:
2114+
//
2115+
// * `V` is the fractional value.
2116+
//
2117+
// * `F_c` is the coefficient component of the fixed-point representation. It is
2118+
// the scaled-up fractional value represented as an integer.
2119+
//
2120+
// * `F_s` is the scale component. It is an integer specifying how
2121+
// many decimal places `F_c` should be divided by to obtain the fractional
2122+
// representation.
2123+
message FixedPoint {
2124+
// The coefficient is the fractional value scaled-up as an integer. This
2125+
// integer is represented as a string as it may be too large to fit in a
2126+
// uint64.
2127+
string coefficient = 1;
2128+
2129+
// The scale is the component that determines how many decimal places
2130+
// the coefficient should be divided by to obtain the fractional value.
2131+
uint32 scale = 2;
2132+
}
2133+
20892134
message AssetLoopOutInfo {
20902135
/*
20912136
The asset id that was used to pay for the swap invoice.

looprpc/client.swagger.json

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,20 +731,28 @@
731731
"format": "byte",
732732
"description": "The Prepay RFQ ID to use to pay for the prepay invoice."
733733
},
734-
"prepay_asset_amt": {
734+
"max_prepay_asset_amt": {
735735
"type": "string",
736736
"format": "uint64",
737-
"description": "The actual asset amt to prepay for the swap invoice."
737+
"description": "The maximum asset amt we'll pay for the prepay payment. This includes the\nmax limit multiplier that was set in the request."
738+
},
739+
"prepay_asset_rate": {
740+
"$ref": "#/definitions/looprpcFixedPoint",
741+
"description": "The asset to BTC conversion rate for the prepay invoice."
738742
},
739743
"swap_rfq_id": {
740744
"type": "string",
741745
"format": "byte",
742746
"description": "The Swap RFQ ID to use to pay for the swap invoice."
743747
},
744-
"swap_asset_amt": {
748+
"max_swap_asset_amt": {
745749
"type": "string",
746750
"format": "uint64",
747-
"description": "The actual asset amt to swap for the swap invoice."
751+
"description": "The maximum asset amt we'll pay for the swap payment. This includes the\nmax limit multiplier that was set in the request."
752+
},
753+
"swap_asset_rate": {
754+
"$ref": "#/definitions/looprpcFixedPoint",
755+
"description": "The asset to BTC conversion rate for the swap invoice."
748756
},
749757
"asset_name": {
750758
"type": "string",
@@ -896,6 +904,21 @@
896904
"looprpcFetchL402TokenResponse": {
897905
"type": "object"
898906
},
907+
"looprpcFixedPoint": {
908+
"type": "object",
909+
"properties": {
910+
"coefficient": {
911+
"type": "string",
912+
"description": "The coefficient is the fractional value scaled-up as an integer. This\ninteger is represented as a string as it may be too large to fit in a\nuint64."
913+
},
914+
"scale": {
915+
"type": "integer",
916+
"format": "int64",
917+
"description": "The scale is the component that determines how many decimal places\nthe coefficient should be divided by to obtain the fractional value."
918+
}
919+
},
920+
"description": "FixedPoint is a scaled integer representation of a fractional number.\n\nThis type consists of two integer fields: a coefficient and a scale.\nUsing this format enables precise and consistent representation of fractional\nnumbers while avoiding floating-point data types, which are prone to\nprecision errors.\n\nThe relationship between the fractional representation and its fixed-point\nrepresentation is expressed as:\n```\nV = F_c / (10^F_s)\n```\nwhere:\n\n* `V` is the fractional value.\n\n* `F_c` is the coefficient component of the fixed-point representation. It is\n the scaled-up fractional value represented as an integer.\n\n* `F_s` is the scale component. It is an integer specifying how\n many decimal places `F_c` should be divided by to obtain the fractional\n representation."
921+
},
899922
"looprpcGetInfoResponse": {
900923
"type": "object",
901924
"properties": {

0 commit comments

Comments
 (0)