yearn-sdk icon indicating copy to clipboard operation
yearn-sdk copied to clipboard

🦧 SDK for the yearn.finance platform. WIP

Yearn SDK

CI Styled With Prettier

Getting Started

Installation

npm i @yfi/sdk

Configuration/Usage

To use the SDK, you will need to instantiate a Yearn object with your desired configuration;

import { Yearn } from "@yfi/sdk";
import { JsonRpcProvider } from "@ethersproject/providers";

// Ethereum mainnet
const chainId = 1;

// It is recommended to use Alchemy for your Web3 provider when using the Yearn SDK.
const rpcUrl = "https://eth-mainnet.alchemyapi.io/v2/secret-id-here";

const yearn = new Yearn(chainId, {
  provider: new JsonRpcProvider(rpcUrl)
});

Documentation

Autogenerated documentation can be found here.

Helpful links

Contributing

  • Code style follows prettier conventions (yarn lint). Commit messages follow Conventional Commits.
  • PR conventions should follow our guidelines outlined at https://github.com/yearn/yearn-sdk/wiki/PR-conventions

Releasing the SDK to npmjs

  • Get write access to the package on npmjs - https://www.npmjs.com/package/@yfi/sdk
  • Login to npm - npm login
  • Install np - https://www.npmjs.com/package/np
  • Checkout and pull the master branch
  • Run yarn build
  • Run np and follow the instructions

Debug the website with a local copy of the sdk

  • Install yalc - https://www.npmjs.com/package/yalc
  • Run yarn build
  • Run yalc publish
  • Clone the website repo, configure the enviornment and open a terminal in it - https://github.com/yearn/yearn-finance-v3
  • Run yalc add @yfi/sdk
  • Run yarn install
  • Run yarn start