Quick Start Guide

Creating a vault

To create a vault use the vault factory. This is the first step in preparing your strategy. Once the vault is created it still needs to be whitelisted if you want to have it included in the IPOR webapp interface.

VIDEO

Vault Setup

Documentation:https://docs.ipor.io/developers-docs/fusion/vault-configuration-step-by-step

Playlist: https://www.youtube.com/playlist?list=PLTda9D8MCj4QafXFkFPR_i27CakEUdBeg

  1. General settings VIDEO

  2. Access manager VIDEO

  3. Integrations VIDEO

    1. Fuses VIDEO

    2. Substrates VIDEO

  4. Scheduled operations VIDEO

  5. Withdrawals

    1. Instant VIDEO

    2. Scheduled VIDEO

  6. Fees VIDEO

  7. Price Oracle VIDEO

  8. Prehooks - VIDEO, Documentation

  9. Price feeds VIDEO

Running Alpha

This section describes how to set up and run the "Alpha" bot, which interacts with the smart contracts of your vault in the IPOR Fusion protocol. The bot uses the official IPOR Fusion SDK for Python.

To run and develop the bot, you will need two main repositories:

How to run the bot as fast as possible 🚀

To run a basic version of the bot in the shortest possible time, follow the steps below using the ipor-fusion-alpha-example repository.

Clone the example repository:

$ git clone https://github.com/IPOR-Labs/ipor-fusion-alpha-example.git
$ cd ipor-fusion-alpha-example

Configure environment variables:

Copy the .env.example file to a new file named .env.

$ cp .env.example .env

Then, open the .env file and fill it with your credentials:

PROVIDER_URL: Your blockchain node provider URL (e.g., from Infura or Alchemy)
PRIVATE_KEY: The private key of your wallet that will manage the vault.
PLASMA_VAULT_ADDRESS: The smart contract address of your IPOR Plasma vault.

Install project dependencies:

Make sure you have Python (version 3.11 or newer) and poetry installed.

$ poetry install

Run the bot:

$ poetry run python main.py

The bot will connect to the blockchain network, initialize the connection to your vault, and start executing the default strategy every 60 seconds.

How to customize the bot for your own strategy? 🛠️

The example bot is designed for easy modification. To implement your own logic:

  • Edit the main strategy logic: Open the alpha_bot.py file and modify the do_fusion() method. This is where you should place the code for your custom strategy (e.g., conditions for opening/closing positions, flashloan logic, looping).

  • Change the execution frequency: Open the main.py file and change the interval value in the scheduler section to adjust how often the bot executes its strategy.

  • Add your own variables: If your strategy requires additional parameters, add them to the .env file and read them in the bot's code (e.g., in alpha_bot.py).

Where to find information during development? 📖

While creating your own strategy or extending the bot, use the following resources:

  • Official IPOR Documentation: The main knowledge base about the protocol, smart contracts, and their functions.

  • SDK Source Code (ipor-fusion.py): Analyzing the SDK's code will help you understand what functions and classes are available under the hood and how to use them.

  • Example Repository (ipor-fusion-alpha-example): The best source for practical usage patterns of the SDK.

How to debug? 🐛

Debugging is crucial for creating a stable and secure bot. Here are some recommended methods:

  • Local Testing with Anvil: The example repository includes a Docker Compose configuration that runs a local blockchain instance (Anvil). This allows you to test interactions with smart contracts without incurring real gas costs.

Start the local environment with the command:

$ docker-compose up -d

The bot will automatically connect to the local Anvil instance.

  • Unit and Integration Tests: The repository includes a test suite. Run them using poetry run pytest. Write your own tests for new features to ensure they work correctly.

  • Logging: Add more detailed logs in the do_fusion() method in the alpha_bot.py file using the built-in logging module. This will help you trace what your bot is doing and what decisions it's making step-by-step.

  • Interactive Debugger: Use a debugger, such as the one built into VS Code or IntelliJ IDA, to set breakpoints in the code and analyze the application's state in real-time.

Last updated