A Node.js tool that monitors Sui network epochs and automatically updates Sui gas price based on SUI token price before the Epoch change.
- Monitors Sui network epoch status every hour
- Fetches current SUI price from CoinMarketCap when epoch is ending (< 1 hour remaining) and executes the following steps.
- Calculates optimal mist value based on price changes
- Automatically updates Sui gas price
- Provides detailed logging of epoch status and price calculations
-
This tool does NOT take the Sui stake subsidies into calcuations
-
This tool users the following reference point:
SUI : 1 USD MIST : 750
-
Ubuntu 22.04
-
SUI client
-
Sui Validator Keystore file. In this case, we have the file at the following location:
~/.sui/sui_config -
Node.js Installation
- Download and install Node.js from official website
- Verify installation:
node --version npm --version
-
CoinMarketCap API Key
- Sign up for a free API key at CoinMarketCap
- Choose "Basic" plan (Free basic access for personal use)
- After signing up, get your API key from the dashboard
-
Clone the Repository
git clone https://github.com/synergynodes/sui-rgp.git cd sui-rgp -
Install Dependencies
npm install
-
Install PM2 Globally
npm install -g pm2
-
Create Environment File
- Create a
.envfile in the project root:touch .env
- Add the following content:
Replace values with your actual configuration:
CMC_API_KEY=your_coinmarketcap_api_key SUI_PATH=/usr/local/bin SUI_RPC_URL=https://fullnode.mainnet.sui.io/- CMC_API_KEY: Your CoinMarketCap API key
- SUI_PATH: Path to the directory containing the sui binary
- SUI_RPC_URL: Sui RPC endpoint (default provided)
- Create a
-
Verify Configuration
- Ensure
reference.jsoncontains the base values:{ "sui_price": 1, "mist": 750 }- sui_price: Reference SUI price in USD
- mist: Reference mist value
- Ensure
-
Start with PM2
pm2 start index.js --name "sui-gas-updater" -
Monitor the Process
pm2 logs sui-gas-updater # View logs pm2 status # Check status
-
Auto-start on System Boot
pm2 startup # Generate startup script pm2 save # Save current process list
-
Hourly Checks
- Tool runs every hour at minute 0
- Fetches current epoch information
- Displays remaining time until epoch end
-
Price Updates When less than 1 hour remains in the current epoch:
- Fetches current SUI price from CoinMarketCap
- Calculates new mist value based on price change ratio
- Executes validator gas price update command
-
Mist Calculation
new_mist = reference_mist * (reference_price / current_price)Example:
- If SUI price doubles (1.00 → 2.00), mist halves (750 → 375)
- If SUI price halves (1.00 → 0.50), mist doubles (750 → 1000, capped)
=== Sui Epoch Information ===
Current Epoch: 666
Time Remaining: 0 hours, 45 minutes, 30 seconds
=========================
=== Price Update ===
Current SUI Price: $1.25 (25% change)
Reference Price: $1.00
New Mist Value: 600 (-20% change)
Reference Mist: 750
=========================
Updating validator gas price...
Successfully updated validator gas price
-
Tool Not Running
- Check environment variables are set correctly
- Verify Sui CLI is installed and accessible
- Check CoinMarketCap API key is valid
-
Command Execution Errors
- Verify SUI_PATH points to correct directory
- Ensure sui binary has execute permissions
- Check validator credentials are properly set up
-
Price Update Issues
- Verify CMC_API_KEY is valid
- Check internet connectivity
- Review API response errors in logs
Feel free to change / update the code based on your requirements.
For issues and feature requests, please open an issue in the GitHub repository.