Documentation
¶
Index ¶
- Constants
- Variables
- func HttpCodeCheck(httpCode int) string
- func InitDB(db *sql.DB)
- func MustInitDecoder() *decode.Decoder
- type AvaxAddressesResponse
- type AvaxEVMTxDetails
- type AvaxErc20
- type AvaxErc20HoldingResponse
- type AvaxTxsResponse
- type BalancesByNetworkResponse
- type BlockTime
- type ChainEntry
- type Config
- type CosmosBalances
- type DbBalance
- type DbEthTxResponse
- type DbOrderFilled
- type DbTxResponse
- type EncodingConfig
- type EthBalanceResponse
- type EthScanTxListResponse
- type EthTxDetails
- type FastTransferOrder
- type FeeStatsSummary
- type FillOrderEnvelope
- type FillStatsResponse
- type MaxFillOrderResponse
- type Monitor
- func (m *Monitor) DecodeTxResponse(r *sdktypes.TxResponse) []FillOrderEnvelope
- func (m *Monitor) FetchAndSaveBlocktimes(intervalSeconds int) error
- func (m *Monitor) GetAllOsmosisOrders(contract_address string, apiUrl string, outputFile string)
- func (m *Monitor) GetCoingeckoPrices() error
- func (m *Monitor) GetDbAverageFill(filler string) (string, error)
- func (m *Monitor) GetDbAverageRevenue(filler string) (string, error)
- func (m *Monitor) GetDbBalancesInTimeRange(network string, from, to time.Time) ([]DbBalance, error)
- func (m *Monitor) GetDbFeesStats() (*FeeStatsSummary, error)
- func (m *Monitor) GetDbFillStats(filler string) (*FillStatsResponse, error)
- func (m *Monitor) GetDbFilledOrderStats(filler string) (*OrderStatsSummary, error)
- func (m *Monitor) GetDbLatestBalances(network string) ([]DbBalance, error)
- func (m *Monitor) GetDbMinFill(filler string) (string, error)
- func (m *Monitor) GetDbMinRevenue(filler string) (string, error)
- func (m *Monitor) GetEthereumTxsFromFile(path string, network string) ([]EthTxDetails, error)
- func (m *Monitor) GetLatestEthHeight(network string) (int64, error)
- func (m *Monitor) GetLatestHeight() int
- func (m *Monitor) GetLatestUsdTokenPrice(token string) (float64, error)
- func (m *Monitor) GetLatestUsdTokenPriceDecimal(token string) (decimal.Decimal, error)
- func (m *Monitor) GetNewOrders(height int, contractAddress string) ([]DbOrderFilled, []*DbTxResponse, error)
- func (m *Monitor) GetOrderDetailsByRange(network string, startBlock uint64, filler string) ([]OrderDetailsInRange, error)
- func (m *Monitor) InsertBalance(balance DbBalance) error
- func (m *Monitor) InsertEthTxResponse(txResponse EthTxDetails, network string, storeRawResponse bool) error
- func (m *Monitor) InsertOrderFilled(order DbOrderFilled) error
- func (m *Monitor) InsertRawTxResponse(txResponse DbTxResponse) error
- func (m *Monitor) InsertUsdPrice(denom string, price float64) error
- func (m *Monitor) LoadFromFile(path string, saveRawResponses bool)
- func (m *Monitor) LoadMissingOrderFromFile(path string)
- func (m *Monitor) OrdersFromFile(filePath string) ([]DbOrderFilled, []*DbTxResponse, error)
- func (m *Monitor) ReadMaxAmountInOrdersByFiller(filler string) ([]DbOrderFilled, error)
- func (m *Monitor) ReadMaxSolverRevenueOrders(filler string) ([]DbOrderFilled, error)
- func (m *Monitor) RunAll(wg *sync.WaitGroup, saveRawResponses bool)
- func (m *Monitor) RunArbitrumBalances() int
- func (m *Monitor) RunArbitrumTxHistory(saveRawResponses bool)
- func (m *Monitor) RunAvalancheBalances()
- func (m *Monitor) RunAvalancheTxHistory(saveRawResponses bool)
- func (m *Monitor) RunBaseBalances() int
- func (m *Monitor) RunBaseTxHistory(saveRawResponses bool)
- func (m *Monitor) RunEthereumBalances() int
- func (m *Monitor) RunEthereumTxHistory(saveRawResponses bool)
- func (m *Monitor) RunOrders(saveRawResponses bool)
- func (m *Monitor) RunOsmosisBalances()
- type NetworkFeeStats
- type NetworkOrderStats
- type NetworkStatsResponse
- type OrderDetailsInRange
- type OrderEnvelope
- type OrderStatsSummary
- type OrderWithMeta
- type OrdersFilledStatsResponse
- type OsmosisConfig
- type PriceResponse
- type Server
- type ShortBlockResp
- type SolverConfig
- type TxsFile
- type UsdPrice
Constants ¶
const ( AVALANCHE_NETWORK = "avalanche" AVALANCHE_CHAIN_ID = 43114 )
const ( COINGECKO_AVALANCHE_ID = "avalanche-2" COINGECKO_OSMOSIS_ID = "osmosis" COINGECKO_ETHEREUM_ID = "ethereum" )
const ( ARBITRUM_NETWORK = "arbitrum" ARBITRUM_CHAIN_ID = 42161 ETHEREUM_NETWORK = "ethereum" ETHEREUM_CHAIN_ID = 1 BASE_NETWORK = "base" BASE_CHAIN_ID = 8453 )
const BLOCK_QUERY string = "/cosmos/base/tendermint/v1beta1/blocks"
Variables ¶
var ChainIdToNetwork = map[string]string{
"42161": "arbitrum",
"43114": "avalanche",
"8453": "base",
"56": "bnb",
"1": "ethereum",
"137": "polygon",
"osmosis-1": "osmosis",
}
var NetworkToChainId = map[string]string{
"arbitrum": "42161",
"avalanche": "43114",
"base": "8453",
"bnb": "56",
"ethereum": "1",
"polygon": "137",
"osmosis": "osmosis-1",
}
var NotAvailableError = errors.New("server not available error")
var RateLimitErr = errors.New("rate limit error")
Functions ¶
func HttpCodeCheck ¶
func MustInitDecoder ¶
Types ¶
type AvaxAddressesResponse ¶
type AvaxAddressesResponse struct {
Address string `json:"address"`
Balance string `json:"balance"` // 18 decimals
FirstActivity time.Time `json:"firstActivity"`
TransactionsCount int `json:"transactionsCount"`
ERC20TransfersCount int `json:"erc20TransfersCount"`
ERC721TransfersCount int `json:"erc721TransfersCount"`
ERC1155TransfersCount int `json:"erc1155TransfersCount"`
}
type AvaxEVMTxDetails ¶
type AvaxEVMTxDetails struct {
Type string `json:"type"`
ID string `json:"id"`
ChainID string `json:"chainId"`
Timestamp string `json:"timestamp"`
BlockNumber int64 `json:"blockNumber"`
BlockHash string `json:"blockHash"`
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
Index int64 `json:"index"`
Status bool `json:"status"`
GasUsed string `json:"gasUsed"`
GasPrice string `json:"gasPrice"`
GasLimit string `json:"gasLimit"`
BurnedFees string `json:"burnedFees"`
Network string `json:"network,omitempty"` // not in the response -- injected by us
GasUsedUsd string `json:"gasUsedUsd"` // not in the response -- calculated by us
}
func (*AvaxEVMTxDetails) ToEthTxDetails ¶
func (td *AvaxEVMTxDetails) ToEthTxDetails() EthTxDetails
type AvaxErc20 ¶
type AvaxErc20 struct {
ChainId string `json:"chainId"`
TokenAddress string `json:"tokenAddress"`
TokenName string `json:"tokenName"`
TokenSymbol string `json:"tokenSymbol"`
TokenDecimals int `json:"tokenDecimals"`
TokenQuantity string `json:"tokenQuantity"`
TokenPrice string `json:"tokenPrice"`
TokenValueInUsd string `json:"tokenValueInUsd"`
UpdatedAtBlock int64 `json:"updatedAtBlock"`
}
type AvaxErc20HoldingResponse ¶
type AvaxErc20HoldingResponse struct {
Items []AvaxErc20 `json:"items"`
}
type AvaxTxsResponse ¶
type AvaxTxsResponse struct {
// not exactly the same as the Etherscan response but works for gas calculations
Items []AvaxEVMTxDetails `json:"items"`
}
type ChainEntry ¶
type ChainEntry struct {
Key string `json:"key,omitempty" yaml:"key,omitempty" toml:"key,omitempty"`
ApiUrl string `json:"api_url,omitempty" yaml:"api_url,omitempty" toml:"api_url,omitempty"`
UsdcAddress string `json:"usdc_address,omitempty" yaml:"usdc_address,omitempty" toml:"usdc_address,omitempty"`
Address string `json:"address,omitempty" yaml:"address,omitempty" toml:"address,omitempty"`
}
type Config ¶
type Config struct {
Arbitrum ChainEntry `json:"arbitrum,omitempty" yaml:"arbitrum,omitempty" toml:"arbitrum,omitempty"`
Ethereum ChainEntry `json:"ethereum,omitempty" yaml:"ethereum,omitempty" toml:"ethereum,omitempty"`
Base ChainEntry `json:"base,omitempty" yaml:"base,omitempty" toml:"base,omitempty"`
Osmosis OsmosisConfig `json:"osmosis,omitempty" yaml:"osmosis,omitempty" toml:"osmosis,omitempty"`
Avalanche ChainEntry `json:"avalanche,omitempty" yaml:"avalanche,omitempty" toml:"avalanche,omitempty"`
}
func MustLoadConfig ¶
type CosmosBalances ¶
type DbEthTxResponse ¶
type DbEthTxResponse struct {
TxHash string `json:"tx_hash"`
Height int64 `json:"height"`
Timestamp int64 `json:"timestamp"`
GasUsedWei int64 `json:"gas_used_wei"` // value in wei -> gasUsed * gasPrice
Valid bool `json:"valid"`
Network string `json:"network"`
TxResponse []byte `json:"tx_response"` // raw response so we can fallback to local stores if we need to recover or sth
}
type DbOrderFilled ¶
type DbOrderFilled struct {
TxHash string `json:"tx_hash"`
Sender string `json:"sender"`
AmountIn string `json:"amount_in"`
AmountOut string `json:"amount_out"`
SourceDomain string `json:"source_domain"`
SolverRevenue int64 `json:"solver_revenue"`
Height int64 `json:"height"`
Code int64 `json:"code"`
IngestionTimestamp time.Time `json:"ingestion_timestamp"`
Filler string `json:"filler"`
}
func ReadOrdersByFiller ¶
func ReadOrdersByFiller(db *sql.DB, filler string) []DbOrderFilled
func ReadOrdersFilled ¶
func ReadOrdersFilled(db *sql.DB) []DbOrderFilled
type DbTxResponse ¶
type EncodingConfig ¶
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
EncodingConfig specifies the concrete encoding types to use for a given app. This is provided for compatibility between protobuf and amino implementations.
func MakeEncodingConfig ¶
func MakeEncodingConfig() EncodingConfig
MakeEncodingConfig creates an EncodingConfig for an amino based test configuration.
type EthBalanceResponse ¶
type EthScanTxListResponse ¶
type EthScanTxListResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Result []EthTxDetails `json:"result"`
}
type EthTxDetails ¶
type EthTxDetails struct {
BlockNumber string `json:"blockNumber"`
BlockHash string `json:"blockHash"`
TimeStamp string `json:"timeStamp"`
Hash string `json:"hash"`
Nonce string `json:"nonce"`
TransactionIndex string `json:"transactionIndex"`
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
Gas string `json:"gas"`
GasPrice string `json:"gasPrice"`
GasPriceBid string `json:"gasPriceBid"`
Input string `json:"input"`
MethodId string `json:"methodId"`
FunctionName string `json:"functionName"`
ContractAddress string `json:"contractAddress"`
CumulativeGasUsed string `json:"cumulativeGasUsed"`
TxreceiptStatus string `json:"txreceipt_status"`
GasUsed string `json:"gasUsed"`
Confirmations string `json:"confirmations"`
IsError string `json:"isError"`
Network string `json:"network,omitempty"` // not in the response -- injected by us
GasUsedUsd string `json:"gasUsedUsd"` // not in the response -- calculated by us
}
type FastTransferOrder ¶
type FastTransferOrder struct {
Sender string `json:"sender"`
Recipient string `json:"recipient"`
AmountIn string `json:"amount_in"`
AmountOut string `json:"amount_out"`
Nonce uint32 `json:"nonce"`
SourceDomain uint32 `json:"source_domain"`
DestinationDomain uint32 `json:"destination_domain"`
TimeoutTimestamp uint64 `json:"timeout_timestamp"`
Data string `json:"data,omitempty"`
}
type FeeStatsSummary ¶
type FeeStatsSummary struct {
TotalGasUSD string `json:"total_gas_usd"`
TotalGasETH string `json:"total_gas_eth"`
TotalGasAVAX string `json:"total_gas_avax"`
TotalTxCount int64 `json:"total_tx_count"`
NetworkStats []NetworkFeeStats `json:"network_stats"`
}
type FillOrderEnvelope ¶
type FillOrderEnvelope struct {
FillOrder *OrderEnvelope `json:"fill_order"`
}
type FillStatsResponse ¶
type FillStatsResponse struct {
AverageRevenue string `json:"average_revenue"`
AverageFill string `json:"average_fill"`
MaxFill string `json:"max_fill"`
MaxRevenue string `json:"max_revenue"`
MinFill string `json:"min_fill"`
MinRevenue string `json:"min_revenue"`
MaxFillOrders []MaxFillOrderResponse `json:"max_fill_details"`
MaxRevenueOrders []MaxFillOrderResponse `json:"max_revenue_details"`
}
type MaxFillOrderResponse ¶
type MaxFillOrderResponse struct {
TxHash string `json:"tx_hash"`
AmountIn string `json:"amount_in"`
AmountOut string `json:"amount_out"`
Network string `json:"network"`
SolverRevenue string `json:"solver_revenue"`
Height int64 `json:"height"`
IngestionTimestamp time.Time `json:"ingestion_timestamp"`
}
type Monitor ¶
func NewMonitor ¶
func (*Monitor) DecodeTxResponse ¶
func (m *Monitor) DecodeTxResponse(r *sdktypes.TxResponse) []FillOrderEnvelope
func (*Monitor) FetchAndSaveBlocktimes ¶
func (*Monitor) GetAllOsmosisOrders ¶
func (*Monitor) GetCoingeckoPrices ¶
func (*Monitor) GetDbAverageFill ¶
func (*Monitor) GetDbAverageRevenue ¶
func (*Monitor) GetDbBalancesInTimeRange ¶
if useDecimals is true, the balance is returned in decimals otherwise, the balance is returned as a string this means that for 10^18, the balance will be "1000000000000000000" with useDecimals = false and "1" with useDecimals = true
func (*Monitor) GetDbFeesStats ¶
func (m *Monitor) GetDbFeesStats() (*FeeStatsSummary, error)
func (*Monitor) GetDbFillStats ¶
func (m *Monitor) GetDbFillStats(filler string) (*FillStatsResponse, error)
func (*Monitor) GetDbFilledOrderStats ¶
func (m *Monitor) GetDbFilledOrderStats(filler string) (*OrderStatsSummary, error)
func (*Monitor) GetDbLatestBalances ¶
if useDecimals is true, the balance is returned in decimals otherwise, the balance is returned as a string this means that for 10^18, the balance will be "1000000000000000000" with useDecimals = false and "1" with useDecimals = true
func (*Monitor) GetEthereumTxsFromFile ¶
func (m *Monitor) GetEthereumTxsFromFile(path string, network string) ([]EthTxDetails, error)
func (*Monitor) GetLatestEthHeight ¶
func (*Monitor) GetLatestHeight ¶
func (*Monitor) GetLatestUsdTokenPrice ¶
func (*Monitor) GetLatestUsdTokenPriceDecimal ¶
func (*Monitor) GetNewOrders ¶
func (m *Monitor) GetNewOrders(height int, contractAddress string) ([]DbOrderFilled, []*DbTxResponse, error)
func (*Monitor) GetOrderDetailsByRange ¶
func (*Monitor) InsertBalance ¶
func (*Monitor) InsertEthTxResponse ¶
func (m *Monitor) InsertEthTxResponse(txResponse EthTxDetails, network string, storeRawResponse bool) error
func (*Monitor) InsertOrderFilled ¶
func (m *Monitor) InsertOrderFilled(order DbOrderFilled) error
func (*Monitor) InsertRawTxResponse ¶
func (m *Monitor) InsertRawTxResponse(txResponse DbTxResponse) error
func (*Monitor) InsertUsdPrice ¶
func (*Monitor) LoadFromFile ¶
func (*Monitor) LoadMissingOrderFromFile ¶
func (*Monitor) OrdersFromFile ¶
func (m *Monitor) OrdersFromFile(filePath string) ([]DbOrderFilled, []*DbTxResponse, error)
func (*Monitor) ReadMaxAmountInOrdersByFiller ¶
func (m *Monitor) ReadMaxAmountInOrdersByFiller(filler string) ([]DbOrderFilled, error)
func (*Monitor) ReadMaxSolverRevenueOrders ¶
func (m *Monitor) ReadMaxSolverRevenueOrders(filler string) ([]DbOrderFilled, error)
func (*Monitor) RunArbitrumBalances ¶
func (*Monitor) RunArbitrumTxHistory ¶
func (*Monitor) RunAvalancheBalances ¶
func (m *Monitor) RunAvalancheBalances()
func (*Monitor) RunAvalancheTxHistory ¶
func (*Monitor) RunBaseBalances ¶
func (*Monitor) RunBaseTxHistory ¶
func (*Monitor) RunEthereumBalances ¶
ethereum balances are handled as strings and stored as strings in the db sqlite cannot store 256 bit integers, so we use strings to get around that
func (*Monitor) RunEthereumTxHistory ¶
func (*Monitor) RunOsmosisBalances ¶
func (m *Monitor) RunOsmosisBalances()
type NetworkFeeStats ¶
type NetworkOrderStats ¶
type NetworkStatsResponse ¶
type OrderDetailsInRange ¶
type OrderDetailsInRange struct {
AmountRange string `json:"amount_range"`
TotalOrdersInRange int `json:"total_orders_in_range"`
ExecutedOrdersInRange int `json:"executed_orders_in_range"`
Filler string `json:"filler"`
TotalVolume float64 `json:"total_volume"`
AvgTransfer float64 `json:"avg_transfer"`
MinTransfer float64 `json:"min_transfer"`
MaxTransfer float64 `json:"max_transfer"`
SourceDomain uint32 `json:"source_domain"`
}
type OrderEnvelope ¶
type OrderEnvelope struct {
Order *FastTransferOrder `json:"order"`
Filler string `json:"filler"`
}
type OrderStatsSummary ¶
type OrderStatsSummary struct {
TotalSolverRevenue int64 `json:"total_solver_revenue"`
TotalOrderCount int64 `json:"total_order_count"`
NetworkOrderStats []NetworkOrderStats `json:"networks"`
}
type OrderWithMeta ¶
type OrderWithMeta struct {
FastTransferOrder
Code int `json:"code"`
TxHash string `json:"tx_hash"`
Height int `json:"height"`
SolverRevenue int `json:"solver_revenue"`
IngestionTimestamp time.Time `json:"ingestion_timestamp"`
}
enrich with db fields
type OrdersFilledStatsResponse ¶
type OrdersFilledStatsResponse struct {
TotalSolverRevenue string `json:"total_solver_revenue"`
TotalOrderCount string `json:"total_order_count"`
NetworkStats []NetworkStatsResponse `json:"networks"`
}
type OsmosisConfig ¶
type OsmosisConfig struct {
ChainEntry
SolverConfig
}
type PriceResponse ¶
Response example from API:
{
"ethereum": {
"usd": 3265.89
},
"osmosis": {
"usd": 0.40659
}
}
type ShortBlockResp ¶
type ShortBlockResp struct {
Block struct {
Header struct {
Version struct {
Block string `json:"block"`
App string `json:"app"`
} `json:"version"`
ChainID string `json:"chain_id"`
Height string `json:"height"`
Time time.Time `json:"time"`
} `json:"header"`
} `json:"block"`
}
don't want to mess widh cosmos/comet encoders again...