mirror of
https://github.com/MAGICGrants/autoforward-autoconvert.git
synced 2026-01-09 13:37:54 -05:00
feat: accept MAX_BITCOIN_FEE_PERCENT and MAX_SLIPPAGE_PERCENT as env variables
This commit is contained in:
13
.env.example
13
.env.example
@@ -1,16 +1,17 @@
|
||||
ELECTRUM_RPC_URL="http://electrum-client:7000"
|
||||
MONERO_RPC_URL="http://monero-wallet-rpc:18082/json_rpc"
|
||||
ELECTRUM_RPC_USERNAME="user"
|
||||
MONERO_RPC_USERNAME="user"
|
||||
MONERO_DAEMON_ADDRESS="xmr.tcpcat.net:18089"
|
||||
|
||||
ELECTRUM_RPC_PASSWORD=""
|
||||
ELECTRUM_SERVER_ADDRESS=""
|
||||
BITCOIN_WALLET_SEED=""
|
||||
|
||||
MONERO_DAEMON_ADDRESS="xmr.tcpcat.net:18089"
|
||||
MONERO_RPC_URL="http://monero-wallet-rpc:18082/json_rpc"
|
||||
MONERO_RPC_USERNAME="user"
|
||||
MONERO_RPC_PASSWORD=""
|
||||
BITCOIN_WALLET_SEED=""
|
||||
MONERO_WALLET_SEED=""
|
||||
MONERO_WALLET_PASSWORD=""
|
||||
MONERO_WALLET_HEIGHT=""
|
||||
|
||||
KRAKEN_API_KEY=""
|
||||
KRAKEN_API_SECRET=""
|
||||
MAX_BITCOIN_FEE_PERCENT="10"
|
||||
MAX_SLIPPAGE_PERCENT="1"
|
||||
@@ -3,8 +3,8 @@ import traceback
|
||||
import random
|
||||
import time
|
||||
|
||||
from constants import MAX_SLIPPAGE_PERCENT
|
||||
import util
|
||||
import env
|
||||
|
||||
order_min = {
|
||||
'XBT': 0.0001,
|
||||
@@ -40,7 +40,7 @@ def attempt_sell(asset: Literal['XBT', 'XMR']):
|
||||
slippage_percent = ((market_price - bid_price) / market_price) * 100 # Example ((161.06-161.05)/161.06)*100 = 0.0062088662610207
|
||||
|
||||
# Break loop if slippage is too high
|
||||
if slippage_percent > MAX_SLIPPAGE_PERCENT:
|
||||
if slippage_percent > env.MAX_SLIPPAGE_PERCENT:
|
||||
break
|
||||
|
||||
# Otherwise, add the bid_volume to the to_sell_amount
|
||||
|
||||
@@ -4,7 +4,7 @@ import traceback
|
||||
import requests
|
||||
import json
|
||||
|
||||
from constants import MAX_BITCOIN_FEE_PERCENT, MIN_BITCOIN_SEND_AMOUNT, MIN_MONERO_SEND_AMOUNT
|
||||
from constants import MIN_BITCOIN_SEND_AMOUNT, MIN_MONERO_SEND_AMOUNT
|
||||
import util
|
||||
import env
|
||||
|
||||
@@ -110,7 +110,7 @@ def attempt_bitcoin_autoforward():
|
||||
total_fee = get_total_psbt_fee(psbt_data)
|
||||
amount = balance
|
||||
|
||||
if total_fee / amount * 100 > MAX_BITCOIN_FEE_PERCENT:
|
||||
if total_fee / amount * 100 > env.MAX_BITCOIN_FEE_PERCENT:
|
||||
print(util.get_time(), f'Not autoforwarding due to high transaction fee.')
|
||||
return
|
||||
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
MIN_BITCOIN_SEND_AMOUNT = 0.0001
|
||||
MAX_BITCOIN_FEE_PERCENT = 10
|
||||
MIN_MONERO_SEND_AMOUNT = 0.01
|
||||
MAX_SLIPPAGE_PERCENT = 1
|
||||
@@ -14,3 +14,6 @@ MONERO_WALLET_HEIGHT = os.getenv('MONERO_WALLET_HEIGHT', '')
|
||||
|
||||
KRAKEN_API_KEY = os.getenv('KRAKEN_API_KEY', '')
|
||||
KRAKEN_API_SECRET = os.getenv('KRAKEN_API_SECRET', '')
|
||||
|
||||
MAX_BITCOIN_FEE_PERCENT = float(os.getenv('MAX_BITCOIN_FEE_PERCENT', '10'))
|
||||
MAX_SLIPPAGE_PERCENT = float(os.getenv('MAX_SLIPPAGE_PERCENT', '1'))
|
||||
Reference in New Issue
Block a user