project screenshot 1
project screenshot 2
project screenshot 3

Myield

Myield manages your Matic to earn the highest amount of Polygon rewards

Myield

Created At

Scaling Ethereum

Project Description

With Myield you can deposit MATIC on the Polygon Chain and earn more of it, currently around 25% APR.

Myield uses AAVE to leverage it's MATIC position, earning multiples of the rewards you'd earn if you were to simply deposit.

If you go on AAVE you can deposit X and earn Y on it. With Myield, you can deposit X, have it leverage to about 2X and earn around 3 times the deposit APR.

There's very little risk as this is an actively managed position, managed by a trusted strategist whose role is limited to exclusively rebalancing the position.

Myield uses one Smart Contract called MyieldWMatic, deployed on the Matic Commit Chain, you can visit https://myield.finance/ to deposit your WMATIC.

In case you have MATIC that is not wrapped, you can use the Wrap / Unwrap utility for your convenience.

Myield takes a 5% performance fee on Harvest (which can be changed by the governance). The fee is applied exclusively to the Rewards, your principal is never touched.

The project is currently managing around 20k MATIC which have earned around 27% APR, has had around 30k MATIC deposited and over 30 people have joined the discord.

Analytics are viewable on the HomePage There's also a leaderboard showing current deposits and shares as well as lifetime earnings: https://myield.finance/leaderboard

How it's Made

The core of the product is built with a monorepo: https://github.com/GalloDaSballo/polygon-yield

** Monorepo Code **

https://github.com/GalloDaSballo/polygon-yield/

The monorepo has 3 packages:

  • Hardhat -> Smart Contract and Unit Tests

  • Next -> NextJS Frontend

  • Subgraph -> The Graph subgraph

There's 2 main smart contracts in hardhat:

Myield.sol

The original Myield contract which I launched on the 2nd of May, which started earning 42% APR

https://twitter.com/GalloDaSballo/status/1388949840651071490

Some users started interacting with the contract, which meant I had to maintain it, the old contract is interactable at:

https://v1.myield.finance/

** MyieldWMatic.sol **

This is the live contract you can interact with at http://myield.finance/

The contract is an extension of the previous one, adding:

  • Reentrancy protection (just in case)

  • A strategist role (to avoid attackers from rebalancing when it wouldn't be appropriate)

  • Adding events for Deposit, Withdrawals and Harvest, used in the Subgraph for showing analytics

  • Adding a 5% (editable) Performance fee on Harvest, the fee is taken on Harvest call, meaning it is calculated exclusively on the Polygon Rewards, keeping users principal safe

The Smart Contract contains methods for depositing and withdrawal, as well as rebalancing and harvesting as well as events used to visualize the data through the Subgraph.

The source code for the contract is here

https://github.com/GalloDaSballo/polygon-yield/blob/main/packages/hardhat/contracts/MyieldWMatic.sol

Depositing, Withdrawals, the side effects of Rebalancing and Harvesting are unit tested here:

https://github.com/GalloDaSballo/polygon-yield/blob/main/packages/hardhat/test/MyieldWMatic.ts

The contract is unit tested to ensure:

  • You can only withdraw what you earned through your ownership

  • As long as rewards are higher than the interest on the debt, any deposit followed by an immediate withdrawal earns MATIC instead of loosing it.

The MATIC deposited is deposited on AAVE and then, through the rebalance function, leveraged.

** Strategist Bot **

rebalance is a protected method that only the deployer or a strategist can call.

Currently it's called by a bot I wrote and deployed on heroku.

The bot will check the balance of the contract, the rewards earned and the health factor on AAVE.

If the health factor is high enough, it means we can borrow more, so we'll rebalance in that way, earning higher APY.

If the rewards are high enough, we can harvest them, earning interest for the vault.

The source code for the bot is here:

https://github.com/GalloDaSballo/myield-bot

** Biggest Challenges **

At the time of writing the harvesting code, AAVE documentation was not available, I had to figure out how the AAVE team wrote their rewards code, I was able to learn that by going through their aave/aave-stake-v2 Github Repo, specifically in their feat/incentive/mumbai-config

https://github.com/aave/aave-stake-v2/tree/feat/incentives%2Fmumbai-config

This proved priceless as the documentation on the AAVE site was wrong (reporting the wrong signature for the claimRewards function, which are different on Mainnet vs Matic)

I flagged up this in the discord and I believe the documentation was changed based on my findings:

https://discord.com/channels/554623348622098432/797031836718989312/837028680735785014

** Biggest Achievement **

People actually used this product! A few people (5 to 10) actually trusted my work enough to deposit and have been earning around 27% APR in the smart contract!

** Future Improvements **

My goal is to rewrite the Vaults code to only handle deposit, withdrawals and harvesting, and then separate the "strategies" code into separate smart contracts, similarly to how yearn is written.

My next immediate goal is to perform this refactoring and then write a Vault that receives USDC and invests it to earn Bitcoin on the Polygon chain.

I want to continue working on this, ideally collaborating with other devs and designers to build a DAO on Polygon (join the discord if interested! https://discord.com/invite/fMmhcJfukN)

All winnings will be used to audit the code and continue building myield

background image mobile

Join the mailing list

Get the latest news and updates