generated from yearn/brownie-strategy-mix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "owner", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"name": "spender", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "Approval", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": true, | ||
"name": "sender", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": true, | ||
"name": "receiver", | ||
"type": "address" | ||
}, | ||
{ | ||
"indexed": false, | ||
"name": "value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "Transfer", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "_symbol", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "_decimals", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"name": "_total_supply", | ||
"type": "uint256" | ||
} | ||
], | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"gas": 1305, | ||
"inputs": [ | ||
{ | ||
"name": "_owner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "balanceOf", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 1489, | ||
"inputs": [ | ||
{ | ||
"name": "_owner", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_spender", | ||
"type": "address" | ||
} | ||
], | ||
"name": "allowance", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 37748, | ||
"inputs": [ | ||
{ | ||
"name": "_spender", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "approve", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 76593, | ||
"inputs": [ | ||
{ | ||
"name": "_to", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "transfer", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 114138, | ||
"inputs": [ | ||
{ | ||
"name": "_from", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_to", | ||
"type": "address" | ||
}, | ||
{ | ||
"name": "_value", | ||
"type": "uint256" | ||
} | ||
], | ||
"name": "transferFrom", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 7733, | ||
"inputs": [], | ||
"name": "name", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 6786, | ||
"inputs": [], | ||
"name": "symbol", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 1391, | ||
"inputs": [], | ||
"name": "decimals", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"gas": 1421, | ||
"inputs": [], | ||
"name": "totalSupply", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# TODO: Add tests here that show the normal operation of this strategy | ||
# Suggestions to include: | ||
# - strategy loading and unloading (via Vault addStrategy/revokeStrategy) | ||
# - change in loading (from low to high and high to low) | ||
# - strategy operation at different loading levels (anticipated and "extreme") | ||
from brownie import Wei, reverts | ||
from useful_methods import genericStateOfVault, genericStateOfStrat | ||
import brownie | ||
|
||
def test_usdt(Vault, StrategyUSDT3pool, usdt_whale, gov, usdt): | ||
# deploy usdt vault | ||
usdt_vault = gov.deploy(Vault, usdt, gov, gov, '', '') | ||
print(f'type of vault: {type(usdt_vault)} @ {usdt_vault}') | ||
|
||
# deploy usdt strategy | ||
usdt_strategy = gov.deploy(StrategyUSDT3pool, usdt_vault) | ||
print(f'type of strategy: {type(usdt_strategy)} @ {usdt_strategy}') | ||
|
||
# activate the strategy from vault view | ||
usdt_vault.addStrategy(usdt_strategy, 2**64, 2**64, 1000, {'from': gov}) | ||
print(f'credit of strategy: {usdt_vault.creditAvailable(usdt_strategy)}') | ||
|
||
# rm yvusdt's guestlist | ||
usdt_vault.setGuestList('0x0000000000000000000000000000000000000000', {'from': gov}) | ||
print(f'yvusdt guest list: {usdt_vault.guestList()}') | ||
|
||
# approve usdt vault to use usdt | ||
usdt.approve(usdt_vault, 2**256-1, {'from': usdt_whale}) | ||
|
||
# start deposit | ||
print('\n=== deposit 100 usdt ===') | ||
print(f'whale\'s usdt balance before deposit: {usdt.balanceOf(usdt_whale)/1e6}') | ||
deposit_amount = Wei('100 ether')/1e12 | ||
usdt_vault.deposit(deposit_amount, {'from': usdt_whale}) | ||
print(f'whale\'s usdt balance after deposit: {usdt.balanceOf(usdt_whale)/1e6}') | ||
|
||
# start strategy | ||
print('\n=== harvest usdt ===') | ||
usdt_strategy.harvest({'from': gov}) | ||
print('harvest done') | ||
|
||
print('\n=== usdt status ===') | ||
genericStateOfStrat(usdt_strategy, usdt, usdt_vault) | ||
genericStateOfVault(usdt_vault, usdt) | ||
|
||
# withdraw | ||
print('\n=== withdraw usdt ===') | ||
print(f'whale\'s usdt vault share: {usdt_vault.balanceOf(usdt_whale)/1e6}') | ||
usdt_vault.withdraw(Wei('1 ether')/1e12, {'from': usdt_whale}) | ||
print(f'withdraw 1 share of usdt done') | ||
print(f'whale\'s usdt vault share: {usdt_vault.balanceOf(usdt_whale)/1e6}') | ||
|
||
# withdraw all | ||
print('\n=== withdraw all usdt ===') | ||
print(f'whale\'s usdt vault share: {usdt_vault.balanceOf(usdt_whale)/1e6}') | ||
usdt_vault.withdraw({'from': usdt_whale}) | ||
print(f'withdraw all usdt') | ||
print(f'whale\'s usdt vault share: {usdt_vault.balanceOf(usdt_whale)/1e6}') | ||
|
||
# call tend | ||
print('\ncall tend') | ||
usdt_strategy.tend() | ||
print('tend done') |