@ormi-fi/protocol v1.0.0
OOOOOOOOO RRRRRRRRRRRRRRRRR MMMMMMMM MMMMMMMMIIIIIIIIII
OO:::::::::OO R::::::::::::::::R M:::::::M M:::::::MI::::::::I
OO:::::::::::::OO R::::::RRRRRR:::::R M::::::::M M::::::::MI::::::::I
O:::::::OOO:::::::ORR:::::R R:::::RM:::::::::M M:::::::::MII::::::II
O::::::O O::::::O R::::R R:::::RM::::::::::M M::::::::::M I::::I
O:::::O O:::::O R::::R R:::::RM:::::::::::M M:::::::::::M I::::I
O:::::O O:::::O R::::RRRRRR:::::R M:::::::M::::M M::::M:::::::M I::::I
O:::::O O:::::O R:::::::::::::RR M::::::M M::::M M::::M M::::::M I::::I
O:::::O O:::::O R::::RRRRRR:::::R M::::::M M::::M::::M M::::::M I::::I
O:::::O O:::::O R::::R R:::::RM::::::M M:::::::M M::::::M I::::I
O:::::O O:::::O R::::R R:::::RM::::::M M:::::M M::::::M I::::I
O::::::O O::::::O R::::R R:::::RM::::::M MMMMM M::::::M I::::I
O:::::::OOO:::::::ORR:::::R R:::::RM::::::M M::::::MII::::::II
OO:::::::::::::OO R::::::R R:::::RM::::::M M::::::MI::::::::I
OO:::::::::OO R::::::R R:::::RM::::::M M::::::MI::::::::I
OOOOOOOOO RRRRRRRR RRRRRRRMMMMMMMM MMMMMMMMIIIIIIIIII
Ormi Lending Protocol
Ormi is made possible because it is built on top of DeFi giant Aave. Ormi's lending protocol began as a fork of Aave's protocol-v2. Special thanks to the Aave team to its commitment to technical excellence, open source, and decentralization to make Ormi a reality.
What is Ormi?
Ormi is a decentralized permissionless, decentralized credit protocol for issuing undercollateralized loans to anyone without relying on real world identities.
Note: Since this repository is a fork of Aave, many of the commands and directory names contain 'aave'. Further work needed to rename 'aave' to 'ormi'
Setup
The repository uses Docker Compose to manage sensitive keys and load the configuration. Prior any action like test or deploy, you must run docker-compose up
to start the contracts-env
container, and then connect to the container console via docker-compose exec contracts-env bash
.
Note: you might need to use 'sudo' in case of permission errors (under Linux/MacOs) when running the docker commands
Follow the next steps to setup the repository:
- Install
docker
anddocker-compose
- Create an enviroment file named
.env
and fill the next enviroment variables
# Mnemonic, only first address will be used
MNEMONIC=""
# Add Alchemy or Infura provider keys, alchemy takes preference at the config level
ALCHEMY_KEY=""
INFURA_KEY=""
# Optional Etherscan key, for automatize the verification of the contracts at Etherscan
ETHERSCAN_KEY=""
# Optional, if you plan to use Tenderly scripts
TENDERLY_PROJECT=""
TENDERLY_USERNAME=""
Test
You can run the full test suite with the following commands:
# In one terminal
docker-compose up
# Open another tab or terminal
docker-compose exec contracts-env bash
# A new Bash terminal is prompted, connected to the container. To run all tests.
# Note: it takes a long time.
npm run test
# To run a single test with no compilation. Note: setup takes a long time.
TS_NODE_TRANSPILE_ONLY=1 npx hardhat test --no-compile ./test-suites/test-aave/liquidation-atoken.spec.ts ./test-suites/test-aave/__setup.spec.ts
Deployments
For deploying Ormi lending pool, you can use the available scripts located at package.json
. For a complete list, run npm run
to see all the tasks.
Note that the deployment scripts save the addresses of the deployed contracts into a local json db deployed-contracts.json
. At the end of a deployment script a list of deployed contracts with their addresses is displayed (see misc_utils.ts
and function printContracts
). This list contains all contracts ever deployed in a specific network (not neccessarily resulting from the last run).
Kovan deployment
# In one terminal
docker-compose up
# Open another tab or terminal
docker-compose exec contracts-env bash
# A new Bash terminal is prompted, connected to the container.
# You can run these commands for deployment with different arguments.
# Deployment (dev) deployment with no contract verification:
npm run aave:kovan:dev:migration
# Deployment with registry deployment and contract verification:
npm run aave:kovan:full:migration:add-registry:verify
# Deployment with registry deployment and no contract verification:
npm run aave:kovan:full:migration:add-registry
# Deployment with no registry deployment and no contract verification:
npm run aave:kovan:full:migration
Note that for the above full deployment, both the first and second accounts will need to be funded. For detail, see:
markets/aave/commons.ts
, where EmergencyAdminIndex, PoolAdminIndex
represent the account indices for contract
calls needed for deployment scripts.
Mainnet fork deployment
You can deploy Ormi in a forked Mainnet chain using Hardhat built-in fork feature:
docker-compose run contracts-env npm run aave:fork:main
Deploy Ormi into a Mainnet Fork via console
You can deploy Ormi into the Hardhat console in fork mode, to interact with the protocol inside the fork or for testing purposes.
Run the console in Mainnet fork mode:
docker-compose run contracts-env npm run console:fork
At the Hardhat console, interact with the Ormi protocol in Mainnet fork mode:
// Deploy the Ormi protocol in fork mode
await run('aave:mainnet')
// Or your custom Hardhat task
await run('your-custom-task');
// After you initialize the HRE via 'set-DRE' task, you can import any TS/JS file
run('set-DRE');
// Import contract getters to retrieve an Ethers.js Contract instance
const contractGetters = require('./helpers/contracts-getters'); // Import a TS/JS file
// Lending pool instance
const lendingPool = await contractGetters.getLendingPool("LendingPool address from 'aave:mainnet' task");
// You can impersonate any Ethereum address
await network.provider.request({ method: "hardhat_impersonateAccount", params: ["0xb1adceddb2941033a090dd166a462fe1c2029484"]});
const signer = await ethers.provider.getSigner("0xb1adceddb2941033a090dd166a462fe1c2029484")
// ERC20 token DAI Mainnet instance
const DAI = await contractGetters.getIErc20Detailed("0x6B175474E89094C44Da98b954EedeAC495271d0F");
// Approve 100 DAI to LendingPool address
await DAI.connect(signer).approve(lendingPool.address, ethers.utils.parseUnits('100'));
// Deposit 100 DAI
await lendingPool.connect(signer).deposit(DAI.address, ethers.utils.parseUnits('100'), await signer.getAddress(), '0');
Interact with Ormi in Mainnet via console
Run the Hardhat console pointing to the Mainnet network:
docker-compose run contracts-env npx hardhat --network main console
At the Hardhat console, you can interact with the protocol:
// Load the HRE into helpers to access signers
run("set-DRE")
// Import getters to instance any Aave contract
const contractGetters = require('./helpers/contracts-getters');
// Load the first signer
const signer = await contractGetters.getFirstSigner();
// Lending pool instance
const lendingPool = await contractGetters.getLendingPool("0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9");
// ERC20 token DAI Mainnet instance
const DAI = await contractGetters.getIErc20Detailed("0x6B175474E89094C44Da98b954EedeAC495271d0F");
// Approve 100 DAI to LendingPool address
await DAI.connect(signer).approve(lendingPool.address, ethers.utils.parseUnits('100'));
// Deposit 100 DAI
await lendingPool.connect(signer).deposit(DAI.address, ethers.utils.parseUnits('100'), await signer.getAddress(), '0');
Creating an npm package
In order to create an npm package similar to you need to run npm publish
in the docker-compose session
3 years ago