Flash Loan Mastery CLI

| 2 min read

Our CLI tool allows you to use Flash Loan Mastery from the command line.

What the CLI can do:

  • Initialize flash loan pools
  • Deposit tokens into flash loan pools
  • Withdraw tokens from flash loan pools
  • Run example flash loan instructions
  • Arbitrage using our flash loans and Jupiter

Installation

  1. Git Clone the CLI repository.
  2. Install all the dependencies with yarn.
yarn
  1. Locate or setup your file system wallet file.
  2. Set up a file named .env (right next to where the file named .env.sample is located) and put in at least the Solana RPC URL you want to use. The file contents would be something like this:
NODE_ENV=production
RPC_URI=https://api.mainnet-beta.solana.com
FLM_PROGRAM_ID=1oanfPPN8r1i4UbugXHDxWMbWVJ5qLSN5qzNFZkz6Fg
  1. Run yarn start help to see all the commands.
yarn start help

You can also run yarn start help command to see what each command is for. e.g.

yarn start help deposit

Examples

Init Pool

To get help on this command:

yarn start help init-pool

To set up a new pool:

yarn start init-pool -k /path/to/solana-wallet.json -tm DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 -pm EEgkPj5Z4J9KMCFSchiMz9wGusJgw6wqGPMyMJT9hoEZ

Note that the pm (Pool Mint) option:

  • should be a new mint that is owned by the user
  • should not have any tokens issued
  • should have the same number of decimals as the tm (Token Mint) option

Note that a pool for any mint can only bet up once, and this can be done by anyone.

Deposit

To get help on this command:

yarn start help deposit

For example, to deposit some BONK:

yarn start deposit -k /path/to/solana-wallet.json -tm DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 -tf Hm4ebPskgjJVesKLowyEhpLW6axodBbH82k5CHz3ynSa -a 10310517.49915

Withdraw

To get help on this command:

yarn start help withdraw

For example, to withdraw some USDC:

yarn start withdraw -k /path/to/solana-wallet.json -tm EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -ptf 6H7ahCDN8hny2mWKoQBycUqLXoq4aaZ6V32rpmh99eGr -a 4.249834

Example Flash Loan

To get help on this command:

yarn start help example-flash-loan

For example, an example of a flash loan of 10 million BONK:

yarn start example-flash-loan -k /path/to/solana-wallet.json -tm DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 -a 10000000

Here is what the transaction itself looks like. We are fairly certain that this might be the very first BONK flash loan ever! :)

Example Flash Loan Using Versioned Transactions

We support flash loans using Solana's versioned transactions.

For example, for a versioned flash loan of 1,000 USDC:

1. Create keys/addresses that should be saved in the address lookup table

yarn start seed-example-flash-loan-lookup-table -k /path/to/solana-wallet.json -tm EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -a 1000

2. Create the address lookup table

yarn start create-versioned-flash-loan-lookup-table-from-cache -k /path/to/solana-wallet.json -tm EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

3. Execute the flash loan using versioned transactions

yarn start example-versioned-flash-loan -k /path/to/solana-wallet.json -tm EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -a 1000

Here is what this versioned flash loan transaction ends up looking like.