Versions in this module Expand all Collapse all v0 v0.2.0 Dec 1, 2025 v0.1.0 Nov 28, 2025 Changes in this version + var ErrNegativeBalance = errors.New("balance calculation resulted in negative value") + var ErrNotManagedByCode = errors.New("explicitly not handling account not managed by code") + var ErrUnhandledAccount = errors.New("unhandled account") + func BatchCalculateFromCacheWithAccountRecords(ctx context.Context, data code_data.Provider, ...) (map[string]uint64, error) + func BatchCalculateFromCacheWithTokenAccounts(ctx context.Context, data code_data.Provider, tokenAccounts ...*common.Account) (map[string]uint64, error) + func Calculate(ctx context.Context, tokenAccount *common.Account, initialBalance uint64, ...) (balance uint64, err error) + func CalculateBatch(ctx context.Context, tokenAccounts []string, strategies ...BatchStrategy) (balanceByTokenAccount map[string]uint64, err error) + func CalculateFromCache(ctx context.Context, data code_data.Provider, tokenAccount *common.Account) (uint64, error) + type BatchCalculator func(ctx context.Context, data code_data.Provider, ...) (map[string]uint64, error) + type BatchState struct + type BatchStrategy func(ctx context.Context, tokenAccounts []string, state *BatchState) (*BatchState, error) + func FundingFromExternalDepositsBatch(ctx context.Context, data code_data.Provider) BatchStrategy + func NetBalanceFromIntentActionsBatch(ctx context.Context, data code_data.Provider) BatchStrategy + type Calculator func(ctx context.Context, data code_data.Provider, tokenAccount *common.Account) (uint64, error) + type OpenCloseStatusLock struct + func NewOpenCloseStatusLock(vault *common.Account) *OpenCloseStatusLock + func (l *OpenCloseStatusLock) OnClose(ctx context.Context, data code_data.Provider) error + func (l *OpenCloseStatusLock) OnPaymentToAccount(ctx context.Context, data code_data.Provider) error + type OptimisticVersionLock struct + func GetOptimisticVersionLock(ctx context.Context, data code_data.Provider, vault *common.Account) (*OptimisticVersionLock, error) + func (l *OptimisticVersionLock) OnNewBalanceVersion(ctx context.Context, data code_data.Provider) error + func (l *OptimisticVersionLock) RequireSameBalanceVerion(ctx context.Context, data code_data.Provider) error + type Source uint8 + const BlockchainSource + const CacheSource + const UnknownSource + func CalculateFromBlockchain(ctx context.Context, data code_data.Provider, tokenAccount *common.Account) (uint64, Source, error) + func (s Source) String() string + type State struct + type Strategy func(ctx context.Context, tokenAccount *common.Account, state *State) (*State, error) + func FundingFromExternalDeposits(ctx context.Context, data code_data.Provider) Strategy + func NetBalanceFromIntentActions(ctx context.Context, data code_data.Provider) Strategy