Giter Site home page Giter Site logo

jungle-fi-sdk's Introduction

JungleFi SDK

A client side SDK for interfacing with Jungle Finance smart contracts.

Installation

Yarn

$ yarn add @junglefinance/jungle-fi-sdk

npm

$ npm intall @junglefinance/jungle-fi-sdk --save

Program Addresses

Contract Mainnet / Devnet
Quarry jDeFipStbGiKTJQGLEQRRA2HNeqjpXKoqgGeM9Fg3XT
Raydium rDeFi3U3Jbj31z8rbHGXxEsiKLTB24EdScFXVCncG3c
Marinade mDeFijC2NYkK2kax3kCHYCgcaBZ9aV4wrpTeDLgcFc9

VaultInfo Addresses

Contract Name Mainnet
Quarry I-JFI-Q3 21Vx4auojCE8xCqPVFhC1M7QiWuRaiXak3Nuh4YiUgX7
Quarry I-JFI-Q4 8ua2wwcuGL9s1hrtcgH8x7KfwvEKXi95aqvJkmiLnKV8
Raydium I-RAY-Q3 2QeZFinvmrinXk9nuLHRvDfW4cWnQMDG7RV3utzHrPHw
Raydium I-RAY-Q4 HwK7u9crC5WjhxmmaxhFgVPbN3anjtbMg3y3uD4iSQEQ
Marinade I-SOL-Q3 BRrVBo3VkisZS1rXkuhp3QKua4S9nEE8kPN6RWXRDdTM

Example

This is an example on depositing into a Marinade vault however there are various different ways to utilize the sdk, this is just one of them.

Setup Code

import { JungleMsolPlatformProvider } from "../jungle_msol";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { EndPoint } from "./types";

const provider = new JungleMsolPlatformProvider(
    new Connection("https://api.devnet.solana.com"),
    new PublicKey("mDeFijC2NYkK2kax3kCHYCgcaBZ9aV4wrpTeDLgcFc9"),
    EndPoint.dev
);

const VAULT_INFO = new PublicKey("iSoLXhjuJJz1pRPd6MkwhGn6Q8qCybZzK9F77dDGK2C");

Deposit

import { Keypair } from "@solana/web3.js";

... (Setup Code)

const DEPOSIT_AMOUNT = 1_000_000;

const vaultInfo = await provider.fetchVault(VAULT_INFO);

const signer = Keypair.generate(); // Your Signer Here!

const txId = await provider.depositRpc(
    [signer],
    DEPOSIT_AMOUNT,
    signer.publicKey,
    vaultInfo
)

console.log("Transaction Signature: " + txId);

Math Library

import JSBI from "jsbi";

... (Setup Code)

const math = provider.createMath();

// Amounts in lamports
const returnAmounts = await math.calcDepositReturns(JSBI.BigInt(DEPOSIT_AMOUNT), vaultInfo);
if (returnAmounts.error){
    console.log("Math Error: " + returnAmounts.error);
} else {
    console.log("Return Amount: " + returnAmounts.result);
}

Build

Run the following commands to fetch dependencies and build the sdk.

$ yarn install
$ yarn build

jungle-fi-sdk's People

Contributors

chasewhip8 avatar

Watchers

Running avatar Darren Deanto avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.