πΈ Supercharged FTX lending from the command line.
- Features
- Prerequisites
- Installation
- Getting started
- Usage
- Examples
- FAQ
- Disclaimer
- Contact
- Donate
- License
π Global exchange: supports FTX and FTX US
π€ Multiple logins: allows switching between API credentials and subaccounts
π Better metrics: displays all the metrics provided by FTX and more
π Repeat commands: compounds lending offers automatically via inbuilt command scheduler
β²οΈ Custom schedules: repeats commands hourly or using custom cron expressions
π Self-hosted: retains your control over your API credentials
βοΈ Close to the metal: remains faithful to FTX terminology, options, and errors
- Node.js v14.13.0+
The quickest and easiest way to install or update Node.js is via nvm.
Before you install, why not try one of the commands out? This one doesn't require authentication and will display information on lending rates.
npx ftx-cli rates
The quickest and easiest way to install is globally from npm.
npm install --global ftx-cli
You can also download (or clone) and install the package manually.
git clone https://github.com/dusktrades/ftx-cli
cd ftx-cli
npm install --global
- Create a new account (5% fees discount) on FTX or FTX US
- Settings > Margin > 'ENABLE SPOT MARGIN TRADING'
- Settings > Api > 'CREATE API KEY'
- Note credentials down temporarily
- Edit API key permissions to the minimum required for this package to function properly
- Disable 'Read-only'
- Disable 'Withdrawals enabled'
- Disable 'Internal transfers enabled'
- If you know the static IP address(es) you will be using, you can further improve security by whitelisting them via 'WHITELIST IP'
- Margin Lending (UI) (FTX US)
- Spot Margin Trading Explainer (Article)
- FTX Guide: How to Borrow and Lend on FTX (Video)
If you need a quick reminder or link back here in future, try ftx --help
.
You can inline these options with any command to modify its behaviour. Inline options take priority over stored credentials/config.
Option | Description | Default | Notes |
---|---|---|---|
-e, --exchange |
FTX exchange platform (FTX or FTX US) | ftx |
Options: ftx , ftx-us |
-k, --key <key> |
FTX API key | ||
-x, --secret <secret> |
FTX API secret | ||
-a, --subaccount <subaccount> |
FTX subaccount name | No subaccount | Learn more about using subaccounts |
-z, --repeat [cron expression] |
Repeat the command with optional cron schedule | false |
Learn more about repeating commands |
Store FTX API credentials locally. This provides a convenient method of remaining authenticated with FTX. Please note any previously stored credentials will be overwritten.
# Store API credentials.
ftx login --key API_KEY --secret API_SECRET
# Store API credentials and subaccount.
ftx login --key API_KEY --secret API_SECRET --subaccount SUBACCOUNT
Remove stored FTX API credentials.
ftx logout
Store option preferences locally. This lets you customise the default behaviour of the package so you don't need to continuously repeat the same options.
# Store preference to use FTX US.
ftx config --exchange ftx-us
Display lending rates for a currency, or all if no currency is provided.
Option | Description | Default |
---|---|---|
-c, --currency <currency> |
Currency symbol | All lendable currencies |
# Display lending rates for all currencies.
ftx rates
# Display lending rates for BTC.
ftx rates --currency btc
Display my lending earnings.
π Requires authentication
ftx earnings
Display my open lending offers.
π Requires authentication
ftx offers
Create a lending offer for a currency, or all if no currency is provided. Please note any matching existing offer(s) will be updated.
π Requires authentication
Option | Description | Default |
---|---|---|
-c, --currency <currency> |
Currency symbol | All lendable currencies |
-s, --size <size> |
Currency amount | Maximum lendable size |
-r, --min-rate <rate> |
Minimum yearly lending rate (%) | 0 |
# Offer all lendable currencies with no minimum rate.
ftx lend
# Offer all BTC with no minimum rate.
ftx lend --currency btc
# Offer all lendable currencies at a minimum rate of 5% per year.
ftx lend --min-rate 5
# Offer 100 TWTR with no minimum rate.
ftx lend --currency twtr --size 100
# Offer all USDT at a minimum rate of 7.5% per year.
ftx lend --currency usdt --min-rate 7.5
# Offer 10,000 USD at a minimum rate of 10% per year.
ftx lend --currency usd --size 10000 --min-rate 10
Withdraw my lending offer for a currency, or all if no currency is provided.
π Requires authentication
Option | Description | Default |
---|---|---|
-c, --currency <currency> |
Currency symbol | All lendable currencies |
# Withdraw all offers.
ftx stop
# Withdraw offer for USD.
ftx stop --currency usd
β οΈ Funds will stay locked by FTX for up to 1 hour after withdrawing your offer.
Subaccounts are fully supported. If you plan on using one subaccount most of the time, you can login
with it. If you plan on switching between subaccounts, you can use inline options.
# Store API credentials and subaccount.
ftx login --key API_KEY --secret API_SECRET --subaccount SUBACCOUNT
# Display my open lending offers on 'Idle' subaccount.
ftx offers --subaccount Idle
Notes:
- FTX subaccount names are case-sensitive
- FTX API credentials can be linked to your whole account or individual subaccounts
β οΈ It is recommended that you create and use a subaccount if you want to keep your lending funds separate. The purpose of this is to prevent conflicts with other trading activity on your account (e.g. using a subaccount when auto-compounding will prevent accidentally lending collateral from elsewhere on your account).
Any command can easily be repeated at specified intervals via the inbuilt command scheduler and will keep running until manually aborted. The default schedule is 'at 5 minutes past every hour' because FTX variable lending rates and balances are updated hourly.
# Auto-compound all lendable currencies with no minimum rate.
ftx lend --repeat
# Auto-compound all USD at a minimum rate of 2.5% per year.
ftx lend --currency usd --min-rate 1 --repeat
# Withdraw all offers at 09:00 every day.
ftx stop --repeat "0 9 * * *"
β οΈ The machine you are using to run repeated commands must remain powered on and capable of communicating with FTX (e.g. PC with no downtime, local server, VM).
The popular crypto phrase 'not your keys, not your coins' holds true for your API keys, too (especially if insecure). The way this project is set up means your API credentials are only communicated between, and stored on, your own machine and FTX β and anyone can scrutinise and build from source to verify that claim.
It's possible to get rate-limited by FTX if you attempt to execute large amounts of commands in a short period of time. Learn more.
The official FTX API sometimes behaves strangely with decimal precision when creating lending offers close to your lendable size, which means you can sometimes unexpectedly receive 'Size too large' errors. To mitigate this, we automatically truncate any size to 8 decimal places before communicating with FTX. This makes the errors less common, but it remains possible to receive them while we look for a more robust solution.
This package doesn't impose many artificial limitations beyond the defaults, meaning most limits and errors are relayed directly from the FTX platform. Please ensure what you're trying to do is possible on FTX before raising the issue with this package.
Auto-compounding is perfect if you want to maximise lending earnings while avoiding manually updating your lending offers to include recent payouts. It is worth the small effort to set up if you intend to lend long-term with decent size. See the table below for examples:
Average annual lending rate | Effective annual rate (with hourly compounding)* |
---|---|
5% | ~5.13% |
10% | ~10.52% |
25% | ~28.40% |
50% | ~64.87% |
*Formula: (1 + X / 8760)8760 - 1
X = Average annual lending rate
FTX CLI is not affiliated with FTX. Your account(s) and funds are your responsibility. Trading involves a high degree of risk and is not suitable for all persons.
- BTC: bc1q5f323q4399s3plle9t33j7czv5knj90ujyg3ys
- ERC-20 (ETH): 0x07324D924CA0C9Fbe933AE7E958e47Dd7d040C4d
- SPL (SOL): 32Jwe936XEN5NEvbWusapYeqwFcuPQkSgCuzduQEkfCV
MIT Β© Dusk