A system for mining and distributing rewards to Liquidity Providers (LPs) in SN10.
This project consists of two main components:
- LP Miner: Sends LP positions to validators on SN10
- Distributor: Distributes rewards the miner receives to LPs based on their fee generation performance
- Automated fee tracking and reward distribution
- Configurable distribution schedules (time-based or frequency-based)
- Robust logging system
- Database-backed transfer queue
- Retry mechanism for failed transfers
- Blacklist support for excluding specific token IDs
- Clone the repository:
git clone https://github.com/Swap-Subnet/distributor.git
cd distributor
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
- Set up virtual env. and install dependencies:
uv sync
source .venv/bin/activate
- Install and set up dbmate: See here for installation instructions.
Once you have installed dbmate, run the following commands to set up the database:
dbmate --url "sqlite:database.db" create
dbmate --url "sqlite:database.db" up
- Set up environment variables in an
.env
file:
# environment variables for running the distributor
POSITION_CHAIN_PROVIDER_URL=<your-provider-url>
# the following may require a connection to sn10 validator
BITTENSOR_MAINNET_PROVIDER_URL=<url>
BITTENSOR_WEB3_PROVIDER_URL=<url>
ETHEREUM_MAINNET_PROVIDER_URL=<url>
The system can be configured using command-line arguments:
--distribution-frequency
: Frequency of reward distributions (seconds)--record-scores-frequency
: Frequency of score recording (seconds)--fee-check-period
: Lookback period for fee calculations (seconds)
--distribution-schedule-timezone
: Timezone for scheduled distributions--distribution-schedule-hour
: Hour(s) to distribute (0-23)--distribution-schedule-minute
: Minute(s) to distribute (0-59)--distribution-schedule-second
: Second(s) to distribute (0-59)--distribution-schedule-days
: Days to distribute (0=Monday, 6=Sunday)
--db-path
: SQLite database path--log-dir
: Log directory--log-level
: Logging level--log-rotation
: Log rotation period--log-retention
: Log retention period
--stake-coldkey
: Coldkey for tracking stake--stake-hotkey
: Hotkey for tracking stake--origin-hotkey
: Origin hotkey for transfers--destination-hotkey
: Destination hotkey for transfers
--blacklist-endpoint
: API endpoint for token ID blacklist--pending-frequency
: Frequency to process pending transfers--retry-frequency
: Frequency to retry failed transfers
Basic usage:
python -m lp_miner.distributor \
--distribution-frequency 86400 \
--record-scores-frequency 4320 \
--netuid 10 \
--wallet.name default \
--wallet.hotkey default
Scheduled distribution:
python -m lp_miner.distributor \
--distribution-schedule-hour 0 \
--distribution-schedule-minute 0 \
--distribution-schedule-timezone UTC \
--distribution-schedule-days 1,3,5 \
--netuid 10 \
--wallet.name default \
--wallet.hotkey default