semvec/pypi-packages huggingface dataset:
great_ape_safe 0.0.1
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.

[![brownie test](https://github.com/gosuto-ai/great-ape-safe/actions/workflows/main.yaml/badge.svg)](https://github.com/gosuto-ai/great-ape-safe/actions/workflows/main.yaml)

# GreatApeSafe

This is an extension of the legendary [Ape Safe](https://github.com/banteg/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](https://etherscan.io/address/0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9#readProxyContract) doesn't require any searching or address copypasting:

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

And making a deposit becomes as simple as:

```python
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:

```python
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](https://user-images.githubusercontent.com/2835259/147793601-c597898e-0e9a-4eac-9413-d3dc6a1534cb.png)
timedpool 0.1.1
Python library adding a dictionary with a maximum size and whose elements are deleted after a delay
Requires Python: >=3.6

# timedpool
Python library adding a dictionary with a maximum size and whose elements are deleted after a delay.

## Installation

Run: `pip install timedpool`

## Usage

TimedPool is a dict with a maximum size whose elements are deleted after a delay.

This object can be used as a dictionary:
```python
p = TimedPool()
p[key] = value
if key in p:
    print(p[key])
print(len(p))
del p[key]
```

The difference with a normal dictionary is that this can contain a maximum
number of objects, after which insertions will raise a `FullException`.
Furthermore, each item can be removed after a certain amount of time (ttl).
Items are not removed immediately, but at fixed intervals.

Using `p[key] = value` will apply the default ttl; instead,
`p.set(ket, value, ttl)` allows to set a specific ttl.

The `stop()` method can be used to stop the cleaning routine.

Both `max_size` and `clean_t` must be greater or equal to 0, negative
values are rounded to 0.

The `initial` parameter can be an iterable of tuples that is used to
populate the pool with some elements.
It is equivalent to adding each key-value tuple to the pool in the order
provided by the iterable. If `initial` is a dictionary, its elements will
be added in the order provided by the dictionary `items()` method.

This object supports all the methods of a python dict with the following exceptions:
* copy
* setdefault
* update
* values
* items

# Implementation

The implementation extends a python dict. A routine is run on another thread to periodically scan the elements and remove those that are expired.

This implies that expired elements will be still available until the cleaning routine is run.

# Contribute

If you find a bug, have a feature request or suggestions, please open an issue on github.