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

@abrandec/protocol-monorepo-upgradeable

v1.0.0-rc.4

Published

Ethereum contracts implementation for the Superfluid Protocol

Downloads

3

Readme

Ethereum contracts implementation for the Superfluid Protocol

🏠 Homepage

Superfluid App

📖 Docs

Usage

If you're building a dapp using the deployed contracts (goerli or mainnet) then you should instead use @superfluid-finance/js-sdk.

If you're building a smart contract that uses Superfluid protocol, or even your own SuperApp, then great! This is definitely the place to be.

Installation

$ yarn add @superfluid-finance/ethereum-contracts

Smart Contract

The contracts can be imported into your .sol file like this:

import { IConstantFlowAgreementV1 } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IConstantFlowAgreementV1.sol";

Writing Test

For writing tests, you can use the the deployment scripts to deploy all the necessary contracts. Currently they only works with web3.js, we are working on to support to other frameworks in the future.

const deployFramework = require("@superfluid-finance/ethereum-contracts/scripts/deploy-framework");
const deployTestToken = require("@superfluid-finance/ethereum-contracts/scripts/deploy-test-token");
const deploySuperToken = require("@superfluid-finance/ethereum-contracts/scripts/deploy-super-token");

contract("My Test", accounts => {
    const [admin, bob, carol, dan] = accounts;

    before(async () => {
        await deployFramework(errorHandler, {
            web3,
            from: admin
        });
    });

    beforeEach(async function() {
        await deployTestToken(errorHandler, [":", "fDAI"], {
            web3,
            from: admin
        });
        await deploySuperToken(errorHandler, [":", "fDAI"], {
            web3,
            from: admin
        });
    });

To interact with the protocol, you should consider to use the @superfluid-finance/js-sdk. Here is a quick-start example:

const SuperfluidSDK = require("@superfluid-finance/js-sdk");

let sf;
let daix;

beforeEach(async () => {
    await deployTestToken(errorHandler, [":", "fDAI"], {
        web3,
        from: admin,
    });
    await deploySuperToken(errorHandler, [":", "fDAI"], {
        web3,
        from: admin,
    });

    sf = new SuperfluidSDK.Framework({
        web3,
        version: "test",
        tokens: ["fDAI"],
    });
    await sf.initialize();

    daix = sf.tokens.fDAIx;

    // Create user objects
    admin = sf.user({ address: adminAddress, token: daix.address });
    alice = sf.user({ address: aliceAddress, token: daix.address });
});

Awesome, now that you have the basics, check out the apps over in the examples folder.

Deploying Superfluid Protocol

Local

To deploy to your local ganache environment:

DISABLE_NATIVE_TRUFFLE=true truffle --network ganache exec "node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-test-environment.js"

Public

If you want to deploy to a public network:

NEW_TEST_RESOLVER=1 DISABLE_NATIVE_TRUFFLE=true truffle --network goerli exec "node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-test-environment.js"

Note NEW_TEST_RESOLVER=1, it is to avoid using the official resolver address. Doing so after the command finishes, you should see:

...
======== Super token deployed ========
=============== TEST ENVIRONMENT RESOLVER ======================
export TEST_RESOLVER_ADDRESS=0x43098b8d85Fe90eCE6B055e135759B558d2c0224

Run the export command to save TEST_RESOLVER_ADDRESS to your local environment. Whenever you run additional tests/scripts this will be the address used to find the SF Framework contracts.

Examples

We created a few examples here. So that you don't have to start everything from the scratch. Clone a project, modify and play!

Troubleshooting

One thing to keep in mind is that Superfluid relies on a persistent 1820 registry contract. This must be deployed before you can interact with the protocol. If you follow the examples using the deployment scripts, you don't need to worry about it.

If you want to see examples for manually deploying contracts, check out the scripts folder.

In case your curious, or really hacking away, you might want to deploy the registry manually. Here is an example for how to deploy the 1820 contract to a local Ganache. (read more about EIP 1820 Pseudo-introspection Registry Contract)

# Start Ganache on 127.0.0.1:8545
ganache-cli

# Build the contracts + prepare the SDK
yarn build

# Deploy the 1820 contract
cd packages/ethereum-contracts
npx truffle exec scripts/deploy-erc1820.js --network ganache

# Now you can run tests and interact with the protocol
yarn test

Contributing

Setup Development Environment

  1. Install dependencies
yarn install
  1. Setup your own .env file from .env.template

Testing

There are two major test suite:

  • Contracts (test/contracts.test.js) tests the contracts Each contracts test suite is named as test/{Type}/{ContractName}.test.js.
  • Deployment (test/deployment.test.js) tests the deployment script
yarn test

Since testing can take a long time to execute, you may want to use the execlusive tests feature from MochaJS to isolate only the test you want. For example:

# Only run deployment.test.js
nodemon -x npx truffle test ./test/contracts/superfluid/Superfluid.test.js

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator