Skip to content

Commit 5e9f822

Browse files
authored
Add more constants for auto swap outs (#443)
* Add configuration for automatic swap operations fees and prepay amount * Refactor AutoLiquidityManagementJob to use constants for service fees and prepay amount
1 parent ac667ef commit 5e9f822

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/Helpers/Constants.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public class Constants
116116
/// </summary>
117117
public static int SWEEP_CONF_TARGET = 6;
118118

119+
/// <summary>
120+
/// Maximum miner fees in satoshis for automatic swap operations
121+
/// </summary>
122+
public static long SWAP_MAX_MINER_FEES_SATS = 15000;
123+
124+
/// <summary>
125+
/// Maximum service fees as a percentage for automatic swap operations
126+
/// </summary>
127+
public static decimal SWAP_MAX_SERVICE_FEES_PERCENT = 0.1m;
128+
129+
/// <summary>
130+
/// Prepay amount in satoshis for automatic swap operations
131+
/// </summary>
132+
public static long SWAP_PREPAY_AMOUNT_SATS = 1337;
133+
119134
public const string IsFrozenTag = "frozen";
120135
public const string IsManuallyFrozenTag = "manually_frozen";
121136

@@ -298,6 +313,16 @@ static Constants()
298313
var scanBatchSize = Environment.GetEnvironmentVariable("SCAN_BATCH_SIZE");
299314
SCAN_BATCH_SIZE = scanBatchSize != null ? int.Parse(scanBatchSize) : SCAN_BATCH_SIZE;
300315

316+
// Swap configuration
317+
var swapMaxMinerFees = Environment.GetEnvironmentVariable("SWAP_MAX_MINER_FEES_SATS");
318+
SWAP_MAX_MINER_FEES_SATS = swapMaxMinerFees != null ? long.Parse(swapMaxMinerFees) : SWAP_MAX_MINER_FEES_SATS;
319+
320+
var swapMaxServiceFeesPercent = Environment.GetEnvironmentVariable("SWAP_MAX_SERVICE_FEES_PERCENT");
321+
SWAP_MAX_SERVICE_FEES_PERCENT = swapMaxServiceFeesPercent != null ? decimal.Parse(swapMaxServiceFeesPercent, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture) : SWAP_MAX_SERVICE_FEES_PERCENT;
322+
323+
var swapPrepayAmount = Environment.GetEnvironmentVariable("SWAP_PREPAY_AMOUNT_SATS");
324+
SWAP_PREPAY_AMOUNT_SATS = swapPrepayAmount != null ? long.Parse(swapPrepayAmount) : SWAP_PREPAY_AMOUNT_SATS;
325+
301326
// DB Initialization
302327
ALICE_PUBKEY = Environment.GetEnvironmentVariable("ALICE_PUBKEY") ?? ALICE_PUBKEY;
303328
ALICE_HOST = Environment.GetEnvironmentVariable("ALICE_HOST") ?? ALICE_HOST;

src/Jobs/AutoLiquidityManagementJob.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ public async Task<ManageNodeLiquidityResult> ManageNodeLiquidity(Node node, Canc
215215
Amount = swapAmount,
216216
Address = destinationAddress,
217217
MaxRoutingFeesPercent = node.MaxSwapRoutingFeeRatio * 100, // Convert to percentage
218-
MaxServiceFeesPercent = 0.1m,
219-
MaxMinerFees = 10000,
218+
MaxServiceFeesPercent = Constants.SWAP_MAX_SERVICE_FEES_PERCENT,
219+
MaxMinerFees = Constants.SWAP_MAX_MINER_FEES_SATS,
220220
SweepConfTarget = Constants.SWEEP_CONF_TARGET,
221-
PrepayAmtSat = 1337, // As there's no quote and this is a edge-case to prepay, we set a fixed prepay amount
221+
PrepayAmtSat = Constants.SWAP_PREPAY_AMOUNT_SATS,
222222
SwapPublicationDeadlineMinutes = 30,
223223
};
224224

0 commit comments

Comments
 (0)