Skip to content

Commit

Permalink
Merge pull request #12 from iamdefinitelyahuman/v0.2.2
Browse files Browse the repository at this point in the history
v0.2.2
  • Loading branch information
iamdefinitelyahuman authored Jun 1, 2021
2 parents dad9df8 + 0b1ae0f commit 5d58971
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 50 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/iamdefinitelyahuman/brownie-token-tester)

## [0.2.2](https://github.com/iamdefinitelyahuman/brownie-token-tester/tree/v0.2.2) - 2021-06-01

### Changed
- Generalize minting logic for Synthetix synths

## [0.2.1](https://github.com/iamdefinitelyahuman/brownie-token-tester/tree/v0.2.1) - 2021-05-26

### Changed
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,14 @@ Tokens for which custom logic is currently implemented:
- [x] EURS
- [x] LinkUSD
- [x] pBTC
- [x] Synthetix synths
- [x] renBTC
- [x] renZEC
- [x] rETH
- [x] RSV
- [x] USDC
- [x] USDN
- [x] USDT
- [x] sBTC
- [x] sETH
- [x] sEURS
- [x] sUSD
- [x] tBTC
- [x] wBTC
- [x] wZEC
Expand Down
84 changes: 41 additions & 43 deletions brownie_tokens/forked.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def _mint_for_testing(self, target: str, amount: Wei, tx: Dict = None) -> None:
getattr(sys.modules[__name__], fn_name)(self, target, amount)
return

# check for token name if no custom minting
# logic exists for address
for name in _token_names:
if hasattr(self, "name") and self.name().startswith(name):
fn_name = f"mint_{name}"
if hasattr(sys.modules[__name__], fn_name):
getattr(sys.modules[__name__], fn_name)(self, target, amount)
# check for token name if no custom minting logic exists for address
if hasattr(self, "name") and not self.name.abi["inputs"]:
name = self.name()
fn_name = next((f"mint_{i}" for i in _token_names if name.startswith(i)), "")
if fn_name and hasattr(sys.modules[__name__], fn_name):
mint_result = getattr(sys.modules[__name__], fn_name)(self, target, amount)
if mint_result:
return

# if no custom logic, fetch a list of the top
Expand Down Expand Up @@ -142,38 +142,6 @@ def mint_0x196f4727526eA7FB1e17b2071B3d8eAA38486988(
token.mint(target, amount, {"from": token.minter()})


def mint_0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6(
token: MintableForkToken, target: str, amount: int
) -> None:
# Synth sBTC
target_contract = Contract("0xDB91E4B3b6E19bF22E810C43273eae48C9037e74")
target_contract.issue(target, amount, {"from": _snx_exchanger()})


def mint_0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb(
token: MintableForkToken, target: str, amount: int
) -> None:
# Synth sETH
target_contract = Contract("0x87641989057242Bff28D0D6108d007C79774D06f")
target_contract.issue(target, amount, {"from": _snx_exchanger()})


def mint_0xD71eCFF9342A5Ced620049e616c5035F1dB98620(
token: MintableForkToken, target: str, amount: int
) -> None:
# Synth sEURS
target_contract = Contract("0xC61b352fCc311Ae6B0301459A970150005e74b3E")
target_contract.issue(target, amount, {"from": _snx_exchanger()})


def mint_0x57Ab1ec28D129707052df4dF418D58a2D46d5f51(
token: MintableForkToken, target: str, amount: int
) -> None:
# Synth sUSD
target_contract = Contract("0x6C85C5198C3CC4dB1b87Cb43b2674241a30f4845")
target_contract.issue(target, amount, {"from": _snx_exchanger()})


def mint_0x8dAEBADE922dF735c38C80C7eBD708Af50815fAa(
token: MintableForkToken, target: str, amount: int
) -> None:
Expand Down Expand Up @@ -229,14 +197,44 @@ def mint_0x9559Aaa82d9649C7A7b220E7c461d2E74c9a3593(
token.mint(target, amount, {"from": minter})


# to add custom minting logic for a token that starts with [NAME], add [NAME] to
# `_token_names` and add a function `mint_[NAME]`
# To add custom minting logic for a token that starts with [NAME], add [NAME] to `_token_names`
# and add a function `mint_[NAME]`. The function should include sanity-checks to prevent false
# positives, and return a bool indicating if the mint operation was successful.


def mint_Aave(token: MintableForkToken, target: str, amount: int) -> bool:
# Aave aTokens
if not hasattr(token, "UNDERLYING_ASSET_ADDRESS"):
return False

def mint_Aave(token: MintableForkToken, target: str, amount: int) -> None:
# aave token
token = MintableForkToken(token.UNDERLYING_ASSET_ADDRESS())
lending_pool = Contract("0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9")
token._mint_for_testing(target, amount)
token.approve(lending_pool, amount, {"from": target})
lending_pool.deposit(token, amount, target, 0, {"from": target})
return True


def mint_Synth(token: MintableForkToken, target: str, amount: int) -> bool:
# Synthetix synths
if not hasattr(token, "target"):
return False

abi = [
{
"inputs": [{"name": "name", "type": "bytes32"}],
"name": "getAddress",
"outputs": [{"internalType": "uint256", "name": "", "type": "address"}],
"stateMutability": "view",
"type": "function",
}
]
resolver = Contract.from_abi(
"AddressResolver", "0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2", abi
)
exchanger_key = "0x45786368616e6765720000000000000000000000000000000000000000000000"
exchanger = resolver.getAddress(exchanger_key)

target_contract = token.target()
target_contract.issue(target, amount, {"from": exchanger})
return True
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1
current_version = 0.2.2

[bumpversion:file:setup.py]

Expand Down Expand Up @@ -28,4 +28,3 @@ addopts =
--cov brownie_tokens/
--cov-report term
--cov-report xml

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name="brownie-token-tester",
packages=find_packages(exclude=["tests", "tests.*"]),
py_modules=["brownie_tokens"],
version="0.2.1", # don't change this manually, use bumpversion instead
version="0.2.2", # don't change this manually, use bumpversion instead
license="MIT",
description="Helper objects for generating ERC20s while testing a Brownie project.",
long_description=long_description,
Expand Down

0 comments on commit 5d58971

Please sign in to comment.