Skip to content

zdbrig/marginfi-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Marginfi Solana Example

This project demonstrates how to interact with Marginfi and Solana using JavaScript. It provides examples of creating a Marginfi account, depositing funds into the account, and withdrawing funds from the account.

Prerequisites

Before running the code, make sure you have the following prerequisites installed:

  • Node.js (version 12 or above)
  • npm (Node Package Manager)

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/marginfi-solana-example.git
    
  2. Navigate to the project directory:

    cd marginfi-solana-example
    
  3. Install the required dependencies:

    npm install
    

Configuration

  1. Create a file named secret in the project directory.
  2. Open the secret file and paste your private key in base58 format. Make sure there are no extra spaces or newline characters.

Usage

To run the example script, use the following command:

node marginfi-example.js

The script will perform the following actions:

  1. Create a new Marginfi account associated with the provided private key.
  2. Deposit 1 SOL into the Marginfi account.
  3. Withdraw 0.5 SOL from the Marginfi account.

Make sure you have sufficient funds in your Solana account associated with the provided private key to cover the transaction fees and the amount being deposited.

Security

Please note that it is crucial to keep your private key secure and never share it publicly. Make sure to store it safely and use appropriate security measures when handling sensitive information like private keys.

Dependencies

This project relies on the following dependencies:

  • @solana/web3.js: Solana JavaScript SDK for interacting with the Solana blockchain.
  • @marginfi/core: Marginfi JavaScript SDK for interacting with Marginfi.
  • bs58: Library for encoding and decoding base58 strings.

License

This project is licensed under the MIT License.

Disclaimer

This example is provided for educational purposes only. Use it at your own risk. Always exercise caution when working with real funds and ensure that you understand the code and its implications before running it in a production environment.


Feel free to customize the README file based on your specific project details and requirements.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published