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

@rari-capital/fuse-sdk

v1.1.0

Published

JavaScript SDK for easy implementation of Fuse by Rari Capital.

Downloads

5

Readme

Rari Capital: Fuse JavaScript SDK

Calling all DeFi developers: Rari Capital's SDK is now available for easy implementation of our smart contract APIs! Simply install the SDK and instantiate the Fuse class. See here for the Fuse dApp or here for the Fuse contracts.

Installation

Node.js

Install the SDK as a dependency of your project:

npm install --save @Rari-Capital/fuse-sdk

Import the fuse-sdk package:

const Fuse = require("@Rari-Capital/fuse-sdk");

Browser

Include the prebuilt dist/fuse.window.js in your HTML to expose the Fuse class on the window object:

<script src="dist/fuse.window.js">

Instantiation

The Fuse class is instantiated with a Web3 provider as the sole constructor parameter.

Node.js

var fuse = new Fuse("http://localhost:8545");

Browser

var fuse = new Fuse(window.ethereum || "http://localhost:8545");

Fuse Class API

The Fuse class is not very useful unless instantiated, except for a couple objects:

SDK web3.js Class: Fuse.Web3

Access the underlying web3.js class used by the SDK.

SDK web3.js Class: Fuse.BN

Access the underlying BN class used by the SDK. (Alias for Fuse.Web3.utils.BN.)

Fuse Instance API

The following objects are available on instances of the Fuse class:

Deploy Fuse Pool: Fuse.deployPool(poolName, isPrivate, closeFactor, maxAssets, liquidationIncentive, priceOracle, options)

Deploys a new Fuse pool and registers it in the FusePoolDirectory.

Deploy Asset to Fuse Pool: Fuse.deployAsset(conf, collateralFactor, options)

Deploys a new asset to an existing Fuse pool.

Compute Fuse Pool Contract Address: Fuse.getCreate2Address(creatorAddress, salt, byteCode)

Returns the Unitroller contract (the proxy for the Comptroller implementation contract) address from the creatorAddress (the FusePoolDirectory contract address that deployed the pool), the salt (the pool name), and the Unitroller proxy contract bytecode.

SDK web3.js Instance: Fuse.web3

Access the underlying web3.js instance used by the SDK.

Examples

Deploy New Fuse Pool

// Set parameters
var poolName = "Compound Finance";
var isPrivate = false;
var closeFactor = Web3.utils.toBN(0.051e18);
var maxAssets = Web3.utils.toBN(10);
var liquidationIncentive = Web3.utils.toBN(1e18);
var priceOracle = "ChainlinkPriceOracle"; // Or set to an address to use an existing price oracle

// Deploy new Fuse pool
try {
    var [poolAddress, receipt] = await fuse.deployPool(poolName, isPrivate, closeFactor, maxAssets, liquidationIncentive, priceOracle, { from: "0x0000000000000000000000000000000000000000" });
} catch (error) {
    return console.error(error);
}

// Log deployed pool contract address and transaction receipt
console.log("Deployed Fuse pool contract address:", poolAddress);
console.log("Deployment transaction receipt:", receipt);

Deploy Asset to Fuse Pool

// Set parameters
var conf = {
    underlying: "0x6b175474e89094c44da98b954eedeac495271d0f", // Leave blank for ETH
    comptroller: "0x0000000000000000000000000000000000000000", // Fuse pool contract address
    interestRateModel: "WhitePaperInterestRateModel", // Or set to an address to use an existing interest rate model
    initialExchangeRateMantissa: Web3.utils.toBN(2e18),
    name: "Compound DAI",
    symbol: "cDAI",
    decimals: 8,
    admin: "0x0000000000000000000000000000000000000000"
};

var collateralFactor = Web3.utils.toBN(0.5e18);

// Deploy new Fuse pool
try {
    var [poolAddress, receipt] = await App.fuse.deployAsset(conf, collateralFactor, { from: "0x0000000000000000000000000000000000000000" });
} catch (error) {
    return console.error(error);
}

// Log deployed pool asset contract address and transaction receipt
console.log("Deployed Fuse pool asset contract address:", poolAddress);
console.log("Deployment transaction receipt:", receipt);

Development

To build the production browser distribution bundle, run npm run build. To build the development browser distribution bundle, run npm run dev.

License

See LICENSE.

Credits

Fuse's SDK is developed by David Lucid of Rari Capital. Find out more about Rari Capital at rari.capital.