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

sf-ethereum-contracts

v0.1.2-preview-20201014-nodep

Published

Ethereum contracts implementation for the Superfluid Protocol

Downloads

8

Readme

Superfluid Protocol

The Superfluid Protocol is a framework that realizes the real-time finance vision where user accounts are connected together, and transactions can happen between user accounts instantaneously as a result.

This repository implements the superfluid protocol as Ethereum contracts. It also contains a Javascript SDK for developing Web3 applications using the superfluid protocol.

For technical document, references and tutorials, etc, please refer to the docs site.

Installation

To install, using its npm package is recommended.

$ npm install @superfluid-finance/ethereum-contracts

Development

To develop the project, pull the repository from GitHub and install its dependencies. You will need npm installed.

$ git clone https://github.com/superfluid-finance/ethereum-contracts
$ cd ethereum-contracts
$ npm ci

Linting

Javascripts are linted using eslint.

Solidity are linted using solhint

Testing

For any feature development, test driven development is recommended:

$ npm run dev

This will detect any code changes then run lint, build and test suite.

NB!: Since these tests take long time to execute, it is quite possible that you want to use the execlusive tests feature from MochaJS to speed up isolated feature development.

There are three major test suite:

  • Contracts (test/contracts.test.js)
  • Deployment (test/deployment.test.js)
  • SDK (test/sdk.test.js)

Each contracts test suite is named as test/{Type}/{ContractName}.test.js.

Deployment test is for testing the deployment script.

SDK test is to test the JS SDK.

Code Coverage

To run the coverage tests please use:

$ truffle run test-coverage

This step is not integraded with the unit test because of the time it consumes to execute.

Integration

It is recommended that you use our JS SDK to interact with the protocol.

NB! The SDK is still under development, its API and interfaces can change.

Initialize the SDK

const SuperfluidSDK = require("@superfluid-finance/ethereum-contracts");
const sf = new SuperfluidSDK.Framework({
    version: "0.1.2-preview-20201014", // This is for using different protocol release
    web3Provider: web3.currentProvider // your web3 provider
});

await sf.initialize();

const daiAddress = await sf.resolver.get("tokens.fDAI");
const dai = await sf.contracts.TestToken.at(daiAddress);
const daixWrapper = await sf.getERC20Wrapper(dai);
// assert(daixWrapper.created);
const daix = await sf.contracts.ISuperToken.at(daixWrapper.wrapperAddress);

What's In the Bag

  • sf.host : The truffle contract instance to interact with the host contract (Superfluid.sol).
  • sf.contracts : The truffle contract objects loaded by the SDK:
    • IERC20 : The ERC20 Interface.
    • TokenInfo : A customary ERC20 token info interface (name/symbol/decimals).
    • ERC20WithTokenInfo : A combination of IERC20 and TokenInfo.
    • TestToken : A ERC20 Test token.
    • IResolver : A simple resolver interface to locate different versions of the contracts.
    • ISuperfluid : The Superfluid host contract interface.
    • ISuperToken : The Super token contract interface.
    • IConstantFlowAgreementV1 : The constant flow agreement (v1) contract interface.
    • IInstantDistributionAgreementV1 : The instant distribution agreement (v1) contract interface.
  • Token wrapper convenient functions:
    • sf.getERC20Wrapper
    • sf.createERC20Wrapper
  • sf.resolver: The resolver used by the SDK.
    • In test nets, there are some test tokens can be located with the resolver:
      • fDAI : The fake DAI. sf.resolver.get("tokens.fDAI").
      • fUSDC : The fake USDC. sf.resolver.get("tokens.fUSDC").
  • sf.agreements :
    • sf.agreements.cfa : Constant flow agreement truffle contract instance.
    • sf.agreements.ida : Instant distribution agreement truffle contract instance.