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

@jbx-protocol/juice-nft-rewards

v7.0.2

Published

## Motivation

Downloads

14

Readme

Juicebox Contribution NFT Reward Mechanism

Motivation

If added to an existing project via a funding cycle, NFT rewards can provide additional incentive for contributors to participate in funding of a project.

Mechanic

Within one collection, NFTs can be minted within any number of pre-programmed tiers.

Each tier has the following optional properties:

  • a contribution floor amount.
  • a max quantity.
  • a number of voting units to associate with each unit within the tier.
  • a reserved rate, allowing a proprtion of units within the tier to be minted to a pre-programmed beneficiary.
  • URI, overridable by a URI resolver that can return dynamic values for each unit with the tier.
  • a lock date, before which the tier must remain accessible.

New tiers can be added, so long as they respect the contract's flags that specify if new tiers can influence voting units, reserved quantities, or be manually minted.

Tiers can also be removed, so long as they are not locked.

An incoming payment can specify any number of tiers to mint as part of the payment, so long as the tier's prices are contained within the paid amount. If specific tiers aren't specified, the best available tier will be minted, unless a flag is specifically sent along with the payment telling the contract to not mint.

If a tier's contribution floor is specified in a currency different to the incoming payment, a JBPrices contract will by used for trying to normalize the values.

If a payment received does not meet a minting threshold or is in excess of the minted tiers, the balance is stored as a credit which will be added to future payments and applied to mints at that time. A flag can also be passed to avoid accepting payments that aren't applied to mints in full.

The contract's owner can mint on demand from tier's that have been pre-programmed to allow manual token minting.

The NFTs from each tier can also be used for redemptions against the underlying Juicebox treasury. The rate of redemptions corresponds to the price floor of the tier being redeemed, compared to the total price floors of all minted NFTs.

The NFTs can serve as utilities for on-chain governance if specified during the collection's deployment. Voting delegation can be made on a per-tier basis, or on a global basis.

Architecture

An understanding of how the Juicebox protocol's pay and redeem functionality works is an important prereq to understanding how this repo's contracts work and attach themselves to Juicebox's regular operating behavior. This contract specifically makes use of the DataSource+Delegate pattern. See https://info.juicebox.money/dev/.

In order to use NFT rewards, a Juicebox project should launched from JBTiered721DelegateProjectDeployer instead of a JBController. This Deployer will deploy a JBTiered721Delegate (through it's reference to a JBTiered721DelegateDeployer) and attach it to the first funding cycle of the newly launched project as a DataSource and Delegate. Funding cycle reconfigurations can also be done using the JBTiered721DelegateProjectDeployer, though it will need to have Operator permissions from the project's owner.

The abstract JB721Delegate implementation of the ERC721 Juicebox DataSource+Delegate extension can be used for any distribution mechanic. This repo includes one implementation – the JBTiered721Delegate – as well as two extensions that offer on-chain governance capabilities to the distributed tokens.

All JBTiered721Delegate's use a generic JBTiered721DelegateStore to store it's data.

Deploy

The deployer copies the data of a pre-existing cononical version of the 721 contracts, which can be either GlobalGovernance, TierGovernance, or no governance. This was done to keep the deployer contract size small enough to be deployable, without the extra cost of the delegatecalls associated with a proxy pattern.

Install

Quick all-in-one command:

rm -Rf juice-nft-rewards || true && git clone -n https://github.com/jbx-protocol/juice-nft-rewards && cd juice-nft-rewards && git pull origin f9893b1497098241dd3a664956d8016ff0d0efd0 && git checkout FETCH_HEAD && foundryup && git submodule update --init --recursive --force && yarn install && forge test --gas-report

To get set up:

  1. Install Foundry.
curl -L https://foundry.paradigm.xyz | sh
  1. Install external lib(s)
git submodule update --init --recursive --force && yarn install

then run

forge update
  1. Run tests:
forge test
  1. Update Foundry periodically:
foundryup

Setup

Configure the .env variables, and add a mnemonic.txt file with the mnemonic of the deployer wallet. The sender address in the .env must correspond to the mnemonic account.

Goerli

yarn deploy-goerli

Mainnet

yarn deploy-mainnet

The deployments are stored in ./broadcast

See the Foundry Book for available options.