- Initialization is only possible during deployment or if there is no shares.
- The assets amount cannot be zero during initialization.
- The user receives the amount of shares equal to provided XTZ.
- Each token can have the only pair.
- Info about previous rewards (if any) should be reset.
- The tokens should be withdrawn from user.
Scope: Test various ways to initialize the contract.
Action: Invoke the InitializeExchange entrypoint.
Test Notes and Preconditions: Ensure all the initialize approaches work.
Verification Steps: Verify the exchange is initialized and the initial state is correct.
Scenario 1: Test initialize during the deployment when
- the pair doesn't exist
- the amount of token A is zero
- the amount of token B is zero
- the pair exists
Scenario 2: Test initialize after liquidity withdrawn when
- liquidity is zero
- liquidity isn't zero
- the amount of token A is zero
- the amount of token B is zero
- Investment is only possible after initialization.
- At least 1 share should be purchased.
- Minimal shares are specified by the user.
- The rewards for the previous period if any should be distributed.
- The rewards to the user if any should be distributed.
- The tokens should be withdrawn from user.
- Shares are calculated as :
shares_purchased = xtz_amount * total_supply / tez_pool
tokens_amount = shares_purchased * token_pool / total_supply
Scope: Test if the investment is allowed.
Action: Invoke the InvestLiquidity entrypoint.
Test Notes and Preconditions: Ensure the investment is only possible after initialization.
Verification Steps: Verify the investment fails if the pool isn't launched.
Scenario 1: Test the investment
- without provided liquidity
- with provided liquidity
Scope: Test various min shared.
Action: Invoke the InvestLiquidity entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the investment fails if the min shares aren't in the range.
Scenario 1: Test the investment with minimal shares of
- 0
- 1
- enough
- exact
Scenario 2: Test purchased shares
- 0
- > 0
- Divestment is only possible after initialization.
- At least 1 share should be burnt.
- Minimal shares are specified by the user.
- Burnt shares can't be smaller than the user's balance.
- The rewards for the previous period if any should be distributed.
- The rewards to the user if any should be distributed.
- The tokens should be sent to user.
- Amounts are calculated as :
tez_divested = tez_pool * burnt_shares / total_supply
tokens_divested = token_pool * burnt_shares / total_supply
Scope: Test if the divestment is allowed.
Action: Invoke the DivestLiquidity entrypoint.
Test Notes and Preconditions: Ensure the divestment is only possible after initialization.
Verification Steps: Verify the divestment fails if the pool isn't launched.
Scenario 1: Test the divestment
- without provided liquidity
- with provided liquidity
Scope: Test various burnt shared.
Action: Invoke the DivestLiquidity entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares aren't in the range.
Scenario 1: Test the divestment with burnt shares of
- 0
- 1
- enough
- exact
- too many
Scenario 2: Test calculated received amount
- Received token a are zero
- Reseived token b are zero
Scenario 3: Test expected amount when
- Expected token a are smaller
- Expected token b are smaller
- Expected token a are exact
- Expected token b are exact
- Expected token a are higher
- Expected token b are higher
- Expected token a are 0
- Expected token b are 0
- Amount of XTZ to swap should be non-zero and received tokens cann't be bigger than 1/3 of reserves.
- Amount of received tokens should be non-zero and received XTZ cann't be bigger than 1/3 of reserves.
- Desirable minimal received amount of tokens should be non-zero.
- The received amount of tokens can't be smaller then minimal decirable amount.
- All bought tokens should be sent to user.
- Tez and token pool should be updated accordingly.
- The output amount is calculated as:
fee = tez_in * fee_rate
tokens_out = token_pool * (tez_in - fee) / (tez_pool + tez_in - fee)
Scope: Test different amount of XTZ to be swapped.
Action: Invoke the TezToToken entrypoint.
Test Notes and Preconditions: Create new pair, provide liquidity.
Verification Steps: Ensure the amount to be swapped cannot be zero.
Scenario 1: Test swap of
- 0 XTZ
- 1% of reserves
- 30% of reserves
- 100% of reserves
- 10000% of reserves
Scope: Test different minimal desirable output amount.
Action: Invoke the TezToToken entrypoint.
Test Notes and Preconditions: Create new pair, provide liquidity.
Verification Steps: Ensure the received amount cannot be zero and is taken into account during the swap, the real output is still equal to the calculated amount.
Scenario 1: Test swap of
- 0 tokens
- too many tokens
- smaller amount of tokens
- exact tokens
- Amount of tokens to swap should be non-zero and received XTZ cann't be bigger than 1/3 of reserves.
- Amount of received tokens should be non-zero and received XTZ cann't be bigger than 1/3 of reserves.
- Desirable minimal received amount of XTZ should be non-zero.
- The received amount of XTZ can't be smaller then minimal decirable amount.
- All bought XTZ should be sent to user.
- Tez and token pool should be updated accordingly.
- The output amount is calculated as:
fee = tez_in * fee_rate
tokens_out = token_pool * (tez_in - fee) / (tez_pool + tez_in - fee)
Scope: Test different amount of XTZ to be swapped.
Action: Invoke the TokenToTez entrypoint.
Test Notes and Preconditions: Create new pair, provide liquidity.
Verification Steps: Ensure the amount to be swapped cannot be zero.
Scenario 1: Test swap of
- 0 tokens
- 0.01% of reserves
- 30% of reserves
- 100% of reserves
- 10000% of reserves
Scope: Test different minimal desirable output amount.
Action: Invoke the TokenToTez entrypoint.
Test Notes and Preconditions: Create new pair, provide liquidity.
Verification Steps: Ensure the received amount cannot be zero and is taken into account during the swap, the real output is still equal to the calculated amount.
Scenario 1: Test swap of
- 0 XTZ
- too many XTZ
- exact XTZ