npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kamino-finance/farms-sdk

v2.0.5

Published

Farms SDK

Downloads

4,094

Readme

Farms SDK

Farms SDK is a TypeScript client SDK for easy access to the Farms on-chain data.

How to install the SDK

npm

npm install @solana/web3.js decimal.js @kamino-finance/farms-sdk 
npm update @kamino-finance/farms-sdk

How to use the SDK

// Initialize the client and then you can use it to fetch data by calling it
const farmsClient = new Farms(env.provider.connection);

How to install the SDK

yarn install

Client (CLI) Usage

.env file

In order to use the CLI, you will need a .env file. An example of it:

RPC=rpc
ADMIN=../user.json
FARMS_GLOBAL_CONFIG=6UodrBjL2ZreDy7QdR4YV1oxqMBjVYSEyrFpctqqwGwL
KLEND_PROGRAM_ID=SLendK7ySfcEzyaFqy93gDnD3RtrpXJcnRwb6zFHJSh
LENDING_MARKET=6WVSwDQXrBZeQVnu6hpnsRZhodaJTZBUaC334SiiBKdb
KLEND_POINTS_MINT=KpsgfQAhVwUosX1SL2eiwBHejcTe8UvwSj4UWwnZiBU
SCOPE_PRICES=3NJYftD5sjVfxSnUdZ1wVML8f3aC6mp1CXCL6L7TnU8C
MULTISIG=BbM3mbcLsa3QcYEVx8iovwfKaA1iZ6DK5fEbbtHwS3N8

cp ./.env.example ./.env

--mode parameter

Most commands will allow you to specify --mode which is used to specify how the txns are ran:

  • --mode simulate - Prints all the logs and simulates the transaction without execution
  • --mode execute - Prints all the logs and executes the transaction
  • --mode multisig - Prints no logs at all. The only output is the transaction in base58 - to be used for multisig

--priority-fee-multiplier paramter

Most commands will allow you to specify --priority-fee-multiplier which is used to set the multiplier pritority fee. The base is 1 lamport so --priority-fee-multiplier 50000 would mean 50_000 lamports.

How to create a global config

yarn ts-node farms-sdk/src/client.ts init-global-config

How to create a farm

yarn ts-node farms-sdk/src/client.ts init-farm --token-mint <mint_pk> --priority-fee-multiplier 50000 --mode execute

How to create a klend farm

npx ts-node farms-sdk/src/client.ts init-klend-farm --reserve <reserve_pk> --kind Collateral/Debt --multisig-to-execute <multisig_auth_pk> --pending-admin <multisig_auth_pk> --priority-fee-multiplier 50000 --mode execute

How to init a reward for a farm

npx ts-node farms-sdk/src/client.ts init-reward --farm <farm_pk> --reward-mint <mint_pk> --priority-fee-multiplier 50000 --mode execute

Initializing a reward can also be done by adding it to the config of an existing farm config. More details of this flow explained below.

How to update a farm

The easiest way to update and batch update farms is to use the following flow:

  1. Download all farm configs: npx ts-node farms-sdk/src/client.ts download-all-farm-configs --target-path configs/latest This will download all farms split in 3 main folders:
  • lending -> split in further folders for each market - based on the API, contains all farms (Coll/Debt) for all reserves for each market.
  • yvaults -> contains all farms for live strategies
  • standaloneFarms -> contains farms which are not included in the first two main folders
  1. Modify the configs you want to. Most modifications are straightforward and almost everything can be changed. To note:
  • rewardAvailable - only shows how much there is available - modifying won't change anything
  • rewardToTopUp - by default always 0 - modify this in order to create a top up change. By default this will be executed by your .env admin as this ixn is permissionless.
  • rewardToTopUpDurationDays - works with rewardToTopUp and is used to calculated the reqiured RPS for the given topUp -> will update the rewardCurve only if it's a signle value curve and it's not modified by you.
  1. Update everything by running: npx ts-node farms-sdk/src/client.ts upsert-all-farm-configs --target-path configs/latest --priority-fee-multiplier 50000 --mode print - to only see the diff of your changes npx ts-node farms-sdk/src/client.ts upsert-all-farm-configs --target-path configs/latest --priority-fee-multiplier 50000 --mode simulate - to only see the transaction simulation of your changes npx ts-node farms-sdk/src/client.ts upsert-all-farm-configs --target-path configs/latest --priority-fee-multiplier 50000 --mode execute/multisig - to either execute or get the bs58 txns for multisig

How to change a farm admin

First you need to make sure the pending admin is set to the right armin. This can be updated following the proccess above.

Then run the following command in order to set the current admin to the pending admin. (Can only be signed by the pending admin)

npx ts-node farms-sdk/src/client.ts update-farm-admin --farm farm_address --priority-fee-multiplier 1000 --mode execute/multisig

How to Initialize and Refresh user obligation for new Klend farm

  1. Download the obligations: npx ts-node farms-sdk/src/client.ts download-all-user-obligations-for-reserve --market <market> --reserve <reserve>

  2. Initialize all user obligations: npx ts-node farms-sdk/src/client.ts init-all-klend-user-obligation-farms-from-file --market <market> --file obligations-<reserve>.json

  3. Refresh all user obligations: npx ts-node farms-sdk/src/client.ts refresh-all-klend-obligation-farms-from-file --market <market> --file obligations-<reserve>.json

How to Set RPS as a delegated farm admin

  const farmsClient = new Farms(connection);

  const updateIxn = await farmsClient.updateFarmRpsForRewardIx(env.initialOwner.publicKey, reward, farm, rewardsPerSecond);

For a full example check farms-sdk/src/commands/example_update_rps_and_top_up.ts

How to top up a farm - permissionless

  const farmsClient = new Farms(connection);

  const topUpIx = await farmsClient.topUpFarmForRewardIx(env.initialOwner.publicKey, reward, farm, amountToTopUp);

For a full example check farms-sdk/src/commands/example_update_rps_and_top_up.ts