inventory

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package inventory contains the inventory manager. the inventory manager is one of the core pieces of the program which manages the currently available inventory.

"All" (committed & uncommitted inventory) is considered to be the current balance on all chains (so, you if you iterate through all erc-20's and call balanceOf()) that is the "All" inventory "Commitable" inventory is "All" inventory net of current commitments. Commitments occur when a user bridge request comes in and the relayer internally commits to filling it. This prevents overcommiting erc-20 balances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceFetchArgOption

type BalanceFetchArgOption func(options *balanceFetchOptions)

BalanceFetchArgOption is an option that can be passed into a balance fetch request. we do this to allow optional args.

func SkipCache

func SkipCache() BalanceFetchArgOption

SkipCache allows someone fetching balance(s) to skip the cache.

type Manager

type Manager interface {
	// Start starts the inventory manager.
	Start(ctx context.Context) (err error)
	// GetCommittableBalance gets the total balance available for quotes
	// this does not include on-chain balances committed in previous quotes that may be
	// refunded in the event of a revert.
	GetCommittableBalance(ctx context.Context, chainID int, token common.Address, options ...BalanceFetchArgOption) (*big.Int, error)
	// GetCommittableBalances gets the total balances committable for all tracked tokens.
	GetCommittableBalances(ctx context.Context, options ...BalanceFetchArgOption) (map[int]map[common.Address]*big.Int, error)
	// ApproveAllTokens approves all tokens for the relayer address.
	ApproveAllTokens(ctx context.Context) error
	// HasSufficientGas checks if there is sufficient gas for a given route.
	HasSufficientGas(ctx context.Context, chainID int, gasValue *big.Int) (bool, error)
	// Rebalance checks whether a given token should be rebalanced, and
	// executes the rebalance if necessary.
	Rebalance(ctx context.Context, chainID int, token common.Address) error
	// GetTokenMetadata gets the metadata for a token.
	GetTokenMetadata(chainID int, token common.Address) (*TokenMetadata, error)
}

Manager is the interface for the inventory manager.

func NewInventoryManager

func NewInventoryManager(ctx context.Context, clientFetcher submitter.ClientFetcher, handler metrics.Handler, cfg relconfig.Config, relayer common.Address, txSubmitter submitter.TransactionSubmitter, db reldb.Service) (Manager, error)

NewInventoryManager creates a new inventory manager. TODO: too many args here.

type RebalanceData added in v0.0.54

type RebalanceData struct {
	OriginMetadata *TokenMetadata
	DestMetadata   *TokenMetadata
	Amount         *big.Int
}

RebalanceData contains metadata for a rebalance action.

type RebalanceManager added in v0.0.54

type RebalanceManager interface {
	// Start starts the rebalance manager.
	Start(ctx context.Context) (err error)
	// Execute executes a rebalance action.
	Execute(ctx context.Context, rebalance *RebalanceData) error
}

RebalanceManager is the interface for the rebalance manager.

type TokenMetadata added in v0.0.54

type TokenMetadata struct {
	Name       string
	Balance    *big.Int
	Decimals   uint8
	Allowances map[spendableContract]*big.Int
	IsGasToken bool
	ChainID    int
	Addr       common.Address
}

TokenMetadata contains metadata for a token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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