Entropyfi Saves Engineering Hours with Chainlink Keepers

Entropyfi
Entropyfi
5 min readDec 22, 2021

--

What is Entropyfi?

Entropyfi is a gamified staking platform that offers competitive, reward-boosted games to users. In Entropyfi 1.0, players stake stablecoins, and the rewards are funded with the yield. In Entropyfi 2.0 (launching Q1, 2022), players stake $ERP, and the rewards are funded with a protocol-controlled vault. Entropyfi 2.0 will also release a PRO version for partners and offer a more sustainable, healthy locking mechanism for our partner projects.

Entropyfi 1.0 zero-loss prediction game

Why Entropyfi uses Chainlink Keepers

Entropyfi is currently offering many gamified yield opportunities to users. These games require periodical triggering of the “start” and “settlement” functions. A common practice is for developers to setup scripts in the cloud and call the functions. Yet this poses a centralization risk, as an interruption at the cloud service provider could also interrupt the dapp operation.

Entropyfi developers want to streamline and decentralize these operations tasks. One of the co-founders of Entropyfi is a longtime admirer of Chainlink services, hence he recommended Chainlink Keepers to the development team. As the team had previously integrated Chainlink Price Feeds into Entropyfi, the integration of Chainlink Keepers into Entropyfi was a breeze.

Integrating with Chainlink Keepers has significantly reduced the repetitive operational work that the Entropyfi team has to do. Currently, Entropyfi has 9 live prediction games, with each settling 5 days apart.

By integrating Chainlink Keepers, the team was able to save 20 engineering hours per week.

Why we think Chainlink Keepers is the best solution

Chainlink Keepers provide us with an easy-to-use solution for enabling automated smart contract execution. Adapting our smart contract and making it Keepers-compatible was easy. Our developers only had to write two wrapper functions, one for checking the execution condition, the other for executing the function.

We choose Chainlink Keepers because Chainlink has a comprehensive suite of development tools. We were already using Chainlink Price Feeds in our product before we integrated Chainlink Keepers. In addition, the Entropyfi team is glad to see the diverse composition of Chainlink nodes, as we believe good decentralization is crucial for reliability and anti-censorship.

How did Entropyfi integrate Chainlink Keepers?

First, the Entropyfi development team added two additional functions in our game logic smart contract (https://github.com/entropyfi/entropy-1.0-core/blob/main/core/LosslessV2Pool.sol). Specifically, we added checkUpkeep and performUpkeep in line 206 to line 238. The input and return variables of these two functions are standardized (https://docs.chain.link/docs/chainlink-keepers/compatible-contracts/).

Within the checkUpkeep function, we implemented the logic that checks whether the prediction game is due for settlement. If the game is due for settlement, the variable upkeepNeeded is set to True.

Chainlink nodes will constantly call the checkUpkeep function, if the upkeepNeeded is evaluated to True, then the nodes will execute performUpkeep function.

Within the performUpkeep function, we implemented the logic that settles the current round of the prediction game. Please note that we perform an additional check on whether the condition of settling game is true in our startGame() and endGame() functions. This is because the performUpkeep function is callable by anyone. Hence our startGame() and endGame() functions will perform the additional check on whether the settlement condition is met or not.

After making our smart contract Chainlink Keepers-compatible, we followed the tutorials here (https://docs.chain.link/docs/chainlink-keepers/register-upkeep/) to register our Keeper tasks. Please make sure you have set the correct gas limit for the task that you wish to perform. Otherwise, Chainlink Keepers will not be able to perform the keeper tasks due to out-of-gas errors.​​

Entropyfi is currently the biggest user of Chainlink Keepers on Polygon, Yay!

Support from the Chainlink Labs team

It’s been a breeze working with the Chainlink Labs team, who supported us with this integration. During the initial integration of Keepers, we ran into some issues with setting the proper gas limit for our keeper tasks. The Chainlink Labs team was able to swiftly answer our developers’ questions. We appreciate the high level of support that the Chainlink Labs team has offered.

Currently, Entropyfi is the biggest user of Chainlink Keepers on the Polygon network. As we expand to other networks, we hope that Chainlink Keepers will also support these new and upcoming networks, as many other developers could also benefit from a trustable, reliable, and decentralized smart contract operation toolkit.

About Entropyfi

Entropyfi is building a hyper-competitive platform offering gamified yields. Entropyfi’s vision is to transform the staking into a thrilling experience and to entice long-term hodlers with our unique hodl-to-earn (H2E) mechanism. With Entropyfi 2.0 launching right around the corner, we invite you to follow us for the latest information.

To learn more about Entropyfi, visit our website and our Medium. Visit Entropyfi’s Gitbook for developer guide and user guide in our Gitbook Docs. For regular updates follow our Twitter and join our Telegram and Discord community.

| Website | Medium | Gitbook | Twitter | Discord |

--

--