-
Notifications
You must be signed in to change notification settings - Fork 47
feature: add outbound-liquidity auction market, bidder pays for channel acceptance #390
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2a5c14
rpc: add auction type field to orders
positiveblue d1b9a63
order: add auction type field to order struct/db
positiveblue 7669c7f
multi: parse and propagate auction type field for orders
positiveblue 34bbd1e
cmd: add auction type param for orders
positiveblue e5d78fd
multi: update order/batch verification for outbound liquidity auctions
positiveblue b851699
docs: sketch the two supported auction types
positiveblue e6b45a7
rpc: update the comment for
positiveblue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,34 @@ const ( | |
| channelTypePeerDependent = "legacy" | ||
| channelTypeScriptEnforced = "script-enforced" | ||
|
|
||
| auctionTypeInboundLiquidity = "inbound" | ||
| auctionTypeOutboundLiquidity = "outbound" | ||
|
|
||
| defaultMaxBatchFeeRateSatPerVByte = 100 | ||
|
|
||
| defaultConfirmationConstraints = 1 | ||
|
|
||
| defaultAuctionType = auctionTypeInboundLiquidity | ||
|
|
||
| submitOrderDescription = ` | ||
| Submit a new order in the given market. Currently, Pool supports two | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great description 👍 |
||
| types of orders: asks, and bids. In Pool, market participants buy/sell | ||
| liquidity in _units_. A unit is 100,000 satoshis. | ||
|
|
||
| In the *inbound* market, the bidder pays the asker a premium for a | ||
| channel with 50% to 100% of inbound liquidity. The premium amount is | ||
| calculated using the funding amount of the asker. | ||
|
|
||
| In the outbound market, the bidder pays the asker a premium for | ||
| a channel with outbound liquidity. | ||
| To participate in the outbound market the asker needs to create an order | ||
| with '--amount=100000' (one unit) and the '--min_chan_amt' equals to | ||
| the minimum channel size that is willing to accept. | ||
| The bidder needs to create an order with '--amount=100000' (one unit) | ||
| and '--self_chan_balance' equals to the funds that is willing to commit | ||
| in a channel. The premium amount is calculated using the funding amount | ||
| of the bidder ('--self_chan_balance'). | ||
| ` | ||
| ) | ||
|
|
||
| var ordersCommands = []cli.Command{ | ||
|
|
@@ -40,9 +65,10 @@ var ordersCommands = []cli.Command{ | |
| ordersListCommand, | ||
| ordersCancelCommand, | ||
| { | ||
| Name: "submit", | ||
| Aliases: []string{"s"}, | ||
| Usage: "submit an order", | ||
| Name: "submit", | ||
| Aliases: []string{"s"}, | ||
| Usage: "submit an order", | ||
| Description: submitOrderDescription, | ||
| Subcommands: []cli.Command{ | ||
| ordersSubmitAskCommand, | ||
| ordersSubmitBidCommand, | ||
|
|
@@ -129,6 +155,14 @@ var sharedFlags = []cli.Flag{ | |
| channelTypePeerDependent, | ||
| channelTypeScriptEnforced), | ||
| }, | ||
| cli.StringFlag{ | ||
| Name: "auction_type", | ||
| Usage: fmt.Sprintf("the auction market where this offer "+ | ||
positiveblue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "must be considered in during matching (%q, %q)", | ||
| auctionTypeInboundLiquidity, | ||
| auctionTypeOutboundLiquidity), | ||
positiveblue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Value: defaultAuctionType, | ||
| }, | ||
| cli.StringSliceFlag{ | ||
| Name: "allowed_node_id", | ||
| Usage: "the list of nodes this order is allowed to match " + | ||
|
|
@@ -287,12 +321,26 @@ func parseCommonParams(ctx *cli.Context, blockDuration uint32) (*poolrpc.Order, | |
| break | ||
| case channelTypePeerDependent: | ||
| params.ChannelType = auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_PEER_DEPENDENT | ||
|
|
||
| case channelTypeScriptEnforced: | ||
| params.ChannelType = auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED | ||
|
|
||
| default: | ||
| return nil, fmt.Errorf("unknown channel type %q", channelType) | ||
| } | ||
|
|
||
| auctionType := ctx.String("auction_type") | ||
| switch auctionType { | ||
| case auctionTypeInboundLiquidity: | ||
| params.AuctionType = auctioneerrpc.AuctionType_AUCTION_TYPE_BTC_INBOUND_LIQUIDITY | ||
|
|
||
| case auctionTypeOutboundLiquidity: | ||
| params.AuctionType = auctioneerrpc.AuctionType_AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY | ||
|
|
||
| default: | ||
| return nil, fmt.Errorf("unknown auction type %q", channelType) | ||
| } | ||
|
|
||
| // Get the list of node ids this order is allowed/not allowed to match | ||
| // with. | ||
| allowedNodeIDs, err := parseNodePubKeySlice(ctx, "allowed_node_id") | ||
|
|
@@ -457,6 +505,28 @@ func ordersSubmitAsk(ctx *cli.Context) error { // nolint: dupl | |
|
|
||
| ask.Details = params | ||
|
|
||
| // Checks for the outbound liquidity market. | ||
| if ask.Details.AuctionType == auctioneerrpc.AuctionType_AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY { | ||
| var err error | ||
| baseSupply := uint64(order.BaseSupplyUnit) | ||
| switch { | ||
| case ask.Details.Amt != baseSupply: | ||
| err = fmt.Errorf("The order amount be exactly the "+ | ||
| "base supply amount (%v sats)", baseSupply) | ||
|
|
||
| case !ctx.IsSet("min_chan_amt") || | ||
| ctx.Uint64("min_chan_amt") == 0: | ||
|
|
||
| err = fmt.Errorf("The `min_chan_amt` parameter must "+ | ||
| "be set to at least %v sats", baseSupply) | ||
| } | ||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("unable to participate in the "+ | ||
| "outbound liquidity market. %v", err) | ||
| } | ||
| } | ||
|
|
||
| client, cleanup, err := getClient(ctx) | ||
| if err != nil { | ||
| return err | ||
|
|
@@ -672,8 +742,9 @@ func parseBaseBid(ctx *cli.Context) (*poolrpc.Bid, *sidecar.Ticket, error) { | |
| if ctx.IsSet("self_chan_balance") { | ||
| bid.SelfChanBalance = ctx.Uint64("self_chan_balance") | ||
| bidAmt := btcutil.Amount(bid.Details.Amt) | ||
| err := sidecar.CheckOfferParams( | ||
| bidAmt, btcutil.Amount(bid.SelfChanBalance), | ||
| err := order.CheckOfferParams( | ||
positiveblue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| order.AuctionType(bid.Details.AuctionType), bidAmt, | ||
| btcutil.Amount(bid.SelfChanBalance), | ||
| order.BaseSupplyUnit, | ||
| ) | ||
| if err != nil { | ||
|
|
@@ -688,6 +759,26 @@ func parseBaseBid(ctx *cli.Context) (*poolrpc.Bid, *sidecar.Ticket, error) { | |
| } | ||
| } | ||
|
|
||
| // Checks for the outbound liquidity market. | ||
| if bid.Details.AuctionType == auctioneerrpc.AuctionType_AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY { | ||
| var err error | ||
| baseSupply := uint64(order.BaseSupplyUnit) | ||
| switch { | ||
| case bid.Details.Amt != baseSupply: | ||
| err = fmt.Errorf("The order amount must be exactly "+ | ||
| "the base supply amount (%v sats)", baseSupply) | ||
|
|
||
| case bid.SelfChanBalance < baseSupply: | ||
| err = fmt.Errorf("The `self_chan_balance` parameter "+ | ||
| "must be set to at least %v sats", baseSupply) | ||
| } | ||
| if err != nil { | ||
| return nil, nil, fmt.Errorf("The unable to"+ | ||
| "participate in the outbound liquidity "+ | ||
| "market. %v", err) | ||
| } | ||
| } | ||
|
|
||
| return bid, ticket, nil | ||
| } | ||
|
|
||
|
|
||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.