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 ShouldRefreshBalances ¶ added in v0.38.0
func ShouldRefreshBalances() BalanceFetchArgOption
ShouldRefreshBalances allows someone fetching balance(s) to skip the cache.
func SkipDBCache ¶ added in v0.38.0
func SkipDBCache() BalanceFetchArgOption
SkipDBCache allows someone fetching balance(s) to skip the cache.
type ClaimInfo ¶ added in v1.1.4
type ClaimInfo struct { From string `json:"from"` To string `json:"to"` Value string `json:"value"` Nonce string `json:"nonce"` Message string `json:"message"` Proof struct { BatchIndex string `json:"batch_index"` MerkleProof string `json:"merkle_proof"` } `json:"proof"` Claimable bool `json:"claimable"` }
ClaimInfo represents the data structure returned by the Scroll API.
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 attempts any rebalances that could be executed across all supported tokens and chains. Rebalance(ctx context.Context) 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 QuoterOption ¶ added in v0.38.0
type QuoterOption func(*inFlightManager)
QuoterOption defines a type for functional options.
func WithTTL ¶ added in v0.38.0
func WithTTL(ttl time.Duration) QuoterOption
WithTTL sets the TTL for the inFlightManager.
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.
type TokenMetadata ¶ added in v0.0.54
type TokenMetadata struct { // Name is the name of the token in the config Name string // ChainName is the name of the token onchain ChainName string Balance *big.Int Decimals uint8 IsGasToken bool ChainID int Addr common.Address }
TokenMetadata contains metadata for a token.