diff --git a/abis/GraphPayments.json b/abis/GraphPayments.json new file mode 100644 index 00000000..156f9b05 --- /dev/null +++ b/abis/GraphPayments.json @@ -0,0 +1,317 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "controller", + "type": "address", + "internalType": "address" + }, + { + "name": "protocolPaymentCut", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "PROTOCOL_PAYMENT_CUT", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "collect", + "inputs": [ + { + "name": "paymentType", + "type": "uint8", + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "receiver", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "dataService", + "type": "address", + "internalType": "address" + }, + { + "name": "dataServiceCut", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "multicall", + "inputs": [ + { + "name": "data", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "outputs": [ + { + "name": "results", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "GraphDirectoryInitialized", + "inputs": [ + { + "name": "graphToken", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "graphStaking", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "graphPayments", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphEscrow", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphController", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "graphEpochManager", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphRewardsManager", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphTokenGateway", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphProxyAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "graphCuration", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "GraphPaymentCollected", + "inputs": [ + { + "name": "paymentType", + "type": "uint8", + "indexed": true, + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "payer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "receiver", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "dataService", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensProtocol", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensDataService", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensDelegationPool", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensReceiver", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AddressEmptyCode", + "inputs": [ + { + "name": "target", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "FailedInnerCall", + "inputs": [] + }, + { + "type": "error", + "name": "GraphDirectoryInvalidZeroAddress", + "inputs": [ + { + "name": "contractName", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "GraphPaymentsInvalidCut", + "inputs": [ + { + "name": "cut", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "GraphPaymentsInvalidProtocolPaymentCut", + "inputs": [ + { + "name": "protocolPaymentCut", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidInitialization", + "inputs": [] + }, + { + "type": "error", + "name": "NotInitializing", + "inputs": [] + }, + { + "type": "error", + "name": "PPMMathInvalidMulPPM", + "inputs": [ + { + "name": "a", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "b", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "PPMMathInvalidPPM", + "inputs": [ + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + } +] \ No newline at end of file diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json new file mode 100644 index 00000000..24ce6816 --- /dev/null +++ b/abis/HorizonStaking.json @@ -0,0 +1,2462 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "controller", + "type": "address" + }, + { + "internalType": "address", + "name": "stakingExtensionAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "subgraphDataServiceAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "contractName", + "type": "bytes" + } + ], + "name": "GraphDirectoryInvalidZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingCallerIsServiceProvider", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minTokens", + "type": "uint256" + } + ], + "name": "HorizonStakingInsufficientDelegationTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minTokens", + "type": "uint256" + } + ], + "name": "HorizonStakingInsufficientIdleStake", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "HorizonStakingInsufficientShares", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minTokens", + "type": "uint256" + } + ], + "name": "HorizonStakingInsufficientStakeForLegacyAllocations", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minRequired", + "type": "uint256" + } + ], + "name": "HorizonStakingInsufficientTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeCut", + "type": "uint256" + } + ], + "name": "HorizonStakingInvalidDelegationFeeCut", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "HorizonStakingInvalidDelegationPool", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "HorizonStakingInvalidDelegationPoolState", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + } + ], + "name": "HorizonStakingInvalidMaxVerifierCut", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "HorizonStakingInvalidProvision", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingInvalidServiceProviderZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingInvalidThawRequestType", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "maxThawingPeriod", + "type": "uint64" + } + ], + "name": "HorizonStakingInvalidThawingPeriod", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "HorizonStakingInvalidVerifier", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingInvalidVerifierZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingInvalidZeroShares", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingInvalidZeroTokens", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingLegacySlashFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "HorizonStakingNotAuthorized", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingNothingThawing", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingNothingToWithdraw", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingProvisionAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "HorizonStakingSlippageProtection", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "until", + "type": "uint256" + } + ], + "name": "HorizonStakingStillThawing", + "type": "error" + }, + { + "inputs": [], + "name": "HorizonStakingTooManyThawRequests", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxTokens", + "type": "uint256" + } + ], + "name": "HorizonStakingTooManyTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "HorizonStakingVerifierNotAllowed", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListEmptyList", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListInvalidIterations", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListInvalidZeroId", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListMaxElementsExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "ManagedIsPaused", + "type": "error" + }, + { + "inputs": [], + "name": "ManagedOnlyController", + "type": "error" + }, + { + "inputs": [], + "name": "ManagedOnlyGovernor", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "PPMMathInvalidMulPPM", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "AllowedLockedVerifierSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "DelegatedTokensWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "paymentType", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeCut", + "type": "uint256" + } + ], + "name": "DelegationFeeCutSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "DelegationSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DelegationSlashingEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "DelegationSlashingSkipped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "graphStaking", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphPayments", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphEscrow", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "graphController", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphEpochManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphRewardsManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphTokenGateway", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphProxyAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphCuration", + "type": "address" + } + ], + "name": "GraphDirectoryInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "HorizonStakeDeposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "until", + "type": "uint256" + } + ], + "name": "HorizonStakeLocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "HorizonStakeWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "maxThawingPeriod", + "type": "uint64" + } + ], + "name": "MaxThawingPeriodSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "OperatorSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + } + ], + "name": "ProvisionCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ProvisionIncreased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + } + ], + "name": "ProvisionParametersSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + } + ], + "name": "ProvisionParametersStaged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ProvisionSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ProvisionThawed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "StakeDelegatedWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "thawingUntil", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "thawRequestId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "name": "ThawRequestCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "thawRequestId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "thawingUntil", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bool", + "name": "valid", + "type": "bool" + } + ], + "name": "ThawRequestFulfilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "thawRequestsFulfilled", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ThawRequestsFulfilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "ThawingPeriodCleared", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "TokensDelegated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "TokensDeprovisioned", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "TokensToDelegationPoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "TokensUndelegated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "destination", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "VerifierTokensSent", + "type": "event" + }, + { + "stateMutability": "nonpayable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "acceptProvisionParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IGraphProxy", + "name": "_proxy", + "type": "address" + } + ], + "name": "acceptProxy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IGraphProxy", + "name": "_proxy", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "acceptProxyAndCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "addToDelegationPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "addToProvision", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "clearThawingPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minSharesOut", + "type": "uint256" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nThawRequests", + "type": "uint256" + } + ], + "name": "deprovision", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "getDelegatedTokensAvailable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "delegator", + "type": "address" + } + ], + "name": "getDelegation", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "internalType": "struct IHorizonStakingTypes.Delegation", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "paymentType", + "type": "uint8" + } + ], + "name": "getDelegationFeeCut", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "getDelegationPool", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokensThawing", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sharesThawing", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "thawingNonce", + "type": "uint256" + } + ], + "internalType": "struct IHorizonStakingTypes.DelegationPool", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "getIdleStake", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMaxThawingPeriod", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "getProviderTokensAvailable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "getProvision", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokensThawing", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sharesThawing", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "createdAt", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "maxVerifierCutPending", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "thawingPeriodPending", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "thawingNonce", + "type": "uint256" + } + ], + "internalType": "struct IHorizonStakingTypes.Provision", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "getServiceProvider", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "tokensStaked", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokensProvisioned", + "type": "uint256" + } + ], + "internalType": "struct IHorizonStakingTypes.ServiceProvider", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "getStake", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStakingExtension", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "thawRequestId", + "type": "bytes32" + } + ], + "name": "getThawRequest", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "thawingUntil", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "next", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "thawingNonce", + "type": "uint256" + } + ], + "internalType": "struct IHorizonStakingTypes.ThawRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getThawRequestList", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "head", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "tail", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "internalType": "struct LinkedList.List", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IHorizonStakingTypes.ThawRequestType", + "name": "requestType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getThawedTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint32", + "name": "delegationRatio", + "type": "uint32" + } + ], + "name": "getTokensAvailable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "isAllowedLockedVerifier", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isAuthorized", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isDelegationSlashingEnabled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + } + ], + "name": "provision", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "maxVerifierCut", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "thawingPeriod", + "type": "uint64" + } + ], + "name": "provisionLocked", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oldServiceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "oldVerifier", + "type": "address" + }, + { + "internalType": "address", + "name": "newServiceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "newVerifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minSharesForNewProvider", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nThawRequests", + "type": "uint256" + } + ], + "name": "redelegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "oldVerifier", + "type": "address" + }, + { + "internalType": "address", + "name": "newVerifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nThawRequests", + "type": "uint256" + } + ], + "name": "reprovision", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "setAllowedLockedVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "paymentType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "feeCut", + "type": "uint256" + } + ], + "name": "setDelegationFeeCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "setDelegationSlashingEnabled", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "maxThawingPeriod", + "type": "uint64" + } + ], + "name": "setMaxThawingPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "setOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "setOperatorLocked", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint32", + "name": "newMaxVerifierCut", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "newThawingPeriod", + "type": "uint64" + } + ], + "name": "setProvisionParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokensVerifier", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifierDestination", + "type": "address" + } + ], + "name": "slash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "stake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "stakeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "stakeToProvision", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "thaw", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "undelegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "undelegate", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "unstake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "verifier", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nThawRequests", + "type": "uint256" + } + ], + "name": "withdrawDelegated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "withdrawDelegated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json new file mode 100644 index 00000000..a99cd7d0 --- /dev/null +++ b/abis/SubgraphService.json @@ -0,0 +1,2254 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "graphController", + "type": "address" + }, + { + "internalType": "address", + "name": "disputeManager", + "type": "address" + }, + { + "internalType": "address", + "name": "graphTallyCollector", + "type": "address" + }, + { + "internalType": "address", + "name": "curation", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "AllocationAlreadyExists", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "internalType": "uint256", + "name": "closedAt", + "type": "uint256" + } + ], + "name": "AllocationClosed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "AllocationDoesNotExist", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "AllocationManagerAllocationClosed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "AllocationManagerAllocationSameSize", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "AllocationManagerInvalidAllocationProof", + "type": "error" + }, + { + "inputs": [], + "name": "AllocationManagerInvalidZeroAllocationId", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "claimId", + "type": "bytes32" + } + ], + "name": "DataServiceFeesClaimNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "DataServiceFeesZeroTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "DataServicePausableNotPauseGuardian", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "DataServicePausablePauseGuardianNoChange", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "internalType": "address", + "name": "disputeManager", + "type": "address" + } + ], + "name": "DirectoryNotDisputeManager", + "type": "error" + }, + { + "inputs": [], + "name": "ECDSAInvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "ECDSAInvalidSignatureLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "ECDSAInvalidSignatureS", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "contractName", + "type": "bytes" + } + ], + "name": "GraphDirectoryInvalidZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "LegacyAllocationAlreadyExists", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListEmptyList", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListInvalidIterations", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListInvalidZeroId", + "type": "error" + }, + { + "inputs": [], + "name": "LinkedListMaxElementsExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "PPMMathInvalidMulPPM", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ProvisionManagerInvalidRange", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ProvisionManagerInvalidValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "internalType": "address", + "name": "caller", + "type": "address" + } + ], + "name": "ProvisionManagerNotAuthorized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "ProvisionManagerProvisionNotFound", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokensAvailable", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokensRequired", + "type": "uint256" + } + ], + "name": "ProvisionTrackerInsufficientTokens", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "SubgraphServiceAllocationIsAltruistic", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "SubgraphServiceAllocationNotAuthorized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "SubgraphServiceCannotForceCloseAllocation", + "type": "error" + }, + { + "inputs": [], + "name": "SubgraphServiceEmptyGeohash", + "type": "error" + }, + { + "inputs": [], + "name": "SubgraphServiceEmptyUrl", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "balanceBefore", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceAfter", + "type": "uint256" + } + ], + "name": "SubgraphServiceInconsistentCollection", + "type": "error" + }, + { + "inputs": [], + "name": "SubgraphServiceIndexerAlreadyRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "providedIndexer", + "type": "address" + }, + { + "internalType": "address", + "name": "expectedIndexer", + "type": "address" + } + ], + "name": "SubgraphServiceIndexerMismatch", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + } + ], + "name": "SubgraphServiceIndexerNotRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "collectionId", + "type": "bytes32" + } + ], + "name": "SubgraphServiceInvalidCollectionId", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "curationCut", + "type": "uint256" + } + ], + "name": "SubgraphServiceInvalidCurationCut", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "paymentType", + "type": "uint8" + } + ], + "name": "SubgraphServiceInvalidPaymentType", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "ravIndexer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationIndexer", + "type": "address" + } + ], + "name": "SubgraphServiceInvalidRAV", + "type": "error" + }, + { + "inputs": [], + "name": "SubgraphServiceInvalidZeroStakeToFeesRatio", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "forceClosed", + "type": "bool" + } + ], + "name": "AllocationClosed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "currentEpoch", + "type": "uint256" + } + ], + "name": "AllocationCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newTokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "oldTokens", + "type": "uint256" + } + ], + "name": "AllocationResized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "curationCut", + "type": "uint256" + } + ], + "name": "CurationCutSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "ratio", + "type": "uint32" + } + ], + "name": "DelegationRatioSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "EIP712DomainChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "graphStaking", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphPayments", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphEscrow", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "graphController", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphEpochManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphRewardsManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphTokenGateway", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphProxyAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphCuration", + "type": "address" + } + ], + "name": "GraphDirectoryInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensRewards", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensIndexerRewards", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensDelegationRewards", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "poi", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "publicPoi", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "currentEpoch", + "type": "uint256" + } + ], + "name": "IndexingRewardsCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + } + ], + "name": "LegacyAllocationMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maxPOIStaleness", + "type": "uint256" + } + ], + "name": "MaxPOIStalenessSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "PauseGuardianSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "ProvisionPendingParametersAccepted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "min", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "max", + "type": "uint256" + } + ], + "name": "ProvisionTokensRangeSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "payer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensCollected", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensCurators", + "type": "uint256" + } + ], + "name": "QueryFeesCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardsDestination", + "type": "address" + } + ], + "name": "RewardsDestinationSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "feeType", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ServicePaymentCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ServiceProviderRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "ServiceProviderSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ServiceStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "ServiceStopped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "claimId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "unlockTimestamp", + "type": "uint256" + } + ], + "name": "StakeClaimLocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "claimId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "releasableAt", + "type": "uint256" + } + ], + "name": "StakeClaimReleased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "serviceProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "claimsCount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensReleased", + "type": "uint256" + } + ], + "name": "StakeClaimsReleased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "ratio", + "type": "uint256" + } + ], + "name": "StakeToFeesRatioSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "subgraphService", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "disputeManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "graphTallyCollector", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "curation", + "type": "address" + } + ], + "name": "SubgraphServiceDirectoryInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "min", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "max", + "type": "uint64" + } + ], + "name": "ThawingPeriodRangeSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "min", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "max", + "type": "uint32" + } + ], + "name": "VerifierCutRangeSet", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "acceptProvisionPendingParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + } + ], + "name": "allocationProvisionTracker", + "outputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "claimId", + "type": "bytes32" + } + ], + "name": "claims", + "outputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "releasableAt", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "nextClaim", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "claimsLists", + "outputs": [ + { + "internalType": "bytes32", + "name": "head", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "tail", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "count", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "closeStaleAllocation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "enum IGraphPayments.PaymentTypes", + "name": "paymentType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "collect", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "curationFeesCut", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "eip712Domain", + "outputs": [ + { + "internalType": "bytes1", + "name": "fields", + "type": "bytes1" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "version", + "type": "string" + }, + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifyingContract", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "salt", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "extensions", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "encodeAllocationProof", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "serviceProvider", + "type": "address" + } + ], + "name": "feesProvisionTracker", + "outputs": [ + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "getAllocation", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "closedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastPOIPresentedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardsPerAllocatedToken", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "accRewardsPending", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdAtEpoch", + "type": "uint256" + } + ], + "internalType": "struct Allocation.State", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "getAllocationData", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCuration", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDelegationRatio", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDisputeManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getGraphTallyCollector", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "allocationId", + "type": "address" + } + ], + "name": "getLegacyAllocation", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + } + ], + "internalType": "struct LegacyAllocation.State", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProvisionTokensRange", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "subgraphDeploymentId", + "type": "bytes32" + } + ], + "name": "getSubgraphAllocatedTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getThawingPeriodRange", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVerifierCutRange", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + } + ], + "name": "indexers", + "outputs": [ + { + "internalType": "uint256", + "name": "registeredAt", + "type": "uint256" + }, + { + "internalType": "string", + "name": "url", + "type": "string" + }, + { + "internalType": "string", + "name": "geoHash", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "minimumProvisionTokens", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "maximumDelegationRatio", + "type": "uint32" + }, + { + "internalType": "uint256", + "name": "stakeToFeesRatio", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + } + ], + "name": "isOverAllocated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxPOIStaleness", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" + } + ], + "name": "migrateLegacyAllocation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pauseGuardian", + "type": "address" + } + ], + "name": "pauseGuardians", + "outputs": [ + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "register", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "numClaimsToRelease", + "type": "uint256" + } + ], + "name": "releaseStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "address", + "name": "allocationId", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokens", + "type": "uint256" + } + ], + "name": "resizeAllocation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + } + ], + "name": "rewardsDestination", + "outputs": [ + { + "internalType": "address", + "name": "destination", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "curationCut", + "type": "uint256" + } + ], + "name": "setCurationCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "delegationRatio", + "type": "uint32" + } + ], + "name": "setDelegationRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maxPOIStaleness", + "type": "uint256" + } + ], + "name": "setMaxPOIStaleness", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "minimumProvisionTokens", + "type": "uint256" + } + ], + "name": "setMinimumProvisionTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pauseGuardian", + "type": "address" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + } + ], + "name": "setPauseGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "rewardsDestination", + "type": "address" + } + ], + "name": "setRewardsDestination", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stakeToFeesRatio_", + "type": "uint256" + } + ], + "name": "setStakeToFeesRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "slash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakeToFeesRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "startService", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "indexer", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "stopService", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/config/addresses.template.ts b/config/addresses.template.ts index dda69c57..89df6658 100644 --- a/config/addresses.template.ts +++ b/config/addresses.template.ts @@ -20,6 +20,8 @@ export class Addresses { l1GraphTokenGateway: string l2GraphTokenGateway: string ethereumDIDRegistry: string + subgraphService: string + graphPayments: string isL1: boolean } @@ -45,5 +47,7 @@ export let addresses: Addresses = { l1GraphTokenGateway: '{{l1GraphTokenGateway}}', l2GraphTokenGateway: '{{l2GraphTokenGateway}}', ethereumDIDRegistry: '{{ethereumDIDRegistry}}', + subgraphService: '{{subgraphService}}', + graphPayments: '{{graphPayments}}', isL1: {{isL1}}, } diff --git a/config/arbitrumGoerliAddressScript.ts b/config/arbitrumGoerliAddressScript.ts deleted file mode 100644 index d83f9f4b..00000000 --- a/config/arbitrumGoerliAddressScript.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as fs from 'fs' -import * as mustache from 'mustache' -import * as networkAddresses from '@graphprotocol/contracts/addresses.json' -import { Addresses } from './addresses.template' - -// mustache doesn't like numbered object keys -// eslint-disable-next-line @typescript-eslint/no-explicit-any -let renameAddresses: any = networkAddresses -renameAddresses['arbgor'] = networkAddresses['421613'] - -export let addresses: Addresses = { - controller: '{{arbgor.Controller.address}}', - graphToken: '{{arbgor.L2GraphToken.address}}', - epochManager: '{{arbgor.EpochManager.address}}', - disputeManager: '{{arbgor.DisputeManager.address}}', - staking: '{{arbgor.L2Staking.address}}', - stakingExtension: '{{arbgor.StakingExtension.address}}', - curation: '{{arbgor.L2Curation.address}}', - rewardsManager: '{{arbgor.RewardsManager.address}}', - serviceRegistry: '{{arbgor.ServiceRegistry.address}}', - gns: '{{arbgor.L2GNS.address}}', - ens: '{{arbgor.IENS.address}}', - ensPublicResolver: '{{arbgor.IPublicResolver.address}}', - blockNumber: '', - bridgeBlockNumber: '', - network: '', - tokenLockManager: '', - subgraphNFT: '{{arbgor.SubgraphNFT.address}}', - l1GraphTokenGateway: '', - l2GraphTokenGateway: '{{arbgor.L2GraphTokenGateway.address}}', - ethereumDIDRegistry: '{{arbgor.IEthereumDIDRegistry.address}}', - isL1: false, -} - -const main = (): void => { - try { - let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses)) - output.blockNumber = '1023264' // Protocol deployment - output.bridgeBlockNumber = '1023272' // Bridge deployment block on L2 - output.network = 'arbitrum-goerli' - output.useTokenLockManager = false - if(output.ens == '') { - output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config - } - fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) - } catch (e) { - console.log(`Error saving artifacts: ${e.message}`) - } -} - -main() diff --git a/config/arbitrumSepoliaAddressScript.ts b/config/arbitrumSepoliaAddressScript.ts index bde52f92..851f6dd3 100644 --- a/config/arbitrumSepoliaAddressScript.ts +++ b/config/arbitrumSepoliaAddressScript.ts @@ -13,8 +13,8 @@ export let addresses: Addresses = { graphToken: '{{arbsep.L2GraphToken.address}}', epochManager: '{{arbsep.EpochManager.address}}', disputeManager: '{{arbsep.DisputeManager.address}}', - staking: '{{arbsep.L2Staking.address}}', - stakingExtension: '{{arbsep.StakingExtension.address}}', + staking: '{{arbsep.HorizonStaking.address}}', + stakingExtension: '{{arbsep.HorizonStaking.address}}', curation: '{{arbsep.L2Curation.address}}', rewardsManager: '{{arbsep.RewardsManager.address}}', serviceRegistry: '{{arbsep.ServiceRegistry.address}}', @@ -29,6 +29,8 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '{{arbsep.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbsep.EthereumDIDRegistry.address}}', + subgraphService: '{{arbsep.SubgraphService.address}}', + graphPayments: '{{arbsep.GraphPayments.address}}', isL1: false, } @@ -45,6 +47,13 @@ const main = (): void => { if(output.ethereumDIDRegistry == '') { output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config } + // remove once we have proper packages + if(output.subgraphService == '') { + output.subgraphService = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + if(output.graphPayments == '') { + output.graphPayments = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) } catch (e) { console.log(`Error saving artifacts: ${e.message}`) diff --git a/config/goerliAddressScript.ts b/config/goerliAddressScript.ts deleted file mode 100644 index f0a48f71..00000000 --- a/config/goerliAddressScript.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as fs from 'fs' -import * as mustache from 'mustache' -import * as networkAddresses from '@graphprotocol/contracts/addresses.json' -import { Addresses } from './addresses.template' - -// mustache doesn't like numbered object keys -// eslint-disable-next-line @typescript-eslint/no-explicit-any -let renameAddresses: any = networkAddresses -renameAddresses['goerli'] = networkAddresses['5'] - -export let addresses: Addresses = { - controller: '{{goerli.Controller.address}}', - graphToken: '{{goerli.GraphToken.address}}', - epochManager: '{{goerli.EpochManager.address}}', - disputeManager: '{{goerli.DisputeManager.address}}', - staking: '{{goerli.L1Staking.address}}', - stakingExtension: '{{goerli.StakingExtension.address}}', - curation: '{{goerli.Curation.address}}', - rewardsManager: '{{goerli.RewardsManager.address}}', - serviceRegistry: '{{goerli.ServiceRegistry.address}}', - gns: '{{goerli.L1GNS.address}}', - ens: '{{goerli.IENS.address}}', - ensPublicResolver: '{{goerli.IPublicResolver.address}}', - blockNumber: '', - bridgeBlockNumber: '', - network: '', - tokenLockManager: '', - subgraphNFT: '{{goerli.SubgraphNFT.address}}', - l1GraphTokenGateway: '{{goerli.L1GraphTokenGateway.address}}', - l2GraphTokenGateway: '', - ethereumDIDRegistry: '{{goerli.IEthereumDIDRegistry.address}}', - isL1: true, -} - -const main = (): void => { - try { - let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses)) - output.blockNumber = '7210000' // Hardcoded from before first contract deploy of the latest phase - output.bridgeBlockNumber = '7891183' // Bridge deployment block on L1 - output.network = 'goerli' - output.tokenLockManager = '0x9a7a54e86560f4304d8862Ea00F45D1090c59ac8' // we don't have one, this is rinkebys' - output.useTokenLockManager = true - if(output.ens == '') { - output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config - } - fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) - } catch (e) { - console.log(`Error saving artifacts: ${e.message}`) - } -} - -main() diff --git a/config/ipfs.json b/config/ipfs.json deleted file mode 100644 index ab467581..00000000 --- a/config/ipfs.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ipfs": true -} diff --git a/config/localNetworkAddressScript.ts b/config/localNetworkAddressScript.ts new file mode 100644 index 00000000..74f08ce1 --- /dev/null +++ b/config/localNetworkAddressScript.ts @@ -0,0 +1,67 @@ +import * as fs from 'fs' +import * as mustache from 'mustache' +// Replace with proper imports once the packages are published +import * as horizonAddresses from '/opt/horizon.json' +import * as subgraphServiceAddresses from '/opt/subgraph-service.json' +import { Addresses } from './addresses.template' + +// mustache doesn't like numbered object keys +// eslint-disable-next-line @typescript-eslint/no-explicit-any +let renameAddresses: any = { + horizon: horizonAddresses['1337'], + subgraphService: subgraphServiceAddresses['1337'], +} + +export let addresses: Addresses = { + controller: '{{horizon.Controller.address}}', + graphToken: '{{horizon.L2GraphToken.address}}', + epochManager: '{{horizon.EpochManager.address}}', + disputeManager: '{{subgraphService.DisputeManager.address}}', + staking: '{{horizon.HorizonStaking.address}}', + stakingExtension: '{{horizon.HorizonStaking.address}}', + curation: '{{horizon.L2Curation.address}}', + rewardsManager: '{{horizon.RewardsManager.address}}', + serviceRegistry: '0x0000000000000000000000000000000000000000', + gns: '{{horizon.L2GNS.address}}', + ens: '{{horizon.IENS.address}}', + ensPublicResolver: '{{horizon.IPublicResolver.address}}', + blockNumber: '', + bridgeBlockNumber: '', + network: '', + tokenLockManager: '', + subgraphNFT: '{{horizon.SubgraphNFT.address}}', + l1GraphTokenGateway: '', + l2GraphTokenGateway: '{{horizon.L2GraphTokenGateway.address}}', + ethereumDIDRegistry: '{{horizon.EthereumDIDRegistry.address}}', + subgraphService: '{{subgraphService.SubgraphService.address}}', + graphPayments: '{{horizon.GraphPayments.address}}', + isL1: false, +} + +const main = (): void => { + try { + let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses)) + output.blockNumber = '1' + output.bridgeBlockNumber = '1' + output.network = 'hardhat' + output.useTokenLockManager = false + if(output.ens == '') { + output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + if(output.ethereumDIDRegistry == '') { + output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + // TODO: Remove this once subgraph service scripts deploy GNS and SubgraphNFT + if(output.gns == '') { + output.gns = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + if(output.subgraphNFT == '') { + output.subgraphNFT = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) + } catch (e) { + console.log(`Error saving artifacts: ${e.message}`) + } +} + +main() diff --git a/config/mainnetAddressScript.ts b/config/mainnetAddressScript.ts deleted file mode 100644 index 4ddba6e9..00000000 --- a/config/mainnetAddressScript.ts +++ /dev/null @@ -1,52 +0,0 @@ -import * as fs from 'fs' -import * as mustache from 'mustache' -import * as networkAddresses from '@graphprotocol/contracts/addresses.json' -import { Addresses } from './addresses.template' - -// mustache doesn't like numbered object keys -// eslint-disable-next-line @typescript-eslint/no-explicit-any -let renameAddresses: any = networkAddresses -renameAddresses['mainnet'] = networkAddresses['1'] - -export let addresses: Addresses = { - controller: '{{mainnet.Controller.address}}', - graphToken: '{{mainnet.GraphToken.address}}', - epochManager: '{{mainnet.EpochManager.address}}', - disputeManager: '{{mainnet.DisputeManager.address}}', - staking: '{{mainnet.L1Staking.address}}', - stakingExtension: '{{mainnet.StakingExtension.address}}', - curation: '{{mainnet.Curation.address}}', - rewardsManager: '{{mainnet.RewardsManager.address}}', - serviceRegistry: '{{mainnet.ServiceRegistry.address}}', - gns: '{{mainnet.L1GNS.address}}', - ens: '{{mainnet.IENS.address}}', - ensPublicResolver: '{{mainnet.IPublicResolver.address}}', - blockNumber: '', - bridgeBlockNumber: '', - network: '', - tokenLockManager: '', - subgraphNFT: '{{mainnet.SubgraphNFT.address}}', - l1GraphTokenGateway: '{{mainnet.L1GraphTokenGateway.address}}', - l2GraphTokenGateway: '', - ethereumDIDRegistry: '{{mainnet.IEthereumDIDRegistry.address}}', - isL1: true, -} - -const main = (): void => { - try { - let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses)) - output.blockNumber = '11440000' // Hardcoded a few thousand blocks before 1st contract deployed - output.network = 'mainnet' - output.bridgeBlockNumber = '16083315' // Bridge deployment block on L1 - output.tokenLockManager = '0xFCf78AC094288D7200cfdB367A8CD07108dFa128' - output.useTokenLockManager = true - if(output.ens == '') { - output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config - } - fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) - } catch (e) { - console.log(`Error saving artifacts: ${e.message}`) - } -} - -main() diff --git a/config/mainnetArbitrumAddressScript.ts b/config/mainnetArbitrumAddressScript.ts index b8fb1985..97f74e18 100644 --- a/config/mainnetArbitrumAddressScript.ts +++ b/config/mainnetArbitrumAddressScript.ts @@ -29,6 +29,8 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '{{arbitrum.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbitrum.IEthereumDIDRegistry.address}}', + subgraphService: '{{arbitrum.SubgraphService.address}}', + graphPayments: '{{arbitrum.GraphPayments.address}}', isL1: false, } @@ -46,6 +48,13 @@ const main = (): void => { if(output.ens == '') { output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config } + // remove once we have proper packages + if(output.subgraphService == '') { + output.subgraphService = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } + if(output.graphPayments == '') { + output.graphPayments = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config + } fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) } catch (e) { console.log(`Error saving artifacts: ${e.message}`) diff --git a/config/no-ipfs.json b/config/no-ipfs.json deleted file mode 100644 index ee53b3b9..00000000 --- a/config/no-ipfs.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ipfs": false -} diff --git a/config/sepoliaAddressScript.ts b/config/sepoliaAddressScript.ts deleted file mode 100644 index 3fe4cf3c..00000000 --- a/config/sepoliaAddressScript.ts +++ /dev/null @@ -1,55 +0,0 @@ -import * as fs from 'fs' -import * as mustache from 'mustache' -import * as networkAddresses from '@graphprotocol/contracts/addresses.json' -import { Addresses } from './addresses.template' - -// mustache doesn't like numbered object keys -// eslint-disable-next-line @typescript-eslint/no-explicit-any -let renameAddresses: any = networkAddresses -renameAddresses['sepolia'] = networkAddresses['11155111'] - -export let addresses: Addresses = { - controller: '{{sepolia.Controller.address}}', - graphToken: '{{sepolia.GraphToken.address}}', - epochManager: '{{sepolia.EpochManager.address}}', - disputeManager: '{{sepolia.DisputeManager.address}}', - staking: '{{sepolia.L1Staking.address}}', - stakingExtension: '{{sepolia.StakingExtension.address}}', - curation: '{{sepolia.Curation.address}}', - rewardsManager: '{{sepolia.RewardsManager.address}}', - serviceRegistry: '{{sepolia.ServiceRegistry.address}}', - gns: '{{sepolia.L1GNS.address}}', - ens: '{{sepolia.IENS.address}}', - ensPublicResolver: '{{sepolia.IPublicResolver.address}}', - blockNumber: '', - bridgeBlockNumber: '', - network: '', - tokenLockManager: '', - subgraphNFT: '{{sepolia.SubgraphNFT.address}}', - l1GraphTokenGateway: '{{sepolia.L1GraphTokenGateway.address}}', - l2GraphTokenGateway: '', - ethereumDIDRegistry: '{{sepolia.EthereumDIDRegistry.address}}', - isL1: true, -} - -const main = (): void => { - try { - let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses)) - output.blockNumber = '4454000' - output.bridgeBlockNumber = '4454000' - output.network = 'sepolia' - //output.tokenLockManager = '0x9a7a54e86560f4304d8862Ea00F45D1090c59ac8' // we don't have one, this is rinkebys' - output.useTokenLockManager = false - if(output.ens == '') { - output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config - } - if(output.ethereumDIDRegistry == '') { - output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config - } - fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2)) - } catch (e) { - console.log(`Error saving artifacts: ${e.message}`) - } -} - -main() diff --git a/config/testAddressesL1.ts b/config/testAddressesL1.ts index d4eacb42..b6faebe5 100644 --- a/config/testAddressesL1.ts +++ b/config/testAddressesL1.ts @@ -29,6 +29,8 @@ export let addresses: Addresses = { l1GraphTokenGateway: '0x0000000000000000000000000000000000000000', l2GraphTokenGateway: '', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', + subgraphService: '0x0000000000000000000000000000000000000000', + graphPayments: '0x0000000000000000000000000000000000000000', isL1: true, } diff --git a/config/testAddressesL2.ts b/config/testAddressesL2.ts index c18dbb4f..4bfc932c 100644 --- a/config/testAddressesL2.ts +++ b/config/testAddressesL2.ts @@ -29,6 +29,8 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '0x0000000000000000000000000000000000000000', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', + subgraphService: '0x0000000000000000000000000000000000000000', + graphPayments: '0x0000000000000000000000000000000000000000', isL1: false, } diff --git a/package.json b/package.json index 262abf34..6d6fffa5 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "devDependencies": { "@graphprotocol/contracts": "6.2.0", "@graphprotocol/graph-cli": "0.68.5", - "@graphprotocol/graph-ts": "0.32.0", + "@graphprotocol/graph-ts": "0.38.0", "@types/node": "^14.0.13", "@typescript-eslint/eslint-plugin": "^3.3.0", "@typescript-eslint/parser": "^3.3.0", @@ -57,6 +57,5 @@ "bugs": { "url": "https://github.com/graphprotocol/graph-network-subgraph/issues" }, - "homepage": "https://github.com/graphprotocol/graph-network-subgraph#readme", - "dependencies": {} + "homepage": "https://github.com/graphprotocol/graph-network-subgraph#readme" } diff --git a/schema.graphql b/schema.graphql index 622f7204..f2146737 100644 --- a/schema.graphql +++ b/schema.graphql @@ -50,7 +50,7 @@ type GraphNetwork @entity { channelDisputeEpochs: Int! "Epochs to wait before delegators can settle" maxAllocationEpochs: Int! - "Time in blocks needed to wait to unstake" + "Time in blocks needed to wait to unstake. Set to 0 to signal Graph Horizon's transition period end." thawingPeriod: Int! "Minimum time an Indexer must use for resetting their Delegation parameters" delegationParametersCooldown: Int! @@ -70,6 +70,10 @@ type GraphNetwork @entity { delegationTaxPercentage: Int! "Asset holder for the protocol" assetHolders: [Bytes!] + "Maximum allowed thawing period for provisions, in seconds" + maxThawingPeriod: BigInt! + "True if delegation slashing is enabled" + delegationSlashingEnabled: Boolean! # Transfers to L2 totals "Total amount of indexer stake transferred to L2" @@ -86,6 +90,10 @@ type GraphNetwork @entity { totalTokensClaimable: BigInt! # TODO - see https://github.com/graphprotocol/graph-network-subgraph/issues/89 "Total tokens that are currently locked or withdrawable in the network from unstaking" totalUnstakedTokensLocked: BigInt! + "Total GRT currently in provisions" + totalTokensProvisioned: BigInt! + "Total GRT currently thawing from provisions" + totalTokensThawing: BigInt! "Total GRT currently in allocation" totalTokensAllocated: BigInt! "Total delegated tokens in the protocol" @@ -231,6 +239,50 @@ type GraphNetwork @entity { currentL1BlockNumber: BigInt } +type DataService @entity { + "Data Service address" + id: ID! + + "Total GRT currently in provisions for this DataService" + totalTokensProvisioned: BigInt! + "Total GRT currently thawing from provisions for this DataService" + totalTokensThawing: BigInt! + "Total GRT currently in allocations for this DataService" + totalTokensAllocated: BigInt! + "Total GRT currently delegated to this DataService" + totalTokensDelegated: BigInt! + + "Minimum provision tokens for this DataService" + minimumProvisionTokens: BigInt! + "Maximum provision tokens for this DataService" + maximumProvisionTokens: BigInt! + + "Minimum verifier cut for this DataService" + minimumVerifierCut: BigInt! + "Maximum verifier cut for this DataService" + maximumVerifierCut: BigInt! + + "Minimum thawing period for this DataService" + minimumThawingPeriod: BigInt! + "Maximum thawing period for this DataService" + maximumThawingPeriod: BigInt! + + "Ratio of max staked delegation tokens to indexers stake that earns rewards" + delegationRatio: Int + + provisions: [Provision!]! @derivedFrom(field: "dataService") + + "True if allowed for usage with token lock wallets" + allowedWithTokenLockWallets: Boolean! + + "[SubgraphService] Curation cut for this DataService" + curationCut: BigInt! + "[SubgraphService] Max POI staleness" + maxPOIStaleness: BigInt! + "[SubgraphService] Stake to fees ratio" + stakeToFeesRatio: BigInt! +} + """ An account within the graph network. Contains metadata and all relevant data for this accounts delegating, curating, and indexing. @@ -253,8 +305,10 @@ type GraphAccount @entity { # Operator info "Operator of other Graph Accounts" operatorOf: [GraphAccount!]! @derivedFrom(field: "operators") - "Operators of this Graph Accounts" + "Operators of this Graph Account" operators: [GraphAccount!]! + "Horizon Operators of this Graph Account" + horizonOperators: [HorizonOperator!]! # GRT info "Graph token balance" @@ -555,11 +609,12 @@ type SubgraphDeployment @entity { indexingDelegatorRewardAmount: BigInt! "Total query fees earned by this Subgraph Deployment, without curator query fees" queryFeesAmount: BigInt! - "Total query fee rebates earned from the protocol, through the rebates formula. Does not include delegation fees" + "Total query fee rebates earned from the protocol, through the rebates formula. Does not include delegation query fees" queryFeeRebates: BigInt! "Total curator rewards from fees" curatorFeeRewards: BigInt! - # TODO - We can add a field here for delegation fees earned when calling claim() + "Total query fee rebates earned from the protocol, through the rebates formula. Does not include indexer query fees" + delegatorsQueryFeeRebates: BigInt! # Subgraph deployment curation bonding curve "CURRENT signalled tokens in the bonding curve" @@ -669,12 +724,21 @@ type Indexer @entity { url: String "Geohash of the indexer. Shows where their indexer is located in the world" geoHash: String + "Address that receives the rewards from the indexer" + rewardsDestination: Bytes "Default display name is the current default name. Used for filtered queries" defaultDisplayName: String + "Whether the indexer is a legacy indexer. This is true for all indexers registered before the Horizon upgrade" + isLegacy: Boolean! + # Staking data "CURRENT tokens staked in the protocol. Decreases on withdraw, not on lock" stakedTokens: BigInt! + "CURRENT tokens provisioned to data services in the protocol. In the V1 protocol, all staked tokens were always provisioned to an implicit 'subgraph data service'" + provisionedTokens: BigInt! + "CURRENT tokens thawing from provisions to data services in the protocol. Only for Horizon" + thawingTokens: BigInt! "CURRENT tokens allocated on all subgraphs" allocatedTokens: BigInt! "NOT IMPLEMENTED - Tokens that have been unstaked and withdrawn" @@ -764,6 +828,9 @@ type Indexer @entity { "Count of how many times this indexer has been forced to close an allocation" forcedClosures: Int! + # Provisioning + provisions: [Provision!]! @derivedFrom(field: "indexer") + # Metrics "NOT IMPLEMENTED - Total return this indexer has earned" totalReturn: BigDecimal! @@ -771,9 +838,6 @@ type Indexer @entity { annualizedReturn: BigDecimal! # You must multiple by 100 to get percentage "NOT IMPLEMENTED - Staking efficiency of the indexer" stakingEfficiency: BigDecimal! - - # Query fees breakdown by payment address - } type PaymentSource @entity { @@ -815,18 +879,173 @@ type IndexerQueryFeePaymentAggregation @entity { paymentSource: PaymentSource! } +type HorizonOperator @entity { + "Joint address of all 3 parties involved (Operator, Indexer, DataService)" + id: ID! + + operatorOf: [GraphAccount!]! @derivedFrom(field: "horizonOperators") + + operator: GraphAccount! + + indexer: Indexer! + + dataService: DataService! + + allowed: Boolean! +} + + """ -A state channel Allocation representing a single Indexer-SubgraphDeployment stake + For the Horizon Stage 1 subgraph, the Provision entity will be mimicking the Indexer entity as closely as possible. + That means that the Provision entity will contain some fields that are particular for the Subgraph Service, even if in Horizon + a Provision could be for a different Data Service from the Subgraph Service. + This is to make the data closer to the legacy protocol, given that the Subgraph Service will be the first Data Service to be supported + + Once the Stage 2 subgraph is implemented, the Provision entity will have to be more generic, and particular data service fields will need to be restructured. +""" +type Provision @entity { + "Join ID of indexer address (service provider) and DataService address" + id: ID! + + indexer: Indexer! + + dataService: DataService! + + tokensProvisioned: BigInt! + + tokensAllocated: BigInt! + + tokensSlashedServiceProvider: BigInt! + + tokensSlashedDelegationPool: BigInt! + + totalAllocationCount: BigInt! + + allocationCount: Int! + + "Active allocations of stake for this Provision" + allocations: [Allocation!]! @derivedFrom(field: "activeForProvision") + + "Timestamp when the provision was created" + createdAt: BigInt! + + "Service provider tokens that are being thawed (and will stop being slashable soon)" + tokensThawing: BigInt! + + "Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed" + maxVerifierCut: BigInt! + + "Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active" + maxVerifierCutPending: BigInt! + + "Time, in seconds, tokens must thaw before being withdrawn" + thawingPeriod: BigInt! + + "Pending value for thawingPeriod. Verifier needs to accept it before it becomes active" + thawingPeriodPending: BigInt! + + # Percentage of rewards/fees that the delegation pool receives + "Raw query fee cut. In Horizon this is amount of query fees that the delegation pool receives in PPM" + queryFeeCut: BigInt! + + "Raw indexing fee cut. In Horizon this is amount of indexing fees that the delegation pool receives in PPM" + indexingFeeCut: BigInt! + + "Raw indexing rewards cut. In Horizon this is amount of indexing rewards that the delegation pool receives in PPM" + indexingRewardsCut: BigInt! + + "The percent of indexing rewards generated by the delegated stake that the Indexer keeps for itself" + indexingRewardEffectiveCut: BigDecimal! + "The percent of query fees generated by the delegated stake that the Indexer keeps for itself" + queryFeeEffectiveCut: BigDecimal! + "The percent of reward dilution delegators experience because of overdelegation. Overdelegated stake can't be used to generate rewards but still gets accounted while distributing the generated rewards. This causes dilution of the rewards for the rest of the pool." + overDelegationDilution: BigDecimal! + + # Might want to add polymorphic handling of different fee cuts through a generic hashmap in the future + + # Indexing rewards. Keeping the same naming from Indexer entity to make it easier to understand + "Total indexing rewards earned by this indexer. Including delegation rewards" + rewardsEarned: BigInt! + "The total amount of indexing rewards the indexer kept" + indexerIndexingRewards: BigInt! + "The total amount of indexing rewards given to delegators" + delegatorIndexingRewards: BigInt! + + # Query fees + "Total query fees collected. Includes the portion given to delegators" + queryFeesCollected: BigInt! + "Query fee amount collected from the protocol. Does not include portion given to delegators" + indexerQueryFees: BigInt! + "Query fee amount collected from the protocol for Delegators. Does not include portion taken by the indexer" + delegatorQueryFees: BigInt! + + # Delegation + "Tokens delegated to the provision" + delegatedTokens: BigInt! + "Total shares of the delegator pool" + delegatorShares: BigInt! + "Exchange rate of tokens received for each share" + delegationExchangeRate: BigDecimal! + "Ratio between the amount of the indexers own stake over the total usable stake (capped by the delegationRatio)." + ownStakeRatio: BigDecimal! + "Ratio between the amount of delegated stake over the total usable stake (capped by the delegationRatio)." + delegatedStakeRatio: BigDecimal! + "Percentage of indexers' own rewards received in relation to its own stake. 1 (100%) means that the indexer is receiving the exact amount that is generated by his own stake, the value can be over 100% or below depending on the amount of delegation and cuts set" + indexerRewardsOwnGenerationRatio: BigDecimal! + + "Service registry URL for the indexer" + url: String + "Geohash of the indexer. Shows where their indexer is located in the world" + geoHash: String + "Address set as rewards destination for payments to the service provider" + rewardsDestination: Bytes +} + +enum ThawRequestType { + Provision + Delegation +} + +type ThawRequest @entity { + id: ID! + + type: ThawRequestType! + + indexer: Indexer! + + dataService: DataService! + + owner: GraphAccount! + + "Shares representing the thawing tokens" + shares: BigInt! + + "Tokens thawed" + tokens: BigInt! + + thawingUntil: BigInt! + + fulfilledAsValid: Boolean + + fulfilled: Boolean! +} + +""" +A state channel Allocation representing a single Indexer/Provision-SubgraphDeployment stake """ type Allocation @entity { "Channel Address" id: ID! "Indexer of this allocation" indexer: Indexer! + "Provision of this allocation (for Horizon allocations only)" + provision: Provision "Creator of the allocation - can be the operator or the indexer" creator: Bytes! "If the Allocation is active it shows the indexer. If closed, it is null" activeForIndexer: Indexer + "If the Allocation is active it shows the provision. If closed, it is null" + activeForProvision: Provision "Subgraph deployment that is being allocated to" subgraphDeployment: SubgraphDeployment! "Tokens allocation in this allocation" @@ -869,10 +1088,22 @@ type Allocation @entity { createdAt: Int! "Timestamp this allocation was closed at" closedAt: Int - "POI submitted with a closed allocation" + "POI submitted when closing allocations in the legacy protocol. Also reflects the latest POI submitted for a Horizon payment collection" poi: Bytes - - # Indexer cut settings at start and close + "POIs submitted when collecting payments in Horizon" + pois: [PoiSubmission!]! @derivedFrom(field: "allocation") + "Public POIs submitted when collecting payments in Horizon" + publicPois: [PublicPoiSubmission!]! @derivedFrom(field: "allocation") + "Number of POIs submitted for this allocation. Only available for Horizon allocations" + poiCount: BigInt + "Timestamp for the latest POI presentation" + latestPoiPresentedAt: Int + "Whether this allocation was created in the legacy protocol. If true, the allocation will not have a provision since it's not a Horizon allocation" + isLegacy: Boolean! + "Whether this allocation was forced closed. Force closures in Horizon can happen when the latest PoI is stale, compared to the legacy protocol, where force closures can happen when the allocation hasn't been closed within the max amount of epochs" + forceClosed: Boolean + + # Indexer/Provision cut settings at start and close indexingRewardCutAtStart: Int! indexingRewardEffectiveCutAtStart: BigDecimal! queryFeeCutAtStart: Int! @@ -890,6 +1121,30 @@ type Allocation @entity { annualizedReturn: BigDecimal! } +type PoiSubmission @entity { + id: ID! + + allocation: Allocation! + + poi: Bytes! + + submittedAtEpoch: Int! + + presentedAtTimestamp: Int! +} + +type PublicPoiSubmission @entity { + id: ID! + + allocation: Allocation! + + publicPoi: Bytes! + + submittedAtEpoch: Int! + + presentedAtTimestamp: Int! +} + enum AllocationStatus { Null # == indexer == address(0) Active # == not Null && tokens > 0 # @@ -951,8 +1206,12 @@ Delegator stake for a single Indexer type DelegatedStake @entity { "Concatenation of Delegator address and Indexer address" id: ID! - "Index the stake is delegated to" + "Indexer the stake is delegated to" indexer: Indexer! + "DataService the stake is delegated to. Only for Horizon delegations" + dataService: DataService + "Provision the stake is delegated to. Only for Horizon delegations" + provision: Provision "Delegator" delegator: Delegator! "CUMULATIVE tokens delegated" diff --git a/src/mappings/graphPayments.ts b/src/mappings/graphPayments.ts new file mode 100644 index 00000000..6a159149 --- /dev/null +++ b/src/mappings/graphPayments.ts @@ -0,0 +1,26 @@ +import { addresses } from "../../config/addresses" +import { GraphPaymentCollected } from "../types/GraphPayments/GraphPayments" +import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadPaymentSource } from "./helpers/helpers" + +export function handleGraphPaymentCollected(event: GraphPaymentCollected): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + + // Update epoch + let epoch = createOrLoadEpoch( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, + ) + epoch.taxedQueryFees = epoch.taxedQueryFees.plus(event.params.tokensProtocol) + epoch.save() + + // update graph network + graphNetwork.totalTaxedQueryFees = graphNetwork.totalTaxedQueryFees.plus(event.params.tokensProtocol) + graphNetwork.save() + + // Replicate for payment source specific data + // Payer here is the PaymentsEscrow in most cases, might need to figure out how to know who funded the escrow in the future + let paymentSource = createOrLoadPaymentSource(event.params.payer) + paymentSource.totalTaxedQueryFees = paymentSource.totalTaxedQueryFees.plus(event.params.tokensProtocol) + paymentSource.save() + + // Might want to add data service tax tracking here +} diff --git a/src/mappings/helpers/decoder.ts b/src/mappings/helpers/decoder.ts new file mode 100644 index 00000000..a78eb895 --- /dev/null +++ b/src/mappings/helpers/decoder.ts @@ -0,0 +1,20 @@ +import { ByteArray, Bytes } from '@graphprotocol/graph-ts'; + + +// Wrap arguments with this function if (and only if) one of the arguments is an array or 'bytes' or 'string' (i.e. variable length arg) +// See: +// - https://medium.com/@r2d2_68242/indexing-transaction-input-data-in-a-subgraph-6ff5c55abf20 +// - https://ethereum.stackexchange.com/questions/114582/the-graph-nodes-cant-decode-abi-encoded-data-containing-arrays +// - https://github.com/enzymefinance/subgraphs/blob/main/packages/utils/utils/decode.ts +export function tuplePrefixBytes(input: Bytes): Bytes { + let inputTypedArray = input.subarray(0); + + let tuplePrefix = ByteArray.fromHexString('0x0000000000000000000000000000000000000000000000000000000000000020'); + + let inputAsTuple = new Uint8Array(tuplePrefix.length + inputTypedArray.length); + + inputAsTuple.set(tuplePrefix, 0); + inputAsTuple.set(inputTypedArray, tuplePrefix.length); + + return Bytes.fromUint8Array(inputAsTuple); +} \ No newline at end of file diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index b19d91e7..ac0966f5 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -26,6 +26,9 @@ import { CurrentSubgraphDeploymentRelation, PaymentSource, IndexerQueryFeePaymentAggregation, + Provision, + DataService, + HorizonOperator, } from '../../types/schema' import { SubgraphDeploymentManifest as SubgraphDeploymentManifestTemplate @@ -99,6 +102,7 @@ export function createOrLoadSubgraphDeployment( deployment.indexingDelegatorRewardAmount = BigInt.fromI32(0) deployment.queryFeesAmount = BigInt.fromI32(0) deployment.queryFeeRebates = BigInt.fromI32(0) + deployment.delegatorsQueryFeeRebates = BigInt.fromI32(0) deployment.curatorFeeRewards = BigInt.fromI32(0) deployment.signalledTokensReceivedOnL2 = BigInt.fromI32(0) deployment.signalledTokensSentToL2 = BigInt.fromI32(0) @@ -125,7 +129,7 @@ export function createOrLoadSubgraphDeployment( return deployment as SubgraphDeployment } -export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): Indexer { +export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt ): Indexer { let id = indexerAddress.toHexString() let indexer = Indexer.load(id) if (indexer == null) { @@ -133,9 +137,14 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I indexer.createdAt = timestamp.toI32() indexer.account = id + // By default we assume indexers are not legacy. Legacy codepaths should flip this to true + indexer.isLegacy = false + indexer.stakedTokens = BigInt.fromI32(0) indexer.transferredToL2 = false indexer.stakedTokensTransferredToL2 = BigInt.fromI32(0) + indexer.provisionedTokens = BigInt.fromI32(0) + indexer.thawingTokens = BigInt.fromI32(0) indexer.allocatedTokens = BigInt.fromI32(0) indexer.lockedTokens = BigInt.fromI32(0) indexer.unstakedTokens = BigInt.fromI32(0) @@ -172,6 +181,10 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I indexer.annualizedReturn = BigDecimal.fromString('0') indexer.stakingEfficiency = BigDecimal.fromString('0') + indexer.url = '' + indexer.geoHash = '' + indexer.rewardsDestination = Address.fromString('0x0000000000000000000000000000000000000000') + let graphAccount = createOrLoadGraphAccount(indexerAddress, timestamp) graphAccount.indexer = id graphAccount.save() @@ -187,6 +200,99 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I return indexer as Indexer } +export function createOrLoadLegacyIndexer(indexerAddress: Bytes, timestamp: BigInt): Indexer { + let indexer = createOrLoadIndexer(indexerAddress, timestamp) + indexer.isLegacy = true + indexer.save() + return indexer +} + +export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: Bytes, timestamp: BigInt): Provision { + let id = joinID([indexerAddress.toHexString(), verifierAddress.toHexString()]) + let provision = Provision.load(id) + if (provision == null) { + provision = new Provision(id) + provision.indexer = indexerAddress.toHexString() + provision.dataService = verifierAddress.toHexString() + provision.tokensProvisioned = BigInt.fromI32(0) + provision.tokensAllocated = BigInt.fromI32(0) + provision.tokensSlashedServiceProvider = BigInt.fromI32(0) + provision.tokensSlashedDelegationPool = BigInt.fromI32(0) + provision.totalAllocationCount = BigInt.fromI32(0) + provision.allocationCount = 0 + provision.tokensThawing = BigInt.fromI32(0) + provision.createdAt = timestamp + provision.maxVerifierCut = BigInt.fromI32(0) + provision.maxVerifierCutPending = BigInt.fromI32(0) + provision.thawingPeriod = BigInt.fromI32(0) + provision.thawingPeriodPending = BigInt.fromI32(0) + provision.queryFeeCut = BigInt.fromI32(0) + provision.indexingFeeCut = BigInt.fromI32(0) + provision.indexingRewardsCut = BigInt.fromI32(0) + provision.indexingRewardEffectiveCut = BigInt.fromI32(0).toBigDecimal() + provision.queryFeeEffectiveCut = BigInt.fromI32(0).toBigDecimal() + provision.overDelegationDilution = BigInt.fromI32(0).toBigDecimal() + provision.rewardsEarned = BigInt.fromI32(0) + provision.indexerIndexingRewards = BigInt.fromI32(0) + provision.delegatorIndexingRewards = BigInt.fromI32(0) + provision.queryFeesCollected = BigInt.fromI32(0) + provision.indexerQueryFees = BigInt.fromI32(0) + provision.delegatorQueryFees = BigInt.fromI32(0) + provision.delegatedTokens = BigInt.fromI32(0) + provision.delegatorShares = BigInt.fromI32(0) + provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal() + provision.ownStakeRatio = BigInt.fromI32(0).toBigDecimal() + provision.delegatedStakeRatio = BigInt.fromI32(0).toBigDecimal() + provision.indexerRewardsOwnGenerationRatio = BigInt.fromI32(0).toBigDecimal() + provision.url = '' + provision.geoHash = '' + provision.rewardsDestination = Bytes.fromI32(0) + provision.save() + } + + return provision as Provision +} + +export function createOrLoadDataService(verifierAddress: Bytes): DataService { + let id = verifierAddress.toHexString() + let service = DataService.load(id) + if (service == null) { + service = new DataService(id) + service.totalTokensAllocated = BigInt.fromI32(0) + service.totalTokensProvisioned = BigInt.fromI32(0) + service.totalTokensThawing = BigInt.fromI32(0) + service.allowedWithTokenLockWallets = false + service.curationCut = BigInt.fromI32(0) + service.maxPOIStaleness = BigInt.fromI32(0) + service.stakeToFeesRatio = BigInt.fromI32(0) + service.minimumProvisionTokens = BigInt.fromI32(0) + service.maximumProvisionTokens = BigInt.fromI32(0) + service.minimumVerifierCut = BigInt.fromI32(0) + service.maximumVerifierCut = BigInt.fromI32(0) + service.minimumThawingPeriod = BigInt.fromI32(0) + service.maximumThawingPeriod = BigInt.fromI32(0) + service.totalTokensDelegated = BigInt.fromI32(0) + service.save() + } + + return service as DataService +} + +export function createOrLoadHorizonOperator(address: Bytes, verifierAddress: Bytes, indexerAddress: Bytes): HorizonOperator { + let id = joinID([address.toHexString(), indexerAddress.toHexString(), verifierAddress.toHexString()]) + let operator = HorizonOperator.load(id) + if (operator == null) { + operator = new HorizonOperator(id) + operator.allowed = false + operator.operator = address.toHexString() + operator.indexer = indexerAddress.toHexString() + operator.dataService = verifierAddress.toHexString() + operator.save() + } + + return operator as HorizonOperator +} + export function createOrLoadPaymentSource(paymentAddress: Bytes): PaymentSource { let id = paymentAddress.toHexString() let paymentSource = PaymentSource.load(id) @@ -284,6 +390,46 @@ export function createOrLoadDelegatedStake( } return delegatedStake as DelegatedStake } + +export function createOrLoadDelegatedStakeForProvision( + delegator: string, + indexer: string, + dataService: string, + timestamp: i32, +): DelegatedStake { + let provisionId = joinID([indexer, dataService]) + let id = joinID([delegator, provisionId]) + let delegatedStake = DelegatedStake.load(id) + if (delegatedStake == null) { + delegatedStake = new DelegatedStake(id) + delegatedStake.indexer = indexer + delegatedStake.dataService = dataService + delegatedStake.provision = provisionId + delegatedStake.delegator = delegator + delegatedStake.stakedTokens = BigInt.fromI32(0) + delegatedStake.transferredToL2 = false + delegatedStake.stakedTokensTransferredToL2 = BigInt.fromI32(0) + delegatedStake.unstakedTokens = BigInt.fromI32(0) + delegatedStake.lockedTokens = BigInt.fromI32(0) + delegatedStake.lockedUntil = 0 + delegatedStake.shareAmount = BigInt.fromI32(0) + delegatedStake.personalExchangeRate = BigDecimal.fromString('1') + delegatedStake.realizedRewards = BigDecimal.fromString('0') + delegatedStake.createdAt = timestamp + + delegatedStake.save() + + let delegatorEntity = Delegator.load(delegator)! + delegatorEntity.stakesCount = delegatorEntity.stakesCount + 1 + delegatorEntity.save() + + let graphNetwork = GraphNetwork.load('1')! + graphNetwork.delegationCount = graphNetwork.delegationCount + 1 + graphNetwork.save() + } + return delegatedStake as DelegatedStake +} + export function createOrLoadCurator(curatorAddress: Bytes, timestamp: BigInt): Curator { let id = curatorAddress.toHexString() let curator = Curator.load(id) @@ -418,6 +564,7 @@ export function createOrLoadGraphAccount(owner: Bytes, timeStamp: BigInt): Graph graphAccount = new GraphAccount(id) graphAccount.createdAt = timeStamp.toI32() graphAccount.operators = [] + graphAccount.horizonOperators = [] graphAccount.balance = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Signalling = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Delegation = BigInt.fromI32(0) @@ -552,6 +699,8 @@ export function createOrLoadGraphNetwork( graphNetwork.totalTokensStaked = BigInt.fromI32(0) graphNetwork.totalTokensClaimable = BigInt.fromI32(0) graphNetwork.totalUnstakedTokensLocked = BigInt.fromI32(0) + graphNetwork.totalTokensProvisioned = BigInt.fromI32(0) + graphNetwork.totalTokensThawing = BigInt.fromI32(0) graphNetwork.totalTokensAllocated = BigInt.fromI32(0) graphNetwork.totalDelegatedTokens = BigInt.fromI32(0) graphNetwork.totalTokensSignalled = BigInt.fromI32(0) @@ -631,6 +780,9 @@ export function createOrLoadGraphNetwork( graphNetwork.totalGRTWithdrawn = BigInt.fromI32(0) graphNetwork.totalGRTWithdrawnConfirmed = BigInt.fromI32(0) + graphNetwork.maxThawingPeriod = BigInt.fromI32(0) + graphNetwork.delegationSlashingEnabled = false + graphNetwork.save() } if (!addresses.isL1) { @@ -832,9 +984,10 @@ export function calculateOverdelegationDilution(indexer: Indexer): BigDecimal { let graphNetwork = GraphNetwork.load('1')! let delegationRatioBD = BigInt.fromI32(graphNetwork.delegationRatio).toBigDecimal() let maxDelegatedStake = stakedTokensBD * delegationRatioBD - return stakedTokensBD == BigDecimal.fromString('0') + let maxDelegatedStakeBD = max(maxDelegatedStake, delegatedTokensBD) + return maxDelegatedStakeBD == BigDecimal.fromString('0') ? BigDecimal.fromString('0') - : BigDecimal.fromString('1') - maxDelegatedStake / max(maxDelegatedStake, delegatedTokensBD) + : BigDecimal.fromString('1') - maxDelegatedStake / maxDelegatedStakeBD } export function updateAdvancedIndexerMetrics(indexer: Indexer): Indexer { @@ -849,6 +1002,71 @@ export function updateAdvancedIndexerMetrics(indexer: Indexer): Indexer { return indexer as Indexer } +export function calculateOwnStakeRatioForProvision(provision: Provision): BigDecimal { + let totalTokens = provision.tokensProvisioned.plus(provision.delegatedTokens) + return totalTokens == BigInt.fromI32(0) + ? BigDecimal.fromString('0') + : provision.tokensProvisioned.toBigDecimal().div(totalTokens.toBigDecimal()) +} + +export function calculateDelegatedStakeRatioForProvision(provision: Provision): BigDecimal { + let totalTokens = provision.tokensProvisioned.plus(provision.delegatedTokens) + return totalTokens == BigInt.fromI32(0) + ? BigDecimal.fromString('0') + : provision.delegatedTokens.toBigDecimal().div(totalTokens.toBigDecimal()) +} + +export function calculateIndexingRewardEffectiveCutForProvision(provision: Provision): BigDecimal { + let delegatorCut = + provision.indexingRewardsCut.toBigDecimal() / + BigDecimal.fromString('1000000') + return provision.delegatedStakeRatio == BigDecimal.fromString('0') + ? BigDecimal.fromString('0') + : BigDecimal.fromString('1') - delegatorCut / provision.delegatedStakeRatio +} + +export function calculateQueryFeeEffectiveCutForProvision(provision: Provision): BigDecimal { + let delegatorCut = + provision.queryFeeCut.toBigDecimal() / BigDecimal.fromString('1000000') + return provision.delegatedStakeRatio == BigDecimal.fromString('0') + ? BigDecimal.fromString('0') + : BigDecimal.fromString('1') - delegatorCut / provision.delegatedStakeRatio +} + +export function calculateIndexerRewardOwnGenerationRatioForProvision(provision: Provision): BigDecimal { + let delegatorCut = + provision.indexingRewardsCut.toBigDecimal() / BigDecimal.fromString('1000000') + return provision.ownStakeRatio == BigDecimal.fromString('0') + ? BigDecimal.fromString('0') + : (BigDecimal.fromString('1') - delegatorCut) / provision.ownStakeRatio +} + +export function calculateOverdelegationDilutionForProvision(provision: Provision): BigDecimal { + let provisionedTokensBD = provision.tokensProvisioned.toBigDecimal() + let delegatedTokensBD = provision.delegatedTokens.toBigDecimal() + let dataService = DataService.load(provision.dataService)! + if (dataService.delegationRatio == null) { + return BigDecimal.fromString('0') + } + let delegationRatioBD = BigInt.fromI32(dataService.delegationRatio).toBigDecimal() + let maxDelegatedStake = provisionedTokensBD * delegationRatioBD + return provisionedTokensBD == BigDecimal.fromString('0') + ? BigDecimal.fromString('0') + : BigDecimal.fromString('1') - maxDelegatedStake / max(maxDelegatedStake, delegatedTokensBD) +} + +export function updateAdvancedProvisionMetrics(provision: Provision): Provision { + provision.ownStakeRatio = calculateOwnStakeRatioForProvision(provision as Provision) + provision.delegatedStakeRatio = calculateDelegatedStakeRatioForProvision(provision as Provision) + provision.indexingRewardEffectiveCut = calculateIndexingRewardEffectiveCutForProvision(provision as Provision) + provision.queryFeeEffectiveCut = calculateQueryFeeEffectiveCutForProvision(provision as Provision) + provision.indexerRewardsOwnGenerationRatio = calculateIndexerRewardOwnGenerationRatioForProvision( + provision as Provision, + ) + provision.overDelegationDilution = calculateOverdelegationDilutionForProvision(provision as Provision) + return provision as Provision +} + export function updateDelegationExchangeRate(indexer: Indexer): Indexer { indexer.delegationExchangeRate = indexer.delegatedTokens .toBigDecimal() @@ -857,6 +1075,14 @@ export function updateDelegationExchangeRate(indexer: Indexer): Indexer { return indexer as Indexer } +export function updateDelegationExchangeRateForProvision(provision: Provision): Provision { + provision.delegationExchangeRate = provision.delegatedTokens + .toBigDecimal() + .div(provision.delegatorShares.toBigDecimal()) + .truncate(18) + return provision as Provision +} + // TODO - this is broken if we change the delegatio ratio // Need to remove, or find a fix export function calculateCapacities(indexer: Indexer): Indexer { @@ -890,10 +1116,10 @@ export function calculatePricePerShare(deployment: SubgraphDeployment): BigDecim deployment.signalAmount == BigInt.fromI32(0) ? BigDecimal.fromString('0') : deployment.signalledTokens - .toBigDecimal() - .div(deployment.signalAmount.toBigDecimal()) - .times(BigInt.fromI32(reserveRatioMultiplier).toBigDecimal()) - .truncate(18) + .toBigDecimal() + .div(deployment.signalAmount.toBigDecimal()) + .times(BigInt.fromI32(reserveRatioMultiplier).toBigDecimal()) + .truncate(18) return pricePerShare } diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts new file mode 100644 index 00000000..1dee16e5 --- /dev/null +++ b/src/mappings/horizonStaking.ts @@ -0,0 +1,524 @@ +import { BigInt } from '@graphprotocol/graph-ts' +import { addresses } from '../../config/addresses' +import { AllowedLockedVerifierSet, DelegatedTokensWithdrawn, DelegationFeeCutSet, DelegationSlashed, DelegationSlashingEnabled, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, MaxThawingPeriodSet, OperatorSet, StakeDelegatedWithdrawn, ThawingPeriodCleared, TokensDelegated, TokensDeprovisioned, TokensToDelegationPoolAdded, TokensUndelegated } from '../types/HorizonStaking/HorizonStaking' +import { DelegatedStake, Delegator, Indexer, Provision, ThawRequest } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadDelegatedStake, createOrLoadDelegatedStakeForProvision, createOrLoadDelegator, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadHorizonOperator, createOrLoadIndexer, createOrLoadProvision, joinID, updateAdvancedIndexerMetrics, updateAdvancedProvisionMetrics, updateDelegationExchangeRate, updateDelegationExchangeRateForProvision } from './helpers/helpers' +import { + ProvisionCreated, + ProvisionIncreased, + ProvisionParametersSet, + ProvisionParametersStaged, + ProvisionSlashed, + ProvisionThawed, + ThawRequestCreated, + ThawRequestFulfilled, +} from '../types/HorizonStaking/HorizonStaking' + +export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + // update indexer + let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) + let previousStake = indexer.stakedTokens + indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) + indexer.save() + + // Update graph network + graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.plus(event.params.tokens) + if (previousStake.isZero()) { + graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount + 1 + } + graphNetwork.save() + + // Update epoch + let epoch = createOrLoadEpoch( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, + ) + epoch.stakeDeposited = epoch.stakeDeposited.plus(event.params.tokens) + epoch.save() +} + +export function handleHorizonStakeLocked(event: HorizonStakeLocked): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + // update indexer + let id = event.params.serviceProvider.toHexString() + let indexer = Indexer.load(id)! + indexer.lockedTokens = event.params.tokens + indexer.tokensLockedUntil = event.params.until.toI32() + indexer.save() + + // update graph network + graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.plus( + event.params.tokens, + ) + graphNetwork.save() +} + +export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + // update indexer + let id = event.params.serviceProvider.toHexString() + let indexer = Indexer.load(id)! + indexer.stakedTokens = indexer.stakedTokens.minus(event.params.tokens) + indexer.lockedTokens = BigInt.fromI32(0) // set to 0 to prevent issues when Stage 2 comes + indexer.tokensLockedUntil = 0 // always set to 0 when withdrawn + indexer.save() + + // Update graph network + graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) + graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.minus( + event.params.tokens, + ) + // We might want to introduce the notion of "provisioned indexer count" or "active indexer count" + // to each data service since that's what this particular count wanted to convey. + if (indexer.stakedTokens.isZero()) { + graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount - 1 + } + graphNetwork.save() +} + +export function handleProvisionCreated(event: ProvisionCreated): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + indexer.provisionedTokens = indexer.provisionedTokens.plus(event.params.tokens) + indexer.save() + + dataService.totalTokensProvisioned = dataService.totalTokensProvisioned.plus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.plus(event.params.tokens) + graphNetwork.save() + + provision.tokensProvisioned = provision.tokensProvisioned.plus(event.params.tokens) + provision.maxVerifierCut = event.params.maxVerifierCut + provision.maxVerifierCutPending = event.params.maxVerifierCut + provision.thawingPeriod = event.params.thawingPeriod + provision.thawingPeriodPending = event.params.thawingPeriod + provision.save() +} + +export function handleProvisionIncreased(event: ProvisionIncreased): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + indexer.provisionedTokens = indexer.provisionedTokens.plus(event.params.tokens) + indexer.save() + + dataService.totalTokensProvisioned = dataService.totalTokensProvisioned.plus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.plus(event.params.tokens) + graphNetwork.save() + + provision.tokensProvisioned = provision.tokensProvisioned.plus(event.params.tokens) + provision.save() +} + +export function handleProvisionThawed(event: ProvisionThawed): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + indexer.thawingTokens = indexer.thawingTokens.plus(event.params.tokens) + indexer.save() + + dataService.totalTokensThawing = dataService.totalTokensThawing.plus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensThawing = graphNetwork.totalTokensThawing.plus(event.params.tokens) + graphNetwork.save() + + provision.tokensThawing = provision.tokensThawing.plus(event.params.tokens) + provision.save() +} + +export function handleTokensDeprovisioned(event: TokensDeprovisioned): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + indexer.provisionedTokens = indexer.provisionedTokens.minus(event.params.tokens) + indexer.thawingTokens = indexer.thawingTokens.minus(event.params.tokens) + indexer.save() + + dataService.totalTokensProvisioned = dataService.totalTokensProvisioned.minus(event.params.tokens) + dataService.totalTokensThawing = dataService.totalTokensThawing.minus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.minus(event.params.tokens) + graphNetwork.totalTokensThawing = graphNetwork.totalTokensThawing.minus(event.params.tokens) + graphNetwork.save() + + provision.tokensProvisioned = provision.tokensProvisioned.minus(event.params.tokens) + provision.tokensThawing = provision.tokensThawing.minus(event.params.tokens) + provision.save() +} + +export function handleProvisionParametersSet(event: ProvisionParametersSet): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.thawingPeriod = event.params.thawingPeriod + provision.maxVerifierCut = event.params.maxVerifierCut + provision.save() +} + +export function handleProvisionParametersStaged(event: ProvisionParametersStaged): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.thawingPeriodPending = event.params.thawingPeriod + provision.maxVerifierCutPending = event.params.maxVerifierCut + provision.save() +} + +export function handleOperatorSet(event: OperatorSet): void { + let indexerGraphAccount = createOrLoadGraphAccount(event.params.serviceProvider, event.block.timestamp) + let operator = createOrLoadHorizonOperator(event.params.operator, event.params.verifier, event.params.serviceProvider) + let operators = indexerGraphAccount.operators + // Will have to handle legacy operators list, and horizon horizonOperators list for extra context + let operatorsIndex = operators.indexOf(event.params.operator.toHexString()) + if (operatorsIndex != -1) { + // false - it existed, and we set it to false, so remove from operators + if (!event.params.allowed) { + operators.splice(operatorsIndex, 1) + } + } else { + // true - it did not exist before, and we say add, so add + if (event.params.allowed) { + operators.push(event.params.operator.toHexString()) + // Create the operator as a graph account + createOrLoadGraphAccount(event.params.operator, event.block.timestamp) + } + } + + let horizonOperators = indexerGraphAccount.horizonOperators + let horizonOperatorsIndex = horizonOperators.indexOf(event.params.operator.toHexString()) + if (horizonOperatorsIndex != -1) { + // false - it existed, and we set it to false, so remove from operators and update operator + if (!event.params.allowed) { + operators.splice(horizonOperatorsIndex, 1) + } + } else { + // true - it did not exist before, and we say add, so add + if (event.params.allowed) { + operators.push(event.params.operator.toHexString()) + // Create the operator as a graph account + createOrLoadGraphAccount(event.params.operator, event.block.timestamp) + } + } + operator.allowed = event.params.allowed + operator.save() + indexerGraphAccount.operators = operators + indexerGraphAccount.horizonOperators = horizonOperators + indexerGraphAccount.save() +} + +export function handleDelegationFeeCutSet(event: DelegationFeeCutSet): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.queryFeeCut = event.params.paymentType == 0 ? event.params.feeCut : provision.queryFeeCut + provision.indexingFeeCut = event.params.paymentType == 1 ? event.params.feeCut : provision.indexingFeeCut + provision.indexingRewardsCut = event.params.paymentType == 2 ? event.params.feeCut : provision.indexingRewardsCut + provision.save() +} + +export function handleProvisionSlashed(event: ProvisionSlashed): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + // Due to thawing tokens potentially getting cancelled, we will need to figure the thawing situation + indexer.provisionedTokens = indexer.provisionedTokens.minus(event.params.tokens) + indexer.stakedTokens = indexer.stakedTokens.minus(event.params.tokens) + indexer.save() + + dataService.totalTokensProvisioned = dataService.totalTokensProvisioned.minus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.minus(event.params.tokens) + graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) + graphNetwork.save() + + provision.tokensProvisioned = provision.tokensProvisioned.minus(event.params.tokens) + // To DO, update thawing tokens according to the accounting calculation from the contract + provision.tokensSlashedServiceProvider = provision.tokensSlashedServiceProvider.plus(event.params.tokens) + provision.save() +} + +export function handleThawRequestCreated(event: ThawRequestCreated): void { + let dataService = createOrLoadDataService(event.params.verifier) + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let owner = createOrLoadGraphAccount(event.params.owner, event.block.timestamp) + + let request = new ThawRequest(event.params.thawRequestId.toHexString()) + request.indexer = indexer.id + request.dataService = dataService.id + request.owner = owner.id + request.shares = event.params.shares + request.tokens = BigInt.fromI32(0) + request.thawingUntil = event.params.thawingUntil + request.fulfilled = false + request.fulfilledAsValid = false + if (event.params.requestType == 0) { + request.type = "Provision" + } else if (event.params.requestType == 1) { + request.type = "Delegation" + } else { + throw new Error("Invalid thaw request type") + } + request.save() +} + +export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { + let request = ThawRequest.load(event.params.thawRequestId.toHexString())! + request.tokens = event.params.tokens + request.fulfilledAsValid = event.params.valid + request.fulfilled = true + request.save() +} + +export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolAdded): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) + graphNetwork.save() + + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.delegatedTokens = provision.delegatedTokens.plus(event.params.tokens) + if (provision.delegatorShares != BigInt.fromI32(0)) { + provision = updateDelegationExchangeRateForProvision(provision as Provision) + } + provision = updateAdvancedProvisionMetrics(provision as Provision) + provision.save() + + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) // this only serves as a general tracker, but the real deal is per provision + if (indexer.delegatorShares != BigInt.fromI32(0)) { + indexer = updateDelegationExchangeRate(indexer as Indexer) + } + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer.save() + + let dataService = createOrLoadDataService(event.params.verifier) + dataService.totalTokensDelegated = dataService.totalTokensDelegated.plus(event.params.tokens) + dataService.save() +} + +// Delegation + +export function handleTokensDelegated(event: TokensDelegated): void { + let zeroShares = event.params.shares.equals(BigInt.fromI32(0)) + + let dataService = createOrLoadDataService(event.params.verifier) + dataService.totalTokensDelegated = dataService.totalTokensDelegated.plus(event.params.tokens) + dataService.save() + + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.delegatedTokens = provision.delegatedTokens.plus(event.params.tokens) + provision.delegatorShares = provision.delegatorShares.plus(event.params.shares) + if (provision.delegatorShares != BigInt.fromI32(0)) { + provision = updateDelegationExchangeRateForProvision(provision as Provision) + } + provision = updateAdvancedProvisionMetrics(provision as Provision) + provision.save() + + // update indexer + let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) + indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) + indexer.delegatorShares = indexer.delegatorShares.plus(event.params.shares) + if (indexer.delegatorShares != BigInt.fromI32(0)) { + indexer = updateDelegationExchangeRate(indexer as Indexer) + } + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer.save() + + // update delegator + let delegatorID = event.params.delegator.toHexString() + let delegator = createOrLoadDelegator(event.params.delegator, event.block.timestamp) + delegator.totalStakedTokens = delegator.totalStakedTokens.plus(event.params.tokens) + delegator.save() + + // update delegated stake + let delegatedStake = createOrLoadDelegatedStakeForProvision( + delegatorID, + indexer.id, + dataService.id, + event.block.timestamp.toI32(), + ) + + if (!zeroShares) { + let previousExchangeRate = delegatedStake.personalExchangeRate + let previousShares = delegatedStake.shareAmount + let averageCostBasisTokens = previousExchangeRate + .times(previousShares.toBigDecimal()) + .plus(event.params.tokens.toBigDecimal()) + let averageCostBasisShares = previousShares.plus(event.params.shares) + if (averageCostBasisShares.gt(BigInt.fromI32(0))) { + delegatedStake.personalExchangeRate = averageCostBasisTokens + .div(averageCostBasisShares.toBigDecimal()) + .truncate(18) + } + } + + let isStakeBecomingActive = delegatedStake.shareAmount.isZero() && !event.params.shares.isZero() + + delegatedStake.stakedTokens = delegatedStake.stakedTokens.plus(event.params.tokens) + delegatedStake.shareAmount = delegatedStake.shareAmount.plus(event.params.shares) + delegatedStake.lastDelegatedAt = event.block.timestamp.toI32() + delegatedStake.save() + + // reload delegator to avoid edge case where we can overwrite stakesCount if stake is new + delegator = Delegator.load(delegatorID) as Delegator + + // upgrade graph network + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) + + if (isStakeBecomingActive) { + graphNetwork.activeDelegationCount = graphNetwork.activeDelegationCount + 1 + delegator.activeStakesCount = delegator.activeStakesCount + 1 + // Is delegator becoming active because of the stake becoming active? + if (delegator.activeStakesCount == 1) { + graphNetwork.activeDelegatorCount = graphNetwork.activeDelegatorCount + 1 + } + } + + graphNetwork.save() + delegator.save() +} + +export function handleDelegationSlashed(event: DelegationSlashed): void { + // This is a delegation pool wide change, no particular delegation or delegator can be updated here. + + // update provision + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + provision.delegatedTokens = provision.delegatedTokens.minus(event.params.tokens) + provision.tokensSlashedDelegationPool = provision.tokensSlashedDelegationPool.plus(event.params.tokens) + if (provision.delegatorShares != BigInt.fromI32(0)) { + provision = updateDelegationExchangeRateForProvision(provision as Provision) + } + provision = updateAdvancedProvisionMetrics(provision as Provision) + provision.save() + + // update indexer + let indexerID = event.params.serviceProvider.toHexString() + let indexer = Indexer.load(indexerID)! + indexer.delegatedTokens = indexer.delegatedTokens.minus(event.params.tokens) + indexer.save() + + // upgrade graph network + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.minus(event.params.tokens) + graphNetwork.save() +} + +export function handleTokensUndelegated(event: TokensUndelegated): void { + // update provision + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + + let beforeUpdateDelegationExchangeRate = provision.delegationExchangeRate + + provision.delegatedTokens = provision.delegatedTokens.minus(event.params.tokens) + provision.delegatorShares = provision.delegatorShares.minus(event.params.shares) + if (provision.delegatorShares != BigInt.fromI32(0)) { + provision = updateDelegationExchangeRateForProvision(provision as Provision) + } + provision = updateAdvancedProvisionMetrics(provision as Provision) + provision.save() + + // update indexer + let indexerID = event.params.serviceProvider.toHexString() + let indexer = Indexer.load(indexerID)! + indexer.delegatedTokens = indexer.delegatedTokens.minus(event.params.tokens) + indexer.delegatorShares = indexer.delegatorShares.minus(event.params.shares) + if (indexer.delegatorShares != BigInt.fromI32(0)) { + indexer = updateDelegationExchangeRate(indexer as Indexer) + } + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer.save() + + // update delegated stake + let delegatorID = event.params.delegator.toHexString() + let id = joinID([delegatorID, provision.id]) + let delegatedStake = DelegatedStake.load(id)! + + let isStakeBecomingInactive = + !delegatedStake.shareAmount.isZero() && delegatedStake.shareAmount == event.params.shares + + delegatedStake.unstakedTokens = delegatedStake.unstakedTokens.plus(event.params.tokens) + delegatedStake.shareAmount = delegatedStake.shareAmount.minus(event.params.shares) + delegatedStake.lockedTokens = delegatedStake.lockedTokens.plus(event.params.tokens) + //delegatedStake.lockedUntil = event.params.until.toI32() // until always updates and overwrites the past lockedUntil time + delegatedStake.lastUndelegatedAt = event.block.timestamp.toI32() + + let currentBalance = event.params.shares.toBigDecimal().times(beforeUpdateDelegationExchangeRate) + let oldBalance = event.params.shares.toBigDecimal().times(delegatedStake.personalExchangeRate) + let realizedRewards = currentBalance.minus(oldBalance) + + delegatedStake.realizedRewards = delegatedStake.realizedRewards.plus(realizedRewards) + delegatedStake.save() + + // update delegator + let delegator = Delegator.load(delegatorID)! + delegator.totalUnstakedTokens = delegator.totalUnstakedTokens.plus(event.params.tokens) + delegator.totalRealizedRewards = delegator.totalRealizedRewards.plus(realizedRewards) + + // upgrade graph network + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.minus(event.params.tokens) + + if (isStakeBecomingInactive) { + graphNetwork.activeDelegationCount = graphNetwork.activeDelegationCount - 1 + delegator.activeStakesCount = delegator.activeStakesCount - 1 + // Is delegator becoming inactive because of the stake becoming inactive? + if (delegator.activeStakesCount == 0) { + graphNetwork.activeDelegatorCount = graphNetwork.activeDelegatorCount - 1 + } + } + + graphNetwork.save() + delegator.save() + + let dataService = createOrLoadDataService(event.params.verifier) + dataService.totalTokensDelegated = dataService.totalTokensDelegated.minus(event.params.tokens) + dataService.save() +} + +export function handleDelegatedTokensWithdrawn(event: DelegatedTokensWithdrawn): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + // might want to track locked/thawing tokens in provision too + provision.save() + + // update delegated stake + let delegatorID = event.params.delegator.toHexString() + let id = joinID([delegatorID, provision.id]) + let delegatedStake = DelegatedStake.load(id)! + delegatedStake.lockedTokens = delegatedStake.lockedTokens.minus(event.params.tokens) + delegatedStake.save() +} + +export function handleMaxThawingPeriodSet(event: MaxThawingPeriodSet): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.maxThawingPeriod = event.params.maxThawingPeriod + graphNetwork.save() +} + +export function handleThawingPeriodCleared(event: ThawingPeriodCleared): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.thawingPeriod = 0 + graphNetwork.save() +} + +export function handleDelegationSlashingEnabled(event: DelegationSlashingEnabled): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.delegationSlashingEnabled = true + graphNetwork.save() +} + +export function handleAllowedLockedVerifierSet(event: AllowedLockedVerifierSet): void { + let dataService = createOrLoadDataService(event.params.verifier) + dataService.allowedWithTokenLockWallets = event.params.allowed + dataService.save() +} diff --git a/src/mappings/serviceRegistry.ts b/src/mappings/serviceRegistry.ts index e401c82d..69c92074 100644 --- a/src/mappings/serviceRegistry.ts +++ b/src/mappings/serviceRegistry.ts @@ -1,7 +1,7 @@ import { ServiceRegistered, ServiceUnregistered } from '../types/ServiceRegistry/ServiceRegistry' import { Indexer } from '../types/schema' -import { createOrLoadIndexer, createOrLoadGraphAccount } from './helpers/helpers' +import { createOrLoadLegacyIndexer, createOrLoadGraphAccount } from './helpers/helpers' /** * @dev handleServiceRegistered @@ -11,7 +11,7 @@ export function handleServiceRegistered(event: ServiceRegistered): void { // Creates Graph Account, if needed createOrLoadGraphAccount(event.params.indexer, event.block.timestamp) - let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + let indexer = createOrLoadLegacyIndexer(event.params.indexer, event.block.timestamp) indexer.url = event.params.url indexer.geoHash = event.params.geohash indexer.save() diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index c720dbdb..d77fd5d4 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -33,7 +33,7 @@ import { import { createOrLoadSubgraphDeployment, - createOrLoadIndexer, + createOrLoadLegacyIndexer, createOrLoadPool, createOrLoadEpoch, joinID, @@ -53,7 +53,7 @@ import { addresses } from '../../config/addresses' export function handleDelegationParametersUpdated(event: DelegationParametersUpdated): void { let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) - let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + let indexer = createOrLoadLegacyIndexer(event.params.indexer, event.block.timestamp) indexer.indexingRewardCut = event.params.indexingRewardCut.toI32() indexer.queryFeeCut = event.params.queryFeeCut.toI32() indexer.delegatorParameterCooldown = event.params.cooldownBlocks.toI32() @@ -73,7 +73,7 @@ export function handleDelegationParametersUpdated(event: DelegationParametersUpd export function handleStakeDeposited(event: StakeDeposited): void { let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) // update indexer - let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + let indexer = createOrLoadLegacyIndexer(event.params.indexer, event.block.timestamp) let previousStake = indexer.stakedTokens indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -106,7 +106,6 @@ export function handleStakeLocked(event: StakeLocked): void { // update indexer let id = event.params.indexer.toHexString() let indexer = Indexer.load(id)! - let oldLockedTokens = indexer.lockedTokens indexer.lockedTokens = event.params.tokens indexer.tokensLockedUntil = event.params.until.toI32() indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -114,11 +113,9 @@ export function handleStakeLocked(event: StakeLocked): void { indexer.save() // update graph network - // the tokens from the event replace the previously locked tokens - // from this indexer graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.plus( event.params.tokens, - ).minus(oldLockedTokens) + ) if (indexer.stakedTokens == indexer.lockedTokens) { graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount - 1 } @@ -180,7 +177,7 @@ export function handleStakeDelegated(event: StakeDelegated): void { let zeroShares = event.params.shares.equals(BigInt.fromI32(0)) // update indexer - let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + let indexer = createOrLoadLegacyIndexer(event.params.indexer, event.block.timestamp) indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) indexer.delegatorShares = indexer.delegatorShares.plus(event.params.shares) @@ -377,6 +374,7 @@ export function handleAllocationCreated(event: AllocationCreated): void { allocation.indexingRewardEffectiveCutAtStart = indexer.indexingRewardEffectiveCut allocation.queryFeeCutAtStart = indexer.queryFeeCut allocation.queryFeeEffectiveCutAtStart = indexer.queryFeeEffectiveCut + allocation.isLegacy = true allocation.save() } @@ -496,12 +494,16 @@ export function handleAllocationClosed(event: AllocationClosed): void { // update indexer let indexer = Indexer.load(indexerID)! + let allocation = Allocation.load(allocationID)! const indexerAccount = GraphAccount.load(indexer.account)! const closedByIndexer = event.params.sender == event.params.indexer const closedByOperator = indexerAccount.operators.includes(event.params.sender.toHexString()) if (!closedByIndexer && !closedByOperator) { indexer.forcedClosures = indexer.forcedClosures + 1 + allocation.forceClosed = true + } else { + allocation.forceClosed = false } indexer.allocatedTokens = indexer.allocatedTokens.minus(event.params.tokens) indexer.allocationCount = indexer.allocationCount - 1 @@ -510,7 +512,6 @@ export function handleAllocationClosed(event: AllocationClosed): void { indexer.save() // update allocation - let allocation = Allocation.load(allocationID)! allocation.poolClosedIn = event.params.epoch.toString() allocation.activeForIndexer = null allocation.closedAtEpoch = event.params.epoch.toI32() @@ -564,12 +565,16 @@ export function handleAllocationClosedCobbDouglas(event: AllocationClosed1): voi // update indexer let indexer = Indexer.load(indexerID)! + let allocation = Allocation.load(allocationID)! const indexerAccount = GraphAccount.load(indexer.account)! const closedByIndexer = event.params.sender == event.params.indexer const closedByOperator = indexerAccount.operators.includes(event.params.sender.toHexString()) if (!closedByIndexer && !closedByOperator) { indexer.forcedClosures = indexer.forcedClosures + 1 + allocation.forceClosed = true + } else { + allocation.forceClosed = false } indexer.allocatedTokens = indexer.allocatedTokens.minus(event.params.tokens) indexer.allocationCount = indexer.allocationCount - 1 @@ -578,7 +583,6 @@ export function handleAllocationClosedCobbDouglas(event: AllocationClosed1): voi indexer.save() // update allocation - let allocation = Allocation.load(allocationID)! allocation.poolClosedIn = event.params.epoch.toString() allocation.activeForIndexer = null allocation.closedAtEpoch = event.params.epoch.toI32() @@ -676,6 +680,7 @@ export function handleRebateClaimed(event: RebateClaimed): void { // update subgraph deployment let subgraphDeployment = SubgraphDeployment.load(subgraphDeploymentID)! subgraphDeployment.queryFeeRebates = subgraphDeployment.queryFeeRebates.plus(event.params.tokens) + subgraphDeployment.delegatorsQueryFeeRebates = subgraphDeployment.delegatorsQueryFeeRebates.plus(event.params.delegationFees) subgraphDeployment.save() // update graph network @@ -754,6 +759,7 @@ export function handleRebateCollected(event: RebateCollected): void { deployment.curatorFeeRewards = deployment.curatorFeeRewards.plus(event.params.curationFees) deployment.pricePerShare = calculatePricePerShare(deployment as SubgraphDeployment) deployment.queryFeeRebates = deployment.queryFeeRebates.plus(event.params.queryRebates) + deployment.delegatorsQueryFeeRebates = deployment.delegatorsQueryFeeRebates.plus(event.params.delegationRewards) deployment.save() batchUpdateSubgraphSignalledTokens(deployment as SubgraphDeployment) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts new file mode 100644 index 00000000..1555bc92 --- /dev/null +++ b/src/mappings/subgraphService.ts @@ -0,0 +1,454 @@ +import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" +import { AllocationClosed, AllocationCreated, AllocationResized, CurationCutSet, DelegationRatioSet, IndexingRewardsCollected, MaxPOIStalenessSet, ProvisionTokensRangeSet, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered, StakeToFeesRatioSet, ThawingPeriodRangeSet, VerifierCutRangeSet } from "../types/SubgraphService/SubgraphService" +import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" +import { Allocation, PublicPoiSubmission, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" +import { addresses } from "../../config/addresses" +import { tuplePrefixBytes } from "./helpers/decoder" +import { createOrLoadIndexer } from "./helpers/helpers" + +export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { + let decodedCalldata = ethereum.decode('(string,string,address)', tuplePrefixBytes(event.params.data)) + if (decodedCalldata != null && decodedCalldata.kind == ethereum.ValueKind.TUPLE) { + let tupleData = decodedCalldata.toTuple() + let url = tupleData[0].toString() + let geoHash = tupleData[1].toString() + let rewardsDestination = tupleData[2].toAddress() + + // Update provision + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + provision.url = url + provision.geoHash = geoHash + provision.rewardsDestination = rewardsDestination + provision.save() + + // Update indexer + let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) + indexer.url = url + indexer.geoHash = geoHash + indexer.rewardsDestination = rewardsDestination + + // Change legacy status in case the indexer was created before the Horizon upgrade + indexer.isLegacy = false + indexer.save() + } else { + log.warning("ServiceProviderRegistered failed to decode: {}", [event.params.data.toHexString()]) + } +} + +export function handleRewardsDestinationSet(event: RewardsDestinationSet): void { + // Update provision + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.rewardsDestination = event.params.rewardsDestination + provision.save() + + // Update indexer + let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + indexer.rewardsDestination = event.params.rewardsDestination + indexer.save() +} + +export function handleDelegationRatioSet(event: DelegationRatioSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.delegationRatio = event.params.ratio.toI32() + dataService.save() +} + +export function handleAllocationCreated(event: AllocationCreated): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let subgraphDeploymentID = event.params.subgraphDeploymentId.toHexString() + let indexerID = event.params.indexer.toHexString() + let allocationID = event.params.allocationId.toHexString() + + // update indexer + let indexer = Indexer.load(indexerID)! + indexer.allocatedTokens = indexer.allocatedTokens.plus(event.params.tokens) + indexer.totalAllocationCount = indexer.totalAllocationCount.plus(BigInt.fromI32(1)) + indexer.allocationCount = indexer.allocationCount + 1 + indexer.save() + + // update provision + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.tokensAllocated = provision.tokensAllocated.plus(event.params.tokens) + provision.totalAllocationCount = provision.totalAllocationCount.plus(BigInt.fromI32(1)) + provision.allocationCount = provision.allocationCount + 1 + provision.save() + + // update graph network + graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.plus(event.params.tokens) + graphNetwork.allocationCount = graphNetwork.allocationCount + 1 + graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount + 1 + graphNetwork.save() + + // update data service + let dataService = createOrLoadDataService(event.address) + dataService.totalTokensAllocated = dataService.totalTokensAllocated.plus(event.params.tokens) + dataService.save() + + // update subgraph deployment + let deployment = createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp) + deployment.stakedTokens = deployment.stakedTokens.plus(event.params.tokens) + deployment.save() + + // create allocation + let allocation = new Allocation(allocationID) + allocation.indexer = indexerID + allocation.provision = provision.id + allocation.creator = event.transaction.from + allocation.activeForIndexer = indexerID + allocation.activeForProvision = provision.id + allocation.subgraphDeployment = subgraphDeploymentID + allocation.allocatedTokens = event.params.tokens + allocation.effectiveAllocation = BigInt.fromI32(0) + allocation.createdAtEpoch = event.params.currentEpoch.toI32() + allocation.createdAtBlockHash = event.block.hash + allocation.createdAtBlockNumber = ( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber! + ).toI32() + allocation.queryFeesCollected = BigInt.fromI32(0) + allocation.queryFeeRebates = BigInt.fromI32(0) + allocation.distributedRebates = BigInt.fromI32(0) + allocation.curatorRewards = BigInt.fromI32(0) + allocation.indexingRewards = BigInt.fromI32(0) + allocation.indexingIndexerRewards = BigInt.fromI32(0) + allocation.indexingDelegatorRewards = BigInt.fromI32(0) + allocation.delegationFees = BigInt.fromI32(0) + allocation.status = 'Active' + allocation.totalReturn = BigDecimal.fromString('0') + allocation.annualizedReturn = BigDecimal.fromString('0') + allocation.createdAt = event.block.timestamp.toI32() + allocation.indexingRewardCutAtStart = provision.indexingRewardsCut.toI32() + allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardEffectiveCut + allocation.queryFeeCutAtStart = provision.queryFeeCut.toI32() + allocation.queryFeeEffectiveCutAtStart = provision.queryFeeEffectiveCut + allocation.poiCount = BigInt.fromI32(0) + allocation.isLegacy = false + allocation.save() +} + +export function handleAllocationClosed(event: AllocationClosed): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let indexerID = event.params.indexer.toHexString() + let allocationID = event.params.allocationId.toHexString() + + // update indexer + let indexer = Indexer.load(indexerID)! + let allocation = Allocation.load(allocationID)! + + if (event.params.forceClosed) { + indexer.forcedClosures = indexer.forcedClosures + 1 + } + + indexer.allocatedTokens = indexer.allocatedTokens.minus(event.params.tokens) + indexer.allocationCount = indexer.allocationCount - 1 + indexer.save() + + // update provision + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.tokensAllocated = provision.tokensAllocated.minus(event.params.tokens) + provision.allocationCount = provision.allocationCount - 1 + provision.save() + + // update allocation + allocation.forceClosed = event.params.forceClosed + allocation.poolClosedIn = graphNetwork.currentEpoch.toString() + allocation.activeForIndexer = null + allocation.closedAtEpoch = graphNetwork.currentEpoch + allocation.closedAtBlockHash = event.block.hash + allocation.closedAtBlockNumber = ( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber! + ).toI32() + allocation.status = 'Closed' + allocation.closedAt = event.block.timestamp.toI32() + allocation.indexingRewardCutAtClose = provision.indexingRewardsCut.toI32() + allocation.indexingRewardEffectiveCutAtClose = provision.indexingRewardEffectiveCut + allocation.queryFeeCutAtClose = provision.queryFeeCut.toI32() + allocation.queryFeeEffectiveCutAtClose = provision.queryFeeEffectiveCut + allocation.save() + + // update epoch - We do it here to have more epochs created, instead of seeing none created + // Likely this problem would go away with a live network with long epochs + let epoch = createOrLoadEpoch( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, + ) + epoch.save() + + let subgraphDeploymentID = event.params.subgraphDeploymentId.toHexString() + let deployment = createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp) + deployment.stakedTokens = deployment.stakedTokens.minus(event.params.tokens) + deployment.save() + + // update graph network + graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount - 1 + graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.minus(event.params.tokens) + graphNetwork.save() + + // update data service + let dataService = createOrLoadDataService(event.address) + dataService.totalTokensAllocated = dataService.totalTokensAllocated.minus(event.params.tokens) + dataService.save() +} + +export function handleAllocationResized(event: AllocationResized): void { + let allocationID = event.params.allocationId.toHexString() + let indexerID = event.params.indexer.toHexString() + let diffTokens = event.params.newTokens.minus(event.params.oldTokens) + + // update indexer + let indexer = Indexer.load(indexerID)! + indexer.allocatedTokens = indexer.allocatedTokens.plus(diffTokens) + indexer.save() + + // update provision + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.tokensAllocated = provision.tokensAllocated.plus(diffTokens) + provision.save() + + // update allocation + let allocation = Allocation.load(allocationID)! + allocation.allocatedTokens = event.params.newTokens + allocation.save() + + // update data service + let dataService = createOrLoadDataService(event.address) + dataService.totalTokensAllocated = dataService.totalTokensAllocated.plus(diffTokens) + dataService.save() + + // update subgraph deployment + let subgraphDeploymentID = allocation.subgraphDeployment + let deployment = createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp) + deployment.stakedTokens = deployment.stakedTokens.plus(diffTokens) + deployment.save() + + // update graph network + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.plus(diffTokens) + graphNetwork.save() +} + +export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let indexerID = event.params.indexer.toHexString() + let allocationID = event.params.allocationId.toHexString() + + // update indexer + let indexer = Indexer.load(indexerID)! + indexer.rewardsEarned = indexer.rewardsEarned.plus(event.params.tokensRewards) + indexer.indexerIndexingRewards = indexer.indexerIndexingRewards.plus(event.params.tokensIndexerRewards) + indexer.delegatorIndexingRewards = indexer.delegatorIndexingRewards.plus(event.params.tokensDelegationRewards) + indexer.save() + + // update provision + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.rewardsEarned = provision.rewardsEarned.plus(event.params.tokensRewards) + provision.indexerIndexingRewards = provision.indexerIndexingRewards.plus(event.params.tokensIndexerRewards) + provision.delegatorIndexingRewards = provision.delegatorIndexingRewards.plus(event.params.tokensDelegationRewards) + // No need to update delegated tokens, as that happens in handleTokensToDelegationPoolAdded + provision.save() + + // update allocation + let allocation = Allocation.load(allocationID)! + allocation.indexingRewards = allocation.indexingRewards.plus(event.params.tokensRewards) + allocation.indexingIndexerRewards = allocation.indexingIndexerRewards.plus(event.params.tokensIndexerRewards) + allocation.indexingDelegatorRewards = allocation.indexingDelegatorRewards.plus( + event.params.tokensDelegationRewards, + ) + allocation.poiCount = allocation.poiCount!.plus(BigInt.fromI32(1)) + allocation.save() + + // Create PoI submission + let poiSubmission = new PoiSubmission(joinID([event.transaction.hash.toHexString(), event.logIndex.toString()])) + poiSubmission.allocation = allocation.id + poiSubmission.poi = event.params.poi + poiSubmission.submittedAtEpoch = event.params.currentEpoch.toI32() + poiSubmission.presentedAtTimestamp = event.block.timestamp.toI32() + poiSubmission.save() + + // Create public PoI submission + let publicPoiSubmission = new PublicPoiSubmission(joinID([event.transaction.hash.toHexString(), event.logIndex.toString()])) + publicPoiSubmission.allocation = allocation.id + publicPoiSubmission.publicPoi = event.params.publicPoi + publicPoiSubmission.submittedAtEpoch = event.params.currentEpoch.toI32() + publicPoiSubmission.presentedAtTimestamp = event.block.timestamp.toI32() + publicPoiSubmission.save() + + // Update latest POI in allocation + allocation.poi = event.params.poi + allocation.latestPoiPresentedAt = event.block.timestamp.toI32() + allocation.save() + + // Update epoch + let epoch = createOrLoadEpoch((addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!)) + epoch.totalRewards = epoch.totalRewards.plus(event.params.tokensRewards) + epoch.totalIndexerRewards = epoch.totalIndexerRewards.plus(event.params.tokensIndexerRewards) + epoch.totalDelegatorRewards = epoch.totalDelegatorRewards.plus(event.params.tokensDelegationRewards) + epoch.save() + + // update subgraph deployment + let subgraphDeploymentID = allocation.subgraphDeployment + let subgraphDeployment = createOrLoadSubgraphDeployment( + subgraphDeploymentID, + event.block.timestamp, + ) + subgraphDeployment.indexingRewardAmount = subgraphDeployment.indexingRewardAmount.plus( + event.params.tokensRewards, + ) + subgraphDeployment.indexingIndexerRewardAmount = subgraphDeployment.indexingIndexerRewardAmount.plus( + event.params.tokensIndexerRewards, + ) + subgraphDeployment.indexingDelegatorRewardAmount = subgraphDeployment.indexingDelegatorRewardAmount.plus( + event.params.tokensDelegationRewards, + ) + subgraphDeployment.save() + + // update graph network + graphNetwork.totalIndexingRewards = graphNetwork.totalIndexingRewards.plus(event.params.tokensRewards) + graphNetwork.totalIndexingIndexerRewards = graphNetwork.totalIndexingIndexerRewards.plus( + event.params.tokensIndexerRewards, + ) + graphNetwork.totalIndexingDelegatorRewards = graphNetwork.totalIndexingDelegatorRewards.plus( + event.params.tokensDelegationRewards, + ) + // No need to update delegated tokens, as that happens in handleTokensToDelegationPoolAdded + graphNetwork.save() +} + +export function handleQueryFeesCollected(event: QueryFeesCollected): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let subgraphDeploymentID = event.params.subgraphDeploymentId.toHexString() + let indexerID = event.params.serviceProvider.toHexString() + let allocationID = event.params.allocationId.toHexString() + let paymentAddress = event.params.payer + + // update provision + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + + let delegationPoolQueryFees = + provision.delegatedTokens == BigInt.fromI32(0) + ? event.params.tokensCollected + : event.params.tokensCollected + .times(provision.queryFeeCut) + .div(BigInt.fromI32(1000000)) + let indexerQueryFees = event.params.tokensCollected.minus(delegationPoolQueryFees) + + provision.queryFeesCollected = provision.queryFeesCollected.plus(event.params.tokensCollected) + provision.indexerQueryFees = provision.indexerQueryFees.plus(indexerQueryFees) + provision.delegatorQueryFees = provision.delegatorQueryFees.plus(delegationPoolQueryFees) + provision.save() + + // update indexer + let indexer = Indexer.load(indexerID)! + indexer.queryFeesCollected = indexer.queryFeesCollected.plus(event.params.tokensCollected) + indexer.queryFeeRebates = indexer.queryFeeRebates.plus(indexerQueryFees) + indexer.delegatorQueryFees = indexer.delegatorQueryFees.plus(delegationPoolQueryFees) + indexer.save() + + // Replicate for payment source specific aggregation + let paymentAggregation = createOrLoadIndexerQueryFeePaymentAggregation(paymentAddress, event.params.serviceProvider) + paymentAggregation.queryFeesCollected = paymentAggregation.queryFeesCollected.plus(event.params.tokensCollected) + paymentAggregation.queryFeeRebates = paymentAggregation.queryFeeRebates.plus(indexerQueryFees) + paymentAggregation.delegatorQueryFees = paymentAggregation.delegatorQueryFees.plus(delegationPoolQueryFees) + paymentAggregation.save() + + // update allocation + let allocation = Allocation.load(allocationID)! + allocation.queryFeesCollected = allocation.queryFeesCollected.plus(event.params.tokensCollected) + allocation.curatorRewards = allocation.curatorRewards.plus(event.params.tokensCurators) + allocation.queryFeeRebates = allocation.queryFeeRebates.plus(indexerQueryFees) + allocation.distributedRebates = allocation.distributedRebates.plus(event.params.tokensCollected) + allocation.delegationFees = allocation.delegationFees.plus(delegationPoolQueryFees) + allocation.save() + + // Update epoch + let epoch = createOrLoadEpoch( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, + ) + epoch.totalQueryFees = epoch.totalQueryFees.plus(event.params.tokensCollected).plus(event.params.tokensCurators) + epoch.queryFeesCollected = epoch.queryFeesCollected.plus(event.params.tokensCollected) + epoch.curatorQueryFees = epoch.curatorQueryFees.plus(event.params.tokensCurators) + epoch.queryFeeRebates = epoch.queryFeeRebates.plus(event.params.tokensCollected) + epoch.save() + + // update subgraph deployment + let deployment = SubgraphDeployment.load(subgraphDeploymentID)! + deployment.queryFeesAmount = deployment.queryFeesAmount.plus(event.params.tokensCollected) + deployment.signalledTokens = deployment.signalledTokens.plus(event.params.tokensCurators) + deployment.curatorFeeRewards = deployment.curatorFeeRewards.plus(event.params.tokensCurators) + deployment.pricePerShare = calculatePricePerShare(deployment as SubgraphDeployment) + deployment.queryFeeRebates = deployment.queryFeeRebates.plus(indexerQueryFees) + deployment.delegatorsQueryFeeRebates = deployment.delegatorsQueryFeeRebates.plus(delegationPoolQueryFees) + deployment.save() + + batchUpdateSubgraphSignalledTokens(deployment as SubgraphDeployment) + + // update graph network + graphNetwork.totalQueryFees = graphNetwork.totalQueryFees.plus(event.params.tokensCollected).plus(event.params.tokensCurators) + graphNetwork.totalIndexerQueryFeesCollected = graphNetwork.totalIndexerQueryFeesCollected.plus( + event.params.tokensCollected, + ) + graphNetwork.totalCuratorQueryFees = graphNetwork.totalCuratorQueryFees.plus( + event.params.tokensCurators, + ) + graphNetwork.totalIndexerQueryFeeRebates = graphNetwork.totalIndexerQueryFeeRebates.plus( + indexerQueryFees, + ) + graphNetwork.totalDelegatorQueryFeeRebates = graphNetwork.totalDelegatorQueryFeeRebates.plus( + delegationPoolQueryFees, + ) + graphNetwork.save() + + // Replicate for payment source specific data + let paymentSource = createOrLoadPaymentSource(paymentAddress) + paymentSource.totalQueryFees = paymentSource.totalQueryFees.plus(event.params.tokensCollected).plus(event.params.tokensCurators) + paymentSource.totalIndexerQueryFeesCollected = paymentSource.totalIndexerQueryFeesCollected.plus( + event.params.tokensCollected, + ) + paymentSource.totalCuratorQueryFees = paymentSource.totalCuratorQueryFees.plus( + event.params.tokensCurators, + ) + paymentSource.totalIndexerQueryFeeRebates = paymentSource.totalIndexerQueryFeeRebates.plus( + indexerQueryFees, + ) + paymentSource.totalDelegatorQueryFeeRebates = paymentSource.totalDelegatorQueryFeeRebates.plus( + delegationPoolQueryFees, + ) + paymentSource.save() +} + +export function handleCurationCutSet(event: CurationCutSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.curationCut = event.params.curationCut + dataService.save() +} + +export function handleMaxPOIStalenessSet(event: MaxPOIStalenessSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.maxPOIStaleness = event.params.maxPOIStaleness + dataService.save() +} + +export function handleStakeToFeesRatioSet(event: StakeToFeesRatioSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.stakeToFeesRatio = event.params.ratio + dataService.save() +} + +export function handleProvisionTokensRangeSet(event: ProvisionTokensRangeSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.minimumProvisionTokens = event.params.min + dataService.maximumProvisionTokens = event.params.max + dataService.save() +} + +export function handleVerifierCutRangeSet(event: VerifierCutRangeSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.minimumVerifierCut = event.params.min + dataService.maximumVerifierCut = event.params.max + dataService.save() +} + +export function handleThawingPeriodRangeSet(event: ThawingPeriodRangeSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.minimumThawingPeriod = event.params.min + dataService.maximumThawingPeriod = event.params.max + dataService.save() +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index c51094bb..ff162e26 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -377,6 +377,148 @@ dataSources: eventHandlers: - event: ParameterUpdated(string) handler: handleParameterUpdated + - kind: ethereum/contract + name: HorizonStaking + network: {{network}} + source: + address: "{{staking}}" + abi: HorizonStaking + startBlock: {{blockNumber}} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/mappings/horizonStaking.ts + entities: + - GraphNetwork + abis: + - name: HorizonStaking + file: ./abis/HorizonStaking.json + - name: GraphToken + file: ./node_modules/@graphprotocol/contracts/dist/abis/GraphToken.json + - name: EpochManager + file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json + eventHandlers: + - event: HorizonStakeDeposited(indexed address,uint256) + handler: handleHorizonStakeDeposited + - event: HorizonStakeLocked(indexed address,uint256,uint256) + handler: handleHorizonStakeLocked + - event: HorizonStakeWithdrawn(indexed address,uint256) + handler: handleHorizonStakeWithdrawn + - event: ProvisionCreated(indexed address,indexed address,uint256,uint32,uint64) + handler: handleProvisionCreated + - event: ProvisionIncreased(indexed address,indexed address,uint256) + handler: handleProvisionIncreased + - event: TokensDeprovisioned(indexed address,indexed address,uint256) + handler: handleTokensDeprovisioned + - event: ProvisionParametersSet(indexed address,indexed address,uint32,uint64) + handler: handleProvisionParametersSet + - event: ProvisionParametersStaged(indexed address,indexed address,uint32,uint64) + handler: handleProvisionParametersStaged + - event: ProvisionSlashed(indexed address,indexed address,uint256) + handler: handleProvisionSlashed + - event: ProvisionThawed(indexed address,indexed address,uint256) + handler: handleProvisionThawed + - event: ThawRequestCreated(indexed uint8,indexed address,indexed address,address,uint256,uint64,bytes32,uint256) + handler: handleThawRequestCreated + - event: ThawRequestFulfilled(indexed uint8,indexed bytes32,uint256,uint256,uint64,bool) + handler: handleThawRequestFulfilled + - event: OperatorSet(indexed address,indexed address,indexed address,bool) + handler: handleOperatorSet + - event: DelegationFeeCutSet(indexed address,indexed address,indexed uint8,uint256) + handler: handleDelegationFeeCutSet + - event: TokensToDelegationPoolAdded(indexed address,indexed address,uint256) + handler: handleTokensToDelegationPoolAdded + - event: TokensDelegated(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleTokensDelegated + - event: DelegationSlashed(indexed address,indexed address,uint256) + handler: handleDelegationSlashed + - event: TokensUndelegated(indexed address,indexed address,indexed address,uint256,uint256) + handler: handleTokensUndelegated + - event: DelegatedTokensWithdrawn(indexed address,indexed address,indexed address,uint256) + handler: handleDelegatedTokensWithdrawn + - event: MaxThawingPeriodSet(uint64) + handler: handleMaxThawingPeriodSet + - event: ThawingPeriodCleared() + handler: handleThawingPeriodCleared + - event: DelegationSlashingEnabled() + handler: handleDelegationSlashingEnabled + - event: AllowedLockedVerifierSet(indexed address,bool) + handler: handleAllowedLockedVerifierSet + - kind: ethereum/contract + name: SubgraphService + network: {{network}} + source: + address: "{{subgraphService}}" + abi: SubgraphService + startBlock: {{blockNumber}} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/mappings/subgraphService.ts + entities: + - GraphNetwork + abis: + - name: SubgraphService + file: ./abis/SubgraphService.json + - name: GraphToken + file: ./node_modules/@graphprotocol/contracts/dist/abis/GraphToken.json + - name: EpochManager + file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json + eventHandlers: + - event: ServiceProviderRegistered(indexed address,bytes) + handler: handleServiceProviderRegistered + - event: RewardsDestinationSet(indexed address,indexed address) + handler: handleRewardsDestinationSet + - event: AllocationCreated(indexed address,indexed address,indexed bytes32,uint256,uint256) + handler: handleAllocationCreated + - event: AllocationResized(indexed address,indexed address,indexed bytes32,uint256,uint256) + handler: handleAllocationResized + - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256,bool) + handler: handleAllocationClosed + - event: IndexingRewardsCollected(indexed address,indexed address,indexed bytes32,uint256,uint256,uint256,bytes32,bytes32,uint256) + handler: handleIndexingRewardsCollected + - event: QueryFeesCollected(indexed address,indexed address,indexed address,bytes32,uint256,uint256) + handler: handleQueryFeesCollected + - event: DelegationRatioSet(uint32) + handler: handleDelegationRatioSet + - event: CurationCutSet(uint256) + handler: handleCurationCutSet + - event: MaxPOIStalenessSet(uint256) + handler: handleMaxPOIStalenessSet + - event: StakeToFeesRatioSet(uint256) + handler: handleStakeToFeesRatioSet + - event: ProvisionTokensRangeSet(uint256,uint256) + handler: handleProvisionTokensRangeSet + - event: VerifierCutRangeSet(uint32,uint32) + handler: handleVerifierCutRangeSet + - event: ThawingPeriodRangeSet(uint64,uint64) + handler: handleThawingPeriodRangeSet + - kind: ethereum/contract + name: GraphPayments + network: {{network}} + source: + address: "{{graphPayments}}" + abi: GraphPayments + startBlock: {{blockNumber}} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/mappings/graphPayments.ts + entities: + - GraphNetwork + abis: + - name: GraphPayments + file: ./abis/GraphPayments.json + - name: GraphToken + file: ./node_modules/@graphprotocol/contracts/dist/abis/GraphToken.json + - name: EpochManager + file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json + eventHandlers: + - event: GraphPaymentCollected(indexed uint8,indexed address,address,indexed address,uint256,uint256,uint256,uint256,uint256) + handler: handleGraphPaymentCollected - kind: ethereum/contract name: Curation network: {{network}} diff --git a/yarn.lock b/yarn.lock index 6529da99..f87c940a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -605,12 +605,12 @@ which "2.0.2" yaml "1.10.2" -"@graphprotocol/graph-ts@0.32.0": - version "0.32.0" - resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.32.0.tgz#36f8cd8e4ef42c3c32536cceb9995ab990f51d29" - integrity sha512-YfKLT2w+ItXD/VPYQiAKtINQONVsAOkcqVFMHlhUy0fcEBVWuFBT53hJNI0/l5ujQa4TSxtzrKW/7EABAdgI8g== +"@graphprotocol/graph-ts@0.38.0": + version "0.38.0" + resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.38.0.tgz#a73cba73bf7931af1c603563416ed6779c4311d7" + integrity sha512-fx9IpqbXHWMskl6wLDstKLy0VeszTQg6K5xsUEHXPkpOtceDkWAiDE8FyqsGF0IVTmE2Pxafw4t6+rEG8lVfyw== dependencies: - assemblyscript "0.19.10" + assemblyscript "0.27.31" "@graphprotocol/pino-sentry-simple@0.7.1": version "0.7.1" @@ -1730,14 +1730,6 @@ asn1js@^3.0.1, asn1js@^3.0.5: pvutils "^1.1.3" tslib "^2.4.0" -assemblyscript@0.19.10: - version "0.19.10" - resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.19.10.tgz#7ede6d99c797a219beb4fa4614c3eab9e6343c8e" - integrity sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg== - dependencies: - binaryen "101.0.0-nightly.20210723" - long "^4.0.0" - assemblyscript@0.19.23: version "0.19.23" resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.19.23.tgz#16ece69f7f302161e2e736a0f6a474e6db72134c" @@ -1747,6 +1739,14 @@ assemblyscript@0.19.23: long "^5.2.0" source-map-support "^0.5.20" +assemblyscript@0.27.31: + version "0.27.31" + resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.27.31.tgz#07412b1bc42c67f78080dbaddca030ab74d3b9b2" + integrity sha512-Ra8kiGhgJQGZcBxjtMcyVRxOEJZX64kd+XGpjWzjcjgxWJVv+CAQO0aDBk4GQVhjYbOkATarC83mHjAVGtwPBQ== + dependencies: + binaryen "116.0.0-nightly.20240114" + long "^5.2.1" + astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -1839,16 +1839,16 @@ binary-install-raw@0.0.13: rimraf "^3.0.2" tar "^6.1.0" -binaryen@101.0.0-nightly.20210723: - version "101.0.0-nightly.20210723" - resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz#b6bb7f3501341727681a03866c0856500eec3740" - integrity sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA== - binaryen@102.0.0-nightly.20211028: version "102.0.0-nightly.20211028" resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz#8f1efb0920afd34509e342e37f84313ec936afb2" integrity sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w== +binaryen@116.0.0-nightly.20240114: + version "116.0.0-nightly.20240114" + resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz#ad8bfbde77d4cb4715b93997114eefc30f45155b" + integrity sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A== + bintrees@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8" @@ -2624,7 +2624,7 @@ electron-fetch@^1.7.2: dependencies: encoding "^0.1.13" -elliptic@6.5.4, elliptic@^6.5.2, elliptic@^6.5.4: +elliptic@6.5.4, elliptic@^6.5.2: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== @@ -2637,6 +2637,19 @@ elliptic@6.5.4, elliptic@^6.5.2, elliptic@^6.5.4: minimalistic-assert "^1.0.1" minimalistic-crypto-utils "^1.0.1" +elliptic@^6.5.7: + version "6.6.1" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" + integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -4361,6 +4374,11 @@ long@^5.2.0: resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== +long@^5.2.1: + version "5.3.2" + resolved "https://registry.yarnpkg.com/long/-/long-5.3.2.tgz#1d84463095999262d7d7b7f8bfd4a8cc55167f83" + integrity sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -4732,6 +4750,11 @@ node-addon-api@^2.0.0: resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== +node-addon-api@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-5.1.0.tgz#49da1ca055e109a23d537e9de43c09cca21eb762" + integrity sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA== + node-fetch@^2.6.12: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" @@ -5568,12 +5591,12 @@ scrypt-js@3.0.1, scrypt-js@^3.0.0: integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== secp256k1@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303" - integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA== + version "4.0.4" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.4.tgz#58f0bfe1830fe777d9ca1ffc7574962a8189f8ab" + integrity sha512-6JfvwvjUOn8F/jUoBY2Q1v5WY5XS+rj8qSe0v8Y4ezH4InLgTEeOOPQsRll9OV429Pvo6BCHGavIyJfr3TAhsw== dependencies: - elliptic "^6.5.4" - node-addon-api "^2.0.0" + elliptic "^6.5.7" + node-addon-api "^5.0.0" node-gyp-build "^4.2.0" semver@7.3.5, semver@^7.2.1, semver@^7.3.2: