collateral

package
v0.79.0-preview.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSystemAccountsMissing signals that a system account is missing, which may means that the
	// collateral engine have not been initialised properly.
	ErrSystemAccountsMissing = errors.New("system accounts missing for collateral engine to work")
	// ErrFeeAccountsMissing signals that a fee account is missing, which may means that the
	// collateral engine have not been initialised properly.
	ErrFeeAccountsMissing = errors.New("fee accounts missing for collateral engine to work")
	// ErrPartyAccountsMissing signals that the accounts for this party do not exists.
	ErrPartyAccountsMissing = errors.New("party accounts missing, cannot collect")
	// ErrAccountDoesNotExist signals that an account par of a transfer do not exists.
	ErrAccountDoesNotExist                     = errors.New("account does not exists")
	ErrNoGeneralAccountWhenCreateMarginAccount = errors.New("party general account missing when trying to create a margin account")
	ErrNoGeneralAccountWhenCreateBondAccount   = errors.New("party general account missing when trying to create a bond account")
	ErrMinAmountNotReached                     = errors.New("unable to reach minimum amount transfer")
	ErrSettlementBalanceNotZero                = errors.New("settlement balance should be zero") // E991 YOU HAVE TOO MUCH ROPE TO HANG YOURSELF
	// ErrAssetAlreadyEnabled signals the given asset has already been enabled in this engine.
	ErrAssetAlreadyEnabled    = errors.New("asset already enabled")
	ErrAssetHasNotBeenEnabled = errors.New("asset has not been enabled")
	// ErrInvalidAssetID signals that an asset id does not exists.
	ErrInvalidAssetID = errors.New("invalid asset ID")
	// ErrInsufficientFundsToPayFees the party do not have enough funds to pay the feeds.
	ErrInsufficientFundsToPayFees = errors.New("insufficient funds to pay fees")
	// ErrInvalidTransferTypeForFeeRequest an invalid transfer type was send to build a fee transfer request.
	ErrInvalidTransferTypeForFeeRequest = errors.New("an invalid transfer type was send to build a fee transfer request")
	// ErrNotEnoughFundsToWithdraw a party requested to withdraw more than on its general account.
	ErrNotEnoughFundsToWithdraw = errors.New("not enough funds to withdraw")
	// ErrInsufficientFundsInAsset is returned if the party doesn't have sufficient funds to cover their order quantity.
	ErrInsufficientFundsInAsset = errors.New("insufficient funds for order")
)
View Source
var (
	ErrInvalidSnapshotNamespace = errors.New("invalid snapshot namespace")
	ErrUnknownSnapshotType      = errors.New("snapshot data type not known")
)

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Send(event events.Event)
	SendBatch(events []events.Event)
}

Broker send events we no longer need to generate this mock here, we can use the broker/mocks package instead.

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

Config represent the configuration of the collateral 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 {
	Config
	// contains filtered or unexported fields
}

Engine is handling the power of the collateral.

func New

func New(log *logging.Logger, conf Config, ts TimeService, broker Broker) *Engine

New instantiates a new collateral engine.

func (*Engine) ADtoID added in v0.56.0

func (e *Engine) ADtoID(ad *types.AccountDetails) string

func (*Engine) AssetExists

func (e *Engine) AssetExists(assetID string) bool

AssetExists no errors if the asset exists.

func (*Engine) BeginBlock added in v0.73.0

func (e *Engine) BeginBlock(ctx context.Context)

func (*Engine) BondSpotUpdate added in v0.72.0

func (e *Engine) BondSpotUpdate(ctx context.Context, market string, transfer *types.Transfer) (*types.LedgerMovement, error)

BondUpdate is to be used for any bond account transfers in a spot market. Update on new orders, updates on commitment changes, or on slashing.

func (*Engine) BondUpdate

func (e *Engine) BondUpdate(ctx context.Context, market string, transfer *types.Transfer) (*types.LedgerMovement, error)

BondUpdate is to be used for any bond account transfers. Update on new orders, updates on commitment changes, or on slashing.

func (*Engine) CanCoverBond

func (e *Engine) CanCoverBond(market, party, asset string, amount *num.Uint) bool

func (*Engine) CheckLeftOverBalance added in v0.58.0

func (e *Engine) CheckLeftOverBalance(ctx context.Context, settle *types.Account, transfers []*types.Transfer, asset string, factor *num.Uint) (*types.LedgerMovement, error)

func (*Engine) CheckOrderSpam added in v0.77.0

