Skip to content

loujacob66/api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

staratlas-labs-solanabot

To start

  • make an .env file with your settings. Review the sample one.
  • exec npm ci after cloning/pulling repo.

Clean Up Starbase Cargo Pods Command

The clean-up-starbase-cargo-pods command checks if a PlayerProfile owns more than one cargo pod at the same Starbase and, if so, removes the extra cargo pods by transferring all the cargo to the main cargo pod at a Starbase.

# Basic usage
npm run start clean-up-starbase-cargo-pods

Parameters

This command does not require any parameters.

Options

This command does not support any options.

craft

The craft command is used to craft a specific recipe in the game. You can control the quantity, crew assignment, location, and other options to customize the crafting process.

Usage

craft [options]

Arguments

  • recipe-namespace: Required. The namespace of the recipe to craft (e.g., Toolkit 3).
    This defines which recipe the command should attempt to craft.

Options

  • -q, --quantity <number>:
    Specify the quantity of the recipe to craft.

    • Default: 1
    • Required: Yes
  • -c, --num-crew <number>:
    The number of crew members assigned to the crafting job.

    • Required: Yes
  • -s, --sector-name <string>:
    The name of the sector where the crafting will take place (e.g., MRZ-22, Ustur CSS).

    • Required: Yes
  • -d, --max-duration <number>:
    Maximum crafting duration in seconds. If not provided or set to 0, there is no limit. This can be used to control the time constraints for crafting operations.

    • Default: 0
    • Optional
  • -f, --inventory-fleets <array>:
    List of additional fleets to check for ingredient inventory. This is helpful if the ingredients required for the recipe are spread across multiple fleets.

    • Default: Empty list ([])
    • Optional
  • -e, --inventory-sectors <array>:
    List of additional sectors to check for ingredient inventory. This allows you to specify multiple sectors to pull resources from during the crafting process.

    • Default: Empty list ([])
    • Optional
  • -m, --mode <string>:
    Crafting mode:

    • recipe: Craft only the main item.
    • recursive: Craft the main item and all its ingredients recursively.
      Choose recipe if the ingredients are already available, or use recursive if you want to craft the required ingredients as well.
    • Choices: recipe, recursive
    • Default: recipe

Examples

  • Craft a single toolkit with a crew of 5 in sector MRZ-22:

    craft "Toolkit 3" -q 1 -c 5 -s "MRZ-22"

  • Craft 3 units of "Toolkit 3" using 7 crew members and check for ingredients in additional fleets:

    craft "Toolkit 3" -q 3 -c 7 -s "MRZ-22" -f fleet1 fleet2

  • Craft a complex recipe recursively, with a max duration of 600 seconds:

    craft "Advanced Reactor" -q 1 -c 10 -s "Ustur CSS" -m recursive -d 600

Export Command

Instructs the application to export resources from a starbase to your wallet, with an option to maintain a minimum balance at the starbase.

# Command template
> npm run start export <resource> <coordinates> [--minBalance=<amount>]

# Example - export all toolkits from starbase at (-40,30)
> npm run start export toolkits '(-40,30)'

# Example - export toolkits from starbase at (-40,30), maintaining a minimum balance of 100 toolkits
> npm run start --- export toolkits '(-40,30)' --minBalance=100

Parameters

  • <resource>: Type of the resource to export.
  • <coordinates>: Coordinates of the starbase from which resources are being exported.

Options

  • --minBalance=<amount>: (Optional) Sets the minimum required level of the resource at the starbase. The application will export resources but ensure that this minimum balance remains at the starbase.

Notes

  • To run this continously on an interval, please use PM2 or something similar.
{ // pm2 config - run export every 15 minutes
  name: "export toolkits",
  script: './dist/main.js',
  args: "export toolkits '(-40,30)'",
  autorestart: true,
  restart_delay: 900_000, // 15 minutes
}

Harvest Claim Stakes Command

Instructs the application to harvest stakes for given mints.

# Command template
> npm run start -- harvest-stakes --mint <mint1> [--mint <mint2> ...]

