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

@lenddao/lend-token

v0.1.1

Published

LendDAO ERC20 token

Downloads

39

Readme

LendDAO Token design

LEND is an ERC-20 compatible token. It implements governance-inspired features, and will allow LendDAO to bootstrap the rewards program for safety and ecosystem growth. The following document explains the main features of LEND, it’s monetary policy, and the redemption process from LEND.

Roles

The initial LEND token implementation does not have any admin roles configured. The contract will be proxied using the Openzeppelin implementation of the EIP-1967 Transparent Proxy pattern. The proxy has an Admin role, and the Admin of the proxy contract will be set upon deployment to the LendDAO governance contracts.

ERC-20

The LEND token implements the standard methods of the ERC-20 interface. A balance snapshot feature has been added to keep track of the balances of the users at specific block heights. This will help with the LendDAO governance integration of LEND. LEND also integrates the EIP 2612 permit function, that will allow gasless transaction and one tx approval/transfer.

Technical implementation

Changes to the Openzeppelin original contracts

In the context of this implementation, we needed apply the following changes to the OpenZepplin implementation:

  • In /contracts/open-zeppelin/ERC20.sol, line 44 and 45, _name and _symbol have been changed from private to internal
  • We extended the original Initializable class from the Openzeppelin contracts and created a VersionedInitializable contract. The main differences compared to the Initializable are:
  1. The boolean initialized has been replaced with a uint256 latestInitializedRevision.
  2. The initializer() modifier fetch the revision of the implementation using a getRevision() function defined in the implementation contract. The initializer modifier forces that an implementation
  3. with a bigger revision number than the current one is being initialized

The change allows us to call initialize() on multiple implementations, that was not possible with the original Initializable implementation from OZ.

_beforeTokenTransfer hook

We override the _beforeTokenTransfer function on the OZ base ERC20 implementation in order to include the following features:

  1. Snapshotting of balances every time an action involved a transfer happens (mint, burn, transfer or transferFrom). If the account does a transfer to itself, no new snapshot is done.
  2. Call to the LendDAO governance contract forwarding the same input parameters of the _beforeTokenTransfer hook. Its an assumption that the LendDAO governance contract is a trustable party, being its responsibility to control all potential reentrancies if calling back the LendToken. If the account does a transfer to itself, no interaction with the LendDAO governance contract should happen.

Development deployment

For development purposes, you can deploy LendToken to a local network via the following command:

npm run dev:deployment

For any other network, you can run the deployment in the following way

npm run ropsten:deployment

You can also set an optional $LEND_ADMIN enviroment variable to set an ETH address as the admin of the LendToken proxies. If not set, the deployment will set the second account of the accounts network configuration at buidler.config.ts.

Mainnet deployment

You can deploy LendToken to the mainnet network via the following command:

LEND_ADMIN=governance_or_ETH_address
LEND_TOKEN=lend_token_address
npm run main:deployment

The $LEND_ADMIN enviroment variable is required to run, set an ETH address as the admin of the LendToken proxies. Check buidler.config.ts for more required enviroment variables for Mainnet deployment.

The proxies will be initialized during the deployment with the $LEND_ADMIN address, but the smart contracts implementations will not be initialized.

Enviroment Variables

| Variable | Description | | ----------------------- | ----------------------------------------------------------------------------------- | | $LEND_ADMIN | ETH Address of the admin of Proxy contracts. Optional for development. | | $LEND_TOKEN | ETH Address of the LEND token. Optional for development. | | $INFURA_KEY | Infura key, only required when using a network different than local network. | | $MNEMONIC_<NETWORK> | Mnemonic phrase, only required when using a network different than local network. | | $ETHERESCAN_KEY | Etherscan key, not currently used, but will be required for contracts verification. |

Audits

Credits

For the proxy-related contracts, we have used the implementation of our friend from OpenZeppelin.

License

The contents of this repository are under the AGPLv3 license.