func (e *Engine) CheckOrderSpam(party, market string, assets []string) error

func (*Engine) CheckOrderSpamAllMarkets added in v0.77.0

func (e *Engine) CheckOrderSpamAllMarkets(party string) error

func (*Engine) Checkpoint

func (e *Engine) Checkpoint() ([]byte, error)

func (*Engine) ClearInsurancepool added in v0.72.0

func (e *Engine) ClearInsurancepool(ctx context.Context, mktID, asset string, clearFees bool) ([]*types.LedgerMovement, error)

func (*Engine) ClearMarket

func (e *Engine) ClearMarket(ctx context.Context, mktID, asset string, parties []string, keepInsurance bool) ([]*types.LedgerMovement, error)

ClearMarket will remove all monies or accounts for parties allocated for a market (margin accounts) when the market reach end of life (maturity).

func (*Engine) ClearPartyMarginAccount

func (e *Engine) ClearPartyMarginAccount(ctx context.Context, party, market, asset string) (*types.LedgerMovement, error)

func (*Engine) ClearPartyOrderMarginAccount added in v0.74.0

func (e *Engine) ClearPartyOrderMarginAccount(ctx context.Context, party, market, asset string) (*types.LedgerMovement, error)

func (*Engine) ClearSpotMarket added in v0.72.0

func (e *Engine) ClearSpotMarket(ctx context.Context, mktID, quoteAsset string, parties []string) ([]*types.LedgerMovement, error)

ClearSpotMarket moves remaining LP fees to the global reward account and removes market accounts.

func (*Engine) CreateMarketAccounts

func (e *Engine) CreateMarketAccounts(ctx context.Context, marketID, asset string) (insuranceID, settleID string, err error)

CreateMarketAccounts will create all required accounts for a market once a new market is accepted through the network.

func (*Engine) CreatePartyAMMsSubAccounts added in v0.77.0

func (e *Engine) CreatePartyAMMsSubAccounts(
	ctx context.Context,
	party, ammKey, asset, market string,
) (general *types.Account, margin *types.Account, err error)

CreatePartyAMMSubAccounts ...

func (*Engine) CreatePartyBondAccount

func (e *Engine) CreatePartyBondAccount(ctx context.Context, partyID, marketID, asset string) (string, error)

CreatePartyBondAccount creates a bond account if it does not exist, will return an error if no general account exist for the party for the given asset.

func (*Engine) CreatePartyGeneralAccount

func (e *Engine) CreatePartyGeneralAccount(ctx context.Context, partyID, asset string) (string, error)

CreatePartyGeneralAccount create the general account for a party.

func (*Engine) CreatePartyHoldingAccount added in v0.72.0

func (e *Engine) CreatePartyHoldingAccount(ctx context.Context, partyID, asset string) (string, error)

CreatePartyHoldingAccount creates a holding account for a party.

func (*Engine) CreatePartyLiquidityFeeAccount added in v0.72.0

func (e *Engine) CreatePartyLiquidityFeeAccount(ctx context.Context, partyID, marketID, asset string) (string, error)

CreatePartyLiquidityFeeAccount creates a bond account if it does not exist, will return an error if no general account exist for the party for the given asset.

func (*Engine) CreatePartyMarginAccount

func (e *Engine) CreatePartyMarginAccount(ctx context.Context, partyID, marketID, asset string) (string, error)

CreatePartyMarginAccount creates a margin account if it does not exist, will return an error if no general account exist for the party for the given asset.

func (*Engine) CreateSpotMarketAccounts added in v0.72.0

func (e *Engine) CreateSpotMarketAccounts(ctx context.Context, marketID, quoteAsset string) error

CreateSpotMarketAccounts creates the required accounts for a market.

func (*Engine) Deposit

func (e *Engine) Deposit(ctx context.Context, partyID, asset string, amount *num.Uint) (*types.LedgerMovement, error)

Deposit will deposit the given amount into the party account.

func (*Engine) EarmarkForAutomatedPurchase

func (e *Engine) EarmarkForAutomatedPurchase(asset string, accountType types.AccountType, min, max *num.Uint) (*num.Uint, error)

func (*Engine) EnableAsset

func (e *Engine) EnableAsset(ctx context.Context, asset types.Asset) error

EnableAsset adds a new asset in the collateral engine this enable the asset to be used by new markets or parties to deposit funds.

func (*Engine) FinalSettlement

