fix: resolve all compilation issues across transport and lifecycle packages
- Fixed duplicate type declarations in transport package - Removed unused variables in lifecycle and dependency injection - Fixed big.Int arithmetic operations in uniswap contracts - Added missing methods to MetricsCollector (IncrementCounter, RecordLatency, etc.) - Fixed jitter calculation in TCP transport retry logic - Updated ComponentHealth field access to use transport type - Ensured all core packages build successfully All major compilation errors resolved: ✅ Transport package builds clean ✅ Lifecycle package builds clean ✅ Main MEV bot application builds clean ✅ Fixed method signature mismatches ✅ Resolved type conflicts and duplications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
962
pkg/arbitrum/registries.go
Normal file
962
pkg/arbitrum/registries.go
Normal file
@@ -0,0 +1,962 @@
|
||||
package arbitrum
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
// ContractRegistry manages known DEX contracts on Arbitrum
|
||||
type ContractRegistry struct {
|
||||
contracts map[common.Address]*ContractInfo
|
||||
contractsLock sync.RWMutex
|
||||
lastUpdated time.Time
|
||||
}
|
||||
|
||||
// NewContractRegistry creates a new contract registry
|
||||
func NewContractRegistry() *ContractRegistry {
|
||||
registry := &ContractRegistry{
|
||||
contracts: make(map[common.Address]*ContractInfo),
|
||||
lastUpdated: time.Now(),
|
||||
}
|
||||
|
||||
// Load default Arbitrum contracts
|
||||
registry.loadDefaultContracts()
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
// GetContract returns contract information for an address
|
||||
func (r *ContractRegistry) GetContract(address common.Address) *ContractInfo {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
if contract, exists := r.contracts[address]; exists {
|
||||
return contract
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddContract adds a new contract to the registry
|
||||
func (r *ContractRegistry) AddContract(contract *ContractInfo) {
|
||||
r.contractsLock.Lock()
|
||||
defer r.contractsLock.Unlock()
|
||||
|
||||
contract.LastUpdated = time.Now()
|
||||
r.contracts[contract.Address] = contract
|
||||
r.lastUpdated = time.Now()
|
||||
}
|
||||
|
||||
// GetContractsByProtocol returns all contracts for a specific protocol
|
||||
func (r *ContractRegistry) GetContractsByProtocol(protocol Protocol) []*ContractInfo {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
var contracts []*ContractInfo
|
||||
for _, contract := range r.contracts {
|
||||
if contract.Protocol == protocol {
|
||||
contracts = append(contracts, contract)
|
||||
}
|
||||
}
|
||||
return contracts
|
||||
}
|
||||
|
||||
// GetContractsByType returns all contracts of a specific type
|
||||
func (r *ContractRegistry) GetContractsByType(contractType ContractType) []*ContractInfo {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
var contracts []*ContractInfo
|
||||
for _, contract := range r.contracts {
|
||||
if contract.ContractType == contractType {
|
||||
contracts = append(contracts, contract)
|
||||
}
|
||||
}
|
||||
return contracts
|
||||
}
|
||||
|
||||
// IsKnownContract checks if an address is a known DEX contract
|
||||
func (r *ContractRegistry) IsKnownContract(address common.Address) bool {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
_, exists := r.contracts[address]
|
||||
return exists
|
||||
}
|
||||
|
||||
// GetContractCount returns the total number of registered contracts
|
||||
func (r *ContractRegistry) GetContractCount() int {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
return len(r.contracts)
|
||||
}
|
||||
|
||||
// loadDefaultContracts loads comprehensive Arbitrum DEX contract addresses
|
||||
func (r *ContractRegistry) loadDefaultContracts() {
|
||||
// Uniswap V2 contracts
|
||||
r.contracts[common.HexToAddress("0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9"),
|
||||
Name: "Uniswap V2 Factory",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 158091,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24"),
|
||||
Name: "Uniswap V2 Router",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 158091,
|
||||
FactoryAddress: common.HexToAddress("0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9"),
|
||||
}
|
||||
|
||||
// Uniswap V3 contracts
|
||||
r.contracts[common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
Name: "Uniswap V3 Factory",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 165,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xE592427A0AEce92De3Edee1F18E0157C05861564")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xE592427A0AEce92De3Edee1F18E0157C05861564"),
|
||||
Name: "Uniswap V3 SwapRouter",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 165,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"),
|
||||
Name: "Uniswap V3 SwapRouter02",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0.2",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 7702620,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xC36442b4a4522E871399CD717aBDD847Ab11FE88")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xC36442b4a4522E871399CD717aBDD847Ab11FE88"),
|
||||
Name: "Uniswap V3 NonfungiblePositionManager",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypeManager,
|
||||
IsActive: true,
|
||||
DeployedBlock: 165,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
// SushiSwap contracts
|
||||
r.contracts[common.HexToAddress("0xc35DADB65012eC5796536bD9864eD8773aBc74C4")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xc35DADB65012eC5796536bD9864eD8773aBc74C4"),
|
||||
Name: "SushiSwap Factory",
|
||||
Protocol: ProtocolSushiSwapV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 1440000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506"),
|
||||
Name: "SushiSwap Router",
|
||||
Protocol: ProtocolSushiSwapV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 1440000,
|
||||
FactoryAddress: common.HexToAddress("0xc35DADB65012eC5796536bD9864eD8773aBc74C4"),
|
||||
}
|
||||
|
||||
// Camelot DEX contracts
|
||||
r.contracts[common.HexToAddress("0x6EcCab422D763aC031210895C81787E87B91425a")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x6EcCab422D763aC031210895C81787E87B91425a"),
|
||||
Name: "Camelot Factory",
|
||||
Protocol: ProtocolCamelotV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 5520000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xc873fEcbd354f5A56E00E710B90EF4201db2448d")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xc873fEcbd354f5A56E00E710B90EF4201db2448d"),
|
||||
Name: "Camelot Router",
|
||||
Protocol: ProtocolCamelotV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 5520000,
|
||||
FactoryAddress: common.HexToAddress("0x6EcCab422D763aC031210895C81787E87B91425a"),
|
||||
}
|
||||
|
||||
// Camelot V3 (Algebra) contracts
|
||||
r.contracts[common.HexToAddress("0x1a3c9B1d2F0529D97f2afC5136Cc23e58f1FD35B")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x1a3c9B1d2F0529D97f2afC5136Cc23e58f1FD35B"),
|
||||
Name: "Camelot Algebra Factory",
|
||||
Protocol: ProtocolCamelotV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 26500000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x00555513Acf282B42882420E5e5bA87b44D8fA6E")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x00555513Acf282B42882420E5e5bA87b44D8fA6E"),
|
||||
Name: "Camelot Algebra Router",
|
||||
Protocol: ProtocolCamelotV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 26500000,
|
||||
FactoryAddress: common.HexToAddress("0x1a3c9B1d2F0529D97f2afC5136Cc23e58f1FD35B"),
|
||||
}
|
||||
|
||||
// TraderJoe contracts
|
||||
r.contracts[common.HexToAddress("0xaE4EC9901c3076D0DdBe76A520F9E90a6227aCB7")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xaE4EC9901c3076D0DdBe76A520F9E90a6227aCB7"),
|
||||
Name: "TraderJoe Factory",
|
||||
Protocol: ProtocolTraderJoeV1,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 1500000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x60aE616a2155Ee3d9A68541Ba4544862310933d4")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x60aE616a2155Ee3d9A68541Ba4544862310933d4"),
|
||||
Name: "TraderJoe Router",
|
||||
Protocol: ProtocolTraderJoeV1,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 1500000,
|
||||
FactoryAddress: common.HexToAddress("0xaE4EC9901c3076D0DdBe76A520F9E90a6227aCB7"),
|
||||
}
|
||||
|
||||
// TraderJoe V2 Liquidity Book contracts
|
||||
r.contracts[common.HexToAddress("0x8e42f2F4101563bF679975178e880FD87d3eFd4e")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x8e42f2F4101563bF679975178e880FD87d3eFd4e"),
|
||||
Name: "TraderJoe LB Factory",
|
||||
Protocol: ProtocolTraderJoeLB,
|
||||
Version: "2.1",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 60000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xb4315e873dBcf96Ffd0acd8EA43f689D8c20fB30"),
|
||||
Name: "TraderJoe LB Router",
|
||||
Protocol: ProtocolTraderJoeLB,
|
||||
Version: "2.1",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 60000000,
|
||||
FactoryAddress: common.HexToAddress("0x8e42f2F4101563bF679975178e880FD87d3eFd4e"),
|
||||
}
|
||||
|
||||
// Curve contracts
|
||||
r.contracts[common.HexToAddress("0x98EE8517825C0bd778a57471a27555614F97F48D")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x98EE8517825C0bd778a57471a27555614F97F48D"),
|
||||
Name: "Curve Registry",
|
||||
Protocol: ProtocolCurve,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 5000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x445FE580eF8d70FF569aB36e80c647af338db351")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x445FE580eF8d70FF569aB36e80c647af338db351"),
|
||||
Name: "Curve Router",
|
||||
Protocol: ProtocolCurve,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 5000000,
|
||||
}
|
||||
|
||||
// Balancer V2 contracts
|
||||
r.contracts[common.HexToAddress("0xBA12222222228d8Ba445958a75a0704d566BF2C8")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
|
||||
Name: "Balancer Vault",
|
||||
Protocol: ProtocolBalancerV2,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeVault,
|
||||
IsActive: true,
|
||||
DeployedBlock: 2230000,
|
||||
}
|
||||
|
||||
// Kyber contracts
|
||||
r.contracts[common.HexToAddress("0x5F1dddbf348aC2fbe22a163e30F99F9ECE3DD50a")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x5F1dddbf348aC2fbe22a163e30F99F9ECE3DD50a"),
|
||||
Name: "Kyber Classic Factory",
|
||||
Protocol: ProtocolKyberClassic,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 3000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xC1e7dFE73E1598E3910EF4C7845B68A9Ab6F4c83")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xC1e7dFE73E1598E3910EF4C7845B68A9Ab6F4c83"),
|
||||
Name: "Kyber Elastic Factory",
|
||||
Protocol: ProtocolKyberElastic,
|
||||
Version: "2.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 15000000,
|
||||
}
|
||||
|
||||
// GMX contracts
|
||||
r.contracts[common.HexToAddress("0x489ee077994B6658eAfA855C308275EAd8097C4A")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x489ee077994B6658eAfA855C308275EAd8097C4A"),
|
||||
Name: "GMX Vault",
|
||||
Protocol: ProtocolGMX,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeVault,
|
||||
IsActive: true,
|
||||
DeployedBlock: 3500000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xaBBc5F99639c9B6bCb58544ddf04EFA6802F4064"),
|
||||
Name: "GMX Router",
|
||||
Protocol: ProtocolGMX,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 3500000,
|
||||
}
|
||||
|
||||
// Ramses Exchange contracts
|
||||
r.contracts[common.HexToAddress("0xAAA20D08e59F6561f242b08513D36266C5A29415")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xAAA20D08e59F6561f242b08513D36266C5A29415"),
|
||||
Name: "Ramses Factory",
|
||||
Protocol: ProtocolRamses,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 80000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xAAA87963EFeB6f7E0a2711F397663105Acb1805e")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xAAA87963EFeB6f7E0a2711F397663105Acb1805e"),
|
||||
Name: "Ramses Router",
|
||||
Protocol: ProtocolRamses,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 80000000,
|
||||
FactoryAddress: common.HexToAddress("0xAAA20D08e59F6561f242b08513D36266C5A29415"),
|
||||
}
|
||||
|
||||
// Chronos contracts
|
||||
r.contracts[common.HexToAddress("0xCe9240869391928253Ed9cc9Bcb8cb98CB5B0722")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xCe9240869391928253Ed9cc9Bcb8cb98CB5B0722"),
|
||||
Name: "Chronos Factory",
|
||||
Protocol: ProtocolChronos,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeFactory,
|
||||
IsActive: true,
|
||||
DeployedBlock: 75000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xE708aA9E887980750C040a6A2Cb901c37Aa34f3b")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xE708aA9E887980750C040a6A2Cb901c37Aa34f3b"),
|
||||
Name: "Chronos Router",
|
||||
Protocol: ProtocolChronos,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 75000000,
|
||||
FactoryAddress: common.HexToAddress("0xCe9240869391928253Ed9cc9Bcb8cb98CB5B0722"),
|
||||
}
|
||||
|
||||
// DEX Aggregators
|
||||
r.contracts[common.HexToAddress("0x1111111254EEB25477B68fb85Ed929f73A960582")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x1111111254EEB25477B68fb85Ed929f73A960582"),
|
||||
Name: "1inch Aggregation Router V5",
|
||||
Protocol: Protocol1Inch,
|
||||
Version: "5.0",
|
||||
ContractType: ContractTypeAggregator,
|
||||
IsActive: true,
|
||||
DeployedBlock: 70000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x1111111254fb6c44bAC0beD2854e76F90643097d")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x1111111254fb6c44bAC0beD2854e76F90643097d"),
|
||||
Name: "1inch Aggregation Router V4",
|
||||
Protocol: Protocol1Inch,
|
||||
Version: "4.0",
|
||||
ContractType: ContractTypeAggregator,
|
||||
IsActive: true,
|
||||
DeployedBlock: 40000000,
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"),
|
||||
Name: "ParaSwap Augustus V5",
|
||||
Protocol: ProtocolParaSwap,
|
||||
Version: "5.0",
|
||||
ContractType: ContractTypeAggregator,
|
||||
IsActive: true,
|
||||
DeployedBlock: 50000000,
|
||||
}
|
||||
|
||||
// Universal Router (Uniswap's new universal router)
|
||||
r.contracts[common.HexToAddress("0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD"),
|
||||
Name: "Universal Router",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "1.0",
|
||||
ContractType: ContractTypeRouter,
|
||||
IsActive: true,
|
||||
DeployedBlock: 100000000,
|
||||
}
|
||||
|
||||
// High-activity pool contracts
|
||||
r.contracts[common.HexToAddress("0xC6962004f452bE9203591991D15f6b388e09E8D0")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0xC6962004f452bE9203591991D15f6b388e09E8D0"),
|
||||
Name: "WETH/USDC Pool",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypePool,
|
||||
IsActive: true,
|
||||
DeployedBlock: 200000,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x641C00A822e8b671738d32a431a4Fb6074E5c79d")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x641C00A822e8b671738d32a431a4Fb6074E5c79d"),
|
||||
Name: "WETH/USDT Pool",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypePool,
|
||||
IsActive: true,
|
||||
DeployedBlock: 300000,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
r.contracts[common.HexToAddress("0x2f5e87C9312fa29aed5c179E456625D79015299c")] = &ContractInfo{
|
||||
Address: common.HexToAddress("0x2f5e87C9312fa29aed5c179E456625D79015299c"),
|
||||
Name: "ARB/WETH Pool",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
Version: "3.0",
|
||||
ContractType: ContractTypePool,
|
||||
IsActive: true,
|
||||
DeployedBlock: 50000000,
|
||||
FactoryAddress: common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984"),
|
||||
}
|
||||
|
||||
// Update timestamps
|
||||
for _, contract := range r.contracts {
|
||||
contract.LastUpdated = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
// ExportContracts returns all contracts as a JSON string
|
||||
func (r *ContractRegistry) ExportContracts() (string, error) {
|
||||
r.contractsLock.RLock()
|
||||
defer r.contractsLock.RUnlock()
|
||||
|
||||
data, err := json.MarshalIndent(r.contracts, "", " ")
|
||||
return string(data), err
|
||||
}
|
||||
|
||||
// SignatureRegistry manages function and event signatures for DEX protocols
|
||||
type SignatureRegistry struct {
|
||||
functionSignatures map[[4]byte]*FunctionSignature
|
||||
eventSignatures map[common.Hash]*EventSignature
|
||||
signaturesLock sync.RWMutex
|
||||
lastUpdated time.Time
|
||||
}
|
||||
|
||||
// NewSignatureRegistry creates a new signature registry
|
||||
func NewSignatureRegistry() *SignatureRegistry {
|
||||
registry := &SignatureRegistry{
|
||||
functionSignatures: make(map[[4]byte]*FunctionSignature),
|
||||
eventSignatures: make(map[common.Hash]*EventSignature),
|
||||
lastUpdated: time.Now(),
|
||||
}
|
||||
|
||||
// Load default signatures
|
||||
registry.loadDefaultSignatures()
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
// GetFunctionSignature returns function signature information
|
||||
func (r *SignatureRegistry) GetFunctionSignature(selector [4]byte) *FunctionSignature {
|
||||
r.signaturesLock.RLock()
|
||||
defer r.signaturesLock.RUnlock()
|
||||
|
||||
if sig, exists := r.functionSignatures[selector]; exists {
|
||||
return sig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetEventSignature returns event signature information
|
||||
func (r *SignatureRegistry) GetEventSignature(topic0 common.Hash) *EventSignature {
|
||||
r.signaturesLock.RLock()
|
||||
defer r.signaturesLock.RUnlock()
|
||||
|
||||
if sig, exists := r.eventSignatures[topic0]; exists {
|
||||
return sig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddFunctionSignature adds a new function signature
|
||||
func (r *SignatureRegistry) AddFunctionSignature(sig *FunctionSignature) {
|
||||
r.signaturesLock.Lock()
|
||||
defer r.signaturesLock.Unlock()
|
||||
|
||||
r.functionSignatures[sig.Selector] = sig
|
||||
r.lastUpdated = time.Now()
|
||||
}
|
||||
|
||||
// AddEventSignature adds a new event signature
|
||||
func (r *SignatureRegistry) AddEventSignature(sig *EventSignature) {
|
||||
r.signaturesLock.Lock()
|
||||
defer r.signaturesLock.Unlock()
|
||||
|
||||
r.eventSignatures[sig.Topic0] = sig
|
||||
r.lastUpdated = time.Now()
|
||||
}
|
||||
|
||||
// loadDefaultSignatures loads comprehensive function and event signatures
|
||||
func (r *SignatureRegistry) loadDefaultSignatures() {
|
||||
// Load function signatures
|
||||
r.loadFunctionSignatures()
|
||||
|
||||
// Load event signatures
|
||||
r.loadEventSignatures()
|
||||
}
|
||||
|
||||
// loadFunctionSignatures loads all DEX function signatures
|
||||
func (r *SignatureRegistry) loadFunctionSignatures() {
|
||||
// Uniswap V2 function signatures
|
||||
r.functionSignatures[bytesToSelector("0x38ed1739")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x38ed1739"),
|
||||
Name: "swapExactTokensForTokens",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Swap exact tokens for tokens",
|
||||
RequiredParams: []string{"amountIn", "amountOutMin", "path", "to", "deadline"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x8803dbee")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x8803dbee"),
|
||||
Name: "swapTokensForExactTokens",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Swap tokens for exact tokens",
|
||||
RequiredParams: []string{"amountOut", "amountInMax", "path", "to", "deadline"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x7ff36ab5")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x7ff36ab5"),
|
||||
Name: "swapExactETHForTokens",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Swap exact ETH for tokens",
|
||||
RequiredParams: []string{"amountOutMin", "path", "to", "deadline"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x18cbafe5")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x18cbafe5"),
|
||||
Name: "swapExactTokensForETH",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Swap exact tokens for ETH",
|
||||
RequiredParams: []string{"amountIn", "amountOutMin", "path", "to", "deadline"},
|
||||
}
|
||||
|
||||
// Uniswap V3 function signatures
|
||||
r.functionSignatures[bytesToSelector("0x414bf389")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x414bf389"),
|
||||
Name: "exactInputSingle",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Exact input single pool swap",
|
||||
RequiredParams: []string{"tokenIn", "tokenOut", "fee", "recipient", "deadline", "amountIn", "amountOutMinimum", "sqrtPriceLimitX96"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xc04b8d59")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xc04b8d59"),
|
||||
Name: "exactInput",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Exact input multi-hop swap",
|
||||
RequiredParams: []string{"path", "recipient", "deadline", "amountIn", "amountOutMinimum"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xdb3e2198")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xdb3e2198"),
|
||||
Name: "exactOutputSingle",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Exact output single pool swap",
|
||||
RequiredParams: []string{"tokenIn", "tokenOut", "fee", "recipient", "deadline", "amountOut", "amountInMaximum", "sqrtPriceLimitX96"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xf28c0498")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xf28c0498"),
|
||||
Name: "exactOutput",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Exact output multi-hop swap",
|
||||
RequiredParams: []string{"path", "recipient", "deadline", "amountOut", "amountInMaximum"},
|
||||
}
|
||||
|
||||
// Multicall signatures
|
||||
r.functionSignatures[bytesToSelector("0xac9650d8")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xac9650d8"),
|
||||
Name: "multicall",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeMulticall,
|
||||
Description: "Execute multiple function calls",
|
||||
RequiredParams: []string{"data"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x5ae401dc")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x5ae401dc"),
|
||||
Name: "multicall",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeMulticall,
|
||||
Description: "Execute multiple function calls with deadline",
|
||||
RequiredParams: []string{"deadline", "data"},
|
||||
}
|
||||
|
||||
// 1inch signatures
|
||||
r.functionSignatures[bytesToSelector("0x7c025200")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x7c025200"),
|
||||
Name: "swap",
|
||||
Protocol: Protocol1Inch,
|
||||
ContractType: ContractTypeAggregator,
|
||||
EventType: EventTypeAggregatorSwap,
|
||||
Description: "1inch aggregator swap",
|
||||
RequiredParams: []string{"caller", "desc", "data"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xe449022e")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xe449022e"),
|
||||
Name: "uniswapV3Swap",
|
||||
Protocol: Protocol1Inch,
|
||||
ContractType: ContractTypeAggregator,
|
||||
EventType: EventTypeAggregatorSwap,
|
||||
Description: "1inch Uniswap V3 swap",
|
||||
RequiredParams: []string{"amount", "minReturn", "pools"},
|
||||
}
|
||||
|
||||
// Balancer V2 signatures
|
||||
r.functionSignatures[bytesToSelector("0x52bbbe29")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x52bbbe29"),
|
||||
Name: "swap",
|
||||
Protocol: ProtocolBalancerV2,
|
||||
ContractType: ContractTypeVault,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Balancer V2 single swap",
|
||||
RequiredParams: []string{"singleSwap", "funds", "limit", "deadline"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x945bcec9")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x945bcec9"),
|
||||
Name: "batchSwap",
|
||||
Protocol: ProtocolBalancerV2,
|
||||
ContractType: ContractTypeVault,
|
||||
EventType: EventTypeBatchSwap,
|
||||
Description: "Balancer V2 batch swap",
|
||||
RequiredParams: []string{"kind", "swaps", "assets", "funds", "limits", "deadline"},
|
||||
}
|
||||
|
||||
// Curve signatures
|
||||
r.functionSignatures[bytesToSelector("0x3df02124")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x3df02124"),
|
||||
Name: "exchange",
|
||||
Protocol: ProtocolCurve,
|
||||
ContractType: ContractTypePool,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Curve token exchange",
|
||||
RequiredParams: []string{"i", "j", "dx", "min_dy"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xa6417ed6")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xa6417ed6"),
|
||||
Name: "exchange_underlying",
|
||||
Protocol: ProtocolCurve,
|
||||
ContractType: ContractTypePool,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Curve exchange underlying tokens",
|
||||
RequiredParams: []string{"i", "j", "dx", "min_dy"},
|
||||
}
|
||||
|
||||
// Universal Router
|
||||
r.functionSignatures[bytesToSelector("0x3593564c")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x3593564c"),
|
||||
Name: "execute",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeMulticall,
|
||||
Description: "Universal router execute",
|
||||
RequiredParams: []string{"commands", "inputs", "deadline"},
|
||||
}
|
||||
|
||||
// Liquidity management signatures
|
||||
r.functionSignatures[bytesToSelector("0xe8e33700")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xe8e33700"),
|
||||
Name: "addLiquidity",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeLiquidityAdd,
|
||||
Description: "Add liquidity to pool",
|
||||
RequiredParams: []string{"tokenA", "tokenB", "amountADesired", "amountBDesired", "amountAMin", "amountBMin", "to", "deadline"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xbaa2abde")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xbaa2abde"),
|
||||
Name: "removeLiquidity",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
ContractType: ContractTypeRouter,
|
||||
EventType: EventTypeLiquidityRemove,
|
||||
Description: "Remove liquidity from pool",
|
||||
RequiredParams: []string{"tokenA", "tokenB", "liquidity", "amountAMin", "amountBMin", "to", "deadline"},
|
||||
}
|
||||
|
||||
// Uniswap V3 Position Manager
|
||||
r.functionSignatures[bytesToSelector("0x88316456")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x88316456"),
|
||||
Name: "mint",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeManager,
|
||||
EventType: EventTypeLiquidityAdd,
|
||||
Description: "Mint new liquidity position",
|
||||
RequiredParams: []string{"params"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x219f5d17")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x219f5d17"),
|
||||
Name: "increaseLiquidity",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeManager,
|
||||
EventType: EventTypePositionUpdate,
|
||||
Description: "Increase liquidity in position",
|
||||
RequiredParams: []string{"params"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0x0c49ccbe")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0x0c49ccbe"),
|
||||
Name: "decreaseLiquidity",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeManager,
|
||||
EventType: EventTypePositionUpdate,
|
||||
Description: "Decrease liquidity in position",
|
||||
RequiredParams: []string{"params"},
|
||||
}
|
||||
|
||||
r.functionSignatures[bytesToSelector("0xfc6f7865")] = &FunctionSignature{
|
||||
Selector: bytesToSelector("0xfc6f7865"),
|
||||
Name: "collect",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
ContractType: ContractTypeManager,
|
||||
EventType: EventTypeFeeCollection,
|
||||
Description: "Collect fees from position",
|
||||
RequiredParams: []string{"params"},
|
||||
}
|
||||
}
|
||||
|
||||
// loadEventSignatures loads all DEX event signatures
|
||||
func (r *SignatureRegistry) loadEventSignatures() {
|
||||
// Uniswap V2 event signatures
|
||||
r.eventSignatures[stringToTopic("Swap(address,uint256,uint256,uint256,uint256,address)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Swap(address,uint256,uint256,uint256,uint256,address)"),
|
||||
Name: "Swap",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Uniswap V2 swap event",
|
||||
IsIndexed: []bool{true, false, false, false, false, true},
|
||||
RequiredTopics: 1,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("Mint(address,uint256,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Mint(address,uint256,uint256)"),
|
||||
Name: "Mint",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
EventType: EventTypeLiquidityAdd,
|
||||
Description: "Uniswap V2 mint event",
|
||||
IsIndexed: []bool{true, false, false},
|
||||
RequiredTopics: 1,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("Burn(address,uint256,uint256,address)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Burn(address,uint256,uint256,address)"),
|
||||
Name: "Burn",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
EventType: EventTypeLiquidityRemove,
|
||||
Description: "Uniswap V2 burn event",
|
||||
IsIndexed: []bool{true, false, false, true},
|
||||
RequiredTopics: 1,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("PairCreated(address,address,address,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("PairCreated(address,address,address,uint256)"),
|
||||
Name: "PairCreated",
|
||||
Protocol: ProtocolUniswapV2,
|
||||
EventType: EventTypePoolCreated,
|
||||
Description: "Uniswap V2 pair created event",
|
||||
IsIndexed: []bool{true, true, false, false},
|
||||
RequiredTopics: 3,
|
||||
}
|
||||
|
||||
// Uniswap V3 event signatures
|
||||
r.eventSignatures[stringToTopic("Swap(address,address,int256,int256,uint160,uint128,int24)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Swap(address,address,int256,int256,uint160,uint128,int24)"),
|
||||
Name: "Swap",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Uniswap V3 swap event",
|
||||
IsIndexed: []bool{true, true, false, false, false, false, false},
|
||||
RequiredTopics: 3,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("Mint(address,address,int24,int24,uint128,uint256,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Mint(address,address,int24,int24,uint128,uint256,uint256)"),
|
||||
Name: "Mint",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
EventType: EventTypeLiquidityAdd,
|
||||
Description: "Uniswap V3 mint event",
|
||||
IsIndexed: []bool{true, true, true, true, false, false, false},
|
||||
RequiredTopics: 4,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("Burn(address,int24,int24,uint128,uint256,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Burn(address,int24,int24,uint128,uint256,uint256)"),
|
||||
Name: "Burn",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
EventType: EventTypeLiquidityRemove,
|
||||
Description: "Uniswap V3 burn event",
|
||||
IsIndexed: []bool{true, true, true, false, false, false},
|
||||
RequiredTopics: 4,
|
||||
}
|
||||
|
||||
r.eventSignatures[stringToTopic("PoolCreated(address,address,uint24,int24,address)")] = &EventSignature{
|
||||
Topic0: stringToTopic("PoolCreated(address,address,uint24,int24,address)"),
|
||||
Name: "PoolCreated",
|
||||
Protocol: ProtocolUniswapV3,
|
||||
EventType: EventTypePoolCreated,
|
||||
Description: "Uniswap V3 pool created event",
|
||||
IsIndexed: []bool{true, true, true, false, false},
|
||||
RequiredTopics: 4,
|
||||
}
|
||||
|
||||
// Balancer V2 event signatures
|
||||
r.eventSignatures[stringToTopic("Swap(bytes32,address,address,uint256,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Swap(bytes32,address,address,uint256,uint256)"),
|
||||
Name: "Swap",
|
||||
Protocol: ProtocolBalancerV2,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Balancer V2 swap event",
|
||||
IsIndexed: []bool{true, true, true, false, false},
|
||||
RequiredTopics: 4,
|
||||
}
|
||||
|
||||
// Curve event signatures
|
||||
r.eventSignatures[stringToTopic("TokenExchange(address,int128,uint256,int128,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("TokenExchange(address,int128,uint256,int128,uint256)"),
|
||||
Name: "TokenExchange",
|
||||
Protocol: ProtocolCurve,
|
||||
EventType: EventTypeSwap,
|
||||
Description: "Curve token exchange event",
|
||||
IsIndexed: []bool{true, false, false, false, false},
|
||||
RequiredTopics: 2,
|
||||
}
|
||||
|
||||
// 1inch event signatures
|
||||
r.eventSignatures[stringToTopic("Swapped(address,address,address,uint256,uint256,uint256)")] = &EventSignature{
|
||||
Topic0: stringToTopic("Swapped(address,address,address,uint256,uint256,uint256)"),
|
||||
Name: "Swapped",
|
||||
Protocol: Protocol1Inch,
|
||||
EventType: EventTypeAggregatorSwap,
|
||||
Description: "1inch swap event",
|
||||
IsIndexed: []bool{false, true, true, false, false, false},
|
||||
RequiredTopics: 3,
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
func bytesToSelector(hexStr string) [4]byte {
|
||||
var selector [4]byte
|
||||
if len(hexStr) >= 10 && hexStr[:2] == "0x" {
|
||||
data := common.FromHex(hexStr)
|
||||
if len(data) >= 4 {
|
||||
copy(selector[:], data[:4])
|
||||
}
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
func stringToTopic(signature string) common.Hash {
|
||||
return crypto.Keccak256Hash([]byte(signature))
|
||||
}
|
||||
|
||||
// GetFunctionSignatureCount returns the total number of function signatures
|
||||
func (r *SignatureRegistry) GetFunctionSignatureCount() int {
|
||||
r.signaturesLock.RLock()
|
||||
defer r.signaturesLock.RUnlock()
|
||||
|
||||
return len(r.functionSignatures)
|
||||
}
|
||||
|
||||
// GetEventSignatureCount returns the total number of event signatures
|
||||
func (r *SignatureRegistry) GetEventSignatureCount() int {
|
||||
r.signaturesLock.RLock()
|
||||
defer r.signaturesLock.RUnlock()
|
||||
|
||||
return len(r.eventSignatures)
|
||||
}
|
||||
|
||||
// ExportSignatures returns all signatures as JSON
|
||||
func (r *SignatureRegistry) ExportSignatures() (string, error) {
|
||||
r.signaturesLock.RLock()
|
||||
defer r.signaturesLock.RUnlock()
|
||||
|
||||
data := map[string]interface{}{
|
||||
"function_signatures": r.functionSignatures,
|
||||
"event_signatures": r.eventSignatures,
|
||||
"last_updated": r.lastUpdated,
|
||||
}
|
||||
|
||||
jsonData, err := json.MarshalIndent(data, "", " ")
|
||||
return string(jsonData), err
|
||||
}
|
||||
Reference in New Issue
Block a user