/funding-rate-arb

Primary LanguageTypeScriptMIT LicenseMIT

Marginfi Mango x 01 Funding Rate Arb Bot

⚠ Warning

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Prerequisites

Fund your wallet with:

  • 0.2 SOL (for margin account + mango + 01 rent)
  • 10 USDC

Setup

cp .env.example.mainnet .env

Set the WALLET= the path of your solana wallet.

Setup node dependencies

yarn

You can follow either the Setup Script or the Cli Setup

Setup Script

Create your marginfi account, fund it, and activate the trading protocols

yarn setup

It is recommended you use a private RPC node, as public ones like to fail/serve stale data.

If at any step the setup script fails, you can continue manually with the CLI from the step that failed

Cli Setup

Download the CLI

yarn global add @mrgnlabs/marginfi-cli

Create your marginfi account

mfi account create -k <wallet_path>

Fund your marginfi account

mfi account deposit <account_address> 10 -k <wallet_path>

Activate and fund Mango

mfi account mango activate <account_address> -k <wallet_path>
mfi account mango deposit  <account_address> -k <wallet_path>

Activate and fund 01

mfi account zo activate <account_address> -k <wallet_path>
mfi account zo deposit <account_address> -k <wallet_path>

Set the MARGINFI_ACCOUNT=<address> to the just created address.

Start the bot

yarn start

Troubleshooting

If anything goes wrong you can set export DEBUG=* and repeat the failing step and send us the log via Telegram ❤️.

DISCLAIMER

Not financial advice.

This bot is written for educational purposes only.