Skip to main content

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 git@github.com: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

Metadata

Release files for great_ape_safe 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for great_ape_safe 0.0.1
File Size Uploaded
great_ape_safe-0.0.1.tar.gz 26.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for great_ape_safe 0.0.1
File Interpreter ABI Platform
great_ape_safe-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 49.4 kB

Release files / great_ape_safe-0.0.1.tar.gz

Download URL great_ape_safe-0.0.1.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e0494fea8e3b30d9776200f7e7da928e3998deaf25d508bdeb0cdf86e741cef8
BLAKE2b-256 checksum
How to use checksums
3b77751808051a34c4498e75bc405cf33146597b11d7c17f7153894938c9734c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / great_ape_safe-0.0.1-py2.py3-none-any.whl

Download URL great_ape_safe-0.0.1-py2.py3-none-any.whl
Size 22.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
31f13e0915f036d4196d09f696dfd3ffb92e81d41fde222bd3c494f8998685d0
BLAKE2b-256 checksum
How to use checksums
f009c0ee4eb084584c2a195e6c6136eb7b42fed7ab645219d72684563a244d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page