Skip to content

Commit

Permalink
test on usdt
Browse files Browse the repository at this point in the history
  • Loading branch information
orbxball committed Jan 12, 2021
1 parent e6ca1db commit 8cfceae
Show file tree
Hide file tree
Showing 3 changed files with 290 additions and 0 deletions.
216 changes: 216 additions & 0 deletions interfaces/USDT.json
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"
}
]
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@ def usdc(interface):
def usdc_whale(accounts):
# binance8
yield accounts.at('0xF977814e90dA44bFA03b6295A0616a897441aceC', force=True)


@pytest.fixture
def usdt(interface):
yield interface.USDT('0xdAC17F958D2ee523a2206206994597C13D831ec7')


@pytest.fixture
def usdt_whale(accounts):
# binance8
yield accounts.at('0xF977814e90dA44bFA03b6295A0616a897441aceC', force=True)
63 changes: 63 additions & 0 deletions tests/test_usdt.py
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')

0 comments on commit 8cfceae

Please sign in to comment.