How to deploy your own iearn.finance

Andre Cronje
Feb 3 · 4 min read

The goal with iearn.finance is simple, aggregate yield for the investor by aggregating lending services including Compound, Fulcrum, Aave, and dYdX.

There is a problem with using iearn.finance though, with iearn.finance you are part of a shared pool of liquidity. This means smaller investments can’t take importunity of flash interest moments. Let’s go through an example;

Let’s say the DAI pool is currently at $50k and sitting at Fulcrum @ 8% APR. There is an opportunity at Aave @ 10% APR, but the maximum amount that can be invested @ Aave is $20k. The current iearn.finance pool implementation will not move the funds, since it calculates it is earning more APR at Fulcrum at $50k DAI, than it would if it moved the $50k to Aave, since this would decrease the Aave APR to 7.5%.

But if you were a solo investor, and you had $10k, you could take advantage of this opportunity. So the goal of this article is to walk you through deploying your own private version of iearn.finance so that you can take advantage of customized opportunities.

Now the process does require some technical knowledge, but I will try to explain as much as possible.

Step 1: head over to the github and fork or clone the following two repositories;

The first repo, iearn-finance is the web interface, it is built in React. After you have forked & cloned it to your local system (and having installed npm and nodejs), simply run the following commands;

npm install
npm start

We do need to update some configs, but we will get back to that after deploying our contracts.

The second repo is the itoken (+ytoken) mono repo.

If you as an investor are only interested in DAI, you only need to deploy yDAI (so simply deploy the contracts you are interested in). Now there are a few ways you can deploy it. If you are comfortable with truffle, my recommendation is with truffle build and truffle deploy, but to keep it simple, we will use remix.

So go over to remix and create a new file;

Click the + on remix (highlighted green below), and enter the name yDAI.sol

Copy the contents of yDAI.sol from the github over to remix and simply save the file, this will build the file for you in the web IDE (remix)

After compiling finishes, click on “Deploy and run transaction” (highlighted below in green).

Next, we need to set some deploy settings;

In the deploy pane, set the following;

  • Environment = Injected Web3
  • Contract = yDAI (the dropdown just above the Deploy button)

And simply click “Deploy”. This will ask you to sign the transaction via Metamask (or whichever web3 plugin you use), and give you an etherscan transaction id;

Take note of the contract address above, we will need it just now.

Next, you need to edit the webapp to talk to your newly created contract.

Open the project folder in your preferred IDE (or simply navigate to /iearn-finance/src/stores/store.jsx and edit in your preferred editor).

In stores.jsx you will see the following;

Remove the ones you aren’t interested in (if you only deployed yDAI, only keep DAI), and update the iEarnContract address to your newly created contract address (from when you deployed the contract above).

And then simply run the webapp by running;

npm start

This will open up the webapp in your browser at http://localhost:3000

And that’s it. Now you can interact with it locally and optimize your yield for your own investment size and stay in full control.

If you want to launch a competitor to iearn.finance, you can also follow all the above steps, you would simply need to host the website yourself :)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade