Skip to content

mrgnlabs/mrgn-ts-scripts

Repository files navigation

Tools Package

A collection of CLI tools and utilities for account and banking operations.

Features

  • Command-line interface tools for common operations.
  • Account and bank search utilities.
  • Collection of debugging and testing scripts.

Requirements

  • Node, with support for crypto. If this is false, upgrade Node versions:
console.log("Environment supports crypto: ", !!global.crypto?.subtle);
  • pnpm (npm install -g pnpm@latest-10)
  • (Optional) A wallet (with SOL) at ~/keys/wallet.json

Create Env File

Copy the env.template file to .env file and populate missing data.

Available Tools

pnpm accounts:get

Description:
Retrieves account details by providing the account public key.

Usage:

pnpm accounts:get --account <ACCOUNT_PUBLIC_KEY>

Options:

  • -a, --account
    Account public key (string, required)

pnpm accounts:get-all

Description:
Retrieves details for all accounts associated with a wallet.

Usage:

pnpm accounts:get-all --wallet <WALLET_PUBLIC_KEY>

Options:

  • -w, --wallet
    Wallet public key (string, required)

pnpm accounts:find-users

Description:
Searches for users based on assets, liabilities, and balance criteria.

Usage:

pnpm accounts:find-users [options]

Options:

  • --assets
    Comma-separated list of token symbols to search for assets.
  • --liabs
    Comma-separated list of token symbols to search for liabilities.
  • -m, --min-balance
    Minimum balance to return (number, default: 0.1)
  • -l, --limit
    Maximum number of accounts to return (number, default: 1)

pnpm accounts:cache

Description:
Caches account data for quicker access.

Usage:

pnpm accounts:cache

Options:

  • No options available.

pnpm banks:get

Description:
Retrieves bank details using either the bank's public key or a token symbol.

Usage:

pnpm banks:get [options]

Options:

  • -a, --address
    Bank public key (string)
  • -s, --symbol
    Token symbol (e.g., 'USDC') (string)

pnpm banks:get-all

Description:
Retrieves details for all banks.

Usage:

pnpm banks:get-all

Options:

  • No options available.

pnpm banks:get-accounts

Description:
Retrieves accounts associated with a specific bank.

Usage:

pnpm banks:get-accounts [options]

Options:

  • -a, --address
    Bank public key (string)
  • -s, --symbol
    Token symbol (e.g., 'USDC') (string)
  • -l, --limit
    Limit the number of accounts to return (number, default: 5)
  • -m, --min-balance
    Minimum balance to return (number, default: 0.01)
  • -t, --type
    Type of accounts to return

simulate-swb-feed

Description
Runs simulations for Switchboard price feeds in an infinite loop and saves simulation results in the swb-sim-output-{DateTime}.csv file.

Usage

pnpm ts-node scripts/simulate-swb-feed.ts <SWB_FEEDS_FILE> <CROSSBAR_URL> [all]

Parameters:

  • SWB_FEEDS_FILE (required) The KVP file with Switchboard price feed addresses. The swb-feeds.kvp file can be taken as prototype.
  • CROSSBAR_URL - (required) the Switchboard Crossbar instance URL. Example: https://crossbar.switchboard.xyz
  • all - (optional) flag to crank all feeds in a single call

Example

[ -f swb-sim.out ] && rm swb-sim.out; nohup pnpm ts-node scripts/simulate-swb-feed.ts data/swb-feeds.kvp https://internal-crossbar.stage.mrgn.app > swb-sim.out 2>&1 &

simulate-swb-feed-dev

tbd

crank-swb-feed

Description
Cranks Switchboard price feeds in an infinite loop and saves simulation results in the swb-crank-output-{DateTime}.csv file.

Usage

pnpm ts-node scripts/crank-swb-feed.ts <SWB_FEEDS_FILE> <CROSSBAR_URL> [all]

Parameters:

  • SWB_FEEDS_FILE (required) The KVP file with Switchboard price feed addresses. The swb-feeds.kvp file can be taken as prototype.
  • CROSSBAR_URL - (required) the Switchboard Crossbar instance URL. Example: https://crossbar.switchboard.xyz
  • all - (optional) flag to run simulation for all feeds in a single call

Example

[ -f swb-crank.out ] && rm swb-crank.out; nohup pnpm ts-node scripts/crank-swb-feed.ts data/swb-feeds.kvp https://internal-crossbar.stage.mrgn.app > swb-crank.out 2>&1 &

fetch-jup-prices

tbd

Additional Help

Run any script with the --help flag for more details.

Example:

pnpm accounts:get --help

About

One-off scripts and basic localhosted UI panels for Mrgnlend monitoring/administration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages