-
Notifications
You must be signed in to change notification settings - Fork 46
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
Premium #264
Premium #264
Conversation
dc5b87f
to
8870169
Compare
6f44cbc
to
4c591cc
Compare
Asking for opinions: Should we have fine grained configuration to allow for setting certain peers a different premium fee rate? |
I think no. But allow separate premiums for received swap ins and swap outs, including negative values. This will allow managing liquidity among BTC, LBTC and Lightning. |
In the future, it may be better to allow premiums to be set according to the degree of use, such as channels that flow easily in both directions or channels that flow only in one direction. |
It is possible to configure swap in and swap out in |
Yes I think so. Channels may have different characteristics that would benefit from having individual premium/discount rates to incentivize swapping in one direction or the other, similar to how routing fee rates can be used to influence how a channel is used? |
e49ad78
to
65dcce8
Compare
Looks like the premium info is missing from the CLN
|
Would it be useful to have the premium rate limit be a config option in |
Hitting this with CLN as sender:
|
CLN plugin crashed when trying a
Looks like
The logs appear to show that the swap I attempted succeeded however.
|
Thanks for the test. |
FIXED. SwapInPremiumRatePPM and SwapInPremiumRatePPM are added to the ListPeers. I rearranged the order of commands. The source of the information was an error, which I corrected. |
@YusukeShimizu Hello. Do you plan RPC endpoints to configure premium rates? |
I have no definite plan. There are some opinions that a fine-grained premium setting is needed, so I may need to think about an appropriate design for that (such as having RPC endpoints, etc.) |
At 9c34c47 my
|
75fb65c
to
d8b683d
Compare
I fixed it on d8b683d |
Yes, they can go negative. |
Tested ACK c84e53a |
I think there should be a method to remove a peer's specific rate from the db so that it reverts to the global default value. |
for a positive premium rate, both counterparties see the same report, so not possible to understand who paid the premium to whom.
A swap with a negative fee rate also resulted in both parties seeing a negative premium_amount:
...but the LN payment was 1% smaller, so the discount worked:
|
For this we could maybe change it to something like |
ppm is not needed, it can be computed from premium_amount and swap amount. I think the premium amount is already correct, except the sign. it should be positive for the peer that received premium, and negative for the one who paid it. |
91e375c
to
f4002f2
Compare
Add a new RPC and CLI command to delete peer-specific premium rates. Ensure default rate usage once the per-peer rate is removed.
f4002f2
to
b26c621
Compare
I just added a new RPC and CLI command to remove a peer-specific premium rate, so it falls back to the global default once the per-peer rate is deleted. Also, I adjusted the sign in PrettyprintFromServiceSwap for the sender role to ensure it’s displayed correctly. delete premium ratelnd./bin/pscli peerswap1 updatepremiumrate --asset LBTC --operation swap_out --node_id 02149a96f829dcfbea2089fd5e3fe3fd9d2d08157694102d3ddf6db346d5dd161d --rate 100
{
"asset": "LBTC",
"operation": "SWAP_OUT",
"premium_rate_ppm": "100"
} ./bin/pscli peerswap1 deletepeerpremiumrate --asset LBTC --operation SWAP_OUT --node_id 02149a96f829dcfbea2089fd5e3fe3fd9d2d08157694102d3ddf6db346d5dd161d
{
"asset": "LBTC",
"operation": "SWAP_OUT",
} fall back to default ./bin/pscli peerswap1 getpeerpremiumrate --asset LBTC --operation SWAP_OUT --node_id 02149a96f829dcfbea2089fd5e3fe3fd9d2d08157694102d3ddf6db346d5dd161d
{
"asset": "LBTC",
"operation": "SWAP_OUT",
"premium_rate_ppm": "10000"
} cln./bin/clncli peerswap-setpremiumrate 02bc29431b3a13172dd1c469aaa718990c37b3a3a4b8098523ad4c3c61f7fb282c lbtc SWAP_OUT 10000
{
"asset": 2,
"operation": 2,
"premium_rate_ppm": 100
} ./bin/clncli peerswap-deletepremiumrate 02bc29431b3a13172dd1c469aaa718990c37b3a3a4b8098523ad4c3c61f7fb282c lbtc SWAP_OUT
{
"asset": 2,
"operation": 2
} fall back to default ./bin/clncli peerswap-getpremiumrate 02bc29431b3a13172dd1c469aaa718990c37b3a3a4b8098523ad4c3c61f7fb282c lbtc SWAP_OUT
{
"asset": 2,
"operation": 2,
"premium_rate_ppm": 10000
} PrettyprintFromServiceSwap./bin/pscli peerswap1 swapout --channel_id $CHANID --sat_amt 1000000 --asset lbtc --premium_limit_rate_ppm 100000
{
"swap": {
"id": "c7a54d60bdf3deb0b0e77bc074cc625d84d5e62dda7aa97df40edf5c9e1a0f31",
"created_at": "1741931535",
"asset": "lbtc",
"type": "swap-out",
"role": "sender",
"state": "State_SwapOutSender_AwaitTxConfirmation",
"initiator_node_id": "03854c727bacb9a39da5cb5bd50fdf250747d32b11c4ff56389adfecabf5c91445",
"peer_node_id": "0276b3477147a0374e5d372c53c394bd1e286cbba613a7ff0fc8afce2d6def07e3",
"amount": "1000000",
"channel_id": "116:1:1",
"opening_tx_id": "05f3d7a7929758ab4c0def7919da41f9b4c184cbd47dd2f85b3694f25a561529",
"claim_tx_id": "",
"cancel_message": "",
"lnd_chan_id": "127543348887553",
"premium_amount": "-10000"
}
} ./bin/pscli peerswap2 listswaps
{
"swaps": [
{
"id": "c7a54d60bdf3deb0b0e77bc074cc625d84d5e62dda7aa97df40edf5c9e1a0f31",
"created_at": "1741931535",
"asset": "lbtc",
"type": "swap-out",
"role": "receiver",
"state": "State_SwapOutReceiver_AwaitClaimInvoicePayment",
"initiator_node_id": "03854c727bacb9a39da5cb5bd50fdf250747d32b11c4ff56389adfecabf5c91445",
"peer_node_id": "03854c727bacb9a39da5cb5bd50fdf250747d32b11c4ff56389adfecabf5c91445",
"amount": "1000000",
"channel_id": "116:1:1",
"opening_tx_id": "05f3d7a7929758ab4c0def7919da41f9b4c184cbd47dd2f85b3694f25a561529",
"claim_tx_id": "",
"cancel_message": "",
"lnd_chan_id": "127543348887553",
"premium_amount": "10000"
}
]
} |
Tested ACK b26c621 |
Replace 'SetDefaultPremiumRate' with 'UpdateGlobalPremiumRate' Replace 'GetDefaultPremiumRate' with 'GetGlobalPremiumRate' Adjust commands in usage and docs.
52902db
to
e20d9aa
Compare
add default premium rates for BTC and LBTC swap operations
e20d9aa
to
6369d6a
Compare
ACK 6369d6a |
When the global rate is zero, the LND peerswap has the field:
|
8d56a98
to
2dc7a91
Compare
Replace direct returns with formatProtoMessage Ensure multiline formatting with protojson Preserve indentation and use enums in textual form
2dc7a91
to
26268a0
Compare
It was caused by how I’ll keep this in mind for the changes introduced in PR #231 as well. |
Tested ACK 26268a0 |
This PR adds premium to peerswap.
design doc
Usage
https://github.com/YusukeShimizu/peerswap/blob/26268a07e923019f9ef46fa5932d183db41de1dc/docs/usage.md