diff --git a/core/integration/features/volume-rebate/0095-HVMR.feature b/core/integration/features/volume-rebate/0095-HVMR.feature index f18b9b3c73..9d8a2c2150 100644 --- a/core/integration/features/volume-rebate/0095-HVMR.feature +++ b/core/integration/features/volume-rebate/0095-HVMR.feature @@ -340,3 +340,66 @@ Feature: Volume rebate program - contributions from trades | party2 | aux1 | 1 | 50000 | sell | 500 | 500 | + + Scenario Outline: Trades on auction uncrossing do not generate maker rebates but do generate buyback and treassury fees + + Given the volume rebate program tiers named "vrt": + | fraction | rebate | + | 0.0001 | 0.001 | + And the volume rebate program: + | id | tiers | closing timestamp | window length | + | id | vrt | 0 | 1 | + And the network moves ahead "1" epochs + + Given the parties place the following orders: + | party | market id | side | volume | price | resulting trades | type | tif | error | + | party1 | | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | + | party2 | | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | + When the network moves ahead "1" blocks + Then the following trades should be executed: + | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | + | party1 | party2 | 1 | 50000 | sell | 0 | 500 | + + # In the following epoch, party1 and party2 are both the maker of a + # trade but only party1 recevieves a rebate. + Given the network moves ahead "1" epochs + And the parties place the following orders: + | party | market id | side | volume | price | resulting trades | type | tif | error | + | party1 | | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | + | party2 | | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | + | aux1 | | sell | 2 | 50000 | 2 | TYPE_LIMIT | TIF_GTC | | + When the network moves ahead "1" blocks + Then the following trades should be executed: + | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | + | party1 | aux1 | 1 | 50000 | sell | 0 | 50 | + | party2 | aux1 | 1 | 50000 | sell | 0 | 0 | + Then the following transfers should happen: + | from | to | from account | to account | market id | amount | asset | type | + | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | | 50 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | + + Given the parties place the following orders: + | party | market id | side | volume | price | resulting trades | type | tif | error | reference | + | aux1 | | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | | auction-order-aux1 | + | aux2 | | sell | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | | auction-order-aux2 | + And the parties cancel the following orders: + | party | reference | + | aux1 | auction-order-aux1 | + | aux2 | auction-order-aux2 | + Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market + + # Exit the PM auction - no rebate should be collected + Given the parties place the following orders: + | party | market id | side | volume | price | resulting trades | type | tif | error | + | party1 | | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | + | party2 | | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | + When the network moves ahead "2" blocks + Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market + And the following trades should be executed: + | buyer | seller | size | price | aggressor side | buyer buyback fee | buyer treasury fee | seller buyback fee | seller treasury fee | buyer high volume maker fee | seller high volume maker fee | + | party1 | party2 | 1 | 50000 | | 2500 | 2500 | 2500 | 2500 | 0 | 0 | + + + Examples: + | market | market string | + | BTC/USD-0-1 | "BTC/USD-0-1" | + | MXN-0-10/USD-0-1 | "MXN-0-10/USD-0-1" | diff --git a/core/integration/steps/the_following_trades_happened.go b/core/integration/steps/the_following_trades_happened.go index 77f8552373..1f22ac7353 100644 --- a/core/integration/steps/the_following_trades_happened.go +++ b/core/integration/steps/the_following_trades_happened.go @@ -66,6 +66,8 @@ func TheFollowingTradesShouldBeExecuted( buyerMakerFeeReferrerDiscount, hasBuyerMakerFeeReferrerDiscount := row.DecimalB("buyer maker fee referrer discount") buyerLiqFeeReferrerDiscount, hasBuyerLiqFeeReferrerDiscount := row.DecimalB("buyer liquidity fee referrer discount") buyerHighVolumeMakerFee, hasBuyerHighVolumeMakerFee := row.DecimalB("buyer high volume maker fee") + buyerBuyBackFee, hasBuyerBuyBackFee := row.DecimalB("buyer buyback fee") + buyerTreasuryFee, hasBuyerTreasuryFee := row.DecimalB("buyer treasury fee") sellerFee, hasSellerFee := row.U64B("seller fee") sellerInfraFee, hasSellerInfraFee := row.U64B("seller infrastructure fee") @@ -78,6 +80,8 @@ func TheFollowingTradesShouldBeExecuted( sellerMakerFeeReferrerDiscount, hasSellerMakerFeeReferrerDiscount := row.DecimalB("seller maker fee referrer discount") sellerLiqFeeReferrerDiscount, hasSellerLiqFeeReferrerDiscount := row.DecimalB("seller liquidity fee referrer discount") sellerHighVolumeMakerFee, hasSellerHighVolumeMakerFee := row.DecimalB("seller high volume maker fee") + sellerBuyBackFee, hasSellerBuyBackFee := row.DecimalB("seller buyback fee") + sellerTreasuryFee, hasSellerTreasuryFee := row.DecimalB("seller treasury fee") data := broker.GetTrades() var found bool @@ -98,6 +102,8 @@ func TheFollowingTradesShouldBeExecuted( (!hasBuyerMakerFeeReferrerDiscount || buyerMakerFeeReferrerDiscount.Equal(num.MustDecimalFromString(v.BuyerFee.MakerFeeReferrerDiscount))) && (!hasBuyerLiqFeeReferrerDiscount || buyerLiqFeeReferrerDiscount.Equal(num.MustDecimalFromString(v.BuyerFee.LiquidityFeeReferrerDiscount))) && (!hasBuyerHighVolumeMakerFee || buyerHighVolumeMakerFee.Equal(num.MustDecimalFromString(v.BuyerFee.HighVolumeMakerFee))) && + (!hasBuyerBuyBackFee || buyerBuyBackFee.Equal(num.MustDecimalFromString(v.BuyerFee.BuyBackFee))) && + (!hasBuyerTreasuryFee || buyerTreasuryFee.Equal(num.MustDecimalFromString(v.BuyerFee.TreasuryFee))) && (!hasSellerFee || sellerFee == feeToU64(v.SellerFee)) && (!hasSellerInfraFee || sellerInfraFee == stringToU64(v.SellerFee.InfrastructureFee)) && (!hasSellerMakerFee || sellerMakerFee == stringToU64(v.SellerFee.MakerFee)) && @@ -108,7 +114,9 @@ func TheFollowingTradesShouldBeExecuted( (!hasSellerInfraFeeReferrerDiscount || sellerInfraFeeReferrerDiscount.Equal(num.MustDecimalFromString(v.SellerFee.InfrastructureFeeReferrerDiscount))) && (!hasSellerMakerFeeReferrerDiscount || sellerMakerFeeReferrerDiscount.Equal(num.MustDecimalFromString(v.SellerFee.MakerFeeReferrerDiscount))) && (!hasSellerLiqFeeReferrerDiscount || sellerLiqFeeReferrerDiscount.Equal(num.MustDecimalFromString(v.SellerFee.LiquidityFeeReferrerDiscount))) && - (!hasSellerHighVolumeMakerFee || sellerHighVolumeMakerFee.Equal(num.MustDecimalFromString(v.SellerFee.HighVolumeMakerFee))) { + (!hasSellerHighVolumeMakerFee || sellerHighVolumeMakerFee.Equal(num.MustDecimalFromString(v.SellerFee.HighVolumeMakerFee))) && + (!hasSellerBuyBackFee || sellerBuyBackFee.Equal(num.MustDecimalFromString(v.SellerFee.BuyBackFee))) && + (!hasSellerTreasuryFee || sellerTreasuryFee.Equal(num.MustDecimalFromString(v.SellerFee.TreasuryFee))) { found = true } } @@ -139,6 +147,8 @@ func parseExecutedTradesTable(table *godog.Table) []RowWrapper { "buyer infrastructure fee", "buyer liquidity fee", "buyer maker fee", + "buyer buyback fee", + "buyer treasury fee", "buyer infrastructure fee volume discount", "buyer liquidity fee volume discount", "buyer maker fee volume discount", @@ -151,6 +161,8 @@ func parseExecutedTradesTable(table *godog.Table) []RowWrapper { "seller infrastructure fee", "seller liquidity fee", "seller maker fee", + "seller buyback fee", + "seller treasury fee", "seller infrastructure fee volume discount", "seller liquidity fee volume discount", "seller maker fee volume discount",