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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pholend-sdk-ts-1

v0.3.20

Published

sdk to communicate with contracts for frontend

Readme

Pholend SDK

This project is designed for simplified interaction between the frontend and Pholend smart contracts

The Pholend SDK is a typescript class containing specific methods that are responsible for individual pages of a web application. You can see an example of how the sdk works here.

SDK setup

First of all you need to install npm package pholend-sdk-ts-1 and import this package.

npm i pholend-sdk-ts-1
import { PholendSDK, SdkConfig } from "pholend-sdk-ts-1"

Then you need to create a object: SdkConfig. Since the config uses LendingPool, it is necessary to call the static function PholendSDK.getLendingPool().

export type SdkConfig = {
	chainId: number
	contractsAddresses: ContractsAddresses
	signer: ethers.Signer
	indexer: string
	network?: TNetwork
}

type ContractsAddresses = {
	UiPoolDataProvider: string
	LendingPoolAddressProvider: string
	WETHGateway: string
}

type TNetwork = {
	nativeTokenName: string
	nativeTokenSymbol: string
	decimals: number
	wrappedTokenAddress: string
}

Now you can create new PholendSDK object

const sdk = new PholendSDK(config)

PholendSDK supports only those networks that are listed in ./networks.ts, but if you want to use it with custom network specify network param in SdkConfig

Methods

Dashboard

| Params | Description | | ------ | -------------- | | user | user's address |

Returns
type DashboardResponse = {
	stats: DashboardStats
	userSupplyAssets: UserAssets<SupplyAsset>
	userBorrowAssets: UserAssets<BorrowAsset>
	allAssetsToSupply: Asset[]
	allAssetsToBorrow: Asset[]
	nativePrice: BigNumber
}

ReserveOverview

| Params | Description | | ----------------- | ---------------------------------------------------------------------------------------- | | asset | Asset's address (example: usdc token address) | | dashboardResponse | Responded data from PholendSDK.Dashboard() | | from | The date from the beginning of which it is necessary to obtain data on the change in apr |

Returns
type ReserveOverviewResponse = {
	stats: OverviewStats
	supplyOverviewInfo: SupplyOverviewInfo
	borrowOverviewInfo: BorrowOverviewInfo
	aprHistory: AprHistory[]
}

ReCalcHealthFactor

| Params | Description | | --------------------- | -------------------------------------------------------------------------------- | | tokenDelta | Delta means that if user want to withdraw/borrow you need to pass -tokenAmount | | aggregatedReserveData | Type AggregatedReserveData about asset (returns in DashboardResponse.allAssets ) |

Returns
type string

Response examples

DashboardResponse

