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

@hubbleprotocol/farms-sdk

v0.3.31

Published

Farms SDK

Downloads

2,665

Readme

Farms SDK

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

Install

npm

npm install @solana/web3.js decimal.js @hubbleprotocol/farms-sdk

Usage

  • DEBUG=true yarn ts-node farms-sdk/src/client.ts init-farm --admin <keypair.json> --rpc --global-config --token-mint

  • DEBUG=true yarn ts-node farms-sdk/src/client.ts init-reward --admin <keypair.json> --rpc --farm --global-config --reward-mint

  • DEBUG=true yarn ts-node farms-sdk/src/client.ts top-up-reward --admin <keypair.json> --rpc --farm --reward-mint --amount

  • DEBUG=true yarn ts-node farms-sdk/src/client.ts update-farm-config --admin <keypair.json> --rpc --farm --reward-mint --mode-name UpdateRewardRps --flag-value 400

Set up test jito farm

DEBUG=true yarn ts-node farms-sdk/src/client.ts init-farm --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --global-config 6UodrBjL2ZreDy7QdR4YV1oxqMBjVYSEyrFpctqqwGwL --token-mint 9EQRQcCDNWc6fWBne8Uxiuv5t4NHZW4QQVWS5mJeCVKV

DEBUG=true yarn ts-node farms-sdk/src/client.ts init-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm EAxbKKCH9oJtNiVXdVcUAEJ2sG8ZJFcZkKATgqgQwqtU --global-config 6UodrBjL2ZreDy7QdR4YV1oxqMBjVYSEyrFpctqqwGwL --reward-mint HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6

DEBUG=true yarn ts-node farms-sdk/src/client.ts top-up-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm EAxbKKCH9oJtNiVXdVcUAEJ2sG8ZJFcZkKATgqgQwqtU --reward-mint HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6 --amount 400

DEBUG=true yarn ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm EAxbKKCH9oJtNiVXdVcUAEJ2sG8ZJFcZkKATgqgQwqtU --reward-mint HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6 --mode-name UpdateRewardRps --flag-value 400

DEBUG=true yarn ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm EAxbKKCH9oJtNiVXdVcUAEJ2sG8ZJFcZkKATgqgQwqtU --reward-mint HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6 --mode-name LockingMode --flag-value 1

DEBUG=true yarn ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm EAxbKKCH9oJtNiVXdVcUAEJ2sG8ZJFcZkKATgqgQwqtU --reward-mint HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6 --mode-name LockingDuration --flag-value 300

Add points

  • Create point keypair solana-keygen grind --starts-with kPs1:4
  • Create mint spl-token create-token --decimals 4 ./kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4.json -u m --mint-authority ../kamino-lending/keys/mainnet-admin.json --fee-payer ../kamino-lending/keys/mainnet-admin.json

-> USDH Collateral Farm: Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 - [x] Initialize reward npx ts-node farms-sdk/src/client.ts initialize-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 - [x] Update reward RewardType Unclaimable npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name UpdateRewardMinClaimDuration --flag-value 18446744000000000000 --multisig - [x] Update reward Reward Type Points npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name RewardType --flag-value 1 --multisig - [x] Update reward Reward Decimals npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name RpsDecimals --flag-value 11 - [x] Top up reward npx ts-node farms-sdk/src/client.ts top-up-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 - [x] Update reward Reward RPS npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm Dyd8UokNjPqPUWcW6NjZf96NaD9AdauumNs8q6XMvr59 --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name RpsDecimals --flag-value 5

-> SOL Collateral Farm: 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX - [x] Initialize reward npx ts-node farms-sdk/src/client.ts initialize-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --multisig - [x] Update reward Reward Type Unclaimable npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name UpdateRewardMinClaimDuration --flag-value 18446744000000000000 --multisig - [x] Update reward Reward Type Points npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141`` --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name RewardType --flag-value 1 --multisig - [x] Update reward Reward Decimals npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name RpsDecimals --flag-value 10 - [x] Top up reward npx ts-node farms-sdk/src/client.ts top-up-reward --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --amount 438000000 - [x] Update reward Reward RPS npx ts-node farms-sdk/src/client.ts update-farm-config --admin ../kamino-lending/keys/mainnet-admin.json --rpc https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --farm 955xWFhSDcDiUgUr4sBRtCpTLiMd4H5uZLAmgtP3R3sX --reward-mint kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 --mode-name UpdateRewardRps --flag-value 11574 --multisig

