Code Monkey home page Code Monkey logo

sajanrajdev / great-ape-safe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from onchainification/great-ape-safe

0.0 0.0 0.0 13.32 MB

An extension of the legendary Ape Safe web3 package. Adding extra functions and making it protocol aware, saving time getting familiar with the source code of every individual smart contract.

Home Page: https://pypi.org/project/great_ape_safe/

License: GNU Affero General Public License v3.0

Shell 0.08% Python 80.49% Solidity 19.42%

great-ape-safe's Introduction

brownie test

GreatApeSafe

This is an extension of the legendary Ape Safe, inheriting all the good stuff from ApeSafe, while adding some extra functions and making it protocol aware.

Instead of (re)writing protocol specific logic for every script, GreatApeSafe contains wrappers for each protocol's specific on-chain API. On top of that, all necessary addresses are hard-coded and loaded.

This prevents having to dive into documentation every time, either for figuring out the exact way to call the on-chain functions or finding deployed addresses.

For example, calling the AAVE lending pool's contract doesn't require any searching or address copypasting:

>>> safe.aave.pool.paused()
False

And making a deposit becomes as simple as:

safe.aave.deposit(usdc, usdc.balanceOf(safe))

Under the hood, the protocol class Aave solves what exact aToken we are dealing with, makes the necessary approval, calls the right functions and makes an on-fork assertion of successful execution:

class Aave():
    ...
    def deposit(self, underlying, mantissa, destination=None):
        # deposit `mantissa` amount of `underlying` into aave pool
        # https://docs.aave.com/developers/the-core-protocol/lendingpool#deposit
        destination = self.safe.address if not destination else destination
        atoken_addr = self.data.getReserveTokensAddresses(underlying)[0]
        atoken = self.safe.contract(atoken_addr)
        bal_before = atoken.balanceOf(destination)
        underlying.approve(self.pool, mantissa)
        self.pool.deposit(underlying, mantissa, destination, 0)
        assert atoken.balanceOf(destination) > bal_before

By no means complete, but included platforms currently are:

  • Aave
  • Compound
  • Convex
  • Curve

Installation

git clone [email protected]:gosuto-ai/great-ape-safe.git
pip install -r requirements-core.txt

And copy .env.example to .env and add your API keys to it if needed.

Running

brownie run example

Testing

brownie test

pngwing com

great-ape-safe's People

Contributors

gosuto-inzasheru avatar jalbrekt85 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.