-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add coverage for AC 0012-POSR-032
Signed-off-by: Elias Van Ootegem <elias@vega.xyz>
- Loading branch information
1 parent
8f92c2f
commit 9a15ec7
Showing
1 changed file
with
132 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
Feature: A network disposal order which crosses with volume implied by an vAMM should trade with the vAMM volume. (0012-POSR-032) | ||
|
||
Background: | ||
Given the average block duration is "1" | ||
And the margin calculator named "margin-calculator-1": | ||
| search factor | initial factor | release factor | | ||
| 1.2 | 1.5 | 1.7 | | ||
And the log normal risk model named "log-normal-risk-model": | ||
| risk aversion | tau | mu | r | sigma | | ||
| 0.001 | 0.0011407711613050422 | 0 | 0.9 | 3.0 | | ||
And the liquidity monitoring parameters: | ||
| name | triggering ratio | time window | scaling factor | | ||
| lqm-params | 1.00 | 20s | 1 | | ||
And the liquidation strategies: | ||
| name | disposal step | disposal fraction | full disposal size | max fraction consumed | disposal slippage range | | ||
| disposal-strat-1 | 5 | 0.2 | 10 | 0.5 | 0.1 | | ||
|
||
And the following network parameters are set: | ||
| name | value | | ||
| market.value.windowLength | 60s | | ||
| network.markPriceUpdateMaximumFrequency | 0s | | ||
| limits.markets.maxPeggedOrders | 6 | | ||
| market.auction.minimumDuration | 1 | | ||
| market.fee.factors.infrastructureFee | 0.001 | | ||
| market.fee.factors.makerFee | 0.004 | | ||
| spam.protection.max.stopOrdersPerMarket | 5 | | ||
| market.liquidity.equityLikeShareFeeFraction | 1 | | ||
| market.amm.minCommitmentQuantum | 1 | | ||
| market.liquidity.bondPenaltyParameter | 0.2 | | ||
| market.liquidity.stakeToCcyVolume | 1 | | ||
| market.liquidity.successorLaunchWindowLength | 1h | | ||
| market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1 | | ||
| market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | | ||
| validators.epoch.length | 10s | | ||
| market.liquidity.earlyExitPenalty | 0.25 | | ||
| market.liquidity.maximumLiquidityFeeFactorLevel | 0.25 | | ||
#risk factor short:3.5569036 | ||
#risk factor long:0.801225765 | ||
And the following assets are registered: | ||
| id | decimal places | | ||
| USD | 0 | | ||
And the fees configuration named "fees-config-1": | ||
| maker fee | infrastructure fee | | ||
| 0.0004 | 0.001 | | ||
|
||
And the liquidity sla params named "SLA-22": | ||
| price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | | ||
| 0.5 | 0.6 | 1 | 1.0 | | ||
|
||
And the oracle spec for settlement data filtering data from "0xCAFECAFE" named "ethMar22Oracle": | ||
| property | type | binding | | ||
| prices.ETH.value | TYPE_INTEGER | settlement data | | ||
And the oracle spec for trading termination filtering data from "0xCAFECAFE" named "ethMar22Oracle": | ||
| property | type | binding | | ||
| trading.terminated | TYPE_BOOLEAN | trading termination | | ||
And the settlement data decimals for the oracle named "ethMar22Oracle" is given in "0" decimal places | ||
|
||
And the markets: | ||
| id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | liquidation strategy | | ||
| ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | default-none | ethMar22Oracle | 1e0 | 0 | SLA-22 | disposal-strat-1 | | ||
|
||
# Setting up the accounts and vAMM submission now is part of the background, because we'll be running scenarios 0087-VAMM-006 through 0087-VAMM-014 on this setup | ||
Given the parties deposit on asset's general account the following amount: | ||
| party | asset | amount | | ||
| lp1 | USD | 1000000 | | ||
| lp2 | USD | 1000000 | | ||
| lp3 | USD | 1000000 | | ||
| party1 | USD | 1000000 | | ||
| party2 | USD | 1000000 | | ||
| party3 | USD | 1000000 | | ||
| party4 | USD | 1000000 | | ||
| party5 | USD | 1000000 | | ||
| partyX | USD | 100 | | ||
| vamm1 | USD | 1000 | | ||
|
||
When the parties submit the following liquidity provision: | ||
| id | party | market id | commitment amount | fee | lp type | | ||
| lp_1 | lp1 | ETH/MAR22 | 600 | 0.02 | submission | | ||
| lp_2 | lp2 | ETH/MAR22 | 400 | 0.015 | submission | | ||
Then the network moves ahead "4" blocks | ||
And the current epoch is "0" | ||
|
||
And the parties place the following orders: | ||
| party | market id | side | volume | price | resulting trades | type | tif | reference | | ||
| lp1 | ETH/MAR22 | buy | 20 | 4 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | | ||
| party1 | ETH/MAR22 | buy | 1 | 5 | 0 | TYPE_LIMIT | TIF_GTC | | | ||
| partyX | ETH/MAR22 | sell | 1 | 5 | 0 | TYPE_LIMIT | TIF_GTC | | | ||
| lp1 | ETH/MAR22 | sell | 10 | 16 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | | ||
When the opening auction period ends for market "ETH/MAR22" | ||
Then the following trades should be executed: | ||
| buyer | price | size | seller | | ||
| party1 | 5 | 1 | partyX | | ||
And the parties cancel the following orders: | ||
| party | reference | | ||
| lp1 | lp1-b | | ||
| lp1 | lp1-s | | ||
|
||
When the parties place the following orders: | ||
| party | market id | side | volume | price | resulting trades | type | tif | reference | | ||
| lp1 | ETH/MAR22 | buy | 20 | 40 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | | ||
| party1 | ETH/MAR22 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | | ||
| party2 | ETH/MAR22 | sell | 1 | 100 | 1 | TYPE_LIMIT | TIF_GTC | | | ||
| lp1 | ETH/MAR22 | sell | 10 | 160 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | | ||
Then the network moves ahead "1" blocks | ||
And the following trades should be executed: | ||
| buyer | price | size | seller | | ||
| party1 | 100 | 1 | party2 | | ||
| partyX | 100 | 1 | network | | ||
And the market data for the market "ETH/MAR22" should be: | ||
| mark price | trading mode | target stake | supplied stake | open interest | ref price | mid price | static mid price | | ||
| 100 | TRADING_MODE_CONTINUOUS | 79 | 1000 | 2 | 100 | 100 | 100 | | ||
When the parties submit the following AMM: | ||
| party | market id | amount | slippage | base | lower bound | upper bound | lower margin ratio | upper margin ratio | proposed fee | | ||
| vamm1 | ETH/MAR22 | 1000 | 0.1 | 100 | 85 | 150 | 0.25 | 0.25 | 0.01 | | ||
Then the AMM pool status should be: | ||
| party | market id | amount | status | base | lower bound | upper bound | lower margin ratio | upper margin ratio | | ||
| vamm1 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 100 | 85 | 150 | 0.25 | 0.25 | | ||
|
||
And set the following AMM sub account aliases: | ||
| party | market id | alias | | ||
| vamm1 | ETH/MAR22 | vamm1-id | | ||
And the following transfers should happen: | ||
| from | from account | to | to account | market id | amount | asset | is amm | type | | ||
| vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL | | 1000 | USD | true | TRANSFER_TYPE_AMM_SUBACCOUNT_LOW | | ||
|
||
@VAMMPOS | ||
Scenario: the distressed party uncrosses with the vAMM orders | ||
# move to ahead to the disposal time step | ||
When the network moves ahead "5" blocks | ||
Then the following trades should be executed: | ||
| buyer | price | size | seller | is amm | | ||
| network | 106 | 1 | vamm1-id | true | |