1 SOL -> 10 points per sol per day -> 1_000_000_000 sol_lamports -> 10_0000 point_laports per day 1_000_000_000 sol_lamports -> 10_0000 point_laports per 60 * 60 * 24 = 86400 seconds
1_000_0 sol_lamports -> 1 point_laports per 60 * 60 * 24 = 86400 seconds
1 sol_lamports -> 0.0001 point_laports per 60 * 60 * 24 = 86400 seconds
1 sol_lamports -> 1.1574074074074074e-9 point_lamports per second
1 sol_lamports -> 11574 * 10-13 point_lamports per second

120k sol in total -> 1.2m points earned per day 1.2m per day -> 1.2 * 365 = 438m

Calculation USDH

  • 1 point per usdh staked per day
  • 17,000 USDH -> 1 point per day -> 17000 points per day -> 1 year -> 17000 * 365 = 6205000
  • 1 point per day = 60 * 60 * 24 = 1 point per 86400 seconds = 1 / 86400 = 0.000011574074074074073 points per second
  • decimals = 4 -> 0.000011574074074074073 * 10^4 = 0.11574074074074074 points per second
  • decimals_adjustment = 5 -> 0.11574074074074073 * 10^5 = 11574.074074074073 points per second
  • mint: spl-token mint --url https://mainnet.helius-rpc.com/?api-key=9fea7846-5312-4627-9e7a-15f74040c141 --mint-authority ../kamino-lending/keys/mainnet-admin.json --fee-payer ../kamino-lending/keys/mainnet-admin.json --output json kPs18H4xTYxHKssMbJeXzC6mGWHvCtU4w4Dq3grGNh4 6205000 A4acQZ6KPYT6m7gxYXbG8idvZKuGDYF7qLmTTwJ8iH1m
  • (above was wrong due to decimals)

Calculation SOL

  • 1 point per SOL staked per day
  • 10000 point_lamports per 1000000000 sol_lamports per day
  • 10000 / 1000000000 = 0.00001 point_lamports per 1 sol_lamports per day / 86400 seconds 0.00001 / 86400 = 1.1574e-10 = 11574 * 10^-14
  • but I want 10 points per sol staked per day -> therefore has 13 zeros

995.792.278

10 seconds -> 115740 6 * 60 * 24 = 8640 -> 115740 * 8640 = 99999.3600 6 * 60 * 24 = 8640 -> 1393267 * 8640 = 1,203,782.6880

Jito cals

Jito calcs

Initial allocation to Kamino farm for 1 month: 1,333,333 tokens

30 days: 37 days: - 1333333 / 37 * 5 = 180180.13513513515 tokens per day on day 1 - 1333333 / 37 * 3 = 108108.08108108108 tokens per day on day 2 - 1333333 / 37 * 2 = 72072.05405405405 tokens per day on day 3 - 1333333 / 37 = 36036.02702702703 tokens per day on day 4

Dates: - day 1 2023-12-07 18:00:00 gmt - unix timestamp 1701972000 - day 2 2023-12-08 18:00:00 gmt - unix timestamp 1701972000 + 86400 = 1702058400 - day 3 2023-12-09 18:00:00 gmt - unix timestamp 1701972000 + 86400 * 2 = 1702144800 - day 4 2023-12-10 18:00:00 gmt - unix timestamp 1701972000 + 86400 * 3 = 1702231200 - day 5 2023-12-11 18:00:00 gmt - unix timestamp 1701972000 + 86400 * 4 = 1702317600

faactor: 1000000000 - 1333333 / 37 * 5 = 180180.13513513515 tokens per day on day 1 - 1333333 / 37 * 3 = 108108.08108108108 tokens per day on day 2 - 1333333 / 37 * 2 = 72072.05405405405 tokens per day on day 3 - 1333333 / 37 = 36036.02702702703 tokens per day on day 4 lamports: - 1333333 / 37 * 5 = 180180.13513513515 * 1000000000 / 86400 = 2085418230 rps on day 1 - 1333333 / 37 * 3 = 108108.08108108108 * 1000000000 / 86400 = 1251250938 rps on day 2 - 1333333 / 37 * 2 = 72072.05405405405 * 1000000000 / 86400 = 834167292 rps on day 3 - 1333333 / 37 = 36036.02702702703 * 1000000000 / 86400 = 417083646 rps on day 4 non lamports rps: - 1333333 / 37 * 5 = 180180.13513513515 / 86400 = 2.0854182307307307 rps on day 1 - 1333333 / 37 * 3 = 108108.08108108108 / 86400 = 1.2512509384384385 rps on day 2 - 1333333 / 37 * 2 = 72072.05405405405 / 86400 = 0.8341672922922923 rps on day 3 - 1333333 / 37 = 36036.02702702703 / 86400 = 0.4170836461461461 rps on day 4

  • 1 kTokens -> x JTOs -> how many JTOs for each x JTO per day?