func (e *Engine) FinalSettlement(ctx context.Context, marketID string, transfers []*types.Transfer, factor *num.Uint, useGeneralAccountForMarginSearch func(string) bool) ([]*types.LedgerMovement, error)

FinalSettlement will process the list of transfers instructed by other engines This func currently only expects TransferType_{LOSS,WIN} transfers other transfer types have dedicated funcs (MarkToMarket, MarginUpdate).

func (*Engine) GetAccountByID

func (e *Engine) GetAccountByID(id string) (*types.Account, error)

GetAccountByID will return an account using the given id.

func (*Engine) GetAllParties added in v0.78.0

func (e *Engine) GetAllParties() []string

func (*Engine) GetAllVestingQuantumBalance added in v0.73.0

func (e *Engine) GetAllVestingQuantumBalance(party string) num.Decimal

func (*Engine) GetAssetQuantum

func (e *Engine) GetAssetQuantum(asset string) (num.Decimal, error)

func (*Engine) GetEnabledAssets

func (e *Engine) GetEnabledAssets() []string

GetEnabledAssets returns the asset IDs of all enabled assets.

func (*Engine) GetGlobalInsuranceAccount added in v0.73.0

func (e *Engine) GetGlobalInsuranceAccount(asset string) (*types.Account, error)

func (*Engine) GetGlobalRewardAccount

func (e *Engine) GetGlobalRewardAccount(asset string) (*types.Account, error)

func (*Engine) GetInfraFeeAccountIDs

func (e *Engine) GetInfraFeeAccountIDs() []string

GetInfraFeeAccountIDs returns the account IDs of the infrastructure fee accounts for all enabled assets.

func (*Engine) GetInsurancePoolBalance added in v0.72.0

func (e *Engine) GetInsurancePoolBalance(marketID, asset string) (*num.Uint, bool)

func (*Engine) GetLiquidityFeesBonusDistributionAccount added in v0.72.0

func (e *Engine) GetLiquidityFeesBonusDistributionAccount(marketID, asset string) (*types.Account, error)

func (*Engine) GetMarketInsurancePoolAccount

func (e *Engine) GetMarketInsurancePoolAccount(market, asset string) (*types.Account, error)

func (*Engine) GetMarketLiquidityFeeAccount

func (e *Engine) GetMarketLiquidityFeeAccount(market, asset string) (*types.Account, error)

func (*Engine) GetMarketMakerFeeAccount added in v0.72.0

func (e *Engine) GetMarketMakerFeeAccount(market, asset string) (*types.Account, error)

func (*Engine) GetNetworkTreasuryAccount added in v0.73.0

func (e *Engine) GetNetworkTreasuryAccount(asset string) (*types.Account, error)

func (*Engine) GetOrCreateBuyBackFeesAccountID

func (e *Engine) GetOrCreateBuyBackFeesAccountID(ctx context.Context, asset string) string

func (*Engine) GetOrCreateGlobalInsuranceAccount added in v0.73.0

func (e *Engine) GetOrCreateGlobalInsuranceAccount(ctx context.Context, asset string) *types.Account

func (*Engine) GetOrCreateLiquidityFeesBonusDistributionAccount added in v0.72.0

func (e *Engine) GetOrCreateLiquidityFeesBonusDistributionAccount(
	ctx context.Context,
	marketID,
	asset string,
) (*types.Account, error)

GetOrCreateLiquidityFeesBonusDistributionAccount returns a liquidity fees bonus distribution account given a set of parameters. crates it if not exists.

func (*Engine) GetOrCreateMarketInsurancePoolAccount added in v0.71.0

func (e *Engine) GetOrCreateMarketInsurancePoolAccount(ctx context.Context, market, asset string) *types.Account

func (*Engine) GetOrCreateNetworkTreasuryAccount added in v0.73.0

func (e *Engine) GetOrCreateNetworkTreasuryAccount(ctx context.Context, asset string) *types.Account

func (*Engine) GetOrCreatePartyBondAccount

func (e *Engine) GetOrCreatePartyBondAccount(ctx context.Context, partyID, marketID, asset string) (*types.Account, error)

GetOrCreatePartyBondAccount returns a bond account given a set of parameters. crates it if not exists.

func (*Engine) GetOrCreatePartyLiquidityFeeAccount added in v0.72.0

func (e *Engine) GetOrCreatePartyLiquidityFeeAccount(ctx context.Context, partyID, marketID, asset string) (*types.Account, error)

GetOrCreatePartyLiquidityFeeAccount returns a party liquidity fee account given a set of parameters. Crates it if not exists.

func (*Engine) GetOrCreatePartyOrderMarginAccount added in v0.74.0

func (e *Engine) GetOrCreatePartyOrderMarginAccount(ctx context.Context, partyID, marketID, asset string) (string, error)

func (*Engine) GetOrCreatePartyVestedRewardAccount added in v0.73.0

func (e *Engine) GetOrCreatePartyVestedRewardAccount(ctx context.Context, partyID, asset string) *types.Account

GetOrCreatePartyVestedRewardAccount create the general account for a party.

func (*Engine) GetOrCreatePartyVestingRewardAccount added in v0.73.0

func (e *Engine) GetOrCreatePartyVestingRewardAccount(ctx context.Context, partyID, asset string) *types.Account

GetOrCreatePartyVestingRewardAccount create the general account for a party.

func (*Engine) GetOrCreateRewardAccount

func (e *Engine) GetOrCreateRewardAccount(ctx context.Context, asset string, market string, rewardAcccountType types.AccountType) (*types.Account, error)

GetRewardAccount returns a reward accound by asset and type.

func (*Engine) GetPartyBalance added in v0.73.0

func (e *Engine) GetPartyBalance(party string) *num.Uint

func (*Engine) GetPartyBondAccount

func (e *Engine) GetPartyBondAccount(market, partyID, asset string) (*types.Account, error)

GetPartyBondAccount returns a general account given the partyID.

func (*Engine) GetPartyGeneralAccount

func (e *Engine) GetPartyGeneralAccount(partyID, asset string) (*types.Account, error)

GetPartyGeneralAccount returns a general account given the partyID.

func (*Engine) GetPartyHoldingAccount added in v0.73.0

func (e *Engine) GetPartyHoldingAccount(party, asset string) (*types.Account, error)

GetPartyHoldingAccount returns a holding account given the partyID and market.

func (*Engine) GetPartyLiquidityFeeAccount added in v0.72.0

func (e *Engine) GetPartyLiquidityFeeAccount(market, partyID, asset string) (*types.Account, error)

GetPartyLiquidityFeeAccount returns a liquidity fee account account given the partyID.

func (*Engine) GetPartyMargin

func (e *Engine) GetPartyMargin(pos events.MarketPosition, asset, marketID string) (events.Margin, error)

GetPartyMargin will return the current margin for a given party.

func (*Engine) GetPartyMarginAccount

func (e *Engine) GetPartyMarginAccount(market, party, asset string) (*types.Account, error)

GetPartyMarginAccount returns a margin account given the partyID and market.

func (*Engine) GetPartyOrderMarginAccount added in v0.74.0

func (e *Engine) GetPartyOrderMarginAccount(market, party, asset string) (*types.Account, error)

GetPartyOrderMarginAccount returns a margin account given the partyID and market.

func (*Engine) GetPartyVestedRewardAccount added in v0.73.0

func (e *Engine) GetPartyVestedRewardAccount(partyID, asset string) (*types.Account, error)

func (*Engine) GetPendingTransfersAccount

func (e *Engine) GetPendingTransfersAccount(asset string) *types.Account

GetPendingTransferAccount return the pending transfers account for the asset.

func (*Engine) GetRewardAccountsByType

func (e *Engine) GetRewardAccountsByType(rewardAcccountType types.AccountType) []*types.Account

func (*Engine) GetState

func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Engine) GetSystemAccountBalance added in v0.72.0

func (e *Engine) GetSystemAccountBalance(asset, market string, accountType types.AccountType) (*num.Uint, error)

func (*Engine) GetVestingAccounts added in v0.73.8

func (e *Engine) GetVestingAccounts() []*types.Account

func (*Engine) GetVestingRecovery added in v0.73.0

func (e *Engine) GetVestingRecovery() map[string]map[string]*num.Uint

func (*Engine) GovernanceTransferFunds added in v0.72.0

func (e *Engine) GovernanceTransferFunds(
	ctx context.Context,
	transfers []*types.Transfer,
	accountTypes []types.AccountType,
	references []string,
) ([]*types.LedgerMovement, error)

func (*Engine) HasGeneralAccount

func (e *Engine) HasGeneralAccount(party, asset string) bool

func (*Engine) Hash

func (e *Engine) Hash() []byte

func (*Engine) IncrementBalance

func (e *Engine) IncrementBalance(ctx context.Context, id string, inc *num.Uint) error

