- 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 XTZ is zero
- the amount of token is zero
- the token isn't approved
- the pair exists
Scenario 2: Test initialize after liquidity withdrawn when
- liquidity is zero
- liquidity isn't zero
- the amount of XTZ is zero
- the amount of token is zero
- the token isn't approved
- 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
- too many
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 tez are zero
- Reseived tokens are zero
Scenario 3: Test expected amount when
- Expected tez are smaller
- Expected tokens are smaller
- Expected tez are exact
- Expected tokens are exact
- Expected tez are higher
- Expected tokens are higher
- Expected tez are 0
- Expected tokens are 0
- The function can be set only once.
- Only functions with index between 0 and 8 can be set as exchange functions.
- Only functions with index between 0 and 4 can be set as token functions.
Scope: Test the all functions can be added.
Action: Invoke the SetXFunctions entrypoint.
Test Notes and Preconditions: Create new empty factory.
Verification Steps: Verify the function can be set only once.
Scenario 1: Test adding of all
- exchange fuctions
- token functions
Scope: Test the function replacement.
Action: Invoke the SetXFunctions entrypoint.
Test Notes and Preconditions: Create new empty factory.
Verification Steps: Verify the function can be set only once.
Scenario 1: Test the replacement of
- exchange fuction
- token function
Scope: Test the function count.
Action: Invoke the SetXFunctions entrypoint.
Test Notes and Preconditions: Create new empty factory.
Verification Steps: Verify only 9 exchange and 4 token functions can be set.
Scenario 1: Test the function setting
- of 5th token function
- of 9th token function
- 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
- Should be possibel to exchange token to token via batch.
Scope: Test correct requied amounts.
Action: Invoke the TokenToTez and TezToToken entrypoints.
Test Notes and Preconditions: Create 2 new pairs, provide liquidity.
Verification Steps: Ensure the received amount is taken into account during the swap, the real output is still equal to the calculated amount.
Scenario 1: Test swap of 1000 tokens
- Vote is only possible if the user has shares in the pool.
- The user cannot vote for the banned candidate.
- The user cannot exceed the share balance (including the amount of voted tokens).
- The other user can vote instead of shares owner if there are enough allowances.
- The previous votes should be removed if the user voted before.
- Total votes, user liquid balance and candidate should be updated.
- Zero vote should be interpreted as removing any candidate.
- If the amount of vote for the candidate is higher than the previous, baker is updated.
Scope: Test the user's vote power.
Action: Invoke the Vote entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the amount of votes can't be higher than the liquid balance.
Scenario 1: Test voting with:
- no shares.
- 0 shares with no candidate.
- more than liquid shares.
- enough liquid shares.
- exactly equal to liquid balance.
- enough liquid shares for revoting.
- 0 shares to remove candidate.
Scope: Test voting permissions.
Action: Invoke the Vote entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to vote.
Verification Steps: Verify the voting for user can only be done by approved users or user by himself.
Scenario 1: Test voting by:
- the user.
- the approved user.
- the unapproved user.
Scope: Test different candidates.
Action: Invoke the Vote entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to vote.
Verification Steps: Verify the candidate of votes can't be higher than the liquid balance.
Scenario 1: Test voting for:
- unregistered candidate with power that makes him delegate.
- unregistered candidate with power that won't makes him delegate.
- new candidate.
- candidate with votes.
- banned candidate.
Scope: Test candidate replacement.
Action: Invoke the Vote entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to vote.
Verification Steps: Verify the candidate of votes can't be higher than the liquid balance.
Scenario 1: Test voting for:
- new candidate if there if no delegate.
- new candidate if there is delegate with lower votes.
- keep candidate if there is delegate with the same votes.
- new candidate if there is delegate with higher votes.
- the delegate.
- delegate by remove votes for him.
- Veto is only possible if the user has shares in the pool.
- The user cannot exceed the share balance (including the amount of tokens veted before).
- The other user can set veto instead of shares owner if there are enough allowances.
- The previous vetos should be removed if the user set veto before for the current delegate.
- Total vetos, user liquid balance and last veto should be updated.
- If the amount of vetos is at least 1/3 of all the votes the delegate receiveddelegate is changed.
- If the delegate is reset the vetos should be reset.
Scope: Test the user's veto power.
Action: Invoke the Veto entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the amount of votes can't be higher than the liquid balance.
Scenario 1: Test veto with:
- no shares.
- 0 shares.
- more than liquid shares.
- enough liquid shares.
- exactly equal to liquid balance.
- enough after delegate removal.
Scope: Test veto permissions.
Action: Invoke the Veto entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to veto.
Verification Steps: Verify the veto agains the delegator can only be done by approved users or user by himself.
Scenario 1: Test veto by:
- the user.
- the approved user.
- the unapproved user.
Scope: Test different delegates.
Action: Invoke the Veto entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to vote.
Verification Steps: Verify the veto can be executed only if there is any delegate.
Scenario 1: Test veto for:
- delegate.
- no delegate.
Scope: Test the veto limit.
Action: Invoke the Veto entrypoint.
Test Notes and Preconditions: The exchange should be launched before, the user should have shares to vote.
Verification Steps: Verify the delegate is banned only if the vote is higher than 1/3 of all votes.
Scenario 1: Test veto with:
- too little vetos.
- exactly 1/3 vetos.
- more than 1/3 vetos.
- Reward should be collected everytime the simple payment to the contract is done.
- Reward is distributed once in the period.
- Rewards is assessed only if thre are some shares in the pool.
Scope: Test the rewards assessment in case of differrent deposits.
Action: Invoke the Default entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test user rewards assesment if
- 0 shares.
- some shares.
Scope: Test the rewards assessment based on the sent amount.
Action: Invoke the Default entrypoint.
Test Notes and Preconditions: The exchange should be launched before, shares should be in the pool.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test user rewards assesment if
- 0 XTZ sent.
- 1 XTZ sent.
Scope: Test the total rewards assessments in case of different periods.
Action: Invoke the Default entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test rewards distribution of
- before period finished.
- after period finished.
- in the middle of the second period.
- Loyalty represents the share of the reward claimable by the user.
- Loyalty depend both of stake duration and amout of the provided liquidity.
- Reward is distributed once in the period.
- Reward can be withdrawn any time and sent to any address.
- The reward should be destributed only if there are any investment.
Scope: Test the loyalty assessment.
Action: Invoke the few entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test user loyalty assesment if
- user own some shares.
- user makes new investment.
- reward withdrawn.
- tokens transfered.
- shares withdrawn.
Scope: Test the user's reward distribution.
Action: Invoke the Default entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test rewards distribution of
- before period finished.
- after period finished.
- in the middle of the second period.
Scope: Test the user's reward distribution with different total rewards.
Action: Invoke the WithdrawProfit entrypoint.
Test Notes and Preconditions: The exchange should be launched before.
Verification Steps: Verify the divestment fails if the the burnt shares are in the range.
Scenario 1: Test user rewards distribution of
- no reward.
- reward is accumulated.
- shares withdrawn but reward assest after.
- Only new owner can be added
- Only existed owner can be removed
- The owner status can be changed only by one of the owners
- The metadate can be changed only by one of the owners
Scope: Test permissions for update owner status.
Action: Invoke the Update_owners entrypoint.
Test Notes and Preconditions: The contract should be deployed.
Verification Steps: Verify the action is only permitted by owner.
Scenario 1: Test update owner status by:
- owner.
- unprivileged user.
Scope: Test permissions for update metadata.
Action: Invoke the Update_storage entrypoint.
Test Notes and Preconditions: The contract should be deployed.
Verification Steps: Verify the action is only permitted by owner.
Scenario 1: Test update metadata status by:
- owner.
- unprivileged user.
Scope: Test owner status update.
Action: Invoke the Update_owners entrypoint.
Test Notes and Preconditions: The contract should be deployed.
Verification Steps: Verify the action is only permitted by owner.
Scenario 1: Test update owner status by:
- adding existed owner.
- removing unxisted owner.
- adding new owner.
- removing existed owner.