SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 471c8c03bbc269df1f322f6484b6e7a7364e5b34
parent 7e5783fa53e9773459a58ea6d784b1ad12abedc0
Author: Kristaps Kaupe <kristaps@blogiem.lv>
Date:   Thu, 26 May 2022 15:21:03 +0300

Add configurable multiplier to allow adjusting BTC exchange rate

Diffstat:
Mconfig.py | 1+
Mconfig.toml | 4++++
Mpayments/price_feed.py | 6+++++-
3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/config.py b/config.py @@ -97,6 +97,7 @@ connection_attempts = get_opt("connection_attempts", 3) redirect = get_opt("redirect", "https://github.com/nickfarrow/satsale") base_currency = get_opt("base_currency", "USD") currency_provider = get_opt("currency_provider", "COINGECKO") +bitcoin_rate_multiplier = get_opt("bitcoin_rate_multiplier", 1.00) liquid_address = get_opt("liquid_address", None) paynym = get_opt("paynym", None) free_mode = get_opt("free_mode", False) diff --git a/config.toml b/config.toml @@ -94,6 +94,10 @@ redirect = "https://github.com/nickfarrow/satsale" base_currency = "USD" currency_provider = "COINGECKO" # Supported: COINDESK | COINGECKO +# Multiplier added on top of BTC / fiat exchange rate. Allows to give discount or add extra commission. +# Values above 1.00 gives discount, values below add extra comission. +bitcoin_rate_multiplier = 1.00 + # Weak Hands Mode - Automatically swap LN-BTC -> L-USDT using sideshift.ai # https://blockstream.com/liquid/ # Change lnd_macaroon='admin.macaroon', as you will also need to be able to spend with your lnd certificates. diff --git a/payments/price_feed.py b/payments/price_feed.py @@ -22,7 +22,7 @@ def get_currency_provider(currency, currency_provider): } -def get_price(currency, currency_provider=config.currency_provider): +def get_price(currency, currency_provider=config.currency_provider, bitcoin_rate_multiplier=config.bitcoin_rate_multiplier): provider = get_currency_provider(currency, currency_provider) for i in range(config.connection_attempts): try: @@ -42,6 +42,10 @@ def get_price(currency, currency_provider=config.currency_provider): try: price = prices[provider["ticker"]][provider["value_attribute"]] + if bitcoin_rate_multiplier != 1.00: + logging.debug("Adjusting BTC price from {} to {} because of rate multiplier {}.".format( + price, price * bitcoin_rate_multiplier, bitcoin_rate_multiplier)) + price = price * bitcoin_rate_multiplier return price except Exception: