Badger-Finance / gitcoin

Repo for gitcoin hack-a-thons,bonunties and code snippets.
7 stars 0 forks source link

Great Ape Safe: Write Unit Tests for a DeFi On-Chain API Wrapper & Tx Builder #38

Closed gosuto-inzasheru closed 2 years ago

gosuto-inzasheru commented 2 years ago

Multisig Txs

Over the last year, Badger DAO and its smart contracts have made thousands of transactions on the EVM and EVM-compatible chains in order to operate and maintain the Badger system. The dev multisig alone has executed 900+ custom transactions in less than a year. Every single one of these multisig transactions has to be written up in code in advance; a lot of times there is no UI available and even if there is it is not used for security reasons.

The speed and frequency with which we need to execute transactions from our multisigs is increasing. On top of that, we found ourselves copypasting a lot of logic from old scripts for platforms we interact with on a regular basis. We are in the process of giving this more structure.

Great Ape Safe

Building on top of the legendary Ape Safe, we have released an alpha of Great Ape Safe. Besides doing everything Ape Safe can, it contains wrappers for on-chain APIs for some commonly used protocols. This simplifies interaction with these protocols immensely, since no more time has to be spent on researching documentation and deployment addresses. A simple call to the wrapper function safe.aave.deposit(usdc, amount) is now all it takes.

Task

As of now, the API library is limited to some of the main functions of Aave, Compound and Convex. We plan to extend this in the future, but for obvious reasons need to know that the underlying logic is bulletproof.

Help us by writing unit tests for each one of these wrapper functions. Using brownie and its built-in pytest framework, it should be fairly straight-forward to make sure each wrapper function actually does what it needs to do---by asserting the necessary mutations took place on-fork. Did the wallet actually receive a token back after a deposit? Was the contract's return value successful? Do the amounts match? Etc.

There are some known bugs in the current logic; the more you are able to break and the tighter your tests are the better!

Getting Started

Everything you need for your first run can be found in the repo's README.md. A toy example of a unit test can be found under tests/test_aave.py and can be run through brownie test.

Brownie's documentation has a whole chapter dedicated to Writing Unit Tests.

Curve.fi has a great video tutorial series on brownie, which includes some very relevant items:

Bounty

There is a budget of up to 100 $BADGER available for this task. It will be distributed based on the amount, the quality and the usability of the submissions.

Bonus

Unit tests are what we are after, but if you are able to also fix some of the wrappers or even add new protocol specific logic, great! Please do so in a separate PR.

Links

Contact

Come join our community of Badger builders on Discord at https://discord.gg/BucHcc57FS. For questions specific to this bounty you can reach out to @gosuto#7559 there.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 100.0 BADGER (2688.0 USD @ $26.88/BADGER) attached to it.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 weeks from now. Please review their action plans below:

1) ereid7 has started work.

Writing complete Unit Tests for GreatApeSafe Repository

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 100.0 BADGER (1434.0 USD @ $14.34/BADGER) has been submitted by:


gitcoinbot commented 2 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 100.0 BADGER (1208.00 USD @ $12.01/BADGER) attached to this issue has been approved & issued to @jalbrekt85.