# Example - harvest stakes for a single mint
> npm run start -- harvest-stakes --mint 5dXaR4G7P4t6XTjR6pZS3Wd3Vb7JZ6Z5o6EFSbXeZVz6

# Example - harvest stakes for multiple mints
> npm run start -- harvest-stakes --mint 5dXaR4G7P4t6XTjR6pZS3Wd3Vb7JZ6Z5o6EFSbXeZVz6 --mint 3vK8izVRV7Rm2VjDV9VcQj9oRcE7gD1r8XjXpCQobLnd

Parameters

  • --mint <mint>: Specify theclaim stake mint identifier to harvest stakes from. This option can be repeated to include multiple mints. Please look at an existing transaction to grab id #13 - Claim Stake Mint

Notes

  • Ensure the specified mints are valid and available for harvesting stakes.
  • The command allows specifying multiple mints, each preceded by its own --mint flag.

Import Command

Instructs the application to import resources to a starbase from your wallet.

# Command template
> npm run start import <resource> <coordinates>

# Example - import toolkits to starbase at (-40,30)
> npm run start import toolkits '(-40,30)'

Parameters

  • <resource>: Type of the resource to import.
  • <coordinates>: Coordinates of the starbase to which resources are being imported.

Notes

  • To run this command continuously at intervals, use PM2 or a similar process manager.
{ // PM2 config - run import every 30 minutes
  name: "import toolkits",
  script: './dist/main.js',
  args: "import toolkits '(-40,30)'",
  autorestart: true,
  restart_delay: 1_800_000, // 30 minutes
}

Limit Sell

The limit-sell command is used to place a limit sell order for a specified resource in the marketplace. This command sets an order to sell a resource at the best available price, with options to set a quantity limit, to ignore orders below a certain quantity threshold, and to define the minimum price per unit.

# Command template
> npm run start limit-sell <resource> <currencyMint> [--maxQuantity=<number>] [--minQuantity=<number>] [--ignoreOrdersBelow=<number>] [--minPrice=<price>]

# Example - Create a limit sell order for up-to 500,000 units of Carbon, receiving payment in ATLAS
> npm run start limit-sell Carbon ATLAS --maxQuantity=500000

# Example - Create a limit sell order for Carbon, only if you have at least 100,000 units, receiving payment in USDC
> npm run start limit-sell Carbon USDC --minQuantity=100000

# Example - Create a limit sell order for Carbon, ignoring orders below 10,000 units and ensuring a minimum price of 0.0009 ATLAS per unit
> npm run start limit-sell Carbon ATLAS --ignoreOrdersBelow=10000 --minPrice=0.0009

Parameters

  • <resource>: The type of resource you want to sell. Example: toolkits.
  • <currencyMint>: The mint (currency) in which payment is to be received. Valid options are 'ATLAS' or 'USDC'.

Options

  • --maxQuantity (alias: -maxQty): (Optional) The maximum quantity of the resource to sell in one order. If not specified, there's no limit on the selling quantity.
  • --minQuantity (alias: -minQty): (Optional) The minimum quantity required to create a sell order. If your holdings are below this amount, no order will be created.
  • --ignoreOrdersBelow (alias: -i): (Optional) Ignore sell orders with quantities below this threshold. Defaults to 0, meaning no orders are ignored.
  • --minPrice (alias: -m): (Optional) The minimum price per unit at which you are willing to sell the resource. If not specified, there is no minimum price.

PM2 Configuration

This command can be run continuously using PM2. Below is an example configuration for the sell-toolkits command:

{
  "name": "sell-toolkits",
  "script": "./dist/main.js",
  "args": "limit-sell toolkits ATLAS --limitQuantity 500000 --ignoreOrdersBelow 10000",
}

Notifications

See command watch-orders to get notification of order changes.

Mining Command

The mine command allows you to mine one or more resources using a fleet in a specified sector. It supports maintaining specific ratios of mined resources and querying inventories from additional starbases.

Command:

mine <fleet> <sector>

Description:

This command enables a fleet to mine multiple resources in a specified sector. You can optionally specify ratios for the resources to maintain balanced mining operations. The command also supports querying additional starbases for inventory to guide mining priorities.

