Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Mar 6, 2024
2 parents 6278e95 + 4a89ba2 commit 2f8da54
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 10 deletions.
30 changes: 30 additions & 0 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ape import project, accounts, chain
import click

deployer = accounts.load("v3_deployer")


def deploy():
print(f"You are using: 'deployer' [{deployer.address}]")
print("Deploying a new strategy on ChainID", chain.chain_id)

if input("Do you want to continue? [y/N]: ").lower() != "y":
return

publish_source = click.confirm("Verify source on etherscan?")

# Address of the underlying asset to use
asset = ""
# Name for your strategy
name = ""

if input(f"Deploy strategy for {asset}, called {name}? [y/N]: ").lower() != "y":
return

strategy = deployer.deploy(project.Strategy, asset, name, publish=publish_source)

print(f"Deployed new strategy to: {strategy.address}")


def main():
deploy()
64 changes: 64 additions & 0 deletions tests/test_function_signatures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import ape
from ape import Contract

# This test should not be overridden and checks that
# no function signature collisions occurred from the custom functions.
# Does not check functions that are strategy dependant and will be checked in other tests
def test_function_collisions(strategy, asset, management, rewards, user, keeper):
wad = int(1e18)

with ape.reverts("initialized"):
strategy.init(asset, "name", management, rewards, keeper, sender=management)

# Check view functions
assert strategy.convertToAssets(wad) == wad
assert strategy.convertToShares(wad) == wad
assert strategy.previewDeposit(wad) == wad
assert strategy.previewMint(wad) == wad
assert strategy.previewWithdraw(wad) == wad
assert strategy.previewRedeem(wad) == wad
assert strategy.totalAssets() == 0
assert strategy.totalSupply() == 0
assert strategy.unlockedShares() == 0
assert strategy.asset() == asset
assert strategy.apiVersion() == "3.0.1"
assert strategy.totalIdle() == 0
assert strategy.totalDebt() == 0
assert strategy.MAX_FEE() == 5_000
assert strategy.MIN_FEE() == 500
assert strategy.fullProfitUnlockDate() == 0
assert strategy.profitUnlockingRate() == 0
assert strategy.lastReport() > 0
assert strategy.pricePerShare() == 10 ** asset.decimals()
assert not strategy.isShutdown()
assert strategy.symbol() == f"ys{asset.symbol()}"
assert strategy.decimals() == asset.decimals()

# Assure modifiers are working
with ape.reverts("!management"):
strategy.setPendingManagement(user, sender=user)
with ape.reverts("!pending"):
strategy.acceptManagement(sender=user)
with ape.reverts("!management"):
strategy.setKeeper(user, sender=user)
with ape.reverts("!management"):
strategy.setEmergencyAdmin(user, sender=user)
with ape.reverts("!management"):
strategy.setPerformanceFee(int(2_000), sender=user)
with ape.reverts("!management"):
strategy.setPerformanceFeeRecipient(user, sender=user)
with ape.reverts("!management"):
strategy.setProfitMaxUnlockTime(1, sender=user)

# Assure checks are being used
with ape.reverts("MIN FEE"):
strategy.setPerformanceFee(int(0), sender=management)
with ape.reverts("Cannot be self"):
strategy.setPerformanceFeeRecipient(strategy.address, sender=management)
with ape.reverts("too long"):
strategy.setProfitMaxUnlockTime(int(2**256 - 1), sender=management)

assert strategy.balanceOf(user) == 0
assert strategy.allowance(keeper, user) == 0
assert strategy.approve(user, wad, sender=keeper)
assert strategy.allowance(keeper, user) == wad
23 changes: 15 additions & 8 deletions tests/test_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test__operation(
# Deposit to the strategy
deposit()

# TODO: Implement logic so totalDebt ends > 0
# TODO: Implement logic so total_debt ends > 0
check_strategy_totals(
strategy, total_assets=amount, total_debt=0, total_idle=amount
)
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_profitable_report(
# Deposit to the strategy
deposit()

# TODO: Implement logic so totalDebt ends > 0
# TODO: Implement logic so total_debt ends > 0
check_strategy_totals(
strategy, total_assets=amount, total_debt=0, total_idle=amount
)
Expand All @@ -73,14 +73,15 @@ def test_profitable_report(

assert profit >= to_airdrop

# TODO: Implement logic so totalDebt == amount + profit
# TODO: Implement logic so total_debt == amount + profit
check_strategy_totals(
strategy, total_assets=amount + profit, total_debt=0, total_idle=amount + profit
)

# needed for profits to unlock
increase_time(chain, strategy.profitMaxUnlockTime() - 1)

# TODO: Implement logic so total_debt == amount + profit
check_strategy_totals(
strategy, total_assets=amount + profit, total_debt=0, total_idle=amount + profit
)
Expand All @@ -102,6 +103,7 @@ def test__profitable_report__with_fee(
rewards,
amount,
whale,
factory,
RELATIVE_APPROX,
keeper,
):
Expand All @@ -115,7 +117,7 @@ def test__profitable_report__with_fee(
# Deposit to the strategy
deposit()

# TODO: Implement logic so totalDebt ends > 0
# TODO: Implement logic so total_debt ends > 0
check_strategy_totals(
strategy, total_assets=amount, total_debt=0, total_idle=amount
)
Expand All @@ -135,16 +137,23 @@ def test__profitable_report__with_fee(

assert profit > 0

expected_performance_fee = profit * performance_fee // MAX_BPS
(protocol_fee, protocol_fee_recipient) = factory.protocol_fee_config(
sender=strategy.address
)

expected_performance_fee = (
(profit * performance_fee // MAX_BPS) * (10_000 - protocol_fee) // MAX_BPS
)

# TODO: Implement logic so totalDebt == amount + profit
# TODO: Implement logic so total_debt == amount + profit
check_strategy_totals(
strategy, total_assets=amount + profit, total_debt=0, total_idle=amount + profit
)

# needed for profits to unlock
increase_time(chain, strategy.profitMaxUnlockTime() - 1)

# TODO: Implement logic so total_debt == amount + profit
check_strategy_totals(
strategy, total_assets=amount + profit, total_debt=0, total_idle=amount + profit
)
Expand All @@ -159,8 +168,6 @@ def test__profitable_report__with_fee(

strategy.redeem(expected_performance_fee, rewards, rewards, sender=rewards)

check_strategy_totals(strategy, total_assets=0, total_debt=0, total_idle=0)

assert asset.balanceOf(rewards) >= rewards_balance_before + expected_performance_fee


Expand Down
4 changes: 2 additions & 2 deletions tests/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def check_oracle(oracle, strategy, user):

# TODO: Uncomment if there are setter functions to test.
"""
with reverts("Ownable: caller is not the owner"):
with reverts("!governance"):
oracle.setterFunction(setterVariable, sender=user)
management = strategy.management()
Expand All @@ -30,4 +30,4 @@ def test__oracle(create_oracle, strategy, user):

oracle = create_oracle()

check_oracle(oracle, strategy, strategy)
check_oracle(oracle, strategy, user)

0 comments on commit 2f8da54

Please sign in to comment.