mirror of
https://github.com/ZmnSCPxj/clboss.git
synced 2026-08-15 12:50:42 +02:00
Previously, CLBOSS initialized the OnchainFeeMonitor with 2 weeks of synthetic data collected at an arbitrary time on an unknown system. This historical data often failed to accurately determine low/high fee conditions until 2 weeks had passed. This update changes the initialization to use a smaller amount of deliberately conservative history. This approach discourages CLBOSS from prematurely declaring a low-fee environment, while still allowing it to recognize low fees after a few days. The new size is designed to have 50% influence on the lower 20th percentile after 24 hours (24 * 6 * 20% * 0.5 = 14.4). This influence decreases over time: to 25% after two days, 10% after five days, and continues to decay until it has no effect after two weeks. It's important to note that CLBOSS will still function in high fee environments to manage initial liquidity, so this change does not impact its ability to operate effectively.
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#ifndef BOSS_MOD_ONCHAINFEEMONITOR_HPP
|
|
#define BOSS_MOD_ONCHAINFEEMONITOR_HPP
|
|
|
|
#include<memory>
|
|
|
|
namespace Boss { namespace Mod { class Waiter; }}
|
|
namespace S { class Bus; }
|
|
|
|
namespace Boss { namespace Mod {
|
|
|
|
/** class Boss::Mod::OnchainFeeMonitor
|
|
*
|
|
* @brief module to keep track of onchain fees.
|
|
*
|
|
* @desc keeps track of historical average (mean)
|
|
* of fees, storing it in a table in the database.
|
|
* Announces changes between "high fee regime" and
|
|
* "low fee regime", and can be queried as well for
|
|
* whether we are in low-fee or high-fee regime.
|
|
*/
|
|
class OnchainFeeMonitor {
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> pimpl;
|
|
|
|
public:
|
|
/* Initialize w/ a small amount of "low fee" history to force
|
|
* clboss to be conservative while it acquires actual history.
|
|
* The size is designed so that after 24 hours it has 50%
|
|
* influence on the lower 20 percentile. 24 * 6 * 20% * 0.5 = 14.4
|
|
*/
|
|
static constexpr std::size_t num_initial_samples = 14;
|
|
|
|
OnchainFeeMonitor() =delete;
|
|
OnchainFeeMonitor(OnchainFeeMonitor const&) =delete;
|
|
OnchainFeeMonitor(S::Bus&, Boss::Mod::Waiter&);
|
|
OnchainFeeMonitor(OnchainFeeMonitor&&);
|
|
~OnchainFeeMonitor();
|
|
|
|
bool is_low_fee() const;
|
|
bool is_high_fee() const { return !is_low_fee(); }
|
|
};
|
|
|
|
}}
|
|
|
|
#endif /* !defined(BOSS_MOD_ONCHAINFEEMONITOR_HPP) */
|