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

@hifi/protocol

v1.12.0

Published

The core Hifi fixed-rate, fixed-term lending protocol

Downloads

240

Readme

Hifi Protocol npm (scoped)

The core Hifi fixed-rate, fixed-term lending protocol. Hifi is a decentralized finance protocol that brings fixed-rate, fixed-term lending to Ethereum-based blockchains.

The build artifacts can be browsed via unpkg.com.

Installation

With yarn:

$ yarn add @hifi/protocol

Or npm:

$ npm install @hifi/protocol

Usage

The node package that you just installed contains both Solidity and JavaScript code. The former is the smart contracts themselves; the latter, the smart contract ABIs and the TypeChain bindings.

Solidity

The core Hifi protocol can only be compiled with Solidity v0.8.4 and above, because we are reverting with custom errors instead of reason strings.

// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

import "@hifi/protocol/contracts/core/balance-sheet/IBalanceSheetV2.sol";

contract YourContract {
    // Find the address on https://docs.hifi.finance
    IBalanceSheetV2 balanceSheet = IBalanceSheetV2(0x...);

    function queryAccountLiquidity(address user) external view returns (uint256 excessLiquidity, uint256 shortfallLiquidity) {
        (excessLiquidity, shortfallLiquidity) = balanceSheet.getCurrentAccountLiquidity(user);
    }

    function queryCollateralAmount(address user, IErc20 collateral) external view returns (uint256 collateralAmount) {
        collateralAmount = balanceSheet.getCollateralAmount(user, collateral);
    }

    function queryDebtAmount(address user, IHToken hToken) external view returns (uint256 debtAmount) {
        debtAmount = balanceSheet.getDebtAmount(user, hToken);
    }
}

JavaScript

import type { BalanceSheetV2__factory } from "@hifi/protocol/dist/types/factories/contracts/core/balance-sheet/BalanceSheetV2__factory";

async function queryAccountLiquidity() {
  const signer = "..."; // Get hold of an ethers.js Signer
  const balanceSheetFactory = new BalanceSheetV2__factory(signer); // Find the address on https://docs.hifi.finance
  const balanceSheet = balanceSheetFactory.attach("0x...");
  const user = "0x...";
  const accountLiquidity = await balanceSheet.getCurrentAccountLiquidity(user);
}

Deployment

Fintroller

$ yarn hardhat deploy:contract:fintroller \
    --new-owner ${NEW_OWNER} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

Chainlink Operator

$ yarn hardhat deploy:contract:chainlink-operator \
    --new-owner ${NEW_OWNER} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

Balance Sheet

$ yarn hardhat deploy:contract:balance-sheet \
    --fintroller ${FINTROLLER} \
    --oracle ${ORACLE} \
    --new-owner ${NEW_OWNER} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

HToken

$ yarn hardhat deploy:contract:h-token \
    --name ${NAME} \
    --symbol ${SYMBOL} \
    --maturity ${MATURITY} \
    --balance-sheet ${BALANCE_SHEET} \
    --fintroller ${FINTROLLER} \
    --underlying ${UNDERLYING} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

Simple Price Feed

$ yarn hardhat deploy:contract:simple-price-feed \
    --description ${DESCRIPTION} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

Stablecoin Price Feed

$ yarn hardhat deploy:contract:stablecoin-price-feed \
    --price ${PRICE} \
    --description ${DESCRIPTION} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

Uniswap V3 Price Feed

$ yarn hardhat deploy:contract:uniswap-v3-price-feed \
    --pool ${POOL} \
    --quoteAsset ${QUOTE_ASSET} \
    --twapInterval ${TWAP_INTERVAL} \
    --maxPrice ${MAX_PRICE} \
    --confirmations 5 \
    --network ${NETWORK} \
    --print true \
    --verify true

License

BUSL 1.1 © Mainframe Group Inc.