0.1.1 • Published 1 year ago

@lenddao/lend-token v0.1.1

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
1 year ago

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

VariableDescription
\$LEND_ADMINETH Address of the admin of Proxy contracts. Optional for development.
\$LEND_TOKENETH Address of the LEND token. Optional for development.
\$INFURA_KEYInfura 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_KEYEtherscan 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.

0.1.1

1 year ago

0.1.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago