Skip to content

Commit

Permalink
test: stable-ng pools
Browse files Browse the repository at this point in the history
  • Loading branch information
Macket committed Feb 5, 2024
1 parent a1b2b1f commit 7c9479e
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__
build/
reports/
.idea
node_modules
27 changes: 27 additions & 0 deletions contracts/pools/usdv/pooldata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"base_pool": "3pool",
"pool_types": ["meta", "factory"],
"lp_contract": "CurveTokenV3",
"swap_address": "0x00e6fd108c4640d21b40d02f18dd6fe7c7f725ca",
"lp_token_address": "0x00e6fd108c4640d21b40d02f18dd6fe7c7f725ca",
"zap_address": "0xA79828DF1850E8a3A3064576f380D90aECDD3359",
"gauge_addresses": ["0x2d5727a90edd42b4d666ff773c7809215284c326"],
"lp_constructor": {
"symbol": "USDV3crv",
"name": "USDV/3Crv"
},
"coins": [
{
"name": "USDV",
"decimals": 6,
"tethered": false,
"underlying_address": "0x0e573ce2736dd9637a0b21058352e1667925c7a8"
},
{
"name": "3CRV",
"decimals": 18,
"base_pool_token": true,
"underlying_address": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490"
}
]
}
25 changes: 25 additions & 0 deletions contracts/pools/veth/pooldata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"lp_contract": "CurveTokenV3",
"swap_address": "0x6685fcfce05e7502bf9f0aa03b36025b09374726",
"lp_token_address": "0x6685fcfce05e7502bf9f0aa03b36025b09374726",
"gauge_addresses": ["0x8dff75976f22db58d7c3fd7b68d782238b0dbe30"],
"lp_constructor": {
"name": "vETH/ETH",
"symbol": "vETHETH"
},
"coins": [
{
"name": "vETH",
"decimals": 18,
"tethered": false,
"underlying_address": "0x38d64ce1bdf1a9f24e0ec469c9cade61236fb4a0"
},
{
"name": "WETH",
"decimals": 18,
"tethered": false,
"underlying_address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"

}
]
}
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

POOLS = ['3pool', 'aave', 'aeth', 'bbtc', 'busd', 'compound', 'dusd', 'gusd', 'hbtc', 'husd', 'ib', 'link', 'musd', 'obtc',
'pax', 'pbtc', 'ren', 'reth', 'rsv', 'saave', 'sbtc', 'seth', 'steth', 'susd', 'tbtc', 'usdk', 'usdn', 'usdp', 'usdt',
'ust', 'y', 'tricrypto2', 'eurt', 'eurtusd', 'crveth', 'cvxeth', 'tusd'] # 'eurs'
'ust', 'y', 'tricrypto2', 'eurt', 'eurtusd', 'crveth', 'cvxeth', 'tusd', 'veth', 'usdv'] # 'eurs'

LENDING_POOLS = ['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib']
META_POOLS = ['gusd', 'husd', 'usdk', 'usdn', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'ust', 'usdp', 'eurtusd']
META_POOLS = ['gusd', 'husd', 'usdk', 'usdn', 'musd', 'rsv', 'tbtc', 'dusd', 'pbtc', 'bbtc', 'obtc', 'ust', 'usdp', 'eurtusd', 'usdv']
FACTORY_POOOLS = ['tusd'] # 'frax', 'lusd', 'busdv2', 'alusd', 'mim'
WETH_POOLS = ['tricrypto2', 'crveth', 'cvxeth']

Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ def wrong_coins(wrong_coin_addresses, pool_data):
@pytest.fixture(scope="module")
def wrapped_coin_addresses(wrapped_coins):
addresses = list(map(lambda x: x if type(x) is str else x.address, wrapped_coins))
return addresses + [ZERO_ADDRESS] * (5 - len(addresses))
return addresses


@pytest.fixture(scope="module")
def wrapped_coin_addresses_wrong_order(wrapped_coins):
addresses = list(map(lambda x: x if type(x) is str else x.address, wrapped_coins))
addresses.reverse()
return addresses + [ZERO_ADDRESS] * (5 - len(addresses))
return addresses


@pytest.fixture(scope="module")
def underlying_coin_addresses(underlying_coins):
addresses = list(map(lambda x: x if type(x) is str else x.address, underlying_coins))
return addresses + [ZERO_ADDRESS] * (5 - len(addresses))
return addresses


@pytest.fixture(scope="module")
def underlying_coin_addresses_wrong_order(underlying_coins):
addresses = list(map(lambda x: x if type(x) is str else x.address, underlying_coins))
addresses.reverse()
return addresses + [ZERO_ADDRESS] * (5 - len(addresses))
return addresses


@pytest.fixture(scope="module")
Expand Down
12 changes: 10 additions & 2 deletions tests/fixtures/pooldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def wrong_amounts_to_mint():
# Different amounts are needed to always pass test_wrong_order_of_coins
@pytest.fixture(scope="module")
def wrapped_amounts(wrapped_decimals, n_coins_wrapped):
return [(10 + i) * 10 ** wrapped_decimals[i] for i in range(n_coins_wrapped)] + [0] * (5 - n_coins_wrapped)
return [(10 + i) * 10 ** wrapped_decimals[i] for i in range(n_coins_wrapped)]


# Different amounts are needed to always pass test_wrong_order_of_coins
@pytest.fixture(scope="module")
def underlying_amounts(underlying_decimals, n_coins_underlying):
return [(10 + i) * 10 ** underlying_decimals[i] for i in range(n_coins_underlying)] + [0] * (5 - n_coins_underlying)
return [(10 + i) * 10 ** underlying_decimals[i] for i in range(n_coins_underlying)]


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -132,3 +132,11 @@ def is_meta(pool_data):
@pytest.fixture(scope="module")
def factory_pool_address(pool_data):
return pool_data["swap_address"] if "factory" in pool_data.get("pool_types", []) else ZERO_ADDRESS


@pytest.fixture(scope="module")
def is_plain_stable_ng(pool_data):
if pool_data['swap_address'] == "0x6685fcfce05e7502bf9f0aa03b36025b09374726": # vETH/ETH
return True

return False
42 changes: 31 additions & 11 deletions tests/test_underlying.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

def test_balance(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, gauge, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, gauge, use_underlying,
is_plain_stable_ng, factory_pool_address
):
assert gauge.balanceOf(margo.address) == 0

Expand All @@ -19,6 +20,7 @@ def test_balance(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)
Expand All @@ -29,7 +31,8 @@ def test_balance(

def test_approve(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying, underlying_coin_addresses,
underlying_amounts, value_underlying, underlying_coins, lp_token, use_underlying, factory_pool_address
underlying_amounts, value_underlying, underlying_coins, lp_token, use_underlying, is_plain_stable_ng,
factory_pool_address
):
for coin in underlying_coins:
if coin == '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE':
Expand All @@ -47,6 +50,7 @@ def test_approve(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)
Expand All @@ -61,9 +65,10 @@ def test_approve(

def test_token_mismatch(
zap, margo, deposit_address, other_token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts("dev: swap-token mismatch"):
with brownie.reverts():
zap.deposit_and_stake(
deposit_address,
other_token_address,
Expand All @@ -73,14 +78,16 @@ def test_token_mismatch(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_gauge_mismatch(
zap, margo, deposit_address, token_address, other_gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -92,14 +99,16 @@ def test_gauge_mismatch(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_n_coins_too_high(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -111,14 +120,16 @@ def test_n_coins_too_high(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_n_coins_too_low(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -130,14 +141,16 @@ def test_n_coins_too_low(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_wrong_coins(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
wrong_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
wrong_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -149,14 +162,16 @@ def test_wrong_coins(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_wrong_order_of_coins(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses_wrong_order, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses_wrong_order, underlying_amounts, value_underlying,
use_underlying, is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -168,14 +183,16 @@ def test_wrong_order_of_coins(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)


def test_wrong_value(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
with brownie.reverts():
zap.deposit_and_stake(
Expand All @@ -187,14 +204,16 @@ def test_wrong_value(
underlying_amounts,
0,
use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': 0 if value_underlying > 0 else 10**18}
)


def test_wrong_use_underlying(
zap, margo, deposit_address, token_address, gauge_address, n_coins_underlying,
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying, factory_pool_address
underlying_coin_addresses, underlying_amounts, value_underlying, use_underlying,
is_plain_stable_ng, factory_pool_address
):
if factory_pool_address == brownie.ZERO_ADDRESS:
with brownie.reverts():
Expand All @@ -207,6 +226,7 @@ def test_wrong_use_underlying(
underlying_amounts,
0,
not use_underlying,
is_plain_stable_ng,
factory_pool_address,
{'from': margo, 'value': value_underlying}
)
Loading

0 comments on commit 7c9479e

Please sign in to comment.