IncrementBalance will increment the balance of a given account using the given value.

func (*Engine) IsolatedMarginUpdate added in v0.74.0

func (e *Engine) IsolatedMarginUpdate(updates []events.Risk) []events.Margin

IsolatedMarginUpdate returns margin events for parties that don't meet their margin requirement (i.e. margin balance < maintenance).

func (*Engine) Keys

func (e *Engine) Keys() []string

func (*Engine) Load

func (e *Engine) Load(ctx context.Context, data []byte) error

func (*Engine) LoadState

func (e *Engine) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)

func (*Engine) MarginUpdate

func (e *Engine) MarginUpdate(ctx context.Context, marketID string, updates []events.Risk) ([]*types.LedgerMovement, []events.Margin, []events.Margin, error)

MarginUpdate will run the margin updates over a set of risk events (margin updates).

func (*Engine) MarginUpdateOnOrder

func (e *Engine) MarginUpdateOnOrder(ctx context.Context, marketID string, update events.Risk) (*types.LedgerMovement, events.Margin, error)

MarginUpdateOnOrder will run the margin updates over a set of risk events (margin updates).

func (*Engine) MarkToMarket

func (e *Engine) MarkToMarket(ctx context.Context, marketID string, transfers []events.Transfer, asset string, useGeneralAccountForMarginSearch func(string) bool) ([]events.Margin, []*types.LedgerMovement, error)

MarkToMarket will run the mark to market settlement over a given set of positions return ledger move stuff here, too (separate return value, because we need to stream those).

func (*Engine) Name

func (e *Engine) Name() types.CheckpointName

func (*Engine) Namespace

func (e *Engine) Namespace() types.SnapshotNamespace

func (*Engine) OnBalanceSnapshotFrequencyUpdated added in v0.73.0

func (e *Engine) OnBalanceSnapshotFrequencyUpdated(ctx context.Context, d time.Duration) error

func (*Engine) OnEpochEvent added in v0.78.0

func (e *Engine) OnEpochEvent(ctx context.Context, epoch types.Epoch)

func (*Engine) OnEpochRestore added in v0.78.0

func (e *Engine) OnEpochRestore(ctx context.Context, epoch types.Epoch)

func (*Engine) PartyCanCoverFees added in v0.75.0

func (e *Engine) PartyCanCoverFees(asset, mktID, partyID string, amount *num.Uint) error

func (*Engine) PartyHasSufficientBalance added in v0.72.0

func (e *Engine) PartyHasSufficientBalance(asset, partyID string, amount *num.Uint, fromAccountType types.AccountType) error

PartyHasSufficientBalance checks if the party has sufficient amount in the <fromAccountType> account.

func (*Engine) PerpsFundingSettlement added in v0.73.0

func (e *Engine) PerpsFundingSettlement(ctx context.Context, marketID string, transfers []events.Transfer, asset string, round *num.Uint, useGeneralAccountForMarginSearch func(string) bool) ([]events.Margin, []*types.LedgerMovement, error)

PerpsFundingSettlement will run a funding settlement over given positions. This works exactly the same as a MTM settlement, but uses different transfer types.

func (*Engine) PropagateAssetUpdate

func (e *Engine) PropagateAssetUpdate(ctx context.Context, asset types.Asset) error

func (*Engine) ReleaseFromHoldingAccount added in v0.72.0

func (e *Engine) ReleaseFromHoldingAccount(ctx context.Context, transfer *types.Transfer, toAccountType types.AccountType) (*types.LedgerMovement, error)

ReleaseFromHoldingAccount releases locked funds from holding account back to the toAccount of the party.

func (*Engine) ReloadConf

func (e *Engine) ReloadConf(cfg Config)

ReloadConf updates the internal configuration of the collateral engine.

func (*Engine) RemoveBondAccount added in v0.69.0

func (e *Engine) RemoveBondAccount(partyID, marketID, asset string) error

func (*Engine) RemoveDistressed

func (e *Engine) RemoveDistressed(ctx context.Context, parties []events.MarketPosition, marketID, asset string, useGeneralAccount func(string) bool) (*types.LedgerMovement, error)

RemoveDistressed will remove all distressed party in the event positions for a given market and asset.

func (*Engine) RemoveLiquidityFeesBonusDistributionAccount added in v0.72.0

func (e *Engine) RemoveLiquidityFeesBonusDistributionAccount(partyID, marketID, asset string) error

func (*Engine) RestoreCheckpointBalance added in v0.56.0

