Coder Social home page Coder Social logo

defisaver-positions-sdk's Introduction

DeFi Saver Positions SDK

Supported protocols:

Setup

Supported Node version is v10.

  • run npm install (first time)
  • run npm run build

build command will generate contracts and build ejs and esm folders

How to use

All available imports

This is a Compound V3 example, and every other protocol is similar

import Web3 from 'web3';
import { compoundV3 } from '@defisaver/positions-sdk';


// every protocol has market data and user data getters
const {
    getCompoundV3MarketsData,
    getCompoundV3AccountData,
} = compoundV3;

const provider = 'Your RPC provider';
const web3 = new Web3(provider);

const user = '0x123...';

const { assetsData } = await getCompoundV3MarketsData(
    web3, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
    1, // network
    selectedMarket, // market object like in /src/markets/compound/index.ts
    web3, // this must be mainnet rpc - used for getting prices onchain and calculating apys
);

const userData = await getCompoundV3AccountData(
    web3,
    1, // network
    userAddress, // EOA or DSProxy
    '', // proxy address of the user, or just empty string if checking for EOA
    {
        selectedMarket, // market object as in /src/markets/compound/index.ts
        assetsData,
    }
);

More examples found here

defisaver-positions-sdk's People

Contributors

matijapojatar avatar cussone avatar stefanmiric avatar sterlu avatar mihai9-lab avatar majkic99 avatar

Watchers

Nenad Palinkasevic avatar  avatar Aleksandar Milosavljević 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.