Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rari-capital/fuse-sdk

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rari-capital/fuse-sdk

JavaScript SDK for easy implementation of Fuse by Rari Capital.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 20 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc