Script for cranking OpenBook V2 markets on Solana.
.
├── Dockerfile
├── package-lock.json
├── package.json
├── src
│ └── crank.ts
├── tsconfig.json
├── wallet.json
├── .env
└── yarn.lock
- src/crank.ts: The main script for running the crank operations.
- package.json: Contains dependencies and scripts for building and running the project.
- tsconfig.json: TypeScript configuration file.
- wallet.json: Contains the wallet keypair used to sign transactions.
- .env: Configuration file for environment variables.
Before you can run this project, ensure you have the following installed:
- Node.js (v14.x or later)
- Yarn
- Solana CLI (optional, for managing Solana wallets)
-
Clone the repository:
git clone https://github.com/TheDeFiQuant/obv2-crank-v2.git cd obv2-crank-v2
-
Install dependencies:
yarn install
-
Create and configure the
.env
file:The
.env
file should be located in the root directory of your project (where yourpackage.json
is). Here’s an example of what your.env
file should look like:CLUSTER=mainnet RPC_URL=https://solana-mainnet.rpc-node.com/your-api-key WALLET_PATH=/path/to/your/wallet.json KEYPAIR= # Leave this empty if you use wallet.json or enter your private keypair in JSON format PROGRAM_ID=opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb INTERVAL=1000 CONSUME_EVENTS_LIMIT=19 MARKETS=marketID1,marketID2,marketID3 PRIORITY_MARKETS=marketID1,marketID2,marketID3 PRIORITY_QUEUE_LIMIT=100 PRIORITY_CU_PRICE=100000 PRIORITY_CU_LIMIT=50000 MAX_TX_INSTRUCTIONS=1 CU_PRICE=0
- RPC_URL: Add the URL of your Solana RPC node.
- WALLET_PATH: Path to your
wallet.json
. See how to generate a wallet.json here. - KEYPAIR: (Optional) Enter your private keypair (same format as in wallet.json). Leave this empty if using
wallet.json
. - MARKETS: Comma-separated list of market IDs to crank.
- PRIORITY_MARKETS: Comma-separated list of market IDs that receive fee bumps.
The script relies on several environment variables defined in the .env
file:
- CLUSTER: Cluster to use. Options:
mainnet
,testnet
,devnet
. Default ismainnet
. - RPC_URL: RPC endpoint URL for the Solana cluster.
- WALLET_PATH: Path to your Solana wallet JSON file.
- KEYPAIR: Private keypair in JSON format. Optional if using
WALLET_PATH
. - PROGRAM_ID: Program ID for OpenBook. Default is set for mainnet.
- INTERVAL: Time interval in milliseconds between each loop. Default is
1000 ms
. - CONSUME_EVENTS_LIMIT: Maximum number of events to consume per transaction. Default is
19
. - MARKETS: Comma-separated list of market IDs to crank.
- PRIORITY_MARKETS: Market IDs that receive priority fees. Comma-separated.
- PRIORITY_QUEUE_LIMIT: Queue size threshold to apply priority fees. Default is
100
. - PRIORITY_CU_PRICE: Compute unit price for priority markets. Default is
100000
. - PRIORITY_CU_LIMIT: Compute unit limit per instruction. Default is
50000
. - MAX_TX_INSTRUCTIONS: Maximum number of instructions per transaction. Default is
1
. - CU_PRICE: Minimum additional micro lamports for all transactions. Default is
0
.
-
Compile the TypeScript code:
yarn build
-
Run the script:
yarn start
Alternatively, you can run the script directly with
ts-node
:yarn dev
If you prefer running the script inside a Docker container, you can pull the image from GHCR.
-
Pull the Docker image from GHCR:
docker pull ghcr.io/thedefiquant/openbook-cranker-v2:v2.0.1
-
Run the Docker container:
docker run --env-file .env obv2-crank-v2
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.