Documentation ¶
Index ¶
- Variables
- type Config
- type Engine
- func (e *Engine) BuildLiquidityFeeAllocationTransfer(shares map[string]num.Decimal, acc *types.Account) events.FeesTransfer
- func (e *Engine) BuildLiquidityFeeDistributionTransfer(shares map[string]num.Decimal, acc *types.Account) events.FeesTransfer
- func (e *Engine) CalculateForAuctionMode(trades []*types.Trade, referral ReferralDiscountRewardService, ...) (events.FeesTransfer, error)
- func (e *Engine) CalculateForContinuousMode(trades []*types.Trade, referral ReferralDiscountRewardService, ...) (events.FeesTransfer, error)
- func (e *Engine) CalculateForFrequentBatchesAuctionMode(trades []*types.Trade, referral ReferralDiscountRewardService, ...) (events.FeesTransfer, error)
- func (e *Engine) GetFeeForPositionResolution(trades []*types.Trade, referral ReferralDiscountRewardService, ...) (events.FeesTransfer, *types.Fee)
- func (e *Engine) GetFeesStatsOnEpochEnd(assetQuantum num.Decimal) (FeesStats *eventspb.FeesStats)
- func (e *Engine) GetLiquidityFee() num.Decimal
- func (e *Engine) GetState(assetQuantum num.Decimal) *eventspb.FeesStats
- func (e *Engine) OnFeeFactorsBuyBackFeeUpdate(f num.Decimal)
- func (e *Engine) OnFeeFactorsInfrastructureFeeUpdate(f num.Decimal)
- func (e *Engine) OnFeeFactorsMakerFeeUpdate(f num.Decimal)
- func (e *Engine) OnFeeFactorsTreasuryFeeUpdate(f num.Decimal)
- func (e *Engine) ReloadConf(cfg Config)
- func (e *Engine) SetLiquidityFee(v num.Decimal)
- func (e *Engine) TotalTradingFeesPerParty() map[string]*num.Uint
- func (e *Engine) UpdateFeeFactors(fees types.Fees) error
- type FeesStats
- func (f *FeesStats) RegisterMakerFee(makerID, takerID string, amount *num.Uint)
- func (f *FeesStats) RegisterRefereeDiscount(party string, amount *num.Uint)
- func (f *FeesStats) RegisterReferrerReward(referrer, referee string, amount *num.Uint)
- func (f *FeesStats) RegisterTradingFees(partyID string, amount *num.Uint)
- func (f *FeesStats) RegisterVolumeDiscount(party string, amount *num.Uint)
- func (f *FeesStats) ToProto(asset string, assetQuantum num.Decimal) *eventspb.FeesStats
- func (f *FeesStats) TotalTradingFeesPerParty() map[string]*num.Uint
- type ReferralDiscountRewardService
- type VolumeDiscountService
- type VolumeRebateService
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyTrades = errors.New("empty trades slice sent to fees") ErrInvalidFeeFactor = errors.New("fee factors must be positive") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config represent the configuration of the fee engine.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewFromState ¶ added in v0.73.0
func (*Engine) BuildLiquidityFeeAllocationTransfer ¶ added in v0.72.0
func (e *Engine) BuildLiquidityFeeAllocationTransfer(shares map[string]num.Decimal, acc *types.Account) events.FeesTransfer
BuildLiquidityFeeAllocationTransfer returns the set of transfers that will be used by the collateral engine to allocate the fees to liquidity providers per market fee accounts. As shares are represented in float64 and fees are uint64, shares are floored and the remainder is assigned to the last party on the share map. Note that the map is sorted lexicographically to keep determinism.
func (*Engine) BuildLiquidityFeeDistributionTransfer ¶
func (e *Engine) BuildLiquidityFeeDistributionTransfer(shares map[string]num.Decimal, acc *types.Account) events.FeesTransfer
BuildLiquidityFeeDistributionTransfer returns the set of transfers that will be used by the collateral engine to distribute the fees. As shares are represented in float64 and fees are uint64, shares are floored and the remainder is assigned to the last party on the share map. Note that the map is sorted lexicographically to keep determinism.
func (*Engine) CalculateForAuctionMode ¶
func (e *Engine) CalculateForAuctionMode( trades []*types.Trade, referral ReferralDiscountRewardService, volumeDiscount VolumeDiscountService, volumeRebate VolumeRebateService, ) (events.FeesTransfer, error)
CalculateForAuctionMode calculate the fee for trades which were produced from a market running in in auction trading mode. A list FeesTransfer is produced each containing fees transfer from a single party.
func (*Engine) CalculateForContinuousMode ¶
func (e *Engine) CalculateForContinuousMode( trades []*types.Trade, referral ReferralDiscountRewardService, volumeDiscountService VolumeDiscountService, volumeRebateService VolumeRebateService, ) (events.FeesTransfer, error)
CalculateForContinuousMode calculate the fee for trades which were produced from a market running in continuous trading mode. A single FeesTransfer is produced here as all fees are paid by the aggressive order.
func (*Engine) CalculateForFrequentBatchesAuctionMode ¶
func (e *Engine) CalculateForFrequentBatchesAuctionMode( trades []*types.Trade, referral ReferralDiscountRewardService, volumeDiscount VolumeDiscountService, volumeRebate VolumeRebateService, ) (events.FeesTransfer, error)
CalculateForFrequentBatchesAuctionMode calculate the fee for trades which were produced from a market running in auction trading mode. A list FeesTransfer is produced each containing fees transfer from a single party.
func (*Engine) GetFeeForPositionResolution ¶ added in v0.74.0
func (e *Engine) GetFeeForPositionResolution(trades []*types.Trade, referral ReferralDiscountRewardService, volumeDiscount VolumeDiscountService, volumeRebate VolumeRebateService, ) (events.FeesTransfer, *types.Fee)
func (*Engine) GetFeesStatsOnEpochEnd ¶ added in v0.73.0
func (*Engine) GetLiquidityFee ¶
func (*Engine) OnFeeFactorsBuyBackFeeUpdate ¶ added in v0.77.8
func (*Engine) OnFeeFactorsInfrastructureFeeUpdate ¶
func (*Engine) OnFeeFactorsMakerFeeUpdate ¶
func (*Engine) OnFeeFactorsTreasuryFeeUpdate ¶ added in v0.77.8
func (*Engine) ReloadConf ¶
ReloadConf is used in order to reload the internal configuration of the fee engine.
func (*Engine) SetLiquidityFee ¶
func (*Engine) TotalTradingFeesPerParty ¶ added in v0.74.0
type FeesStats ¶ added in v0.73.0
type FeesStats struct { // TotalMakerFeesReceived is the total of maker fees received by the maker side. // maker -> amount TotalMakerFeesReceived map[string]*num.Uint // TradingFeesPaidAndReceived tracks all trading fees paid and received by party. TradingFeesPaidAndReceived map[string]*num.Uint // MakerFeesGenerated tracks maker fees paid by taker (aggressor) to the maker. // taker -> maker -> amount MakerFeesGenerated map[string]map[string]*num.Uint // TotalRewardsReceived is the total of rewards received by the referrer. // referrer -> amount TotalRewardsReceived map[string]*num.Uint ReferrerRewardsGenerated map[string]map[string]*num.Uint RefereeDiscountApplied map[string]*num.Uint VolumeDiscountApplied map[string]*num.Uint }
func NewFeesStats ¶ added in v0.73.0
func NewFeesStats() *FeesStats
func NewFeesStatsFromProto ¶ added in v0.73.0
func (*FeesStats) RegisterMakerFee ¶ added in v0.73.0
func (*FeesStats) RegisterRefereeDiscount ¶ added in v0.73.0
func (*FeesStats) RegisterReferrerReward ¶ added in v0.73.0
func (*FeesStats) RegisterTradingFees ¶ added in v0.74.0
RegisterTradingFees registers fees paid or received by the party.