func (e *Engine) RestoreCheckpointBalance(
	ctx context.Context,
	market, party, asset string,
	typ types.AccountType,
	amount *num.Uint,
) (*types.LedgerMovement, error)

RestoreCheckpointBalance will credit account with a balance from a checkpoint. This function assume the accounts have been created before.

func (*Engine) RollbackMarginUpdateOnOrder

func (e *Engine) RollbackMarginUpdateOnOrder(ctx context.Context, marketID string, assetID string, transfer *types.Transfer) (*types.LedgerMovement, error)

RollbackMarginUpdateOnOrder moves funds from the margin to the general account.

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) SubAccountClosed added in v0.77.0

func (e *Engine) SubAccountClosed(ctx context.Context, party, subAccount, asset, market string) ([]*types.LedgerMovement, error)

func (*Engine) SubAccountRelease added in v0.77.0

func (e *Engine) SubAccountRelease(
	ctx context.Context,
	party, subAccount, asset, market string,
	pos events.MarketPosition,
) ([]*types.LedgerMovement, events.Margin, error)

func (*Engine) SubAccountUpdate added in v0.77.0

func (e *Engine) SubAccountUpdate(
	ctx context.Context,
	party, subAccount, asset, market string,
	transferType types.TransferType,
	amount *num.Uint,
) (*types.LedgerMovement, error)

func (*Engine) SuccessorInsuranceFraction added in v0.72.0

func (e *Engine) SuccessorInsuranceFraction(ctx context.Context, successor, parent, asset string, fraction num.Decimal) *types.LedgerMovement

func (*Engine) TransferFees

func (e *Engine) TransferFees(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error)

func (*Engine) TransferFeesContinuousTrading

func (e *Engine) TransferFeesContinuousTrading(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error)

func (*Engine) TransferFunds

func (e *Engine) TransferFunds(
	ctx context.Context,
	transfers []*types.Transfer,
	accountTypes []types.AccountType,
	references []string,
	feeTransfers []*types.Transfer,
	feeTransfersAccountType []types.AccountType,
) ([]*types.LedgerMovement, error)

func (*Engine) TransferRewards

func (e *Engine) TransferRewards(ctx context.Context, rewardAccountID string, transfers []*types.Transfer, rewardType types.AccountType) ([]*types.LedgerMovement, error)

TransferRewards takes a slice of transfers and serves them to transfer rewards from the reward account to parties general account.

func (*Engine) TransferSpot added in v0.72.0

func (e *Engine) TransferSpot(ctx context.Context, party, toParty, asset string, quantity *num.Uint, fromAccountType types.AccountType, toAccountType types.AccountType) (*types.LedgerMovement, error)

TransferSpot transfers the given asset/quantity from partyID to partyID. The source partyID fromAccountType account must exist in the asset, the target partyID account in the asset is created if it doesn't yet exist.

func (*Engine) TransferSpotFees added in v0.72.0

func (e *Engine) TransferSpotFees(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer, fromAccountType types.AccountType) ([]*types.LedgerMovement, error)

func (*Engine) TransferSpotFeesContinuousTrading added in v0.72.0

func (e *Engine) TransferSpotFeesContinuousTrading(ctx context.Context, marketID string, assetID string, ft events.FeesTransfer) ([]*types.LedgerMovement, error)

func (*Engine) TransferToHoldingAccount added in v0.72.0

func (e *Engine) TransferToHoldingAccount(ctx context.Context, transfer *types.Transfer, accountTypeFrom types.AccountType) (*types.LedgerMovement, error)

TransferToHoldingAccount locks funds from accountTypeFrom into holding account account of the party.

func (*Engine) TransferVestedRewards added in v0.73.0

func (e *Engine) TransferVestedRewards(ctx context.Context, transfers []*types.Transfer) ([]*types.LedgerMovement, error)

func (*Engine) UnearmarkForAutomatedPurchase

func (e *Engine) UnearmarkForAutomatedPurchase(asset string, accountType types.AccountType, releaseRequest *num.Uint) error

func (*Engine) UpdateBalance

func (e *Engine) UpdateBalance(ctx context.Context, id string, balance *num.Uint) error

UpdateBalance will update the balance of a given account.

func (*Engine) Withdraw

func (e *Engine) Withdraw(ctx context.Context, partyID, asset string, amount *num.Uint) (*types.LedgerMovement, error)

Withdraw will remove the specified amount from the party general account.

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
}

TimeService provide the time of the vega node.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL