code.vegaprotocol.io/vega@v0.79.0/core/integration/steps/the_referral_benefit_tiers_configuration.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package steps
    17  
    18  import (
    19  	referralcfg "code.vegaprotocol.io/vega/core/integration/steps/referral"
    20  	"code.vegaprotocol.io/vega/core/types"
    21  	"code.vegaprotocol.io/vega/libs/num"
    22  
    23  	"github.com/cucumber/godog"
    24  )
    25  
    26  func TheReferralBenefitTiersConfiguration(config *referralcfg.Config, name string, table *godog.Table) error {
    27  	benefitTiers := parseBenefitTiersConfigTable(table)
    28  
    29  	config.BenefitTiersConfigs.Add(name, benefitTiers)
    30  	return nil
    31  }
    32  
    33  func parseBenefitTiersConfigTable(table *godog.Table) []*types.BenefitTier {
    34  	rows := StrictParseTable(table, []string{
    35  		"minimum running notional taker volume",
    36  		"minimum epochs",
    37  		"referral reward infra factor",
    38  		"referral reward maker factor",
    39  		"referral reward liquidity factor",
    40  		"referral discount infra factor",
    41  		"referral discount maker factor",
    42  		"referral discount liquidity factor",
    43  	}, []string{})
    44  
    45  	benefitTiers := make([]*types.BenefitTier, 0, len(rows))
    46  	for _, row := range rows {
    47  		specificRow := benefitTiersConfigRow{row: row}
    48  		benefitTiers = append(benefitTiers, &types.BenefitTier{
    49  			MinimumRunningNotionalTakerVolume: specificRow.MinimumRunningNotionalTakerVolume(),
    50  			MinimumEpochs:                     specificRow.MinimumEpochs(),
    51  			ReferralRewardFactors: types.Factors{
    52  				Infra:     specificRow.ReferralRewardInfraFactor(),
    53  				Maker:     specificRow.ReferralRewardMakerFactor(),
    54  				Liquidity: specificRow.ReferralRewardLiqFactor(),
    55  			},
    56  			ReferralDiscountFactors: types.Factors{
    57  				Infra:     specificRow.ReferralDiscountInfraFactor(),
    58  				Maker:     specificRow.ReferralDiscountMakerFactor(),
    59  				Liquidity: specificRow.ReferralDiscountLiqFactor(),
    60  			},
    61  		})
    62  	}
    63  
    64  	return benefitTiers
    65  }
    66  
    67  type benefitTiersConfigRow struct {
    68  	row RowWrapper
    69  }
    70  
    71  func (r benefitTiersConfigRow) MinimumRunningNotionalTakerVolume() *num.Uint {
    72  	return r.row.MustUint("minimum running notional taker volume")
    73  }
    74  
    75  func (r benefitTiersConfigRow) MinimumEpochs() *num.Uint {
    76  	return r.row.MustUint("minimum epochs")
    77  }
    78  
    79  func (r benefitTiersConfigRow) ReferralRewardInfraFactor() num.Decimal {
    80  	return r.row.MustDecimal("referral reward infra factor")
    81  }
    82  
    83  func (r benefitTiersConfigRow) ReferralRewardMakerFactor() num.Decimal {
    84  	return r.row.MustDecimal("referral reward maker factor")
    85  }
    86  
    87  func (r benefitTiersConfigRow) ReferralRewardLiqFactor() num.Decimal {
    88  	return r.row.MustDecimal("referral reward liquidity factor")
    89  }
    90  
    91  func (r benefitTiersConfigRow) ReferralDiscountInfraFactor() num.Decimal {
    92  	return r.row.MustDecimal("referral discount infra factor")
    93  }
    94  
    95  func (r benefitTiersConfigRow) ReferralDiscountMakerFactor() num.Decimal {
    96  	return r.row.MustDecimal("referral discount maker factor")
    97  }
    98  
    99  func (r benefitTiersConfigRow) ReferralDiscountLiqFactor() num.Decimal {
   100  	return r.row.MustDecimal("referral discount liquidity factor")
   101  }