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 ¶
var ErrUnsupportedChain = errors.New("could not get gas balance for unsupported chain")
ErrUnsupportedChain is the error for an unsupported chain.
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 Method relconfig.RebalanceMethod }
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.