Arguments:

  • <fleet> (string): Required. The name of the fleet that will perform the mining operation.

    • Example: Fleet1
  • <sector> (string): Required. The sector where the mining operation will take place. This should be a known sector name like MRZ-22 or Ustur CSS.

    • Example: MRZ-22

Options:

  • --resources, -r (array): Required. A list of resources to mine, with optional ratios. Specify resources as ResourceName:Ratio. If no ratio is supplied, it defaults to 1.

    • Example: "Carbon:5" "Copper Ore:6"
    • Default Ratio: 1 (e.g., "Carbon" is treated as "Carbon:1").
  • --inventory-sectors, -e (array): Optional. A list of additional starbases to query for inventory to guide mining priorities.

    • Example: MRZ-22 MRZ-34

Example Usage:

  • Single Resource Without Ratio (Defaults to 1):
    mine Fleet1 MRZ-22 --resources "Carbon"

  • Single Resource With Ratio:
    mine Fleet1 MRZ-22 --resources "Carbon:5"

  • Multiple Resources Without Ratios:
    mine Fleet1 MRZ-22 --resources "Carbon" "Copper Ore"

  • Multiple Resources With Ratios:
    mine Fleet1 MRZ-22 --resources "Carbon:5" "Copper Ore:6"

  • With Additional Inventory Sectors:
    mine Fleet1 MRZ-22 --resources "Carbon:5" "Copper Ore:6" --inventory-sectors MRZ-34 MRZ-22

Notes:

  • At least one resource must be specified using the --resources option.
  • Ratios help balance the mining of multiple resources efficiently.
  • Additional inventory sectors are optional but can improve mining prioritization based on crafting needs.
  • Ensure fleet availability and proper configuration for mining operations.
  • Double-check sector names and resource names for accuracy.

Replenish Command

Ensures a minimum quantity of a specific resource in the game by buying the resource from the marketplace and transferring it to the game. The command allows setting a maximum price per unit to control costs.

This can be useful to support fleets that rely on R4 resources (ex: Fuel) to ensure their's always enough resources to maintain fleet operations.

Command Template

# Basic usage
> npm run start replenish <resource> <minimumQuantity> <coordinates>

# With maximum price per unit
> npm run start replenish <resource> <minimumQuantity> <coordinates> --maxPrice <maxPricePerUnit>

# Example - Ensure at least 5 million units of Fuel at coordinates (-40,30)
> npm run start replenish fuel 5000000 '(-40,30)'

# Example with maximum price per unit (Atlas)
> npm run start replenish fuel 5000000 '(-40,30)' --maxPrice 0.002

Parameters

  • <resource>: The type of resource to ensure (e.g., 'fuel').
  • <minimumQuantity>: The minimum quantity of the resource to maintain in the game (e.g., 5000000).
  • <coordinates>: The coordinates of the starbase or location in the game where the resource is managed (e.g., '(-40,30)').

Options

  • --maxPrice <maxPricePerUnit>: (Optional) The maximum price per unit (Atlas) you are willing to pay for the resource (e.g., 0.002).

transport <fleet>

Description:
Transports resources from one base to another using the specified fleet.

Usage:

transport <fleet> [options]

  • fleet (string, required): The name of the fleet to use for transport.

Options:

  • --base (string, required):
    The base to move resources to. All target starbases will transport resources to this base.

  • --target-resources (array):
    Specify resources to fetch for the corresponding target starbase in the format <target>:<resource1>,<resource2>.
    Example: --target-resources MRZ-22:iron_ore,copper_ore

  • --target-recipes (array):
    Specify recipes to fetch resources for the corresponding target starbase in the format <target>:<recipe1>,<recipe2>.
    Example: --target-recipes MRZ-22:Fimbul Mamba Ex,Fimbul ECOS

  • --craft-buffer (number, default: 1): Buffer for recipe crafting. Maintains additional items worth of ingredients. Useful when crafting Golden Tickets, not so much ships. Example: --craft-buffer 5000

  • --crew (string):
    Specify crew requirements for starbases in the format <starbase>:<crewCount>. Must match either the base or one of the targets.
    Example: --crew MRZ-22:100

  • --supply, -s (string[]):
    Specify resources and their minimum levels to maintain at the base. Use the format <resource>:<minLevel>.
    Example: --supply fuel:100000 --supply food:50000

  • --warpThreshold (number, default: MAX_SAFE_INTEGER):
    Quantity of resources at a target starbase above which warp travel will be used.

  • --minSuppliesWarpThreshold (number, default: 0):
    Percentage threshold for minimum resource levels at the base. If any resource falls below this percentage, warp travel is triggered.

  • --forceWarp (boolean, default: false):
    Forces warp travel regardless of resource levels.

  • --forceSubwarp (boolean, default: false):
    Forces subwarp travel regardless of resource levels.

  • --route-refuel (array, required):
    Specifies refueling rules for routes between starbases. Use the format <from>:<to>:<mode>.

    • <from>: The origin starbase. Use * as a wildcard to match any starbase.
    • <to>: The destination starbase. Use * as a wildcard to match any starbase.
    • <mode>: The refueling mode, which can be:
      • none: No refueling at this route.
      • minimal: Minimal refueling, only filling what's necessary.
      • full: Full refueling.

    Example:

    • --route-refuel MRZ-22:MRZ-21:full
    • --route-refuel MRZ-22:*:minimal
    • --route-refuel *:MRZ-22:none

Examples:

  1. Basic resource transport between a base and multiple targets:

    transport haul02
        --base MRZ-22
        --target-resources MRZ-16:titanium_ore
        --target-resources MRZ-17:arco
        --target-resources MRZ-21:fuel
        --target-resources MRZ-34:silica,lumanite
        --target-resources MRZ-35:iron_ore,nitrogen
        --route-refuel MRZ-22:MRZ-21:minimal
        --route-refuel MRZ-21:*:full
  2. Transport using recipe-based resource calculation:

    transport haul01
        --base 'Ustur CSS'
        --target-recipes 'MRZ-22:Fimbul Mamba Ex'
        --warpThreshold 500000
        --route-refuel 'MRZ-22:Ustur CSS:full'
        --route-refuel 'Ustur CSS:MRZ-22:full'
        --supply fuel:2000000
        --supply food:4000000
  3. Setting up complex refuel rules for wildcard routes:

    transport haul03
        --base MRZ-30
        --target-resources MRZ-10:food,fuel
        --route-refuel MRZ-10:MRZ-30:minimal
        --route-refuel MRZ-30:*:full
        --route-refuel *:MRZ-10:none

Notes:

  • The --route-refuel option ensures flexible control over refueling behavior for each route. Use wildcards (*) for generalized rules.
  • At least one --route-refuel rule must be provided to guarantee refueling.

Scan Command

The scan command performs a scan with your fleet. It includes an option to set the minimum probability for acceptable scans, allowing the fleet to move to a new spot if several consecutive scan probabilities are below the minimum.

# Basic usage
npm run start scan <fleet> <starbaseCoordinates> [--minProbability=<value>]

# Example - Perform a scan with a fleet named "MyFleet" at starbase coordinates "-40,30" with a minimum probability of 25%.
npm run start scan MyFleet '(-40,30)' --minProbability 0.25

Parameters

  • <fleet>: Name of the fleet.
  • <starbaseCoordinates>: Coordinates of the starbase to unload and resupply.

Options

  • --minProbability=<value>: (Optional) Sets the minimum probability for acceptable scans. If the fleet has several consecutive scan probabilities that are below the minimum, then the fleet will move to a new spot. (Value range: 0-1, Default: 0.1)
  • --scanStrikeCount=<value>: (Optional) Sets the number of consecutive low-probability scans allowed before the fleet moves to a new spot. (Default: 4)
  • --postSuccessProbabilityDrop=<value>: (Optional) Adjusts the probability of a successful scan by this amount when evaluating if the fleet should move. This accounts for the typical drop in probability after a successful scan. (Value range: 0-1, Default: 0.0)

Sell Command

Instructs the application to sell a specified resource to the highest bidder.

# Command template
> npm run start sell <resource> <currencyMint> [--fee <number>] [--ignoreBots]

# Example - sell all toolkits in ATLAS and use default 6% marketplace fee for calculation
> npm run start sell toolkits ATLAS

# Example - sell all toolkits in ATLAS and use a 5.4% marketplace fee for calculation and don't sell to bots
> npm run start sell toolkits ATLAS --fee 5.4 --ignoreBots

Parameters

  • <resource>: Type of the resource to sell.
  • <currencyMint>: The mint (currency) in which payment is to be received. Valid options are 'ATLAS' or 'USDC'.
  • --fee (Optional): The marketplace fee for your account. Defaults to 6%. Used to calculate notification messages.
  • --ignoreBots (Optional): Do not sell to known bots. Defaults to false.

Notes

  • This command will sell the entire quantity of the specified resource.
  • Ensure the specified resource is available for sale in your inventory.
  • The market conditions for selling the resource are not accounted for in the command; it executes a direct sale.
  • To run this continously on an interval, please use PM2 or something similar.
{ // pm2 config - run sell every 15 minutes
  name: "sell toolkits",
  script: './dist/main.js',
  args: "sell toolkits",
  autorestart: true,
  restart_delay: 900_000, // 15 minutes
}

Swap Tokens Command

Swap ATLAS tokens for either SOL or USDC, optionally retaining a specified amount of the source token untouched in your wallet.

# Command template
> npm run start swap-tokens <from> <to> [--retainAmount=<amount>]

# Example - Swap ATLAS for USDC, retaining 1000 ATLAS in your wallet
> npm run start swap-tokens ATLAS USDC --retainAmount=1000

# Example - Swap SOL for ATLAS without retaining any SOL
> npm run start swap-tokens SOL ATLAS

Parameters

  • <from>: The token you are swapping from. Valid options are 'ATLAS', 'SOL', and 'USDC'.
  • <to>: The target token you want to swap to. Valid options are 'ATLAS', 'SOL', and 'USDC'.

Options

  • --retainAmount=<amount>: The amount of the source token to retain in your wallet. This ensures that after the swap, at least this amount of the source token remains untouched. If not specified, defaults to 0, meaning no specific amount is retained.

Notes

  • Ensure you have sufficient balance of the token in your wallet for the swap, accounting for the amount you wish to retain.
  • The swap operation is subject to availability and rates on the exchange platform used.
  • To run this command continuously at intervals, use PM2 or a similar process manager.
{ // PM2 config - run swap-tokens command as needed
  name: "swap-tokens",
  script: "./dist/main.js",
  args: "swap-tokens ATLAS USDC --retainAmount=1000",
  instances: 1,
  autorestart: false,  // Prevents restart unless specified by cron
  cron_restart: '0 0 * * *', // every day at midnight
}

Watch Orders Command

The watch-orders command is designed to monitor your marketplace orders and notify you of significant events. This includes the creation of new orders, cancellations, and order fills.

Command Usage

# Example - watching your sell orders
> npm run start watch-orders

# Example - watching your sell orders and use a 5.4% marketplace fee
> npm run start watch-orders --fee 5.4

Parameters

  • --fee (Optional): The marketplace fee for your account. Defaults to 6% Used to calculate notification messages.

PM2 Configuration

To ensure continuous monitoring, this command can be managed and run periodically using PM2. The following configuration in PM2 sets up the watch-orders command to restart every 4 hours:

{
  "name": "watch-orders",
  "script": "./dist/main.js",
  "args": "watch-orders",
  "cron_restart": "0 */4 * * *", // restart every 4 hours
  "autorestart": true,
}

Features

  • Order Monitoring: Continuously checks for updates on your marketplace orders.
  • Event Notifications: Sends notifications for the following events:
    • New Orders: When a new order is created in the marketplace.
    • Order Cancellations: When any of your orders are canceled.
    • Order Fills: When your orders are partially or fully filled.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages