-
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
5 changed files
with
85 additions
and
75 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
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
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import pytest | ||
|
||
from utils import generate_token_combinations | ||
from utils import generate_list_combinations | ||
import address_book as ab | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"stableswap_pool", | ||
generate_token_combinations(ab.all_stables), # Generate token combinations | ||
indirect=True, # Pass token combinations to the fixture | ||
) | ||
def test_stableswap_pool_with_liquidity(stableswap_pool, add_liquidity): | ||
N_COMBINATIONS = 1 # num of combinations in stableswap tests (>=36 => all combinations) | ||
|
||
# produce tokens for stableswap to pair against crvusd | ||
paired_token_combinations = generate_list_combinations(ab.all_stables, [1, 2], randomize=True) | ||
tokens_subset = paired_token_combinations[0:N_COMBINATIONS] | ||
|
||
|
||
@pytest.mark.parametrize("paired_tokens", tokens_subset, indirect=True) | ||
def test_stableswap_pool_with_liquidity(stableswap_pool, paired_tokens): | ||
""" | ||
Test deploying stableswap pool with different token combinations, | ||
then adds liquidity to the pool and checks balances. | ||
""" | ||
|
||
# Check balances in the pool after adding liquidity | ||
n_coins = stableswap_pool.n_coins() | ||
n_coins = stableswap_pool.N_COINS() | ||
print(f"n_coins: {n_coins}") | ||
for i in range(n_coins): | ||
print(f"balance {i}: {stableswap_pool.balances(i)}") |
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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
from itertools import combinations | ||
import address_book as ab | ||
import random | ||
|
||
|
||
def generate_token_combinations(other_tokens): | ||
"""Generate all unique combinations with my_token and 1–2 other tokens.""" | ||
def generate_list_combinations(data_list, combo_sizes, randomize=False): | ||
combos = [] | ||
for count in range(1, 3): # for 2 or 3 tokens in total | ||
for combo in combinations(other_tokens.values(), count): | ||
combos.append([*combo]) | ||
for count in combo_sizes: | ||
for combo in combinations(data_list, count): | ||
combos.append(list(combo)) # Convert each combination to a list | ||
if randomize: | ||
random.shuffle(combos) | ||
return combos | ||
|
||
|
||
# test functionality if run as a script | ||
if __name__ == "__main__": | ||
combos = generate_token_combinations(ab.all_stables) | ||
combos = generate_list_combinations(ab.all_stables, [1, 2]) | ||
print(combos) | ||
print(len(combos)) |