100 JTOs in the Farm -> 1 for every 12 -> 1/12 for each -> 1/12 = 0.08333333333333333 per day = 0.08333333333333333 / 86400 = 9.645061728395062e-7 = 0.0000009645061728395062 = 0.0000009645

= how mant JTOs per second 

1/12 JTOs for each 1 JTO in the farm per 1 day 1/12 * 1000000000 JTO lamports for each 1 JTO in the farm per 1 day 1/12 * 1000000000 JTO lamports for each 1 * 1000000000 JTO lamports in the farm per 1 day

x kTokens

oracle_price = 0.0002328412320 JTOs per kToken ktokens_staked = 1717908469

1,717.908469 kTokens -> 1717.908469 * 0.0002328412320 = 0.39999992438519383

0.4 * 1/12 = 0.03333333333333333

1/12 = 0.08333333333333333

oracle_price = 0.0002328412320 JTOs per kToken ktokens_lamports_staked = 1717908469 jtos_lamports_staked = jtos_staked = 1717908469 * 0.0002328412320

1/12 jtos per jto staked -> 0.4 jtos staked -> 1/12 * 0.4 = 0.03333333333333333 * 1000000000 = 33333333.333333332 after 1 day

= 33333333.333333332 / 86400 = 385.8024691358025 after 1 second

385.8024691358025 = 1717908469 * 0.0002328412320 * rps rps = 385.802469135802 / (1717908469 * 0.0002328412320) = 0.0000009645061728395062 JTO lamports per second


rps = 0.0000009645061728395062 1717908469 * num_seconds * rps * oracle = 1717908469 * 86400 * rps * 0.0002328412320 = 33333327.0320994851

rps = 33333327.0320994851 / (1717908469 * 86400 * 0.0002328412320) = 0.0009645

0.03333333333333333 * 1000000000 = 33333333.333333332

1717908469

ktoken_lamports_staked * rps * one_day * oracle_orice = 1 / 12 * 1000000000 = 83333333.33333333

1717908469 * 0.0009645 * 86400 * 0.0002328412320 = 33333113.698806476 = 33333333.333333332 33333333.333333332

day rps 1: 0.0009645 * 5 = 0.0048225 / 30 = 0.00016075 day rps 2: 0.0009645 * 3 = 0.0028935 / 30 = 0.00009645 day rps 3: 0.0009645 * 2 = 0.001929 / 30 = 0.0000643 day rps 4: 0.0009645 * 1 = 0.0009645 / 30 = 0.00003215

  • [ ] TODO: add issuance deposit cap per day

"rewardCurve": [ { "startTs": 1701972000, "rps": 0.0048225 }, { "startTs": 1702058400, "rps": 0.0028935 }, { "startTs": 1702144800, "rps": 0.0019290 }, { "startTs": 1702231200, "rps": 0.0009645 } ],

600000 * 12 / 30 = 240000

--- MAx: 600000 JTOS for the month --- 600000 / 37 = 16216.216216216217 jto daily rewards
--- 16216.216216216217 * 12 = max jtos in farm --- 16216.216216216217 * 12 * 30 = 5,837,837.837837839 = 194594.59459459462 --- ktokens_cap * oracle_price = 194594.59459459462


600000 JTOS for the 30 days

600000 / 37 = 16216.216216216217 jto daily rewards

16216.216216216217 * 12 = 16000000 jtos total in the pool


16,000,000.00 * 1/12 16000000.00 * 1/12 = 1333333.3333333333 / 600000 = 2.222222222222222

16000000 / 2.222222222222222 = 7,200,000.000000001

4m cap

4000000 * 10^9 = 4000000000000000


Caps: yvaults cap dollar cap -> $5m farms cap: jto cap -> 4m jtos

Farm: Cik985zLyHYdv5Hs73BUWUcMHMhgfBNwbcCYyvBjV2tt

151247171289911, exp: 18 151247171289911 / 10^18 = 0.000151247171289911

6453632600922820 * 0.000151247171289911 = 976093675433.9275

16,000

11 seconds -> 1.780047655

1.780047655 / 11 * 60 * 60 * 24 = 13981.465217454544

Points / Klend

  • ./farms-sdk/src/client.ts set-klend-points --config ./configs/points/staging/sol_EaAuYkMrA9rmnU9eVvHi63yqZzKzmnVj3PWFnmW9RD4W.json --mode execute

Client Commands

Download a farm klend config: npx ts-node farms-sdk/src/client.ts download-klend-farm-config --reserve-address H9vmCVd77N1HZa36eBn3UnftYmg4vQzPfm1RxabHAMER --farm-kind Collateral Update farm config: npx ts-node farms-sdk/src/client.ts upsert-klend-farm --config ./configs/bSOL-Collateral.json - use --mode execute to execute