mirror of
https://github.com/lightninglabs/loop
synced 2024-11-08 01:10:29 +00:00
Merge pull request #595 from GeorgeTsagk/easy-autoloop-feeppm-param
Easy autoloop feeppm parameter
This commit is contained in:
commit
9847f3ab3b
@ -25,6 +25,10 @@ channel balance of 1M sats. Keep in mind that on first time use this will use
|
||||
the default budget parameters. If you wish to configure a custom budget you can
|
||||
find more info in the [Budget](#budget) section.
|
||||
|
||||
In addition, if you want to control the maximum amount of fees you're willing to
|
||||
spend per swap, as a percentage of the total swap amount, you can use the
|
||||
`feepercent` parameter as explained in the [Fees](#fees) section.
|
||||
|
||||
## Liquidity Rules
|
||||
|
||||
At present, autoloop can be configured to either acquire incoming liquidity
|
||||
@ -89,10 +93,11 @@ to a percentage of the swap amount using the fee percentage parameter:
|
||||
loop setparams --feepercent={percentage of swap amount}
|
||||
```
|
||||
|
||||
If you would like finer grained control over swap fees, there are multiple fee
|
||||
related settings which can be used to tune the autolooper to your preference.
|
||||
The sections that follow explain these settings in detail. Note that these fees
|
||||
are expressed on a per-swap basis, rather than as an overall budget.
|
||||
If you are not using easyautoloop and you would like finer grained control over
|
||||
swap fees, there are multiple fee related settings which can be used to tune the
|
||||
autolooper to your preference. The sections that follow explain these settings
|
||||
in detail. Note that these fees are expressed on a per-swap basis, rather than
|
||||
as an overall budget.
|
||||
|
||||
### On-Chain Fees
|
||||
When performing a successful loop out swap, the loop client needs to sweep the
|
||||
|
@ -1419,6 +1419,33 @@ func TestEasyAutoloop(t *testing.T) {
|
||||
|
||||
c.easyautoloop(step, true)
|
||||
c.stop()
|
||||
|
||||
// Restore the local balance to a higher value that will trigger a swap.
|
||||
easyChannel2.LocalBalance = btcutil.Amount(95000)
|
||||
channels = []lndclient.ChannelInfo{
|
||||
easyChannel1, easyChannel2,
|
||||
}
|
||||
|
||||
// Override the feeppm with a lower one.
|
||||
params.FeeLimit = NewFeePortion(5)
|
||||
|
||||
c = newAutoloopTestCtx(t, params, channels, testRestrictions)
|
||||
c.start()
|
||||
|
||||
// Even though there should be a swap dispatched in order to meet the
|
||||
// local balance target, we expect no action as the user defined feeppm
|
||||
// should not be sufficient for the swap to be dispatched.
|
||||
step = &easyAutoloopStep{
|
||||
minAmt: 1,
|
||||
maxAmt: 50000,
|
||||
// Since we have the exact same balance as the first step, we
|
||||
// can reuse the quoteOut1 for the expected loop out quote.
|
||||
quotesOut: quotesOut1,
|
||||
expectedOut: nil,
|
||||
}
|
||||
|
||||
c.easyautoloop(step, false)
|
||||
c.stop()
|
||||
}
|
||||
|
||||
// existingSwapFromRequest is a helper function which returns the db
|
||||
|
@ -600,11 +600,21 @@ func (m *Manager) dispatchBestEasyAutoloopSwap(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Override our current parameters in order to use the const percent
|
||||
// limit of easy-autoloop.
|
||||
// If no fee is set, override our current parameters in order to use the
|
||||
// default percent limit of easy-autoloop.
|
||||
easyParams := m.params
|
||||
easyParams.FeeLimit = &FeePortion{
|
||||
PartsPerMillion: defaultFeePPM,
|
||||
|
||||
switch feeLimit := easyParams.FeeLimit.(type) {
|
||||
case *FeePortion:
|
||||
if feeLimit.PartsPerMillion == 0 {
|
||||
feeLimit = &FeePortion{
|
||||
PartsPerMillion: defaultFeePPM,
|
||||
}
|
||||
}
|
||||
default:
|
||||
feeLimit = &FeePortion{
|
||||
PartsPerMillion: defaultFeePPM,
|
||||
}
|
||||
}
|
||||
|
||||
// Set the swap outgoing channel to the chosen channel.
|
||||
|
Loading…
Reference in New Issue
Block a user