Documentation ¶
Index ¶
- Variables
- func EstimateFee(assetQuantum num.Decimal, maxQuantumAmount num.Decimal, ...) (fee *num.Uint, discount *num.Uint)
- type Assets
- type Collateral
- type Config
- type ERC20BridgeView
- type Engine
- func (e *Engine) ApplyFeeDiscount(ctx context.Context, asset string, party string, fee *num.Uint) (discountedFee *num.Uint, discount *num.Uint)
- func (e *Engine) AvailableFeeDiscount(asset string, party string) *num.Uint
- func (e *Engine) BridgeResumed(ctx context.Context, resumed bool, id string, block, logIndex uint64, ...) error
- func (e *Engine) BridgeStopped(ctx context.Context, stopped bool, id string, block, logIndex uint64, ...) error
- func (e *Engine) CalculateGovernanceTransferAmount(asset string, market string, accountType types.AccountType, ...) (*num.Uint, error)
- func (e *Engine) CancelGovTransfer(ctx context.Context, ID string) error
- func (e *Engine) CancelTransferFunds(ctx context.Context, cancel *types.CancelTransferFunds) error
- func (e *Engine) CheckTransfer(t *types.TransferBase) error
- func (e *Engine) Checkpoint() ([]byte, error)
- func (e *Engine) DepositBuiltinAsset(ctx context.Context, d *types.BuiltinAssetDeposit, id string, nonce uint64) error
- func (e *Engine) DepositERC20(ctx context.Context, d *types.ERC20Deposit, id string, ...) error
- func (e *Engine) ERC20WithdrawalEvent(ctx context.Context, w *types.ERC20Withdrawal, blockNumber, txIndex uint64, ...) error
- func (e *Engine) EnableBuiltinAsset(ctx context.Context, assetID string) error
- func (e *Engine) EnableERC20(_ context.Context, al *types.ERC20AssetList, id string, ...) error
- func (e *Engine) EstimateFeeDiscount(asset string, party string, fee *num.Uint) (discountedFee *num.Uint, discount *num.Uint)
- func (e *Engine) GetDispatchStrategy(hash string) *proto.DispatchStrategy
- func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)
- func (e *Engine) Keys() []string
- func (e *Engine) Load(ctx context.Context, data []byte) error
- func (e *Engine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)
- func (e *Engine) Name() types.CheckpointName
- func (e *Engine) Namespace() types.SnapshotNamespace
- func (e *Engine) NewGovernanceTransfer(ctx context.Context, ID, reference string, ...) error
- func (e *Engine) OnEpoch(ctx context.Context, ep types.Epoch)
- func (e *Engine) OnEpochRestore(ctx context.Context, ep types.Epoch)
- func (e *Engine) OnMaxAmountChanged(ctx context.Context, f num.Decimal) error
- func (e *Engine) OnMaxFractionChanged(ctx context.Context, f num.Decimal) error
- func (e *Engine) OnMaxQuantumAmountUpdate(ctx context.Context, f num.Decimal) error
- func (e *Engine) OnMinTransferQuantumMultiple(ctx context.Context, f num.Decimal) error
- func (e *Engine) OnMinWithdrawQuantumMultiple(ctx context.Context, f num.Decimal) error
- func (e *Engine) OnStateLoaded(ctx context.Context) error
- func (e *Engine) OnTick(ctx context.Context, _ time.Time)
- func (e *Engine) OnTransferFeeDiscountDecayFractionUpdate(ctx context.Context, v num.Decimal) error
- func (e *Engine) OnTransferFeeDiscountMinimumTrackedAmountUpdate(ctx context.Context, v num.Decimal) error
- func (e *Engine) OnTransferFeeFactorUpdate(ctx context.Context, f num.Decimal) error
- func (e *Engine) RegisterTradingFees(ctx context.Context, assetID string, feesPerParty map[string]*num.Uint)
- func (e *Engine) ReloadConf(cfg Config)
- func (e *Engine) Stopped() bool
- func (e *Engine) TransferFunds(ctx context.Context, transfer *types.TransferFunds) error
- func (e *Engine) UpdateERC20(_ context.Context, event *types.ERC20AssetLimitsUpdated, id string, ...) error
- func (e *Engine) VerifyCancelGovernanceTransfer(transferID string) error
- func (e *Engine) VerifyGovernanceTransfer(transfer *types.NewTransferConfiguration) error
- func (e *Engine) WithdrawBuiltinAsset(ctx context.Context, id, party, assetID string, amount *num.Uint) error
- func (e *Engine) WithdrawERC20(ctx context.Context, id, party, assetID string, amount *num.Uint, ...) error
- type EpochService
- type EthereumEventSource
- type MarketActivityTracker
- type Notary
- type TimeService
- type Topology
- type Witness
Constants ¶
This section is empty.
Variables ¶
var ( ErrRecurringTransferDoesNotExists = errors.New("recurring transfer does not exists") ErrCannotCancelOtherPartiesRecurringTransfers = errors.New("cannot cancel other parties recurring transfers") )
var ( ErrWrongAssetTypeUsedInBuiltinAssetChainEvent = errors.New("non builtin asset used for builtin asset chain event") ErrWrongAssetTypeUsedInERC20ChainEvent = errors.New("non ERC20 for ERC20 chain event") ErrWrongAssetUsedForERC20Withdraw = errors.New("non erc20 asset used for lock withdraw") ErrInvalidWithdrawalState = errors.New("invalid withdrawal state") ErrNotMatchingWithdrawalForReference = errors.New("invalid reference for withdrawal chain event") ErrWithdrawalNotReady = errors.New("withdrawal not ready") ErrNotEnoughFundsToTransfer = errors.New("not enough funds to transfer") )
var ( ErrInvalidWithdrawalReferenceNonce = errors.New("invalid withdrawal reference nonce") ErrWithdrawalAmountUnderMinimalRequired = errors.New("invalid withdrawal, amount under minimum required") ErrAssetAlreadyBeingListed = errors.New("asset already being listed") ErrWithdrawalDisabledWhenBridgeIsStopped = errors.New("withdrawal issuance is disabled when the erc20 is stopped") )
var ( ErrStartEpochInThePast = errors.New("start epoch in the past") ErrCannotSubmitDuplicateRecurringTransferWithSameFromAndTo = errors.New("cannot submit duplicate recurring transfer with same from and to") )
var ErrUnknownAssetAction = errors.New("unknown asset action")
var ErrUnsupportedTransferKind = errors.New("unsupported transfer kind")
Functions ¶
func EstimateFee ¶ added in v0.74.0
func EstimateFee( assetQuantum num.Decimal, maxQuantumAmount num.Decimal, transferFeeFactor num.Decimal, amount *num.Uint, accumulatedDiscount *num.Uint, from string, fromAccountType types.AccountType, to string, ) (fee *num.Uint, discount *num.Uint)
EstimateFee returns a transaction fee estimate with potential discount that can be applied to it.
Types ¶
type Collateral ¶
type Collateral interface { Deposit(ctx context.Context, party, asset string, amount *num.Uint) (*types.LedgerMovement, error) Withdraw(ctx context.Context, party, asset string, amount *num.Uint) (*types.LedgerMovement, error) EnableAsset(ctx context.Context, asset types.Asset) error GetPartyGeneralAccount(party, asset string) (*types.Account, error) GetPartyVestedRewardAccount(partyID, asset string) (*types.Account, error) TransferFunds(ctx context.Context, transfers []*types.Transfer, accountTypes []types.AccountType, references []string, feeTransfers []*types.Transfer, feeTransfersAccountTypes []types.AccountType, ) ([]*types.LedgerMovement, error) GovernanceTransferFunds(ctx context.Context, transfers []*types.Transfer, accountTypes []types.AccountType, references []string) ([]*types.LedgerMovement, error) PropagateAssetUpdate(ctx context.Context, asset types.Asset) error GetSystemAccountBalance(asset, market string, accountType types.AccountType) (*num.Uint, error) }
Collateral engine.
type Config ¶
Config represents governance specific configuration.
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig creates an instance of the package specific configuration.
type ERC20BridgeView ¶
type ERC20BridgeView interface { FindAssetList(al *types.ERC20AssetList, blockNumber, logIndex uint64, txHash string) error FindBridgeStopped(al *types.ERC20EventBridgeStopped, blockNumber, logIndex uint64, txHash string) error FindBridgeResumed(al *types.ERC20EventBridgeResumed, blockNumber, logIndex uint64, txHash string) error FindDeposit(d *types.ERC20Deposit, blockNumber, logIndex uint64, ethAssetAddress string, txHash string) error FindAssetLimitsUpdated(update *types.ERC20AssetLimitsUpdated, blockNumber uint64, logIndex uint64, ethAssetAddress string, txHash string) error }
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func New ¶
func New( log *logging.Logger, cfg Config, col Collateral, witness Witness, tsvc TimeService, assets Assets, notary Notary, broker broker.Interface, top Topology, marketActivityTracker MarketActivityTracker, bridgeView ERC20BridgeView, ethEventSource EthereumEventSource, ) (e *Engine)
func (*Engine) ApplyFeeDiscount ¶ added in v0.74.0
func (*Engine) AvailableFeeDiscount ¶ added in v0.74.0
func (*Engine) BridgeResumed ¶
func (*Engine) BridgeStopped ¶
func (*Engine) CalculateGovernanceTransferAmount ¶ added in v0.72.0
func (e *Engine) CalculateGovernanceTransferAmount(asset string, market string, accountType types.AccountType, fraction num.Decimal, amount *num.Uint, transferType vegapb.GovernanceTransferType) (*num.Uint, error)
CalculateGovernanceTransferAmount calculates the balance of a governance transfer as follows:
transfer_amount = min(
proposal.fraction_of_balance * source.balance, proposal.amount, NETWORK_MAX_AMOUNT, NETWORK_MAX_FRACTION * source.balance
) where NETWORK_MAX_AMOUNT is a network parameter specifying the maximum absolute amount that can be transferred by governance for the source account type NETWORK_MAX_FRACTION is a network parameter specifying the maximum fraction of the balance that can be transferred by governance for the source account type (must be <= 1)
If type is "all or nothing" then the transfer will only proceed if:
transfer_amount == min(proposal.fraction_of_balance * source.balance,proposal.amount).
func (*Engine) CancelGovTransfer ¶ added in v0.72.0
func (*Engine) CancelTransferFunds ¶
func (*Engine) CheckTransfer ¶ added in v0.68.0
func (e *Engine) CheckTransfer(t *types.TransferBase) error
func (*Engine) Checkpoint ¶
func (*Engine) DepositBuiltinAsset ¶
func (*Engine) DepositERC20 ¶
func (*Engine) ERC20WithdrawalEvent ¶
func (*Engine) EnableBuiltinAsset ¶
func (*Engine) EnableERC20 ¶
func (*Engine) EstimateFeeDiscount ¶ added in v0.74.0
func (*Engine) GetDispatchStrategy ¶ added in v0.73.0
func (e *Engine) GetDispatchStrategy(hash string) *proto.DispatchStrategy
func (*Engine) Name ¶
func (e *Engine) Name() types.CheckpointName
func (*Engine) Namespace ¶
func (e *Engine) Namespace() types.SnapshotNamespace
func (*Engine) NewGovernanceTransfer ¶ added in v0.72.0
func (*Engine) OnEpochRestore ¶
func (*Engine) OnMaxAmountChanged ¶ added in v0.72.0
func (*Engine) OnMaxFractionChanged ¶ added in v0.72.0
func (*Engine) OnMaxQuantumAmountUpdate ¶ added in v0.74.0
func (*Engine) OnMinTransferQuantumMultiple ¶
func (*Engine) OnMinWithdrawQuantumMultiple ¶ added in v0.67.0
func (*Engine) OnStateLoaded ¶ added in v0.69.0
func (*Engine) OnTransferFeeDiscountDecayFractionUpdate ¶ added in v0.74.0
func (*Engine) OnTransferFeeDiscountMinimumTrackedAmountUpdate ¶ added in v0.74.0
func (*Engine) OnTransferFeeFactorUpdate ¶
func (*Engine) RegisterTradingFees ¶ added in v0.74.0
func (*Engine) ReloadConf ¶
ReloadConf updates the internal configuration.
func (*Engine) TransferFunds ¶
func (*Engine) UpdateERC20 ¶
func (*Engine) VerifyCancelGovernanceTransfer ¶ added in v0.72.0
func (*Engine) VerifyGovernanceTransfer ¶ added in v0.72.0
func (e *Engine) VerifyGovernanceTransfer(transfer *types.NewTransferConfiguration) error
func (*Engine) WithdrawBuiltinAsset ¶
type EpochService ¶
type EpochService interface {
NotifyOnEpoch(f func(context.Context, types.Epoch), r func(context.Context, types.Epoch))
}
Epochervice ...
type EthereumEventSource ¶ added in v0.69.0
type EthereumEventSource interface {
UpdateCollateralStartingBlock(uint64)
}
type MarketActivityTracker ¶
type MarketActivityTracker interface { CalculateMetricForIndividuals(ds *vega.DispatchStrategy) []*types.PartyContributionScore CalculateMetricForTeams(ds *vega.DispatchStrategy) ([]*types.PartyContributionScore, map[string][]*types.PartyContributionScore) GetMarketsWithEligibleProposer(asset string, markets []string, payoutAsset string, funder string) []*types.MarketContributionScore MarkPaidProposer(asset, market, payoutAsset string, marketsInScope []string, funder string) MarketTrackedForAsset(market, asset string) bool TeamStatsForMarkets(allMarketsForAssets, onlyTheseMarkets []string) map[string]map[string]*num.Uint }
type Notary ¶
type Notary interface { StartAggregate(resID string, kind types.NodeSignatureKind, signature []byte) IsSigned(ctx context.Context, id string, kind types.NodeSignatureKind) ([]types.NodeSignature, bool) OfferSignatures(kind types.NodeSignatureKind, f func(resources string) []byte) }
type TimeService ¶
TimeService provide the time of the vega node using the tm time.