{
  stats: {
    netWorth: '1.5232361778223975',
    netApy: '-2.9343100466735383',
    healthFactor: '9.95995650334386908758',
	collateral: '1.6546059195367664630095988',
    borrowPowerUsed: '10.717878145061177758'
  },
  userSupplyAssets: {
    assets: [
		{
			underlyingAsset: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
			name: 'USD Coin (PoS)',
			symbol: 'USDC',
			tokenAmount: '1.00136340252977700316',
			tokenUsdBalance: '1.0014184675032802351253096',
			apy: '0.6663598668003257',
			_amountOfTokenInNative: BigNumber { s: 1, e: -4, c: [ 34455495183, 47210200000000 ] },// only for internal usage
			_userReserveData: { // only for internal usage
				underlyingAsset: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
				usageAsCollateralEnabledOnUser: true,
				scaledATokenBalance: BigNumber { s: 1, e: 5, c: [Array] },
				stableBorrowRate: BigNumber { s: 1, e: 0, c: [Array] },
				scaledVariableDebt: BigNumber { s: 1, e: 4, c: [Array] },
				principalStableDebt: BigNumber { s: 1, e: 0, c: [Array] },
				stableBorrowLastUpdateTimestamp: BigNumber { s: 1, e: 0, c: [Array] }
			},
			_aggregatedReserveData: {// only for internal usage
				underlyingAsset: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
				name: 'USD Coin (PoS)',
				symbol: 'USDC',
				decimals: BigNumber { s: 1, e: 0, c: [Array] },
				baseLTVasCollateral: BigNumber { s: 1, e: 3, c: [Array] },
				reserveLiquidationThreshold: BigNumber { s: 1, e: 3, c: [Array] },
				reserveLiquidationBonus: BigNumber { s: 1, e: 4, c: [Array] },
				reserveFactor: BigNumber { s: 1, e: 3, c: [Array] },
				usageAsCollateralEnabled: true,
				borrowingEnabled: true,
				stableBorrowRateEnabled: false,
				isActive: true,
				isFrozen: false,
				liquidityIndex: BigNumber { s: 1, e: 27, c: [Array] },
				variableBorrowIndex: BigNumber { s: 1, e: 27, c: [Array] },
				liquidityRate: BigNumber { s: 1, e: 24, c: [Array] },
				variableBorrowRate: BigNumber { s: 1, e: 26, c: [Array] },
				stableBorrowRate: BigNumber { s: 1, e: 26, c: [Array] },
				lastUpdateTimestamp: BigNumber { s: 1, e: 9, c: [Array] },
				aTokenAddress: '0x1a13F4Ca1d028320A707D99520AbFefca3998b7F',
				stableDebtTokenAddress: '0xdeb05676dB0DB85cecafE8933c903466Bf20C572',
				variableDebtTokenAddress: '0x248960A9d75EdFa3de94F7193eae3161Eb349a12',
				interestRateStrategyAddress: '0x15d31D8a5da6A57Ea8EaDc12261777768b1E8C60',
				availableLiquidity: BigNumber { s: 1, e: 12, c: [Array] },
				totalPrincipalStableDebt: BigNumber { s: 1, e: 0, c: [Array] },
				averageStableRate: BigNumber { s: 1, e: 0, c: [Array] },
				stableDebtLastUpdateTimestamp: BigNumber { s: 1, e: 0, c: [Array] },
				totalScaledVariableDebt: BigNumber { s: 1, e: 12, c: [Array] },
				priceInMarketReferenceCurrency: BigNumber { s: 1, e: 14, c: [Array] },
				variableRateSlope1: BigNumber { s: 1, e: 25, c: [Array] },
				variableRateSlope2: BigNumber { s: 1, e: 27, c: [Array] },
				stableRateSlope1: BigNumber { s: 1, e: 25, c: [Array] },
				stableRateSlope2: BigNumber { s: 1, e: 27, c: [Array] },
				aTokenReserveSize: BigNumber { s: 1, e: 12, c: [Array] },
				baseVariableBorrowRate: BigNumber { s: 1, e: 0, c: [Array] },
				optimalUtilizationRate: BigNumber { s: 1, e: 26, c: [Array] }
			},
			reserveFactor: '98'
		} as SupplyAsset,
		...
	],
    totalAssetsInfo: {
      averageApy: '0.4033056630321186',
      totalUsdBalance: '1.6546059195367664'
    }
  },
  userBorrowAssets: {
    assets: [ [BorrowAsset], ... ],
    totalAssetsInfo: {
      averageApy: '39.103062017473995',
      totalUsdBalance: '0.13136974171436885'
    }
  },
  allAssetsToSupply: [
    {
      underlyingAsset: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
      name: 'USD Coin (PoS)',
      symbol: 'USDC',
      tokenAmount: '2.099725',
      tokenUsdBalance: '2.0998404638777460678595224',
      apy: '0.6663598668003257',
      reserveFactor: '98',
      _aggregatedReserveData: [Object]
    },
    ...
  ],
  allAssetsToBorrow: [
    {
      underlyingAsset: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
      name: 'USD Coin (PoS)',
      symbol: 'USDC',
      tokenAmount: '1.09427670183418956568',
      tokenUsdBalance: '1.094336876110021367708248',
      apy: '49.73693556883148',
      reserveFactor: '98',
      _aggregatedReserveData: [Object]
    },
    ...
  ],
  nativePrice: BigNumber { s: 1, e: 11, c: [ 290641148000 ] }
}

Thats is how the dashboard looks like for the response above

alt text

OverviewResponse

{
  tokenAmount: '2.099725',
  availableToBorrow: '1.09427670183418956568',
  reserveSizeUsd: '8979766.144842865481672244194462796',
  availableLiquidity: '1593384.91077',
  availableLiquidityUsd: '1593472.531006240261687417047137064',
  utilizationRate: '82.255830663417769717',
  oraclePrice: '1.0000549899999981293832'
}
{
  liquidationThreshold: '85',
  liquidationPenalty: '5',
  totalTokenAmount: '8979272.374655',
  usdValue: '8979766.144842865481672244194462796',
  maxLTV: '80',
  apy: '0.6663598668003257',
  reserveFactor: '98'
}
{
  totalTokenAmount: '7385887.463885',
  usdValue: '7386293.613836625219984827147325732',
  apy: '0.6663598668003257',
  interestRateModelPoints: [
		{ utilizationRate: 0, amount: '-7385887.463885', apr: '0' },
		{
		utilizationRate: 0.5,
		amount: '-7340991.63459049517207662419',
		apr: '0.06331168831168831169'
		},
		...
	]
}

Thats is how the overview looks like for the response above

alt text

alt text