From 9ee86cb85e765797c0206ba3c0744063d7ccdf96 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 10 Feb 2025 17:52:58 -0300 Subject: [PATCH 01/57] feat: add basic handlers for stake management in Horizon, and update old ones --- abis/HorizonStaking.json | 2408 +++++++++++++++++++++++++++++++ abis/SubgraphService.json | 2287 +++++++++++++++++++++++++++++ schema.graphql | 31 +- src/mappings/helpers/helpers.ts | 2 + src/mappings/horizonStaking.ts | 78 + src/mappings/staking.ts | 4 + subgraph.template.yaml | 28 + 7 files changed, 4835 insertions(+), 3 deletions(-) create mode 100644 abis/HorizonStaking.json create mode 100644 abis/SubgraphService.json create mode 100644 src/mappings/horizonStaking.ts diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json new file mode 100644 index 00000000..b1089b90 --- /dev/null +++ b/abis/HorizonStaking.json @@ -0,0 +1,2408 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "controller", + "type": "address", + "internalType": "address" + }, + { + "name": "stakingExtensionAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "subgraphDataServiceAddress", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "fallback", + "stateMutability": "nonpayable" + }, + { + "type": "receive", + "stateMutability": "payable" + }, + { + "type": "function", + "name": "acceptProvisionParameters", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "acceptProxy", + "inputs": [ + { + "name": "_proxy", + "type": "address", + "internalType": "contract IGraphProxy" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "acceptProxyAndCall", + "inputs": [ + { + "name": "_proxy", + "type": "address", + "internalType": "contract IGraphProxy" + }, + { + "name": "_data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "addToDelegationPool", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "addToProvision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "clearThawingPeriod", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegate", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "delegate", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minSharesOut", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "deprovision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "nThawRequests", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getDelegatedTokensAvailable", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegation", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "delegator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IHorizonStakingTypes.Delegation", + "components": [ + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegationFeeCut", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "paymentType", + "type": "uint8", + "internalType": "enum IGraphPayments.PaymentTypes" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegationPool", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IHorizonStakingTypes.DelegationPool", + "components": [ + { + "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": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getIdleStake", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getMaxThawingPeriod", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getProviderTokensAvailable", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getProvision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IHorizonStakingTypes.Provision", + "components": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokensThawing", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "sharesThawing", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "createdAt", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxVerifierCutPending", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "thawingPeriodPending", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "thawingNonce", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getServiceProvider", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IHorizonStakingTypes.ServiceProvider", + "components": [ + { + "name": "tokensStaked", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokensProvisioned", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getStake", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getThawRequest", + "inputs": [ + { + "name": "requestType", + "type": "uint8", + "internalType": "enum IHorizonStakingTypes.ThawRequestType" + }, + { + "name": "thawRequestId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IHorizonStakingTypes.ThawRequest", + "components": [ + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "thawingUntil", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "next", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "thawingNonce", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getThawRequestList", + "inputs": [ + { + "name": "requestType", + "type": "uint8", + "internalType": "enum IHorizonStakingTypes.ThawRequestType" + }, + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct LinkedList.List", + "components": [ + { + "name": "head", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "tail", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "count", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getThawedTokens", + "inputs": [ + { + "name": "requestType", + "type": "uint8", + "internalType": "enum IHorizonStakingTypes.ThawRequestType" + }, + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTokensAvailable", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "delegationRatio", + "type": "uint32", + "internalType": "uint32" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isAllowedLockedVerifier", + "inputs": [ + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isAuthorized", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isDelegationSlashingEnabled", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "multicall", + "inputs": [ + { + "name": "data", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "outputs": [ + { + "name": "results", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "provision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "provisionLocked", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "redelegate", + "inputs": [ + { + "name": "oldServiceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "oldVerifier", + "type": "address", + "internalType": "address" + }, + { + "name": "newServiceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "newVerifier", + "type": "address", + "internalType": "address" + }, + { + "name": "minSharesForNewProvider", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "nThawRequests", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reprovision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "oldVerifier", + "type": "address", + "internalType": "address" + }, + { + "name": "newVerifier", + "type": "address", + "internalType": "address" + }, + { + "name": "nThawRequests", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setAllowedLockedVerifier", + "inputs": [ + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setDelegationFeeCut", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "paymentType", + "type": "uint8", + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "feeCut", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setDelegationSlashingEnabled", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMaxThawingPeriod", + "inputs": [ + { + "name": "maxThawingPeriod", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setOperator", + "inputs": [ + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setOperatorLocked", + "inputs": [ + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setProvisionParameters", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "newMaxVerifierCut", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "newThawingPeriod", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "slash", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokensVerifier", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "verifierDestination", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stake", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stakeTo", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stakeToProvision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "thaw", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "undelegate", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "undelegate", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unstake", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdraw", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawDelegated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "nThawRequests", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawDelegated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "AllowedLockedVerifierSet", + "inputs": [ + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegatedTokensWithdrawn", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "delegator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegationFeeCutSet", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "paymentType", + "type": "uint8", + "indexed": true, + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "feeCut", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegationSlashed", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegationSlashingEnabled", + "inputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "DelegationSlashingSkipped", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "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": "HorizonStakeDeposited", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "HorizonStakeLocked", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "until", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "HorizonStakeWithdrawn", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "MaxThawingPeriodSet", + "inputs": [ + { + "name": "maxThawingPeriod", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OperatorSet", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionCreated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionIncreased", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionParametersSet", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionParametersStaged", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "maxVerifierCut", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "thawingPeriod", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionSlashed", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionThawed", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakeDelegatedWithdrawn", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "delegator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ThawRequestCreated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "thawingUntil", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "thawRequestId", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ThawRequestFulfilled", + "inputs": [ + { + "name": "thawRequestId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "thawingUntil", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "valid", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ThawRequestsFulfilled", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "thawRequestsFulfilled", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "requestType", + "type": "uint8", + "indexed": false, + "internalType": "enum IHorizonStakingTypes.ThawRequestType" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ThawingPeriodCleared", + "inputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "TokensDelegated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "delegator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "TokensDeprovisioned", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "TokensToDelegationPoolAdded", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "TokensUndelegated", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "delegator", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "VerifierTokensSent", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "destination", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "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": "HorizonStakingCallerIsServiceProvider", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingInsufficientDelegationTokens", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minTokens", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInsufficientIdleStake", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minTokens", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInsufficientShares", + "inputs": [ + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minShares", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInsufficientStakeForLegacyAllocations", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minTokens", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInsufficientTokens", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minRequired", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidDelegationFeeCut", + "inputs": [ + { + "name": "feeCut", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidDelegationPool", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidDelegationPoolState", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidMaxVerifierCut", + "inputs": [ + { + "name": "maxVerifierCut", + "type": "uint32", + "internalType": "uint32" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidProvision", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidServiceProviderZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingInvalidThawRequestType", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingInvalidThawingPeriod", + "inputs": [ + { + "name": "thawingPeriod", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxThawingPeriod", + "type": "uint64", + "internalType": "uint64" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingInvalidVerifierZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingInvalidZeroShares", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingInvalidZeroTokens", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingNotAuthorized", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "verifier", + "type": "address", + "internalType": "address" + }, + { + "name": "caller", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingNothingThawing", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingProvisionAlreadyExists", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingSlippageProtection", + "inputs": [ + { + "name": "shares", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "minShares", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingStillThawing", + "inputs": [ + { + "name": "until", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingTooManyThawRequests", + "inputs": [] + }, + { + "type": "error", + "name": "HorizonStakingTooManyTokens", + "inputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxTokens", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "HorizonStakingVerifierNotAllowed", + "inputs": [ + { + "name": "verifier", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "LinkedListEmptyList", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListInvalidIterations", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListInvalidZeroId", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListMaxElementsExceeded", + "inputs": [] + }, + { + "type": "error", + "name": "ManagedIsPaused", + "inputs": [] + }, + { + "type": "error", + "name": "ManagedOnlyController", + "inputs": [] + }, + { + "type": "error", + "name": "ManagedOnlyGovernor", + "inputs": [] + }, + { + "type": "error", + "name": "PPMMathInvalidMulPPM", + "inputs": [ + { + "name": "a", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "b", + "type": "uint256", + "internalType": "uint256" + } + ] + } +] \ No newline at end of file diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json new file mode 100644 index 00000000..3da88ad2 --- /dev/null +++ b/abis/SubgraphService.json @@ -0,0 +1,2287 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "graphController", + "type": "address", + "internalType": "address" + }, + { + "name": "disputeManager", + "type": "address", + "internalType": "address" + }, + { + "name": "tapCollector", + "type": "address", + "internalType": "address" + }, + { + "name": "curation", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "acceptProvisionPendingParameters", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allocationProvisionTracker", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claims", + "inputs": [ + { + "name": "claimId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "createdAt", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "releasableAt", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "nextClaim", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claimsLists", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "head", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "tail", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "nonce", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "count", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "closeStaleAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "collect", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "paymentType", + "type": "uint8", + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "curationFeesCut", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "delegationRatio", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "eip712Domain", + "inputs": [], + "outputs": [ + { + "name": "fields", + "type": "bytes1", + "internalType": "bytes1" + }, + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "version", + "type": "string", + "internalType": "string" + }, + { + "name": "chainId", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "verifyingContract", + "type": "address", + "internalType": "address" + }, + { + "name": "salt", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "extensions", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "encodeAllocationProof", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "feesProvisionTracker", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct Allocation.State", + "components": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "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" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getAllocationData", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getDelegationRatio", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getLegacyAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct LegacyAllocation.State", + "components": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getProvisionTokensRange", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getSubgraphAllocatedTokens", + "inputs": [ + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getThawingPeriodRange", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getVerifierCutRange", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "indexers", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "registeredAt", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "url", + "type": "string", + "internalType": "string" + }, + { + "name": "geoHash", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "minimumProvisionTokens", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximumDelegationRatio", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stakeToFeesRatio", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isActiveAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isOverAllocated", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isStaleAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maxPOIStaleness", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maximumProvisionTokens", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maximumThawingPeriod", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "maximumVerifierCut", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "migrateLegacyAllocation", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "internalType": "address" + }, + { + "name": "subgraphDeploymentID", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "minimumProvisionTokens", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "minimumThawingPeriod", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "minimumVerifierCut", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "multicall", + "inputs": [ + { + "name": "data", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "outputs": [ + { + "name": "results", + "type": "bytes[]", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pause", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "pauseGuardians", + "inputs": [ + { + "name": "pauseGuardian", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "paused", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "register", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "releaseStake", + "inputs": [ + { + "name": "numClaimsToRelease", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "resizeAllocation", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "rewardsDestination", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "destination", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setCurationCut", + "inputs": [ + { + "name": "curationCut", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setDelegationRatio", + "inputs": [ + { + "name": "delegationRatio", + "type": "uint32", + "internalType": "uint32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMaxPOIStaleness", + "inputs": [ + { + "name": "maxPOIStaleness", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMinimumProvisionTokens", + "inputs": [ + { + "name": "minimumProvisionTokens", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPauseGuardian", + "inputs": [ + { + "name": "pauseGuardian", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRewardsDestination", + "inputs": [ + { + "name": "rewardsDestination", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setStakeToFeesRatio", + "inputs": [ + { + "name": "stakeToFeesRatio_", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "slash", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stakeToFeesRatio", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "startService", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stopService", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unpause", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "AllocationClosed", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "AllocationCreated", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "AllocationResized", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "newTokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "oldTokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CurationCutSet", + "inputs": [ + { + "name": "curationCut", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DelegationRatioSet", + "inputs": [ + { + "name": "ratio", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "EIP712DomainChanged", + "inputs": [], + "anonymous": false + }, + { + "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": "IndexingRewardsCollected", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokensRewards", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensIndexerRewards", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensDelegationRewards", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "poi", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + }, + { + "name": "currentEpoch", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "LegacyAllocationMigrated", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "subgraphDeploymentId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "MaxPOIStalenessSet", + "inputs": [ + { + "name": "maxPOIStaleness", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PauseGuardianSet", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Paused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionPendingParametersAccepted", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProvisionTokensRangeSet", + "inputs": [ + { + "name": "min", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "max", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "QueryFeesCollected", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokensCollected", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensCurators", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RewardsDestinationSet", + "inputs": [ + { + "name": "indexer", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "rewardsDestination", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ServicePaymentCollected", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "feeType", + "type": "uint8", + "indexed": true, + "internalType": "enum IGraphPayments.PaymentTypes" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ServiceProviderRegistered", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ServiceProviderSlashed", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ServiceStarted", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ServiceStopped", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakeClaimLocked", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "claimId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "unlockTimestamp", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakeClaimReleased", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "claimId", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "tokens", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "releasableAt", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakeClaimsReleased", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "claimsCount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokensReleased", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StakeToFeesRatioSet", + "inputs": [ + { + "name": "ratio", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SubgraphServiceDirectoryInitialized", + "inputs": [ + { + "name": "subgraphService", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "disputeManager", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "tapCollector", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "curation", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ThawingPeriodRangeSet", + "inputs": [ + { + "name": "min", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "max", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Unpaused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "VerifierCutRangeSet", + "inputs": [ + { + "name": "min", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "max", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AddressEmptyCode", + "inputs": [ + { + "name": "target", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AllocationAlreadyExists", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AllocationClosed", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + }, + { + "name": "closedAt", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "AllocationDoesNotExist", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AllocationManagerAllocationClosed", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AllocationManagerAllocationSameSize", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + }, + { + "name": "tokens", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "AllocationManagerInvalidAllocationProof", + "inputs": [ + { + "name": "signer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AllocationManagerInvalidZeroAllocationId", + "inputs": [] + }, + { + "type": "error", + "name": "DataServiceFeesClaimNotFound", + "inputs": [ + { + "name": "claimId", + "type": "bytes32", + "internalType": "bytes32" + } + ] + }, + { + "type": "error", + "name": "DataServiceFeesZeroTokens", + "inputs": [] + }, + { + "type": "error", + "name": "DataServicePausableNotPauseGuardian", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "DataServicePausablePauseGuardianNoChange", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "type": "error", + "name": "DirectoryNotDisputeManager", + "inputs": [ + { + "name": "caller", + "type": "address", + "internalType": "address" + }, + { + "name": "disputeManager", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ECDSAInvalidSignature", + "inputs": [] + }, + { + "type": "error", + "name": "ECDSAInvalidSignatureLength", + "inputs": [ + { + "name": "length", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ECDSAInvalidSignatureS", + "inputs": [ + { + "name": "s", + "type": "bytes32", + "internalType": "bytes32" + } + ] + }, + { + "type": "error", + "name": "EnforcedPause", + "inputs": [] + }, + { + "type": "error", + "name": "ExpectedPause", + "inputs": [] + }, + { + "type": "error", + "name": "FailedInnerCall", + "inputs": [] + }, + { + "type": "error", + "name": "GraphDirectoryInvalidZeroAddress", + "inputs": [ + { + "name": "contractName", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "InvalidInitialization", + "inputs": [] + }, + { + "type": "error", + "name": "LegacyAllocationAlreadyExists", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "LinkedListEmptyList", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListInvalidIterations", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListInvalidZeroId", + "inputs": [] + }, + { + "type": "error", + "name": "LinkedListMaxElementsExceeded", + "inputs": [] + }, + { + "type": "error", + "name": "NotInitializing", + "inputs": [] + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "PPMMathInvalidMulPPM", + "inputs": [ + { + "name": "a", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "b", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ProvisionManagerInvalidRange", + "inputs": [ + { + "name": "min", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "max", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ProvisionManagerInvalidValue", + "inputs": [ + { + "name": "message", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "min", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "max", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ProvisionManagerNotAuthorized", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + }, + { + "name": "caller", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ProvisionManagerProvisionNotFound", + "inputs": [ + { + "name": "serviceProvider", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ProvisionTrackerInsufficientTokens", + "inputs": [ + { + "name": "tokensAvailable", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "tokensRequired", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceAllocationIsAltruistic", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceAllocationNotAuthorized", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceCannotForceCloseAllocation", + "inputs": [ + { + "name": "allocationId", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceEmptyGeohash", + "inputs": [] + }, + { + "type": "error", + "name": "SubgraphServiceEmptyUrl", + "inputs": [] + }, + { + "type": "error", + "name": "SubgraphServiceInconsistentCollection", + "inputs": [ + { + "name": "balanceBefore", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "balanceAfter", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceIndexerAlreadyRegistered", + "inputs": [] + }, + { + "type": "error", + "name": "SubgraphServiceIndexerMismatch", + "inputs": [ + { + "name": "providedIndexer", + "type": "address", + "internalType": "address" + }, + { + "name": "expectedIndexer", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceIndexerNotRegistered", + "inputs": [ + { + "name": "indexer", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceInvalidCurationCut", + "inputs": [ + { + "name": "curationCut", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceInvalidPaymentType", + "inputs": [ + { + "name": "paymentType", + "type": "uint8", + "internalType": "enum IGraphPayments.PaymentTypes" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceInvalidRAV", + "inputs": [ + { + "name": "ravIndexer", + "type": "address", + "internalType": "address" + }, + { + "name": "allocationIndexer", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "SubgraphServiceInvalidZeroStakeToFeesRatio", + "inputs": [] + } +] \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index 622f7204..71f4179b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -86,6 +86,8 @@ 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 in allocation" totalTokensAllocated: BigInt! "Total delegated tokens in the protocol" @@ -231,6 +233,16 @@ type GraphNetwork @entity { currentL1BlockNumber: BigInt } +type DataService @entity { + "Verifier address" + id: ID! + + "Total GRT currently in provisions for this DataService" + totalTokensProvisioned: BigInt! + "Total GRT currently in allocations for this DataService" + totalTokensAllocated: BigInt! +} + """ An account within the graph network. Contains metadata and all relevant data for this accounts delegating, curating, and indexing. @@ -675,6 +687,8 @@ type Indexer @entity { # 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 since there was only one data service" + provisionedTokens: BigInt! "CURRENT tokens allocated on all subgraphs" allocatedTokens: BigInt! "NOT IMPLEMENTED - Tokens that have been unstaked and withdrawn" @@ -764,6 +778,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 +788,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,6 +829,17 @@ type IndexerQueryFeePaymentAggregation @entity { paymentSource: PaymentSource! } +type Provision @entity { + "Join ID of indexer address (service provider) and DataService address (verifier)" + id: ID! + + indexer: Indexer! + + service: DataService! + + tokensProvisioned: BigInt! +} + """ A state channel Allocation representing a single Indexer-SubgraphDeployment stake """ diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index b19d91e7..7803a443 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -136,6 +136,7 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I indexer.stakedTokens = BigInt.fromI32(0) indexer.transferredToL2 = false indexer.stakedTokensTransferredToL2 = BigInt.fromI32(0) + indexer.provisionedTokens = BigInt.fromI32(0) indexer.allocatedTokens = BigInt.fromI32(0) indexer.lockedTokens = BigInt.fromI32(0) indexer.unstakedTokens = BigInt.fromI32(0) @@ -552,6 +553,7 @@ export function createOrLoadGraphNetwork( graphNetwork.totalTokensStaked = BigInt.fromI32(0) graphNetwork.totalTokensClaimable = BigInt.fromI32(0) graphNetwork.totalUnstakedTokensLocked = BigInt.fromI32(0) + graphNetwork.totalTokensProvisioned = BigInt.fromI32(0) graphNetwork.totalTokensAllocated = BigInt.fromI32(0) graphNetwork.totalDelegatedTokens = BigInt.fromI32(0) graphNetwork.totalTokensSignalled = BigInt.fromI32(0) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts new file mode 100644 index 00000000..43e50c28 --- /dev/null +++ b/src/mappings/horizonStaking.ts @@ -0,0 +1,78 @@ +import { BigInt } from '@graphprotocol/graph-ts' +import { addresses } from '../../config/addresses.template' +import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn} from '../types/HorizonStaking/HorizonStaking' +import { Indexer } from '../types/schema' +import { calculateCapacities, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, updateAdvancedIndexerMetrics } from './helpers/helpers' + + +export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void { + // To Do + 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 = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = calculateCapacities(indexer as Indexer) + indexer.save() + + // Update graph network + graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.plus(event.params.tokens) + if (previousStake == BigInt.fromI32(0)) { + 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 { + // To Do + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + // update indexer + let id = event.params.serviceProvider.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) + indexer = calculateCapacities(indexer as Indexer) + 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 + } + graphNetwork.save() +} + +export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void { + // To Do + 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 = indexer.lockedTokens.minus(event.params.tokens) + indexer.tokensLockedUntil = 0 // always set to 0 when withdrawn + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = calculateCapacities(indexer as Indexer) + indexer.save() + + // Update graph network + graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) + graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.minus( + event.params.tokens, + ) + graphNetwork.save() +} diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index c720dbdb..d61834a3 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -76,12 +76,14 @@ export function handleStakeDeposited(event: StakeDeposited): void { let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) let previousStake = indexer.stakedTokens indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) + indexer.provisionedTokens = indexer.provisionedTokens.plus(event.params.tokens) indexer = updateAdvancedIndexerMetrics(indexer as Indexer) indexer = calculateCapacities(indexer as Indexer) indexer.save() // Update graph network graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.plus(event.params.tokens) + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.plus(event.params.tokens) if (previousStake == BigInt.fromI32(0)) { graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount + 1 } @@ -136,6 +138,7 @@ export function handleStakeWithdrawn(event: StakeWithdrawn): void { let id = event.params.indexer.toHexString() let indexer = Indexer.load(id)! indexer.stakedTokens = indexer.stakedTokens.minus(event.params.tokens) + indexer.provisionedTokens = indexer.provisionedTokens.minus(event.params.tokens) indexer.lockedTokens = indexer.lockedTokens.minus(event.params.tokens) indexer.tokensLockedUntil = 0 // always set to 0 when withdrawn indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -144,6 +147,7 @@ export function handleStakeWithdrawn(event: StakeWithdrawn): void { // Update graph network graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.minus(event.params.tokens) graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.minus( event.params.tokens, ) diff --git a/subgraph.template.yaml b/subgraph.template.yaml index c51094bb..850b2095 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -377,6 +377,34 @@ 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/staking.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 - kind: ethereum/contract name: Curation network: {{network}} From 721d93db9b4e9d1e4a55f6a31fb867e9c85dcfb3 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 10 Feb 2025 18:30:15 -0300 Subject: [PATCH 02/57] fix: potential issue for Stage 2 --- src/mappings/horizonStaking.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 43e50c28..c5c277e5 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -63,7 +63,7 @@ export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void let id = event.params.serviceProvider.toHexString() let indexer = Indexer.load(id)! indexer.stakedTokens = indexer.stakedTokens.minus(event.params.tokens) - indexer.lockedTokens = indexer.lockedTokens.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 = updateAdvancedIndexerMetrics(indexer as Indexer) indexer = calculateCapacities(indexer as Indexer) From cdbbe77853499f1912545948d55c80f5662ee04f Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 01:34:08 -0300 Subject: [PATCH 03/57] fix: comments from latest round of reviews --- schema.graphql | 8 ++++---- src/mappings/staking.ts | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/schema.graphql b/schema.graphql index 71f4179b..95969531 100644 --- a/schema.graphql +++ b/schema.graphql @@ -234,7 +234,7 @@ type GraphNetwork @entity { } type DataService @entity { - "Verifier address" + "Data Service address" id: ID! "Total GRT currently in provisions for this DataService" @@ -687,7 +687,7 @@ type Indexer @entity { # 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 since there was only one data service" + "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 allocated on all subgraphs" allocatedTokens: BigInt! @@ -830,12 +830,12 @@ type IndexerQueryFeePaymentAggregation @entity { } type Provision @entity { - "Join ID of indexer address (service provider) and DataService address (verifier)" + "Join ID of indexer address (service provider) and DataService address" id: ID! indexer: Indexer! - service: DataService! + dataService: DataService! tokensProvisioned: BigInt! } diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index d61834a3..c720dbdb 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -76,14 +76,12 @@ export function handleStakeDeposited(event: StakeDeposited): void { let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) let previousStake = indexer.stakedTokens indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) - indexer.provisionedTokens = indexer.provisionedTokens.plus(event.params.tokens) indexer = updateAdvancedIndexerMetrics(indexer as Indexer) indexer = calculateCapacities(indexer as Indexer) indexer.save() // Update graph network graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.plus(event.params.tokens) - graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.plus(event.params.tokens) if (previousStake == BigInt.fromI32(0)) { graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount + 1 } @@ -138,7 +136,6 @@ export function handleStakeWithdrawn(event: StakeWithdrawn): void { let id = event.params.indexer.toHexString() let indexer = Indexer.load(id)! indexer.stakedTokens = indexer.stakedTokens.minus(event.params.tokens) - indexer.provisionedTokens = indexer.provisionedTokens.minus(event.params.tokens) indexer.lockedTokens = indexer.lockedTokens.minus(event.params.tokens) indexer.tokensLockedUntil = 0 // always set to 0 when withdrawn indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -147,7 +144,6 @@ export function handleStakeWithdrawn(event: StakeWithdrawn): void { // Update graph network graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) - graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.minus(event.params.tokens) graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.minus( event.params.tokens, ) From f9a676bba2f6122a896dc77d359fb39930c70401 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 01:46:06 -0300 Subject: [PATCH 04/57] fix: more fixes from reviews, and fixed addresses import preventing build --- src/mappings/horizonStaking.ts | 88 ++++++++++++++++------------------ src/mappings/staking.ts | 5 +- subgraph.template.yaml | 2 +- 3 files changed, 44 insertions(+), 51 deletions(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index c5c277e5..c1c5b410 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,12 +1,11 @@ import { BigInt } from '@graphprotocol/graph-ts' -import { addresses } from '../../config/addresses.template' -import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn} from '../types/HorizonStaking/HorizonStaking' +import { addresses } from '../../config/addresses' +import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn } from '../types/HorizonStaking/HorizonStaking' import { Indexer } from '../types/schema' import { calculateCapacities, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, updateAdvancedIndexerMetrics } from './helpers/helpers' export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void { - // To Do let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) // update indexer let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) @@ -15,64 +14,61 @@ export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void indexer = updateAdvancedIndexerMetrics(indexer as Indexer) indexer = calculateCapacities(indexer as Indexer) indexer.save() - + // Update graph network graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.plus(event.params.tokens) - if (previousStake == BigInt.fromI32(0)) { - graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount + 1 + if (previousStake.isZero()) { + graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount + 1 } graphNetwork.save() - + // Update epoch let epoch = createOrLoadEpoch( - addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!, ) epoch.stakeDeposited = epoch.stakeDeposited.plus(event.params.tokens) epoch.save() } export function handleHorizonStakeLocked(event: HorizonStakeLocked): void { - // To Do - let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) - // update indexer - let id = event.params.serviceProvider.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) - indexer = calculateCapacities(indexer as Indexer) - indexer.save() + 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 = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = calculateCapacities(indexer as Indexer) + 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 - } - graphNetwork.save() + // update graph network + graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.plus( + event.params.tokens, + ) + graphNetwork.save() } export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void { - // To Do - 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 = updateAdvancedIndexerMetrics(indexer as Indexer) - indexer = calculateCapacities(indexer as Indexer) - indexer.save() + 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 = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = calculateCapacities(indexer as Indexer) + indexer.save() - // Update graph network - graphNetwork.totalTokensStaked = graphNetwork.totalTokensStaked.minus(event.params.tokens) - graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.minus( - event.params.tokens, - ) - graphNetwork.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() } diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index c720dbdb..a35d7b52 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -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 } diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 850b2095..ff4b23ce 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -388,7 +388,7 @@ dataSources: kind: ethereum/events apiVersion: 0.0.7 language: wasm/assemblyscript - file: ./src/mappings/staking.ts + file: ./src/mappings/horizonStaking.ts entities: - GraphNetwork abis: From 49808b42e0f59372390baa3635d42867d599d348 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Tue, 11 Feb 2025 02:43:31 -0300 Subject: [PATCH 05/57] feat: add initial provision management, without thawing tracking --- schema.graphql | 29 +++++++ src/mappings/helpers/helpers.ts | 39 ++++++++++ src/mappings/horizonStaking.ts | 129 ++++++++++++++++++++++++++++++-- subgraph.template.yaml | 22 ++++++ 4 files changed, 214 insertions(+), 5 deletions(-) diff --git a/schema.graphql b/schema.graphql index 95969531..89807977 100644 --- a/schema.graphql +++ b/schema.graphql @@ -88,6 +88,8 @@ type GraphNetwork @entity { 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" @@ -239,8 +241,12 @@ type DataService @entity { "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! + + provisions: [Provision!]! @derivedFrom(field: "service") } """ @@ -689,6 +695,8 @@ type Indexer @entity { 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" @@ -838,6 +846,27 @@ type Provision @entity { dataService: DataService! tokensProvisioned: BigInt! + + "Service provider tokens that are being thawed (and will stop being slashable soon)" + tokensThawing: BigInt! + + "Shares representing the thawing tokens" + sharesThawing: BigInt! + + "Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed" + maxVerifierCut: Int! + + "Time, in seconds, tokens must thaw before being withdrawn" + thawingPeriod: BigInt! + + "Timestamp when the provision was created" + createdAt: BigInt! + + "Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active" + maxVerifierCutPending: Int! + + "Pending value for thawingPeriod. Verifier needs to accept it before it becomes active" + thawingPeriodPending: BigInt! } """ diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 7803a443..8ff45eca 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -26,6 +26,8 @@ import { CurrentSubgraphDeploymentRelation, PaymentSource, IndexerQueryFeePaymentAggregation, + Provision, + DataService, } from '../../types/schema' import { SubgraphDeploymentManifest as SubgraphDeploymentManifestTemplate @@ -137,6 +139,7 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I 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) @@ -188,6 +191,41 @@ export function createOrLoadIndexer(indexerAddress: Bytes, timestamp: BigInt): I return indexer as 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.service = verifierAddress.toHexString() + provision.tokensProvisioned = BigInt.fromI32(0) + provision.tokensThawing = BigInt.fromI32(0) + provision.sharesThawing = BigInt.fromI32(0) + provision.createdAt = timestamp + provision.maxVerifierCut = 0 + provision.maxVerifierCutPending = 0 + provision.thawingPeriod = BigInt.fromI32(0) + provision.thawingPeriodPending = BigInt.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.save() + } + + return service as DataService +} + export function createOrLoadPaymentSource(paymentAddress: Bytes): PaymentSource { let id = paymentAddress.toHexString() let paymentSource = PaymentSource.load(id) @@ -554,6 +592,7 @@ export function createOrLoadGraphNetwork( 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) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index c1c5b410..1312e740 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,9 +1,20 @@ -import { BigInt } from '@graphprotocol/graph-ts' +import { BigInt, log } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' -import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn } from '../types/HorizonStaking/HorizonStaking' -import { Indexer } from '../types/schema' -import { calculateCapacities, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, updateAdvancedIndexerMetrics } from './helpers/helpers' - +import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' +import { Indexer, GraphNetwork } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' +import { + ProvisionCreated, + ProvisionIncreased, + ProvisionParametersSet, + ProvisionParametersStaged, + ProvisionSlashed, + ProvisionThawed, + ThawRequestCreated, + ThawRequestFulfilled, + ThawRequestsFulfilled, + ThawingPeriodCleared +} from '../types/HorizonStaking/HorizonStaking' export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void { let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) @@ -72,3 +83,111 @@ export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void } 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.save() + + dataService.totalTokensProvisioned = dataService.totalTokensProvisioned.minus(event.params.tokens) + dataService.save() + + graphNetwork.totalTokensProvisioned = graphNetwork.totalTokensProvisioned.minus(event.params.tokens) + graphNetwork.save() + + provision.tokensProvisioned = provision.tokensProvisioned.minus(event.params.tokens) + provision.save() +} + +export function handleProvisionParametersSet(event: ProvisionParametersSet): void { + // To Do +} + +export function handleProvisionParametersStaged(event: ProvisionParametersStaged): void { + // To Do +} + +export function handleProvisionSlashed(event: ProvisionSlashed): void { + // To Do +} + +export function handleThawRequestCreated(event: ThawRequestCreated): void { + // To Do +} + +export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { + // To Do +} + +export function handleThawRequestsFulfilled(event: ThawRequestsFulfilled): void { + // To Do +} + +export function handleThawingPeriodCleared(event: ThawingPeriodCleared): void { + // To Do +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index ff4b23ce..c916346f 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -405,6 +405,28 @@ dataSources: 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 address,indexed address,indexed address,uint256,uint64,bytes32) + handler: handleThawRequestCreated + - event: ThawRequestFulfilled(indexed bytes32,uint256,uint256,uint64,bool) + handler: handleThawRequestFulfilled + - event: ThawRequestsFulfilled(indexed address,indexed address,indexed address,uint256,uint256,uint8) + handler: handleThawRequestsFulfilled + - event: ThawingPeriodCleared() + handler: handleThawingPeriodCleared - kind: ethereum/contract name: Curation network: {{network}} From 353e18f53362d039bc9c5c07d441357e71a63572 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 12 Feb 2025 01:21:25 -0300 Subject: [PATCH 06/57] feat: basic implementation for ThawRequests --- schema.graphql | 35 +++++++++++++++++++++++++--------- src/mappings/horizonStaking.ts | 32 ++++++++++++++++++------------- subgraph.template.yaml | 4 ---- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/schema.graphql b/schema.graphql index 89807977..e9e1825a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -847,28 +847,45 @@ type Provision @entity { tokensProvisioned: BigInt! + "Timestamp when the provision was created" + createdAt: BigInt! + "Service provider tokens that are being thawed (and will stop being slashable soon)" tokensThawing: BigInt! - "Shares representing the thawing tokens" - sharesThawing: BigInt! - "Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed" maxVerifierCut: Int! - "Time, in seconds, tokens must thaw before being withdrawn" - thawingPeriod: BigInt! - - "Timestamp when the provision was created" - createdAt: BigInt! - "Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active" maxVerifierCutPending: Int! + "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! } +type ThawRequest @entity { + id: ID! + + indexer: Indexer! + + service: DataService! + + owner: GraphAccount! + + "Shares representing the thawing tokens" + shares: BigInt! + + "Tokens thawed" + tokens: BigInt! + + thawingUntil: BigInt! + + valid: Boolean +} + """ A state channel Allocation representing a single Indexer-SubgraphDeployment stake """ diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 1312e740..85570993 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,8 +1,8 @@ import { BigInt, log } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' -import { Indexer, GraphNetwork } from '../types/schema' -import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' +import { Indexer, GraphNetwork, ThawRequest } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -177,17 +177,23 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void { } export function handleThawRequestCreated(event: ThawRequestCreated): void { - // To Do + 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.service = dataService.id + request.owner = owner.id + request.shares = event.params.shares + request.tokens = BigInt.fromI32(0) + request.thawingUntil = event.params.thawingUntil + request.save() } export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { - // To Do -} - -export function handleThawRequestsFulfilled(event: ThawRequestsFulfilled): void { - // To Do -} - -export function handleThawingPeriodCleared(event: ThawingPeriodCleared): void { - // To Do -} + let request = ThawRequest.load(event.params.thawRequestId.toHexString()) + request.tokens = event.params.tokens + request.valid = event.params.valid + request.save() +} \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index c916346f..4036bfec 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -423,10 +423,6 @@ dataSources: handler: handleThawRequestCreated - event: ThawRequestFulfilled(indexed bytes32,uint256,uint256,uint64,bool) handler: handleThawRequestFulfilled - - event: ThawRequestsFulfilled(indexed address,indexed address,indexed address,uint256,uint256,uint8) - handler: handleThawRequestsFulfilled - - event: ThawingPeriodCleared() - handler: handleThawingPeriodCleared - kind: ethereum/contract name: Curation network: {{network}} From 4fee2d0d5516534ec3b3cf28c681a7fac812d1a4 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 02:10:20 -0300 Subject: [PATCH 07/57] fix: schema --- schema.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.graphql b/schema.graphql index e9e1825a..dadf5e5d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -246,7 +246,7 @@ type DataService @entity { "Total GRT currently in allocations for this DataService" totalTokensAllocated: BigInt! - provisions: [Provision!]! @derivedFrom(field: "service") + provisions: [Provision!]! @derivedFrom(field: "dataService") } """ From 89ec3ed683b49d9bf62fa9509099ad06a73e5d2d Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 02:17:22 -0300 Subject: [PATCH 08/57] fix: maxVerifierCut/Pending wrong types, schema issues and more --- schema.graphql | 6 +++--- src/mappings/helpers/helpers.ts | 7 +++---- src/mappings/horizonStaking.ts | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/schema.graphql b/schema.graphql index dadf5e5d..f915cc7b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -854,10 +854,10 @@ type Provision @entity { tokensThawing: BigInt! "Max amount that can be taken by the verifier when slashing, expressed in parts-per-million of the amount slashed" - maxVerifierCut: Int! + maxVerifierCut: BigInt! "Pending value for maxVerifierCut. Verifier needs to accept it before it becomes active" - maxVerifierCutPending: Int! + maxVerifierCutPending: BigInt! "Time, in seconds, tokens must thaw before being withdrawn" thawingPeriod: BigInt! @@ -871,7 +871,7 @@ type ThawRequest @entity { indexer: Indexer! - service: DataService! + dataService: DataService! owner: GraphAccount! diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 8ff45eca..10a08d7e 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -197,13 +197,12 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By if (provision == null) { provision = new Provision(id) provision.indexer = indexerAddress.toHexString() - provision.service = verifierAddress.toHexString() + provision.dataService = verifierAddress.toHexString() provision.tokensProvisioned = BigInt.fromI32(0) provision.tokensThawing = BigInt.fromI32(0) - provision.sharesThawing = BigInt.fromI32(0) provision.createdAt = timestamp - provision.maxVerifierCut = 0 - provision.maxVerifierCutPending = 0 + provision.maxVerifierCut = BigInt.fromI32(0) + provision.maxVerifierCutPending = BigInt.fromI32(0) provision.thawingPeriod = BigInt.fromI32(0) provision.thawingPeriodPending = BigInt.fromI32(0) provision.save() diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 85570993..d9613323 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -183,7 +183,7 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { let request = new ThawRequest(event.params.thawRequestId.toHexString()) request.indexer = indexer.id - request.service = dataService.id + request.dataService = dataService.id request.owner = owner.id request.shares = event.params.shares request.tokens = BigInt.fromI32(0) @@ -192,7 +192,7 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { } export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { - let request = ThawRequest.load(event.params.thawRequestId.toHexString()) + let request = ThawRequest.load(event.params.thawRequestId.toHexString())! request.tokens = event.params.tokens request.valid = event.params.valid request.save() From 67a0f5cfb0cbc8f2f8e867308e8fdbeadf20be20 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 02:24:37 -0300 Subject: [PATCH 09/57] feat: added ProvisionSlashed support --- src/mappings/horizonStaking.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index d9613323..25875716 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -173,7 +173,25 @@ export function handleProvisionParametersStaged(event: ProvisionParametersStaged } export function handleProvisionSlashed(event: ProvisionSlashed): void { - // To Do + 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) + provision.save() } export function handleThawRequestCreated(event: ThawRequestCreated): void { From 9517b035b2e774e72fe73972fbb144d159131f20 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 12 Feb 2025 02:34:18 -0300 Subject: [PATCH 10/57] feat: add ParametersSet and Staged support for provisions --- src/mappings/horizonStaking.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 25875716..c920c06a 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -165,11 +165,17 @@ export function handleTokensDeprovisioned(event: TokensDeprovisioned): void { } export function handleProvisionParametersSet(event: ProvisionParametersSet): void { - // To Do + 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 { - // To Do + 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 handleProvisionSlashed(event: ProvisionSlashed): void { From 7c2bd905e2ed63c2e9458eabfdf72f6ba7e74051 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 13 Feb 2025 01:28:38 -0300 Subject: [PATCH 11/57] chore: placeholder for SetOperator and DelegationFeeCutSet --- src/mappings/horizonStaking.ts | 14 +++++++++++++- subgraph.template.yaml | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index c920c06a..918342c6 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,6 +1,6 @@ import { BigInt, log } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' -import { HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' +import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' import { Indexer, GraphNetwork, ThawRequest } from '../types/schema' import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' import { @@ -178,6 +178,18 @@ export function handleProvisionParametersStaged(event: ProvisionParametersStaged provision.save() } +export function handleOperatorSet(event: OperatorSet): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + // To Do + provision.save() +} + +export function handleDelegationFeeCutSet(event: DelegationFeeCutSet): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + // To Do + provision.save() +} + export function handleProvisionSlashed(event: ProvisionSlashed): void { let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) let dataService = createOrLoadDataService(event.params.verifier) diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 4036bfec..3f2361b7 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -423,6 +423,10 @@ dataSources: handler: handleThawRequestCreated - event: ThawRequestFulfilled(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 - kind: ethereum/contract name: Curation network: {{network}} From 9f52dc70407285c986d792ebfead27e9ab198f17 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Tue, 18 Feb 2025 02:04:25 -0300 Subject: [PATCH 12/57] feat: added new OperatorSet and DelegationFeeCutSet event support --- schema.graphql | 32 ++++++++++++++++++++++ src/mappings/helpers/helpers.ts | 19 +++++++++++++ src/mappings/horizonStaking.ts | 48 +++++++++++++++++++++++++++++---- 3 files changed, 94 insertions(+), 5 deletions(-) diff --git a/schema.graphql b/schema.graphql index f915cc7b..961e6428 100644 --- a/schema.graphql +++ b/schema.graphql @@ -273,6 +273,8 @@ type GraphAccount @entity { operatorOf: [GraphAccount!]! @derivedFrom(field: "operators") "Operators of this Graph Accounts" operators: [GraphAccount!]! + "Operators of this Graph Accounts" + provisionedOperators: [Operator!]! # GRT info "Graph token balance" @@ -837,6 +839,21 @@ type IndexerQueryFeePaymentAggregation @entity { paymentSource: PaymentSource! } +type Operator @entity { + "Joint address of all 3 parties involved (Operator, Indexer, DataService)" + id: ID! + + operatorOf: [GraphAccount!]! @derivedFrom(field: "provisionedOperators") + + operator: GraphAccount! + + indexer: Indexer! + + dataService: DataService! + + allowed: Boolean! +} + type Provision @entity { "Join ID of indexer address (service provider) and DataService address" id: ID! @@ -864,6 +881,21 @@ type Provision @entity { "Pending value for thawingPeriod. Verifier needs to accept it before it becomes active" thawingPeriodPending: BigInt! + + # Cuts for subgraph service. Percentage of rewards that the delegation pool receives + queryFeeCut: BigInt! + + indexingFeeCut: BigInt! + + indexingRewardsCut: BigInt! + + # Might want to add polymorphic handling of different fee cuts through a generic hashmap in the future +} + +enum PaymentTypes { + QueryFee, + IndexingFee, + IndexingRewards } type ThawRequest @entity { diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 10a08d7e..49657375 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -28,6 +28,7 @@ import { IndexerQueryFeePaymentAggregation, Provision, DataService, + Operator, } from '../../types/schema' import { SubgraphDeploymentManifest as SubgraphDeploymentManifestTemplate @@ -205,6 +206,9 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By 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.save() } @@ -225,6 +229,21 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { return service as DataService } +export function createOrLoadOperator(address: Bytes, verifierAddress: Bytes, indexerAddress: Bytes): Operator { + let id = joinID([address.toHexString(), indexerAddress.toHexString(), verifierAddress.toHexString()]) + let operator = Operator.load(id) + if (operator == null) { + operator = new Operator(id) + operator.allowed = false + operator.operator = address.toHexString() + operator.indexer = indexerAddress.toHexString() + operator.dataService = verifierAddress.toHexString() + operator.save() + } + + return operator as Operator +} + export function createOrLoadPaymentSource(paymentAddress: Bytes): PaymentSource { let id = paymentAddress.toHexString() let paymentSource = PaymentSource.load(id) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 918342c6..95a337ca 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -2,7 +2,7 @@ import { BigInt, log } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' import { Indexer, GraphNetwork, ThawRequest } from '../types/schema' -import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' +import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -179,14 +179,52 @@ export function handleProvisionParametersStaged(event: ProvisionParametersStaged } export function handleOperatorSet(event: OperatorSet): void { - let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) - // To Do - provision.save() + let indexerGraphAccount = createOrLoadGraphAccount(event.params.serviceProvider, event.block.timestamp) + let operator = createOrLoadOperator(event.params.operator, event.params.verifier, event.params.serviceProvider) + let operators = indexerGraphAccount.operators + // Will have to handle legacy operators list, and horizon provisionedOperators 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 provisionedOperators = indexerGraphAccount.provisionedOperators + let provisionedOperatorsIndex = provisionedOperators.indexOf(event.params.operator.toHexString()) + if (provisionedOperatorsIndex != -1) { + // false - it existed, and we set it to false, so remove from operators and update operator + if (!event.params.allowed) { + operators.splice(provisionedOperatorsIndex, 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.provisionedOperators = provisionedOperators + indexerGraphAccount.save() } export function handleDelegationFeeCutSet(event: DelegationFeeCutSet): void { let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) - // To Do + 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() } From dadddd95662e197d98463ffae38799f84761ee91 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Tue, 18 Feb 2025 02:07:58 -0300 Subject: [PATCH 13/57] fix: provisionedOperators missing init --- src/mappings/helpers/helpers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 49657375..3f1d4547 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -475,6 +475,7 @@ export function createOrLoadGraphAccount(owner: Bytes, timeStamp: BigInt): Graph graphAccount = new GraphAccount(id) graphAccount.createdAt = timeStamp.toI32() graphAccount.operators = [] + graphAccount.provisionedOperators = [] graphAccount.balance = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Signalling = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Delegation = BigInt.fromI32(0) From a404cba7477a3d084883e8ca8f7dc62b7d5ea826 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Tue, 18 Feb 2025 02:50:17 -0300 Subject: [PATCH 14/57] feat: added basic delegation pool management --- src/mappings/helpers/helpers.ts | 12 ++++++++++++ src/mappings/horizonStaking.ts | 26 +++++++++++++++++--------- subgraph.template.yaml | 2 ++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 3f1d4547..6faf1fbe 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -909,6 +909,18 @@ export function updateAdvancedIndexerMetrics(indexer: Indexer): Indexer { return indexer as Indexer } +export function updateAdvancedIndexerMetricsHorizon(indexer: Indexer, provision: Provision): Indexer { + indexer.ownStakeRatio = calculateOwnStakeRatio(indexer as Indexer) + indexer.delegatedStakeRatio = calculateDelegatedStakeRatio(indexer as Indexer) + indexer.indexingRewardEffectiveCut = provision.indexingRewardsCut.toBigDecimal() + indexer.queryFeeEffectiveCut = provision.queryFeeCut.toBigDecimal() + indexer.indexerRewardsOwnGenerationRatio = calculateIndexerRewardOwnGenerationRatio( + indexer as Indexer, + ) + indexer.overDelegationDilution = calculateOverdelegationDilution(indexer as Indexer) + return indexer as Indexer +} + export function updateDelegationExchangeRate(indexer: Indexer): Indexer { indexer.delegationExchangeRate = indexer.delegatedTokens .toBigDecimal() diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 95a337ca..a085403a 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,8 +1,8 @@ -import { BigInt, log } from '@graphprotocol/graph-ts' +import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' -import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned } from '../types/HorizonStaking/HorizonStaking' -import { Indexer, GraphNetwork, ThawRequest } from '../types/schema' -import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateAdvancedIndexerMetrics } from './helpers/helpers' +import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned, TokensToDelegationPoolAdded } from '../types/HorizonStaking/HorizonStaking' +import { Indexer, ThawRequest } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateAdvancedIndexerMetrics, updateAdvancedIndexerMetricsHorizon, updateDelegationExchangeRate } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -12,8 +12,6 @@ import { ProvisionThawed, ThawRequestCreated, ThawRequestFulfilled, - ThawRequestsFulfilled, - ThawingPeriodCleared } from '../types/HorizonStaking/HorizonStaking' export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void { @@ -22,7 +20,7 @@ export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) let previousStake = indexer.stakedTokens indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) - indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way indexer = calculateCapacities(indexer as Indexer) indexer.save() @@ -48,7 +46,7 @@ export function handleHorizonStakeLocked(event: HorizonStakeLocked): void { let indexer = Indexer.load(id)! indexer.lockedTokens = event.params.tokens indexer.tokensLockedUntil = event.params.until.toI32() - indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way indexer = calculateCapacities(indexer as Indexer) indexer.save() @@ -67,7 +65,7 @@ export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void 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 = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way indexer = calculateCapacities(indexer as Indexer) indexer.save() @@ -270,4 +268,14 @@ export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { request.tokens = event.params.tokens request.valid = event.params.valid request.save() +} + +export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolAdded): void { + let indexer = Indexer.load(event.params.serviceProvider.toHexString())! + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) + indexer = updateAdvancedIndexerMetricsHorizon(indexer, provision) + indexer = updateDelegationExchangeRate(indexer) + indexer = calculateCapacities(indexer) + indexer.save() } \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 3f2361b7..4b9e6b87 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -427,6 +427,8 @@ dataSources: handler: handleOperatorSet - event: DelegationFeeCutSet(indexed address,indexed address,indexed uint8,uint256) handler: handleDelegationFeeCutSet + - event: TokensToDelegationPoolAdded(indexed address,indexed address,uint256) + handler: handleTokensToDelegationPoolAdded - kind: ethereum/contract name: Curation network: {{network}} From f55ca4143faf4a22aab624c91f98f13cd25ccc51 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 19 Feb 2025 01:44:53 -0300 Subject: [PATCH 15/57] feat: added provision delegated fields --- schema.graphql | 8 ++++++++ src/mappings/helpers/helpers.ts | 3 +++ src/mappings/horizonStaking.ts | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/schema.graphql b/schema.graphql index 961e6428..650e3c2d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -890,6 +890,14 @@ type Provision @entity { indexingRewardsCut: BigInt! # Might want to add polymorphic handling of different fee cuts through a generic hashmap in the future + + # Delegation + "Tokens delegated to the provision" + delegatedTokens: BigInt! + "Total shares of the delegator pool" + delegatorShares: BigInt! + "Exchange rate of of tokens received for each share" + delegationExchangeRate: BigDecimal! } enum PaymentTypes { diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 6faf1fbe..970de53f 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -209,6 +209,9 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By provision.queryFeeCut = BigInt.fromI32(0) provision.indexingFeeCut = BigInt.fromI32(0) provision.indexingRewardsCut = BigInt.fromI32(0) + provision.delegatedTokens = BigInt.fromI32(0) + provision.delegatorShares = BigInt.fromI32(0) + provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal() provision.save() } diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index a085403a..022e03bc 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -273,9 +273,9 @@ export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolAdded): void { let indexer = Indexer.load(event.params.serviceProvider.toHexString())! let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) - indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) - indexer = updateAdvancedIndexerMetricsHorizon(indexer, provision) - indexer = updateDelegationExchangeRate(indexer) - indexer = calculateCapacities(indexer) + provision.delegatedTokens = provision.delegatedTokens.plus(event.params.tokens) + provision.save() + + indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) // this only serves as a general tracker, but the real deal is per provision indexer.save() } \ No newline at end of file From 9b2275f7140bf7e6e316de9074a33e59a4079d75 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 19 Feb 2025 01:46:56 -0300 Subject: [PATCH 16/57] feat: removed advanced metrics for indexer on horizon since it makes no sense --- src/mappings/helpers/helpers.ts | 12 ------------ src/mappings/horizonStaking.ts | 8 +------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 970de53f..19cb75d2 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -912,18 +912,6 @@ export function updateAdvancedIndexerMetrics(indexer: Indexer): Indexer { return indexer as Indexer } -export function updateAdvancedIndexerMetricsHorizon(indexer: Indexer, provision: Provision): Indexer { - indexer.ownStakeRatio = calculateOwnStakeRatio(indexer as Indexer) - indexer.delegatedStakeRatio = calculateDelegatedStakeRatio(indexer as Indexer) - indexer.indexingRewardEffectiveCut = provision.indexingRewardsCut.toBigDecimal() - indexer.queryFeeEffectiveCut = provision.queryFeeCut.toBigDecimal() - indexer.indexerRewardsOwnGenerationRatio = calculateIndexerRewardOwnGenerationRatio( - indexer as Indexer, - ) - indexer.overDelegationDilution = calculateOverdelegationDilution(indexer as Indexer) - return indexer as Indexer -} - export function updateDelegationExchangeRate(indexer: Indexer): Indexer { indexer.delegationExchangeRate = indexer.delegatedTokens .toBigDecimal() diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 022e03bc..0af83856 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -2,7 +2,7 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned, TokensToDelegationPoolAdded } from '../types/HorizonStaking/HorizonStaking' import { Indexer, ThawRequest } from '../types/schema' -import { calculateCapacities, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateAdvancedIndexerMetrics, updateAdvancedIndexerMetricsHorizon, updateDelegationExchangeRate } from './helpers/helpers' +import { createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -20,8 +20,6 @@ export function handleHorizonStakeDeposited(event: HorizonStakeDeposited): void let indexer = createOrLoadIndexer(event.params.serviceProvider, event.block.timestamp) let previousStake = indexer.stakedTokens indexer.stakedTokens = indexer.stakedTokens.plus(event.params.tokens) - indexer = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way - indexer = calculateCapacities(indexer as Indexer) indexer.save() // Update graph network @@ -46,8 +44,6 @@ export function handleHorizonStakeLocked(event: HorizonStakeLocked): void { let indexer = Indexer.load(id)! indexer.lockedTokens = event.params.tokens indexer.tokensLockedUntil = event.params.until.toI32() - indexer = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way - indexer = calculateCapacities(indexer as Indexer) indexer.save() // update graph network @@ -65,8 +61,6 @@ export function handleHorizonStakeWithdrawn(event: HorizonStakeWithdrawn): void 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 = updateAdvancedIndexerMetrics(indexer as Indexer) // Can't rely on provision here, will need to figure out a way - indexer = calculateCapacities(indexer as Indexer) indexer.save() // Update graph network From 33f0c3b803e67a23d400acca59cdac9961cfb9d5 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 19 Feb 2025 02:03:52 -0300 Subject: [PATCH 17/57] feat: prepared configs, placeholder mapping file --- config/addresses.template.ts | 2 + config/arbitrumGoerliAddressScript.ts | 51 ------------------------ config/arbitrumSepoliaAddressScript.ts | 1 + config/goerliAddressScript.ts | 52 ------------------------ config/ipfs.json | 3 -- config/mainnetAddressScript.ts | 52 ------------------------ config/mainnetArbitrumAddressScript.ts | 5 +++ config/no-ipfs.json | 3 -- config/sepoliaAddressScript.ts | 55 -------------------------- config/testAddressesL1.ts | 1 + config/testAddressesL2.ts | 1 + src/mappings/subgraphService.ts | 1 + subgraph.template.yaml | 26 ++++++++++++ 13 files changed, 37 insertions(+), 216 deletions(-) delete mode 100644 config/arbitrumGoerliAddressScript.ts delete mode 100644 config/goerliAddressScript.ts delete mode 100644 config/ipfs.json delete mode 100644 config/mainnetAddressScript.ts delete mode 100644 config/no-ipfs.json delete mode 100644 config/sepoliaAddressScript.ts create mode 100644 src/mappings/subgraphService.ts diff --git a/config/addresses.template.ts b/config/addresses.template.ts index dda69c57..3121b7e5 100644 --- a/config/addresses.template.ts +++ b/config/addresses.template.ts @@ -20,6 +20,7 @@ export class Addresses { l1GraphTokenGateway: string l2GraphTokenGateway: string ethereumDIDRegistry: string + subgraphService: string isL1: boolean } @@ -45,5 +46,6 @@ export let addresses: Addresses = { l1GraphTokenGateway: '{{l1GraphTokenGateway}}', l2GraphTokenGateway: '{{l2GraphTokenGateway}}', ethereumDIDRegistry: '{{ethereumDIDRegistry}}', + subgraphService: '{{subgraphService}}', 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..44334c9d 100644 --- a/config/arbitrumSepoliaAddressScript.ts +++ b/config/arbitrumSepoliaAddressScript.ts @@ -29,6 +29,7 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '{{arbsep.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbsep.EthereumDIDRegistry.address}}', + subgraphService: '{{arbsep.SubgraphService.address}}', isL1: false, } 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/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..9384be1e 100644 --- a/config/mainnetArbitrumAddressScript.ts +++ b/config/mainnetArbitrumAddressScript.ts @@ -29,6 +29,7 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '{{arbitrum.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbitrum.IEthereumDIDRegistry.address}}', + subgraphService: '{{arbitrum.SubgraphService.address}}', isL1: false, } @@ -46,6 +47,10 @@ 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 + } 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..56bbbb32 100644 --- a/config/testAddressesL1.ts +++ b/config/testAddressesL1.ts @@ -29,6 +29,7 @@ export let addresses: Addresses = { l1GraphTokenGateway: '0x0000000000000000000000000000000000000000', l2GraphTokenGateway: '', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', + subgraphService: '0x0000000000000000000000000000000000000000', isL1: true, } diff --git a/config/testAddressesL2.ts b/config/testAddressesL2.ts index c18dbb4f..0fab2b9a 100644 --- a/config/testAddressesL2.ts +++ b/config/testAddressesL2.ts @@ -29,6 +29,7 @@ export let addresses: Addresses = { l1GraphTokenGateway: '', l2GraphTokenGateway: '0x0000000000000000000000000000000000000000', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', + subgraphService: '0x0000000000000000000000000000000000000000', isL1: false, } diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts new file mode 100644 index 00000000..423e1c85 --- /dev/null +++ b/src/mappings/subgraphService.ts @@ -0,0 +1 @@ +// ToDo \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 4b9e6b87..857af4b2 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -429,6 +429,32 @@ dataSources: handler: handleDelegationFeeCutSet - event: TokensToDelegationPoolAdded(indexed address,indexed address,uint256) handler: handleTokensToDelegationPoolAdded + - 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 - kind: ethereum/contract name: Curation network: {{network}} From 9570a04e076a3600cd5936bfb86316e311f641ec Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 20 Feb 2025 01:26:38 -0300 Subject: [PATCH 18/57] feat: added basic service registry for Horizon --- schema.graphql | 7 +++++++ src/mappings/subgraphService.ts | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/schema.graphql b/schema.graphql index 650e3c2d..543a342d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -898,6 +898,13 @@ type Provision @entity { delegatorShares: BigInt! "Exchange rate of of tokens received for each share" delegationExchangeRate: 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 PaymentTypes { diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 423e1c85..3a5b6b64 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1 +1,17 @@ -// ToDo \ No newline at end of file +import { ethereum } from "@graphprotocol/graph-ts" +import { RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +import { createOrLoadProvision } from "./helpers/helpers" + +export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { + let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data).toTuple() + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + provision.url = decodedCalldata[0].toString() + provision.geoHash = decodedCalldata[1].toString() + provision.save() +} + +export function handleRewardsDestinationSet(event: RewardsDestinationSet): void { + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + provision.rewardsDestination = event.params.rewardsDestination + provision.save() +} From a24e02cd1e8e9485732bb361b178cb93d5621fbe Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 24 Feb 2025 04:12:42 -0300 Subject: [PATCH 19/57] fix: abi.decode potential decoding failure --- src/mappings/subgraphService.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 3a5b6b64..1ba54400 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,13 +1,18 @@ -import { ethereum } from "@graphprotocol/graph-ts" +import { ethereum, ValueKind, log } from "@graphprotocol/graph-ts" import { RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" import { createOrLoadProvision } from "./helpers/helpers" export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { - let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data).toTuple() - let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) - provision.url = decodedCalldata[0].toString() - provision.geoHash = decodedCalldata[1].toString() - provision.save() + let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data) + if( decodedCalldata != null && decodedCalldata.kind == ethereum.ValueKind.TUPLE) { + let tupleData = decodedCalldata.toTuple() + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + provision.url = tupleData[0].toString() + provision.geoHash = tupleData[1].toString() + provision.save() + } else { + log.warning("ServiceProviderRegistered failed to decode: {}", [event.params.data.toHexString()]) + } } export function handleRewardsDestinationSet(event: RewardsDestinationSet): void { From cbe7db7415b9f06e3f6a5aecaefab616e1094d09 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 20 Feb 2025 02:07:57 -0300 Subject: [PATCH 20/57] chore: placeholder event handlers --- src/mappings/subgraphService.ts | 22 +++++++++++++++++++++- subgraph.template.yaml | 6 ++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 1ba54400..04c7a3c1 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,5 +1,5 @@ import { ethereum, ValueKind, log } from "@graphprotocol/graph-ts" -import { RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +import { AllocationClosed, AllocationCreated, AllocationResized, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" import { createOrLoadProvision } from "./helpers/helpers" export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { @@ -20,3 +20,23 @@ export function handleRewardsDestinationSet(event: RewardsDestinationSet): void provision.rewardsDestination = event.params.rewardsDestination provision.save() } + +export function handleAllocationClosed(event: AllocationClosed): void { + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + // To Do + provision.save() +} + + +export function handleAllocationCreated(event: AllocationCreated): void { + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + // To Do + provision.save() +} + + +export function handleAllocationResized(event: AllocationResized): void { + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + // To Do + provision.save() +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 857af4b2..34b6d4a8 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -455,6 +455,12 @@ dataSources: handler: handleServiceProviderRegistered - event: RewardsDestinationSet(indexed address,indexed address) handler: handleRewardsDestinationSet + - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256) + handler: handleAllocationClosed + - event: AllocationCreated(indexed address,indexed address,indexed bytes32,uint256) + handler: handleAllocationCreated + - event: AllocationResized(indexed address,indexed address,indexed bytes32,uint256,uint256) + handler: handleAllocationResized - kind: ethereum/contract name: Curation network: {{network}} From 414a76b08b77c0da78210f60f0909985e133d025 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 24 Feb 2025 03:07:17 -0300 Subject: [PATCH 21/57] chore: updated ABIs --- abis/HorizonStaking.json | 4833 +++++++++++++++++++------------------ abis/SubgraphService.json | 4552 +++++++++++++++++----------------- subgraph.template.yaml | 10 +- 3 files changed, 4701 insertions(+), 4694 deletions(-) diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json index b1089b90..6472aeaa 100644 --- a/abis/HorizonStaking.json +++ b/abis/HorizonStaking.json @@ -1,2408 +1,2431 @@ [ { - "type": "constructor", - "inputs": [ - { - "name": "controller", - "type": "address", - "internalType": "address" - }, - { - "name": "stakingExtensionAddress", - "type": "address", - "internalType": "address" - }, - { - "name": "subgraphDataServiceAddress", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "fallback", - "stateMutability": "nonpayable" - }, - { - "type": "receive", - "stateMutability": "payable" - }, - { - "type": "function", - "name": "acceptProvisionParameters", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "acceptProxy", - "inputs": [ - { - "name": "_proxy", - "type": "address", - "internalType": "contract IGraphProxy" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "acceptProxyAndCall", - "inputs": [ - { - "name": "_proxy", - "type": "address", - "internalType": "contract IGraphProxy" - }, - { - "name": "_data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addToDelegationPool", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "addToProvision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "clearThawingPeriod", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "delegate", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "delegate", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minSharesOut", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "deprovision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "nThawRequests", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "getDelegatedTokensAvailable", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getDelegation", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "delegator", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IHorizonStakingTypes.Delegation", - "components": [ - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getDelegationFeeCut", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "paymentType", - "type": "uint8", - "internalType": "enum IGraphPayments.PaymentTypes" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getDelegationPool", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IHorizonStakingTypes.DelegationPool", - "components": [ - { - "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": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getIdleStake", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getMaxThawingPeriod", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getProviderTokensAvailable", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getProvision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IHorizonStakingTypes.Provision", - "components": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "tokensThawing", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "sharesThawing", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "createdAt", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "maxVerifierCutPending", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "thawingPeriodPending", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "thawingNonce", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getServiceProvider", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IHorizonStakingTypes.ServiceProvider", - "components": [ - { - "name": "tokensStaked", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "tokensProvisioned", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getStake", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getThawRequest", - "inputs": [ - { - "name": "requestType", - "type": "uint8", - "internalType": "enum IHorizonStakingTypes.ThawRequestType" - }, - { - "name": "thawRequestId", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IHorizonStakingTypes.ThawRequest", - "components": [ - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "thawingUntil", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "next", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "thawingNonce", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getThawRequestList", - "inputs": [ - { - "name": "requestType", - "type": "uint8", - "internalType": "enum IHorizonStakingTypes.ThawRequestType" - }, - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct LinkedList.List", - "components": [ - { - "name": "head", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "tail", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "count", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getThawedTokens", - "inputs": [ - { - "name": "requestType", - "type": "uint8", - "internalType": "enum IHorizonStakingTypes.ThawRequestType" - }, - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getTokensAvailable", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "delegationRatio", - "type": "uint32", - "internalType": "uint32" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "isAllowedLockedVerifier", - "inputs": [ - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "isAuthorized", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "operator", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "isDelegationSlashingEnabled", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "multicall", - "inputs": [ - { - "name": "data", - "type": "bytes[]", - "internalType": "bytes[]" - } - ], - "outputs": [ - { - "name": "results", - "type": "bytes[]", - "internalType": "bytes[]" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "provision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "provisionLocked", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "redelegate", - "inputs": [ - { - "name": "oldServiceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "oldVerifier", - "type": "address", - "internalType": "address" - }, - { - "name": "newServiceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "newVerifier", - "type": "address", - "internalType": "address" - }, - { - "name": "minSharesForNewProvider", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "nThawRequests", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "reprovision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "oldVerifier", - "type": "address", - "internalType": "address" - }, - { - "name": "newVerifier", - "type": "address", - "internalType": "address" - }, - { - "name": "nThawRequests", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setAllowedLockedVerifier", - "inputs": [ - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setDelegationFeeCut", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "paymentType", - "type": "uint8", - "internalType": "enum IGraphPayments.PaymentTypes" - }, - { - "name": "feeCut", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setDelegationSlashingEnabled", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setMaxThawingPeriod", - "inputs": [ - { - "name": "maxThawingPeriod", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setOperator", - "inputs": [ - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "operator", - "type": "address", - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setOperatorLocked", - "inputs": [ - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "operator", - "type": "address", - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setProvisionParameters", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "newMaxVerifierCut", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "newThawingPeriod", - "type": "uint64", - "internalType": "uint64" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "slash", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "tokensVerifier", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "verifierDestination", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stake", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stakeTo", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stakeToProvision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "thaw", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "undelegate", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "undelegate", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unstake", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "withdraw", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "withdrawDelegated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "nThawRequests", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "withdrawDelegated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "AllowedLockedVerifierSet", - "inputs": [ - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegatedTokensWithdrawn", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "delegator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegationFeeCutSet", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "paymentType", - "type": "uint8", - "indexed": true, - "internalType": "enum IGraphPayments.PaymentTypes" - }, - { - "name": "feeCut", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegationSlashed", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegationSlashingEnabled", - "inputs": [], - "anonymous": false - }, - { - "type": "event", - "name": "DelegationSlashingSkipped", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "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": "HorizonStakeDeposited", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "HorizonStakeLocked", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "until", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "HorizonStakeWithdrawn", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "MaxThawingPeriodSet", - "inputs": [ - { - "name": "maxThawingPeriod", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OperatorSet", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "operator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionCreated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionIncreased", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionParametersSet", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionParametersStaged", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "maxVerifierCut", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - }, - { - "name": "thawingPeriod", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionSlashed", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionThawed", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StakeDelegatedWithdrawn", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "delegator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ThawRequestCreated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "shares", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "thawingUntil", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - }, - { - "name": "thawRequestId", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ThawRequestFulfilled", - "inputs": [ - { - "name": "thawRequestId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "shares", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "thawingUntil", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - }, - { - "name": "valid", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ThawRequestsFulfilled", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "owner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "thawRequestsFulfilled", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "requestType", - "type": "uint8", - "indexed": false, - "internalType": "enum IHorizonStakingTypes.ThawRequestType" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ThawingPeriodCleared", - "inputs": [], - "anonymous": false - }, - { - "type": "event", - "name": "TokensDelegated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "delegator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "shares", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TokensDeprovisioned", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TokensToDelegationPoolAdded", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "TokensUndelegated", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "delegator", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "VerifierTokensSent", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "destination", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "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": "HorizonStakingCallerIsServiceProvider", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingInsufficientDelegationTokens", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minTokens", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInsufficientIdleStake", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minTokens", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInsufficientShares", - "inputs": [ - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minShares", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInsufficientStakeForLegacyAllocations", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minTokens", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInsufficientTokens", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minRequired", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidDelegationFeeCut", - "inputs": [ - { - "name": "feeCut", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidDelegationPool", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidDelegationPoolState", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidMaxVerifierCut", - "inputs": [ - { - "name": "maxVerifierCut", - "type": "uint32", - "internalType": "uint32" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidProvision", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidServiceProviderZeroAddress", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingInvalidThawRequestType", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingInvalidThawingPeriod", - "inputs": [ - { - "name": "thawingPeriod", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "maxThawingPeriod", - "type": "uint64", - "internalType": "uint64" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingInvalidVerifierZeroAddress", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingInvalidZeroShares", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingInvalidZeroTokens", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingNotAuthorized", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "verifier", - "type": "address", - "internalType": "address" - }, - { - "name": "caller", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingNothingThawing", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingProvisionAlreadyExists", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingSlippageProtection", - "inputs": [ - { - "name": "shares", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "minShares", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingStillThawing", - "inputs": [ - { - "name": "until", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingTooManyThawRequests", - "inputs": [] - }, - { - "type": "error", - "name": "HorizonStakingTooManyTokens", - "inputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maxTokens", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "HorizonStakingVerifierNotAllowed", - "inputs": [ - { - "name": "verifier", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "LinkedListEmptyList", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListInvalidIterations", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListInvalidZeroId", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListMaxElementsExceeded", - "inputs": [] - }, - { - "type": "error", - "name": "ManagedIsPaused", - "inputs": [] - }, - { - "type": "error", - "name": "ManagedOnlyController", - "inputs": [] - }, - { - "type": "error", - "name": "ManagedOnlyGovernor", - "inputs": [] - }, - { - "type": "error", - "name": "PPMMathInvalidMulPPM", - "inputs": [ - { - "name": "a", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "b", - "type": "uint256", - "internalType": "uint256" - } - ] + "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": [ + { + "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": "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" + } + ], + "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" + } + ], + "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": "tokens", + "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": [ + { + "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" + }, + { + "stateMutability": "payable", + "type": "receive" } -] \ No newline at end of file + ] \ No newline at end of file diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json index 3da88ad2..f2ffdcc6 100644 --- a/abis/SubgraphService.json +++ b/abis/SubgraphService.json @@ -1,2287 +1,2271 @@ [ { - "type": "constructor", - "inputs": [ - { - "name": "graphController", - "type": "address", - "internalType": "address" - }, - { - "name": "disputeManager", - "type": "address", - "internalType": "address" - }, - { - "name": "tapCollector", - "type": "address", - "internalType": "address" - }, - { - "name": "curation", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "acceptProvisionPendingParameters", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "allocationProvisionTracker", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "claims", - "inputs": [ - { - "name": "claimId", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "createdAt", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "releasableAt", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "nextClaim", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "claimsLists", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "head", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "tail", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "nonce", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "count", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "closeStaleAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "collect", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "paymentType", - "type": "uint8", - "internalType": "enum IGraphPayments.PaymentTypes" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "curationFeesCut", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "delegationRatio", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "eip712Domain", - "inputs": [], - "outputs": [ - { - "name": "fields", - "type": "bytes1", - "internalType": "bytes1" - }, - { - "name": "name", - "type": "string", - "internalType": "string" - }, - { - "name": "version", - "type": "string", - "internalType": "string" - }, - { - "name": "chainId", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "verifyingContract", - "type": "address", - "internalType": "address" - }, - { - "name": "salt", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "extensions", - "type": "uint256[]", - "internalType": "uint256[]" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "encodeAllocationProof", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "feesProvisionTracker", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct Allocation.State", - "components": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "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" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getAllocationData", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - }, - { - "name": "", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getDelegationRatio", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getLegacyAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct LegacyAllocation.State", - "components": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "internalType": "bytes32" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getProvisionTokensRange", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getSubgraphAllocatedTokens", - "inputs": [ - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getThawingPeriodRange", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - }, - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getVerifierCutRange", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "indexers", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "registeredAt", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "url", - "type": "string", - "internalType": "string" - }, - { - "name": "geoHash", - "type": "string", - "internalType": "string" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "initialize", - "inputs": [ - { - "name": "minimumProvisionTokens", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "maximumDelegationRatio", - "type": "uint32", - "internalType": "uint32" - }, - { - "name": "stakeToFeesRatio", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "isActiveAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "isOverAllocated", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "isStaleAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maxPOIStaleness", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maximumProvisionTokens", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maximumThawingPeriod", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "maximumVerifierCut", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "migrateLegacyAllocation", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "internalType": "address" - }, - { - "name": "subgraphDeploymentID", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "minimumProvisionTokens", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "minimumThawingPeriod", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint64", - "internalType": "uint64" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "minimumVerifierCut", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint32", - "internalType": "uint32" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "multicall", - "inputs": [ - { - "name": "data", - "type": "bytes[]", - "internalType": "bytes[]" - } - ], - "outputs": [ - { - "name": "results", - "type": "bytes[]", - "internalType": "bytes[]" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "pause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "pauseGuardians", - "inputs": [ - { - "name": "pauseGuardian", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "paused", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "bool", - "internalType": "bool" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "register", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "releaseStake", - "inputs": [ - { - "name": "numClaimsToRelease", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "resizeAllocation", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "rewardsDestination", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [ - { - "name": "destination", - "type": "address", - "internalType": "address" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "setCurationCut", - "inputs": [ - { - "name": "curationCut", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setDelegationRatio", - "inputs": [ - { - "name": "delegationRatio", - "type": "uint32", - "internalType": "uint32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setMaxPOIStaleness", - "inputs": [ - { - "name": "maxPOIStaleness", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setMinimumProvisionTokens", - "inputs": [ - { - "name": "minimumProvisionTokens", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setPauseGuardian", - "inputs": [ - { - "name": "pauseGuardian", - "type": "address", - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRewardsDestination", - "inputs": [ - { - "name": "rewardsDestination", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setStakeToFeesRatio", - "inputs": [ - { - "name": "stakeToFeesRatio_", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "slash", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stakeToFeesRatio", - "inputs": [], - "outputs": [ - { - "name": "", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "startService", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "stopService", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "internalType": "bytes" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { - "name": "newOwner", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "unpause", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "AllocationClosed", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "AllocationCreated", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "AllocationResized", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "newTokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "oldTokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "CurationCutSet", - "inputs": [ - { - "name": "curationCut", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "DelegationRatioSet", - "inputs": [ - { - "name": "ratio", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "EIP712DomainChanged", - "inputs": [], - "anonymous": false - }, - { - "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": "IndexingRewardsCollected", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokensRewards", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "tokensIndexerRewards", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "tokensDelegationRewards", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "poi", - "type": "bytes32", - "indexed": false, - "internalType": "bytes32" - }, - { - "name": "currentEpoch", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "LegacyAllocationMigrated", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "subgraphDeploymentId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "MaxPOIStalenessSet", - "inputs": [ - { - "name": "maxPOIStaleness", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "PauseGuardianSet", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "indexed": false, - "internalType": "bool" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Paused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionPendingParametersAccepted", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ProvisionTokensRangeSet", - "inputs": [ - { - "name": "min", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "max", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "QueryFeesCollected", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokensCollected", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "tokensCurators", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "RewardsDestinationSet", - "inputs": [ - { - "name": "indexer", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "rewardsDestination", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ServicePaymentCollected", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "feeType", - "type": "uint8", - "indexed": true, - "internalType": "enum IGraphPayments.PaymentTypes" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ServiceProviderRegistered", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "indexed": false, - "internalType": "bytes" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ServiceProviderSlashed", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ServiceStarted", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "indexed": false, - "internalType": "bytes" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ServiceStopped", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "data", - "type": "bytes", - "indexed": false, - "internalType": "bytes" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StakeClaimLocked", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "claimId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "unlockTimestamp", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StakeClaimReleased", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "claimId", - "type": "bytes32", - "indexed": true, - "internalType": "bytes32" - }, - { - "name": "tokens", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "releasableAt", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StakeClaimsReleased", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "claimsCount", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - }, - { - "name": "tokensReleased", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "StakeToFeesRatioSet", - "inputs": [ - { - "name": "ratio", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "SubgraphServiceDirectoryInitialized", - "inputs": [ - { - "name": "subgraphService", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "disputeManager", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "tapCollector", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "curation", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "ThawingPeriodRangeSet", - "inputs": [ - { - "name": "min", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - }, - { - "name": "max", - "type": "uint64", - "indexed": false, - "internalType": "uint64" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Unpaused", - "inputs": [ - { - "name": "account", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "VerifierCutRangeSet", - "inputs": [ - { - "name": "min", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - }, - { - "name": "max", - "type": "uint32", - "indexed": false, - "internalType": "uint32" - } - ], - "anonymous": false - }, - { - "type": "error", - "name": "AddressEmptyCode", - "inputs": [ - { - "name": "target", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "AllocationAlreadyExists", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "AllocationClosed", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - }, - { - "name": "closedAt", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "AllocationDoesNotExist", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "AllocationManagerAllocationClosed", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "AllocationManagerAllocationSameSize", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - }, - { - "name": "tokens", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "AllocationManagerInvalidAllocationProof", - "inputs": [ - { - "name": "signer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "AllocationManagerInvalidZeroAllocationId", - "inputs": [] - }, - { - "type": "error", - "name": "DataServiceFeesClaimNotFound", - "inputs": [ - { - "name": "claimId", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "DataServiceFeesZeroTokens", - "inputs": [] - }, - { - "type": "error", - "name": "DataServicePausableNotPauseGuardian", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "DataServicePausablePauseGuardianNoChange", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - }, - { - "name": "allowed", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "type": "error", - "name": "DirectoryNotDisputeManager", - "inputs": [ - { - "name": "caller", - "type": "address", - "internalType": "address" - }, - { - "name": "disputeManager", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "ECDSAInvalidSignature", - "inputs": [] - }, - { - "type": "error", - "name": "ECDSAInvalidSignatureLength", - "inputs": [ - { - "name": "length", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "ECDSAInvalidSignatureS", - "inputs": [ - { - "name": "s", - "type": "bytes32", - "internalType": "bytes32" - } - ] - }, - { - "type": "error", - "name": "EnforcedPause", - "inputs": [] - }, - { - "type": "error", - "name": "ExpectedPause", - "inputs": [] - }, - { - "type": "error", - "name": "FailedInnerCall", - "inputs": [] - }, - { - "type": "error", - "name": "GraphDirectoryInvalidZeroAddress", - "inputs": [ - { - "name": "contractName", - "type": "bytes", - "internalType": "bytes" - } - ] - }, - { - "type": "error", - "name": "InvalidInitialization", - "inputs": [] - }, - { - "type": "error", - "name": "LegacyAllocationAlreadyExists", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "LinkedListEmptyList", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListInvalidIterations", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListInvalidZeroId", - "inputs": [] - }, - { - "type": "error", - "name": "LinkedListMaxElementsExceeded", - "inputs": [] - }, - { - "type": "error", - "name": "NotInitializing", - "inputs": [] - }, - { - "type": "error", - "name": "OwnableInvalidOwner", - "inputs": [ - { - "name": "owner", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "OwnableUnauthorizedAccount", - "inputs": [ - { - "name": "account", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "PPMMathInvalidMulPPM", - "inputs": [ - { - "name": "a", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "b", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "ProvisionManagerInvalidRange", - "inputs": [ - { - "name": "min", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "max", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "ProvisionManagerInvalidValue", - "inputs": [ - { - "name": "message", - "type": "bytes", - "internalType": "bytes" - }, - { - "name": "value", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "min", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "max", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "ProvisionManagerNotAuthorized", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - }, - { - "name": "caller", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "ProvisionManagerProvisionNotFound", - "inputs": [ - { - "name": "serviceProvider", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "ProvisionTrackerInsufficientTokens", - "inputs": [ - { - "name": "tokensAvailable", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "tokensRequired", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceAllocationIsAltruistic", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceAllocationNotAuthorized", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceCannotForceCloseAllocation", - "inputs": [ - { - "name": "allocationId", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceEmptyGeohash", - "inputs": [] - }, - { - "type": "error", - "name": "SubgraphServiceEmptyUrl", - "inputs": [] - }, - { - "type": "error", - "name": "SubgraphServiceInconsistentCollection", - "inputs": [ - { - "name": "balanceBefore", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "balanceAfter", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceIndexerAlreadyRegistered", - "inputs": [] - }, - { - "type": "error", - "name": "SubgraphServiceIndexerMismatch", - "inputs": [ - { - "name": "providedIndexer", - "type": "address", - "internalType": "address" - }, - { - "name": "expectedIndexer", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceIndexerNotRegistered", - "inputs": [ - { - "name": "indexer", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceInvalidCurationCut", - "inputs": [ - { - "name": "curationCut", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceInvalidPaymentType", - "inputs": [ - { - "name": "paymentType", - "type": "uint8", - "internalType": "enum IGraphPayments.PaymentTypes" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceInvalidRAV", - "inputs": [ - { - "name": "ravIndexer", - "type": "address", - "internalType": "address" - }, - { - "name": "allocationIndexer", - "type": "address", - "internalType": "address" - } - ] - }, - { - "type": "error", - "name": "SubgraphServiceInvalidZeroStakeToFeesRatio", - "inputs": [] + "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" + } + ], + "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": "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": 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": "delegationRatio", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": "getDelegationRatio", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": "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": [], + "name": "maximumProvisionTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maximumThawingPeriod", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maximumVerifierCut", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": [], + "name": "minimumProvisionTokens", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minimumThawingPeriod", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minimumVerifierCut", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": [], + "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 + ] \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 34b6d4a8..1c8d28b3 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -419,9 +419,9 @@ dataSources: handler: handleProvisionSlashed - event: ProvisionThawed(indexed address,indexed address,uint256) handler: handleProvisionThawed - - event: ThawRequestCreated(indexed address,indexed address,indexed address,uint256,uint64,bytes32) + - event: ThawRequestCreated(indexed uint8,indexed address,indexed address,address,uint256,uint64,bytes32) handler: handleThawRequestCreated - - event: ThawRequestFulfilled(indexed bytes32,uint256,uint256,uint64,bool) + - event: ThawRequestFulfilled(indexed uint8,indexed bytes32,uint256,uint256,uint64,bool) handler: handleThawRequestFulfilled - event: OperatorSet(indexed address,indexed address,indexed address,bool) handler: handleOperatorSet @@ -455,12 +455,12 @@ dataSources: handler: handleServiceProviderRegistered - event: RewardsDestinationSet(indexed address,indexed address) handler: handleRewardsDestinationSet - - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256) - handler: handleAllocationClosed - - event: AllocationCreated(indexed address,indexed address,indexed bytes32,uint256) + - 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) + handler: handleAllocationClosed - kind: ethereum/contract name: Curation network: {{network}} From 396dbc6dc71e16c33e457f2ecb8423eb62bb38cd Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 24 Feb 2025 04:05:33 -0300 Subject: [PATCH 22/57] feat: implemented AllocationCreated, Closed and Resized --- schema.graphql | 31 ++++++- src/mappings/helpers/helpers.ts | 3 + src/mappings/subgraphService.ts | 143 ++++++++++++++++++++++++++++++-- 3 files changed, 166 insertions(+), 11 deletions(-) diff --git a/schema.graphql b/schema.graphql index 543a342d..0ca6b80c 100644 --- a/schema.graphql +++ b/schema.graphql @@ -864,6 +864,15 @@ type Provision @entity { tokensProvisioned: BigInt! + tokensAllocated: 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! @@ -934,17 +943,21 @@ type ThawRequest @entity { } """ -A state channel Allocation representing a single Indexer-SubgraphDeployment stake +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" @@ -987,10 +1000,12 @@ 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 + "POIs submitted when collecting payments in Horizon" + pois: [PoiSubmission!]! @derivedFrom(field: "allocation") - # Indexer cut settings at start and close + # Indexer/Provision cut settings at start and close indexingRewardCutAtStart: Int! indexingRewardEffectiveCutAtStart: BigDecimal! queryFeeCutAtStart: Int! @@ -1008,6 +1023,16 @@ type Allocation @entity { annualizedReturn: BigDecimal! } +type PoiSubmission @entity { + id: ID! + + allocation: Allocation! + + poi: Bytes! + + submittedAtEpoch: Int! +} + enum AllocationStatus { Null # == indexer == address(0) Active # == not Null && tokens > 0 # diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 19cb75d2..2c5829c7 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -200,6 +200,9 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By provision.indexer = indexerAddress.toHexString() provision.dataService = verifierAddress.toHexString() provision.tokensProvisioned = BigInt.fromI32(0) + provision.tokensAllocated = BigInt.fromI32(0) + provision.totalAllocationCount = BigInt.fromI32(0) + provision.allocationCount = 0 provision.tokensThawing = BigInt.fromI32(0) provision.createdAt = timestamp provision.maxVerifierCut = BigInt.fromI32(0) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 04c7a3c1..93608512 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,6 +1,8 @@ -import { ethereum, ValueKind, log } from "@graphprotocol/graph-ts" +import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" import { AllocationClosed, AllocationCreated, AllocationResized, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" -import { createOrLoadProvision } from "./helpers/helpers" +import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadProvision, createOrLoadSubgraphDeployment } from "./helpers/helpers" +import { Allocation, GraphAccount, Indexer } from "../types/schema" +import { addresses } from "../../config/addresses" export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data) @@ -21,22 +23,147 @@ export function handleRewardsDestinationSet(event: RewardsDestinationSet): void provision.save() } -export function handleAllocationClosed(event: AllocationClosed): void { +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) - // To Do + 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 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 + allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() + allocation.queryFeeCutAtStart = provision.queryFeeCut + allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() + 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() -export function handleAllocationCreated(event: AllocationCreated): void { + // update indexer + let indexer = Indexer.load(indexerID)! + const indexerAccount = GraphAccount.load(indexer.account)! + const closedByIndexer = event.transaction.from == event.params.indexer + const closedByOperator = indexerAccount.operators.includes(event.transaction.from.toHexString()) + + if (!closedByIndexer && !closedByOperator) { + 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) - // To Do + provision.tokensAllocated = provision.tokensAllocated.minus(event.params.tokens) + provision.allocationCount = provision.allocationCount - 1 provision.save() -} + // update allocation + let allocation = Allocation.load(allocationID)! + allocation.poolClosedIn = graphNetwork.currentEpoch + 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.indexingRewardCutAtStart = provision.indexingRewardsCut + allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() + allocation.queryFeeCutAtStart = provision.queryFeeCut + allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() + 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() +} 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) - // To Do + provision.tokensAllocated = provision.tokensAllocated.plus(diffTokens) provision.save() + + // update allocation + let allocation = Allocation.load(allocationID)! + allocation.allocatedTokens = event.params.newTokens + allocation.save() } From 9c76ef1359cac88f50b1a39a0aa578c42c80e10b Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 24 Feb 2025 04:17:01 -0300 Subject: [PATCH 23/57] fix: build issues --- src/mappings/subgraphService.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 93608512..d0342038 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -81,9 +81,9 @@ export function handleAllocationCreated(event: AllocationCreated): void { allocation.totalReturn = BigDecimal.fromString('0') allocation.annualizedReturn = BigDecimal.fromString('0') allocation.createdAt = event.block.timestamp.toI32() - allocation.indexingRewardCutAtStart = provision.indexingRewardsCut + allocation.indexingRewardCutAtStart = provision.indexingRewardsCut.toI32() allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() - allocation.queryFeeCutAtStart = provision.queryFeeCut + allocation.queryFeeCutAtStart = provision.queryFeeCut.toI32() allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() allocation.save() } @@ -114,7 +114,7 @@ export function handleAllocationClosed(event: AllocationClosed): void { // update allocation let allocation = Allocation.load(allocationID)! - allocation.poolClosedIn = graphNetwork.currentEpoch + allocation.poolClosedIn = graphNetwork.currentEpoch.toString() allocation.activeForIndexer = null allocation.closedAtEpoch = graphNetwork.currentEpoch allocation.closedAtBlockHash = event.block.hash @@ -123,9 +123,9 @@ export function handleAllocationClosed(event: AllocationClosed): void { ).toI32() allocation.status = 'Closed' allocation.closedAt = event.block.timestamp.toI32() - allocation.indexingRewardCutAtStart = provision.indexingRewardsCut + allocation.indexingRewardCutAtStart = provision.indexingRewardsCut.toI32() allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() - allocation.queryFeeCutAtStart = provision.queryFeeCut + allocation.queryFeeCutAtStart = provision.queryFeeCut.toI32() allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() allocation.save() From 926bb93b223e91daae1585ac26a1b7e28d2da2a4 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 24 Feb 2025 04:27:07 -0300 Subject: [PATCH 24/57] chore: placeholder handler definition --- src/mappings/subgraphService.ts | 14 +++++++++++++- subgraph.template.yaml | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index d0342038..73d47f67 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,5 +1,5 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" -import { AllocationClosed, AllocationCreated, AllocationResized, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +import { AllocationClosed, AllocationCreated, AllocationResized, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadProvision, createOrLoadSubgraphDeployment } from "./helpers/helpers" import { Allocation, GraphAccount, Indexer } from "../types/schema" import { addresses } from "../../config/addresses" @@ -167,3 +167,15 @@ export function handleAllocationResized(event: AllocationResized): void { allocation.allocatedTokens = event.params.newTokens allocation.save() } + +export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): void { + let provision = createOrLoadProvision(event.params.indexer, event.address, event.block.timestamp) + // To Do + provision.save() +} + +export function handleQueryFeesCollected(event: QueryFeesCollected): void { + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + // To Do + provision.save() +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 1c8d28b3..18bfa2e0 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -461,6 +461,10 @@ dataSources: handler: handleAllocationResized - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256) handler: handleAllocationClosed + - event: IndexingRewardsCollected(indexed address,indexed address,indexed bytes32,uint256,uint256,uint256,bytes32,uint256) + handler: handleIndexingRewardsCollected + - event: QueryFeesCollected(indexed address,uint256,uint256) + handler: handleQueryFeesCollected - kind: ethereum/contract name: Curation network: {{network}} From b811361f7b3f26262969dc50546c4139ec7e9864 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Tue, 25 Feb 2025 02:04:27 -0300 Subject: [PATCH 25/57] feat: added indexing rewards collection handler --- schema.graphql | 8 ++++ src/mappings/horizonStaking.ts | 9 +++- src/mappings/subgraphService.ts | 76 ++++++++++++++++++++++++++++++--- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/schema.graphql b/schema.graphql index 0ca6b80c..99e1dcfd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -900,6 +900,14 @@ type Provision @entity { # 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! + # Delegation "Tokens delegated to the provision" delegatedTokens: BigInt! diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 0af83856..3253cea6 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -2,7 +2,7 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned, TokensToDelegationPoolAdded } from '../types/HorizonStaking/HorizonStaking' import { Indexer, ThawRequest } from '../types/schema' -import { createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision } from './helpers/helpers' +import { createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateDelegationExchangeRate } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -265,11 +265,18 @@ export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { } export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolAdded): void { + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) let indexer = Indexer.load(event.params.serviceProvider.toHexString())! let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) provision.delegatedTokens = provision.delegatedTokens.plus(event.params.tokens) provision.save() 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.save() + + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) + graphNetwork.save() } \ No newline at end of file diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 73d47f67..e1756e92 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,12 +1,12 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" import { AllocationClosed, AllocationCreated, AllocationResized, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" -import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadProvision, createOrLoadSubgraphDeployment } from "./helpers/helpers" -import { Allocation, GraphAccount, Indexer } from "../types/schema" +import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" +import { Allocation, GraphAccount, Indexer, PoiSubmission } from "../types/schema" import { addresses } from "../../config/addresses" export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { let decodedCalldata = ethereum.decode('(string,string,address)', event.params.data) - if( decodedCalldata != null && decodedCalldata.kind == ethereum.ValueKind.TUPLE) { + if (decodedCalldata != null && decodedCalldata.kind == ethereum.ValueKind.TUPLE) { let tupleData = decodedCalldata.toTuple() let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) provision.url = tupleData[0].toString() @@ -169,13 +169,77 @@ export function handleAllocationResized(event: AllocationResized): void { } 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) - // To Do + 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.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.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 provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) // To Do - provision.save() } From 7cf9e114eef5889841cd28ccb3e1dbb41c6aaa68 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 26 Feb 2025 04:10:35 -0300 Subject: [PATCH 26/57] feat: add QueryFeesCollected support --- abis/HorizonStaking.json | 4860 +++++++++++++++---------------- abis/SubgraphService.json | 4511 ++++++++++++++-------------- schema.graphql | 4 + src/mappings/subgraphService.ts | 71 +- subgraph.template.yaml | 2 +- 5 files changed, 4745 insertions(+), 4703 deletions(-) diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json index 6472aeaa..67eb616b 100644 --- a/abis/HorizonStaking.json +++ b/abis/HorizonStaking.json @@ -1,2431 +1,2431 @@ [ - { - "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": [ - { - "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": "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" - } - ], - "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" - } - ], - "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": "tokens", - "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": [ - { - "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" - }, - { - "stateMutability": "payable", - "type": "receive" - } - ] \ No newline at end of file + { + "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": [ + { + "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": "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" + } + ], + "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" + } + ], + "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": "tokens", + "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": [ + { + "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" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json index f2ffdcc6..3fa424a0 100644 --- a/abis/SubgraphService.json +++ b/abis/SubgraphService.json @@ -1,2271 +1,2242 @@ [ - { - "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" - } - ], - "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": "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": 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": "delegationRatio", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "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": "getDelegationRatio", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "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": "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": [], - "name": "maximumProvisionTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maximumThawingPeriod", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "maximumVerifierCut", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "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": [], - "name": "minimumProvisionTokens", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minimumThawingPeriod", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "minimumVerifierCut", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "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": [], - "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 + { + "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" + } + ], + "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": "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/schema.graphql b/schema.graphql index 99e1dcfd..721ba75f 100644 --- a/schema.graphql +++ b/schema.graphql @@ -908,6 +908,10 @@ type Provision @entity { "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! + # Delegation "Tokens delegated to the provision" delegatedTokens: BigInt! diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index e1756e92..7ef17c62 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,7 +1,7 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" import { AllocationClosed, AllocationCreated, AllocationResized, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" -import { createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" -import { Allocation, GraphAccount, Indexer, PoiSubmission } from "../types/schema" +import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" +import { Allocation, GraphAccount, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" import { addresses } from "../../config/addresses" export function handleServiceProviderRegistered(event: ServiceProviderRegistered): void { @@ -242,4 +242,71 @@ export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): export function handleQueryFeesCollected(event: QueryFeesCollected): void { // To Do + + 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 indexer + let indexer = Indexer.load(indexerID)! + indexer.queryFeesCollected = indexer.queryFeesCollected.plus(event.params.tokensCollected) + indexer.save() + + // update provision + let provision = createOrLoadProvision(event.params.serviceProvider, event.address, event.block.timestamp) + provision.queryFeesCollected = provision.queryFeesCollected.plus(event.params.tokensCollected) + provision.save() + + // Replicate for payment source specific aggregation + let paymentAggregation = createOrLoadIndexerQueryFeePaymentAggregation(paymentAddress, event.params.serviceProvider) + paymentAggregation.queryFeesCollected = paymentAggregation.queryFeesCollected.plus(event.params.tokensCollected) + 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.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.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.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.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.save() } diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 18bfa2e0..96c7b177 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -463,7 +463,7 @@ dataSources: handler: handleAllocationClosed - event: IndexingRewardsCollected(indexed address,indexed address,indexed bytes32,uint256,uint256,uint256,bytes32,uint256) handler: handleIndexingRewardsCollected - - event: QueryFeesCollected(indexed address,uint256,uint256) + - event: QueryFeesCollected(indexed address,indexed address,indexed address,bytes32,uint256,uint256) handler: handleQueryFeesCollected - kind: ethereum/contract name: Curation From 6b3584ec038b0320c1688f3373bf032b80ce884a Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 27 Feb 2025 01:24:56 -0300 Subject: [PATCH 27/57] feat: added QueryFeesCollected handler with latest contract changes --- schema.graphql | 9 +++++-- src/mappings/helpers/helpers.ts | 1 + src/mappings/staking.ts | 2 ++ src/mappings/subgraphService.ts | 45 ++++++++++++++++++++++++++++----- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/schema.graphql b/schema.graphql index 721ba75f..c12b4561 100644 --- a/schema.graphql +++ b/schema.graphql @@ -575,11 +575,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" @@ -911,6 +912,10 @@ type Provision @entity { # 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" + providerQueryFees: BigInt! + "Query fee amount collected from the protocol for Delegators. Does not include portion taken by the provider" + delegatorQueryFees: BigInt! # Delegation "Tokens delegated to the provision" diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 2c5829c7..a70eef19 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -102,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) diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index a35d7b52..ab4a2c71 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -673,6 +673,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 @@ -751,6 +752,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 index 7ef17c62..dd27b7e0 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -241,33 +241,49 @@ export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): } export function handleQueryFeesCollected(event: QueryFeesCollected): void { - // To Do - 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 indexer - let indexer = Indexer.load(indexerID)! - indexer.queryFeesCollected = indexer.queryFeesCollected.plus(event.params.tokensCollected) - indexer.save() - // 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.providerQueryFees = provision.providerQueryFees.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 @@ -277,6 +293,7 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { 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 @@ -285,6 +302,8 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { 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) @@ -297,6 +316,12 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { 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 @@ -308,5 +333,11 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { paymentSource.totalCuratorQueryFees = paymentSource.totalCuratorQueryFees.plus( event.params.tokensCurators, ) + paymentSource.totalIndexerQueryFeeRebates = paymentSource.totalIndexerQueryFeeRebates.plus( + indexerQueryFees, + ) + paymentSource.totalDelegatorQueryFeeRebates = paymentSource.totalDelegatorQueryFeeRebates.plus( + delegationPoolQueryFees, + ) paymentSource.save() } From af1ab1ca033d629cdd24a8cce436645e2f1ce31d Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 27 Feb 2025 01:33:23 -0300 Subject: [PATCH 28/57] feat: add GraphPayments abi --- abis/GraphPayments.json | 317 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 abis/GraphPayments.json 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 From 1aa856bfd2c6d44e257d5788386b4ed2daa60994 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 27 Feb 2025 01:58:53 -0300 Subject: [PATCH 29/57] feat: add tax tracking for Horizon through GraphPayments --- config/addresses.template.ts | 2 ++ config/arbitrumSepoliaAddressScript.ts | 8 ++++++++ config/mainnetArbitrumAddressScript.ts | 4 ++++ config/testAddressesL1.ts | 1 + config/testAddressesL2.ts | 1 + src/mappings/graphPayments.ts | 25 +++++++++++++++++++++++++ subgraph.template.yaml | 24 ++++++++++++++++++++++++ 7 files changed, 65 insertions(+) create mode 100644 src/mappings/graphPayments.ts diff --git a/config/addresses.template.ts b/config/addresses.template.ts index 3121b7e5..89df6658 100644 --- a/config/addresses.template.ts +++ b/config/addresses.template.ts @@ -21,6 +21,7 @@ export class Addresses { l2GraphTokenGateway: string ethereumDIDRegistry: string subgraphService: string + graphPayments: string isL1: boolean } @@ -47,5 +48,6 @@ export let addresses: Addresses = { l2GraphTokenGateway: '{{l2GraphTokenGateway}}', ethereumDIDRegistry: '{{ethereumDIDRegistry}}', subgraphService: '{{subgraphService}}', + graphPayments: '{{graphPayments}}', isL1: {{isL1}}, } diff --git a/config/arbitrumSepoliaAddressScript.ts b/config/arbitrumSepoliaAddressScript.ts index 44334c9d..35f7daf0 100644 --- a/config/arbitrumSepoliaAddressScript.ts +++ b/config/arbitrumSepoliaAddressScript.ts @@ -30,6 +30,7 @@ export let addresses: Addresses = { l2GraphTokenGateway: '{{arbsep.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbsep.EthereumDIDRegistry.address}}', subgraphService: '{{arbsep.SubgraphService.address}}', + graphPayments: '{{arbsep.GraphPayments.address}}', isL1: false, } @@ -46,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/mainnetArbitrumAddressScript.ts b/config/mainnetArbitrumAddressScript.ts index 9384be1e..97f74e18 100644 --- a/config/mainnetArbitrumAddressScript.ts +++ b/config/mainnetArbitrumAddressScript.ts @@ -30,6 +30,7 @@ export let addresses: Addresses = { l2GraphTokenGateway: '{{arbitrum.L2GraphTokenGateway.address}}', ethereumDIDRegistry: '{{arbitrum.IEthereumDIDRegistry.address}}', subgraphService: '{{arbitrum.SubgraphService.address}}', + graphPayments: '{{arbitrum.GraphPayments.address}}', isL1: false, } @@ -51,6 +52,9 @@ const main = (): void => { 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/testAddressesL1.ts b/config/testAddressesL1.ts index 56bbbb32..b6faebe5 100644 --- a/config/testAddressesL1.ts +++ b/config/testAddressesL1.ts @@ -30,6 +30,7 @@ export let addresses: Addresses = { l2GraphTokenGateway: '', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', subgraphService: '0x0000000000000000000000000000000000000000', + graphPayments: '0x0000000000000000000000000000000000000000', isL1: true, } diff --git a/config/testAddressesL2.ts b/config/testAddressesL2.ts index 0fab2b9a..4bfc932c 100644 --- a/config/testAddressesL2.ts +++ b/config/testAddressesL2.ts @@ -30,6 +30,7 @@ export let addresses: Addresses = { l2GraphTokenGateway: '0x0000000000000000000000000000000000000000', ethereumDIDRegistry: '0x0000000000000000000000000000000000000000', subgraphService: '0x0000000000000000000000000000000000000000', + graphPayments: '0x0000000000000000000000000000000000000000', isL1: false, } diff --git a/src/mappings/graphPayments.ts b/src/mappings/graphPayments.ts new file mode 100644 index 00000000..408560ee --- /dev/null +++ b/src/mappings/graphPayments.ts @@ -0,0 +1,25 @@ +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 + 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/subgraph.template.yaml b/subgraph.template.yaml index 96c7b177..7b3bb3f3 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -465,6 +465,30 @@ dataSources: handler: handleIndexingRewardsCollected - event: QueryFeesCollected(indexed address,indexed address,indexed address,bytes32,uint256,uint256) handler: handleQueryFeesCollected + - 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}} From 4c3030abdec53494318849a1d5fdb7a15da6cc30 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 27 Feb 2025 02:36:24 -0300 Subject: [PATCH 30/57] feat: placeholders and manifest changes for delegation --- src/mappings/horizonStaking.ts | 24 +++++++++++++++++++++++- subgraph.template.yaml | 10 ++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 3253cea6..cb6a5f72 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,6 +1,6 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' -import { DelegationFeeCutSet, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, TokensDeprovisioned, TokensToDelegationPoolAdded } from '../types/HorizonStaking/HorizonStaking' +import { DelegatedTokensWithdrawn, DelegationFeeCutSet, DelegationSlashed, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, StakeDelegatedWithdrawn, TokensDelegated, TokensDeprovisioned, TokensToDelegationPoolAdded, TokensUndelegated } from '../types/HorizonStaking/HorizonStaking' import { Indexer, ThawRequest } from '../types/schema' import { createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateDelegationExchangeRate } from './helpers/helpers' import { @@ -279,4 +279,26 @@ export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolA graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) graphNetwork.save() +} + +// Delegation + +export function handleTokensDelegated(event: TokensDelegated): void { + // To Do +} + +export function handleDelegationSlashed(event: DelegationSlashed): void { + // To Do +} + +export function handleTokensUndelegated(event: TokensUndelegated): void { + // To Do +} + +export function handleDelegatedTokensWithdrawn(event: DelegatedTokensWithdrawn): void { + // To Do +} + +export function handleStakeDelegatedWithdrawn(event: StakeDelegatedWithdrawn): void { + // To Do } \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 7b3bb3f3..2cbdc33a 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -429,6 +429,16 @@ dataSources: 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) + handler: handleTokensUndelegated + - event: DelegatedTokensWithdrawn(indexed address,indexed address,indexed address,uint256) + handler: handleDelegatedTokensWithdrawn + - event: StakeDelegatedWithdrawn(indexed address,indexed address,uint256) + handler: handleStakeDelegatedWithdrawn - kind: ethereum/contract name: SubgraphService network: {{network}} From 1956b90b8f76f64509a546eb05c17d8eeaa5c7c1 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 3 Mar 2025 20:35:00 -0300 Subject: [PATCH 31/57] feat: added horizon delegation events support --- abis/HorizonStaking.json | 35 ++++++- schema.graphql | 20 +++- src/mappings/helpers/helpers.ts | 118 ++++++++++++++++++++- src/mappings/horizonStaking.ts | 176 ++++++++++++++++++++++++++++++-- subgraph.template.yaml | 4 +- 5 files changed, 331 insertions(+), 22 deletions(-) diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json index 67eb616b..1b2a72f6 100644 --- a/abis/HorizonStaking.json +++ b/abis/HorizonStaking.json @@ -254,6 +254,11 @@ "name": "HorizonStakingInvalidZeroTokens", "type": "error" }, + { + "inputs": [], + "name": "HorizonStakingLegacySlashFailed", + "type": "error" + }, { "inputs": [ { @@ -280,6 +285,11 @@ "name": "HorizonStakingNothingThawing", "type": "error" }, + { + "inputs": [], + "name": "HorizonStakingNothingToWithdraw", + "type": "error" + }, { "inputs": [], "name": "HorizonStakingProvisionAlreadyExists", @@ -1159,6 +1169,12 @@ "internalType": "uint256", "name": "tokens", "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" } ], "name": "TokensUndelegated", @@ -1517,7 +1533,7 @@ "outputs": [ { "internalType": "uint256", - "name": "tokens", + "name": "", "type": "uint256" } ], @@ -1682,6 +1698,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "getStakingExtension", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -2423,9 +2452,5 @@ ], "stateMutability": "nonpayable", "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" } ] \ No newline at end of file diff --git a/schema.graphql b/schema.graphql index c12b4561..d388b553 100644 --- a/schema.graphql +++ b/schema.graphql @@ -893,12 +893,22 @@ type Provision @entity { thawingPeriodPending: BigInt! # Cuts for subgraph service. Percentage of rewards 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 rebate rewards 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 @@ -924,6 +934,10 @@ type Provision @entity { delegatorShares: BigInt! "Exchange rate of of tokens received for each share" delegationExchangeRate: BigDecimal! + "Ratio between the amount of the indexers own stake over the total usable stake." + ownStakeRatio: BigDecimal! + "Ratio between the amount of delegated stake over the total usable stake." + delegatedStakeRatio: BigDecimal! "Service registry URL for the indexer" url: String @@ -1111,8 +1125,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/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index a70eef19..93d815d2 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -348,6 +348,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) @@ -916,6 +956,68 @@ 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 rewardCut = + provision.indexingRewardsCut.toBigDecimal() / BigDecimal.fromString('1000000') + return provision.ownStakeRatio == BigDecimal.fromString('0') + ? BigDecimal.fromString('0') + : rewardCut / provision.ownStakeRatio +} + +export function calculateOverdelegationDilutionForProvision(provision: Provision): BigDecimal { + let provisionedTokensBD = provision.tokensProvisioned.toBigDecimal() + let delegatedTokensBD = provision.delegatedTokens.toBigDecimal() + let graphNetwork = GraphNetwork.load('1')! + let delegationRatioBD = BigInt.fromI32(graphNetwork.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() @@ -924,6 +1026,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 { @@ -957,10 +1067,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 index cb6a5f72..40519a75 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,8 +1,8 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { DelegatedTokensWithdrawn, DelegationFeeCutSet, DelegationSlashed, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, StakeDelegatedWithdrawn, TokensDelegated, TokensDeprovisioned, TokensToDelegationPoolAdded, TokensUndelegated } from '../types/HorizonStaking/HorizonStaking' -import { Indexer, ThawRequest } from '../types/schema' -import { createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, updateDelegationExchangeRate } from './helpers/helpers' +import { DelegatedStake, Delegator, Indexer, Provision, ThawRequest } from '../types/schema' +import { calculateCapacities, createOrLoadDataService, createOrLoadDelegatedStake, createOrLoadDelegatedStakeForProvision, createOrLoadDelegator, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, joinID, updateAdvancedIndexerMetrics, updateAdvancedProvisionMetrics, updateDelegationExchangeRate, updateDelegationExchangeRateForProvision } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -284,21 +284,179 @@ export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolA // Delegation export function handleTokensDelegated(event: TokensDelegated): void { - // To Do + let zeroShares = event.params.shares.equals(BigInt.fromI32(0)) + + let dataService = createOrLoadDataService(event.params.verifier) + // Might want to track some stuff here in the future + 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) + 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 { - // To Do + // 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) + 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 { - // To Do + // 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) + 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() } export function handleDelegatedTokensWithdrawn(event: DelegatedTokensWithdrawn): void { - // To Do -} + let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) + // might want to track locked/thawing tokens in provision too + provision.save() -export function handleStakeDelegatedWithdrawn(event: StakeDelegatedWithdrawn): void { - // To Do + // 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() } \ No newline at end of file diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 2cbdc33a..34b1f105 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -433,12 +433,10 @@ dataSources: handler: handleTokensDelegated - event: DelegationSlashed(indexed address,indexed address,uint256) handler: handleDelegationSlashed - - event: TokensUndelegated(indexed address,indexed address,indexed address,uint256) + - event: TokensUndelegated(indexed address,indexed address,indexed address,uint256,uint256) handler: handleTokensUndelegated - event: DelegatedTokensWithdrawn(indexed address,indexed address,indexed address,uint256) handler: handleDelegatedTokensWithdrawn - - event: StakeDelegatedWithdrawn(indexed address,indexed address,uint256) - handler: handleStakeDelegatedWithdrawn - kind: ethereum/contract name: SubgraphService network: {{network}} From c646fed0522e0a58b8ab080dd5e4502ca21c7b19 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Thu, 6 Mar 2025 01:12:50 -0300 Subject: [PATCH 32/57] fix: missing inits --- schema.graphql | 2 ++ src/mappings/helpers/helpers.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/schema.graphql b/schema.graphql index d388b553..86526577 100644 --- a/schema.graphql +++ b/schema.graphql @@ -938,6 +938,8 @@ type Provision @entity { ownStakeRatio: BigDecimal! "Ratio between the amount of delegated stake over the total usable stake." 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" + indexerRewardsOwnGenerationRatio: BigDecimal! "Service registry URL for the indexer" url: String diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 93d815d2..f2f233c0 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -216,6 +216,11 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By provision.delegatedTokens = BigInt.fromI32(0) provision.delegatorShares = BigInt.fromI32(0) provision.delegationExchangeRate = BigInt.fromI32(0).toBigDecimal() + provision.indexingRewardEffectiveCut = BigInt.fromI32(0).toBigDecimal() + provision.queryFeeEffectiveCut = BigInt.fromI32(0).toBigDecimal() + provision.ownStakeRatio = BigInt.fromI32(0).toBigDecimal() + provision.delegatedStakeRatio = BigInt.fromI32(0).toBigDecimal() + provision.indexerRewardsOwnGenerationRatio = BigInt.fromI32(0).toBigDecimal() provision.save() } From add1dc5ec5830d860f164a709f35e62138a9272a Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 17:37:10 -0300 Subject: [PATCH 33/57] fix: address gh pr feedback --- schema.graphql | 15 +++++++++++---- src/mappings/helpers/helpers.ts | 13 +++++++++---- src/mappings/horizonStaking.ts | 8 +++++--- src/mappings/subgraphService.ts | 10 ++++++++-- subgraph.template.yaml | 2 ++ 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/schema.graphql b/schema.graphql index 86526577..fdf94006 100644 --- a/schema.graphql +++ b/schema.graphql @@ -246,6 +246,9 @@ type DataService @entity { "Total GRT currently in allocations for this DataService" totalTokensAllocated: BigInt! + "Ratio of max staked delegation tokens to indexers stake that earns rewards" + delegationRatio: Int + provisions: [Provision!]! @derivedFrom(field: "dataService") } @@ -867,6 +870,10 @@ type Provision @entity { tokensAllocated: BigInt! + tokensSlashedServiceProvider: BigInt! + + tokensSlashedDelegationPool: BigInt! + totalAllocationCount: BigInt! allocationCount: Int! @@ -904,7 +911,7 @@ type Provision @entity { "The percent of indexing rewards generated by the delegated stake that the Indexer keeps for itself" indexingRewardEffectiveCut: BigDecimal! - "The percent of query rebate rewards generated by the delegated stake that the Indexer keeps for itself" + "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! @@ -934,11 +941,11 @@ type Provision @entity { delegatorShares: BigInt! "Exchange rate of of tokens received for each share" delegationExchangeRate: BigDecimal! - "Ratio between the amount of the indexers own stake over the total usable stake." + "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." + "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" + "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" diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index f2f233c0..1787efbe 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -202,6 +202,8 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By 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) @@ -993,18 +995,21 @@ export function calculateQueryFeeEffectiveCutForProvision(provision: Provision): } export function calculateIndexerRewardOwnGenerationRatioForProvision(provision: Provision): BigDecimal { - let rewardCut = + let delegatorCut = provision.indexingRewardsCut.toBigDecimal() / BigDecimal.fromString('1000000') return provision.ownStakeRatio == BigDecimal.fromString('0') ? BigDecimal.fromString('0') - : rewardCut / provision.ownStakeRatio + : (BigDecimal.fromString('1') - delegatorCut) / provision.ownStakeRatio } export function calculateOverdelegationDilutionForProvision(provision: Provision): BigDecimal { let provisionedTokensBD = provision.tokensProvisioned.toBigDecimal() let delegatedTokensBD = provision.delegatedTokens.toBigDecimal() - let graphNetwork = GraphNetwork.load('1')! - let delegationRatioBD = BigInt.fromI32(graphNetwork.delegationRatio).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') diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 40519a75..3407d6a2 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -230,15 +230,16 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void { 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) + provision.tokensSlashedServiceProvider = provision.tokensSlashedServiceProvider.plus(event.params.tokens) provision.save() } @@ -366,6 +367,7 @@ export function handleDelegationSlashed(event: DelegationSlashed): void { // 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) } diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index dd27b7e0..fe686087 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,6 +1,6 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" -import { AllocationClosed, AllocationCreated, AllocationResized, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" -import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" +import { AllocationClosed, AllocationCreated, AllocationResized, DelegationRatioSet, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" import { Allocation, GraphAccount, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" import { addresses } from "../../config/addresses" @@ -23,6 +23,12 @@ export function handleRewardsDestinationSet(event: RewardsDestinationSet): void provision.save() } +export function handleDelegationRatioSet(event: DelegationRatioSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.delegationRatio = event.params.ratio + dataService.save() +} + export function handleAllocationCreated(event: AllocationCreated): void { let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) let subgraphDeploymentID = event.params.subgraphDeploymentId.toHexString() diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 34b1f105..156c77a2 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -473,6 +473,8 @@ dataSources: handler: handleIndexingRewardsCollected - event: QueryFeesCollected(indexed address,indexed address,indexed address,bytes32,uint256,uint256) handler: handleQueryFeesCollected + - event: DelegationRatioSet(uint32) + handler: handleDelegationRatioSet - kind: ethereum/contract name: GraphPayments network: {{network}} From 3ee2ea1f3403a1eeb437ec4937c8e96d304a1e18 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 18:05:59 -0300 Subject: [PATCH 34/57] fix: build issues and feedback from PaymentCollection PR --- schema.graphql | 4 ++-- src/mappings/graphPayments.ts | 1 + src/mappings/subgraphService.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/schema.graphql b/schema.graphql index fdf94006..7fe20c8a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -930,8 +930,8 @@ type Provision @entity { "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" - providerQueryFees: BigInt! - "Query fee amount collected from the protocol for Delegators. Does not include portion taken by the provider" + indexerQueryFees: BigInt! + "Query fee amount collected from the protocol for Delegators. Does not include portion taken by the indexer" delegatorQueryFees: BigInt! # Delegation diff --git a/src/mappings/graphPayments.ts b/src/mappings/graphPayments.ts index 408560ee..6a159149 100644 --- a/src/mappings/graphPayments.ts +++ b/src/mappings/graphPayments.ts @@ -17,6 +17,7 @@ export function handleGraphPaymentCollected(event: GraphPaymentCollected): void 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() diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index fe686087..f9c1d3d4 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -25,7 +25,7 @@ export function handleRewardsDestinationSet(event: RewardsDestinationSet): void export function handleDelegationRatioSet(event: DelegationRatioSet): void { let dataService = createOrLoadDataService(event.address) - dataService.delegationRatio = event.params.ratio + dataService.delegationRatio = event.params.ratio.toI32() dataService.save() } @@ -265,7 +265,7 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { let indexerQueryFees = event.params.tokensCollected.minus(delegationPoolQueryFees) provision.queryFeesCollected = provision.queryFeesCollected.plus(event.params.tokensCollected) - provision.providerQueryFees = provision.providerQueryFees.plus(indexerQueryFees) + provision.indexerQueryFees = provision.indexerQueryFees.plus(indexerQueryFees) provision.delegatorQueryFees = provision.delegatorQueryFees.plus(delegationPoolQueryFees) provision.save() From 8085cf784dd0652e2f9f09946c626221d399dfc9 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 20:25:00 -0300 Subject: [PATCH 35/57] fix: addressed AllocationManagement pr feedback --- schema.graphql | 6 ++++++ src/mappings/staking.ts | 11 +++++++++-- src/mappings/subgraphService.ts | 20 +++++++++++++------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/schema.graphql b/schema.graphql index 7fe20c8a..2110b3cd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1044,6 +1044,12 @@ type Allocation @entity { poi: Bytes "POIs submitted when collecting payments in Horizon" pois: [PoiSubmission!]! @derivedFrom(field: "allocation") + "Number of POIs submitted for this allocation. Only available for Horizon allocations" + poiCount: BigInt + "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! diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index ab4a2c71..db5551c2 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -374,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() } @@ -493,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 @@ -507,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() @@ -561,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 @@ -575,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() diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index f9c1d3d4..6efed72c 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -88,9 +88,11 @@ export function handleAllocationCreated(event: AllocationCreated): void { allocation.annualizedReturn = BigDecimal.fromString('0') allocation.createdAt = event.block.timestamp.toI32() allocation.indexingRewardCutAtStart = provision.indexingRewardsCut.toI32() - allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() + allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardEffectiveCut allocation.queryFeeCutAtStart = provision.queryFeeCut.toI32() - allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() + allocation.queryFeeEffectiveCutAtStart = provision.queryFeeEffectiveCut + allocation.poiCount = BigInt.fromI32(0) + allocation.isLegacy = false allocation.save() } @@ -101,12 +103,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.transaction.from == event.params.indexer const closedByOperator = indexerAccount.operators.includes(event.transaction.from.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 @@ -119,7 +125,6 @@ export function handleAllocationClosed(event: AllocationClosed): void { provision.save() // update allocation - let allocation = Allocation.load(allocationID)! allocation.poolClosedIn = graphNetwork.currentEpoch.toString() allocation.activeForIndexer = null allocation.closedAtEpoch = graphNetwork.currentEpoch @@ -129,10 +134,10 @@ export function handleAllocationClosed(event: AllocationClosed): void { ).toI32() allocation.status = 'Closed' allocation.closedAt = event.block.timestamp.toI32() - allocation.indexingRewardCutAtStart = provision.indexingRewardsCut.toI32() - allocation.indexingRewardEffectiveCutAtStart = provision.indexingRewardsCut.toBigDecimal() - allocation.queryFeeCutAtStart = provision.queryFeeCut.toI32() - allocation.queryFeeEffectiveCutAtStart = provision.queryFeeCut.toBigDecimal() + 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 @@ -201,6 +206,7 @@ export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): allocation.indexingDelegatorRewards = allocation.indexingDelegatorRewards.plus( event.params.tokensDelegationRewards, ) + allocation.poiCount = allocation.poiCount!.plus(BigInt.fromI32(1)) allocation.save() // Create PoI submission From e2de8d43958dfe968744e632cdb99f99f95cfc3d Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 23:01:02 -0300 Subject: [PATCH 36/57] fix: address feedback from Subgraph Indexing Registration PR --- schema.graphql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/schema.graphql b/schema.graphql index 2110b3cd..07d5f1d3 100644 --- a/schema.graphql +++ b/schema.graphql @@ -858,6 +858,15 @@ type Operator @entity { allowed: Boolean! } + +""" + 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! From c8854a9c7ab383f7975f903549da77b04e3f3994 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 23:15:22 -0300 Subject: [PATCH 37/57] fix: address feedback from Delegation Pool pr --- schema.graphql | 2 +- src/mappings/horizonStaking.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/schema.graphql b/schema.graphql index 07d5f1d3..4688488d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -948,7 +948,7 @@ type Provision @entity { delegatedTokens: BigInt! "Total shares of the delegator pool" delegatorShares: BigInt! - "Exchange rate of of tokens received for each share" + "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! diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 3407d6a2..42be6276 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -270,6 +270,9 @@ export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolA let indexer = Indexer.load(event.params.serviceProvider.toHexString())! 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.save() indexer.delegatedTokens = indexer.delegatedTokens.plus(event.params.tokens) // this only serves as a general tracker, but the real deal is per provision From 88e42051b6fabe60d824eb2505798da2f96bb240 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Sun, 30 Mar 2025 23:24:54 -0300 Subject: [PATCH 38/57] fix: addressed provision config PR feedback --- schema.graphql | 18 ++++++------------ src/mappings/helpers/helpers.ts | 12 ++++++------ src/mappings/horizonStaking.ts | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/schema.graphql b/schema.graphql index 4688488d..ee5c29b4 100644 --- a/schema.graphql +++ b/schema.graphql @@ -274,10 +274,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!]! - "Operators of this Graph Accounts" - provisionedOperators: [Operator!]! + "Horizon Operators of this Graph Account" + horizonOperators: [HorizonOperator!]! # GRT info "Graph token balance" @@ -843,11 +843,11 @@ type IndexerQueryFeePaymentAggregation @entity { paymentSource: PaymentSource! } -type Operator @entity { +type HorizonOperator @entity { "Joint address of all 3 parties involved (Operator, Indexer, DataService)" id: ID! - operatorOf: [GraphAccount!]! @derivedFrom(field: "provisionedOperators") + operatorOf: [GraphAccount!]! @derivedFrom(field: "horizonOperators") operator: GraphAccount! @@ -908,7 +908,7 @@ type Provision @entity { "Pending value for thawingPeriod. Verifier needs to accept it before it becomes active" thawingPeriodPending: BigInt! - # Cuts for subgraph service. Percentage of rewards that the delegation pool receives + # 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! @@ -965,12 +965,6 @@ type Provision @entity { rewardsDestination: Bytes } -enum PaymentTypes { - QueryFee, - IndexingFee, - IndexingRewards -} - type ThawRequest @entity { id: ID! diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 1787efbe..3665dd73 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -28,7 +28,7 @@ import { IndexerQueryFeePaymentAggregation, Provision, DataService, - Operator, + HorizonOperator, } from '../../types/schema' import { SubgraphDeploymentManifest as SubgraphDeploymentManifestTemplate @@ -243,11 +243,11 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { return service as DataService } -export function createOrLoadOperator(address: Bytes, verifierAddress: Bytes, indexerAddress: Bytes): Operator { +export function createOrLoadHorizonOperator(address: Bytes, verifierAddress: Bytes, indexerAddress: Bytes): HorizonOperator { let id = joinID([address.toHexString(), indexerAddress.toHexString(), verifierAddress.toHexString()]) - let operator = Operator.load(id) + let operator = HorizonOperator.load(id) if (operator == null) { - operator = new Operator(id) + operator = new HorizonOperator(id) operator.allowed = false operator.operator = address.toHexString() operator.indexer = indexerAddress.toHexString() @@ -255,7 +255,7 @@ export function createOrLoadOperator(address: Bytes, verifierAddress: Bytes, ind operator.save() } - return operator as Operator + return operator as HorizonOperator } export function createOrLoadPaymentSource(paymentAddress: Bytes): PaymentSource { @@ -529,7 +529,7 @@ export function createOrLoadGraphAccount(owner: Bytes, timeStamp: BigInt): Graph graphAccount = new GraphAccount(id) graphAccount.createdAt = timeStamp.toI32() graphAccount.operators = [] - graphAccount.provisionedOperators = [] + graphAccount.horizonOperators = [] graphAccount.balance = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Signalling = BigInt.fromI32(0) graphAccount.balanceReceivedFromL1Delegation = BigInt.fromI32(0) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 42be6276..26bc4d0a 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -2,7 +2,7 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' import { DelegatedTokensWithdrawn, DelegationFeeCutSet, DelegationSlashed, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, StakeDelegatedWithdrawn, 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, createOrLoadIndexer, createOrLoadOperator, createOrLoadProvision, joinID, updateAdvancedIndexerMetrics, updateAdvancedProvisionMetrics, updateDelegationExchangeRate, updateDelegationExchangeRateForProvision } from './helpers/helpers' +import { calculateCapacities, createOrLoadDataService, createOrLoadDelegatedStake, createOrLoadDelegatedStakeForProvision, createOrLoadDelegator, createOrLoadEpoch, createOrLoadGraphAccount, createOrLoadGraphNetwork, createOrLoadHorizonOperator, createOrLoadIndexer, createOrLoadProvision, joinID, updateAdvancedIndexerMetrics, updateAdvancedProvisionMetrics, updateDelegationExchangeRate, updateDelegationExchangeRateForProvision } from './helpers/helpers' import { ProvisionCreated, ProvisionIncreased, @@ -172,9 +172,9 @@ export function handleProvisionParametersStaged(event: ProvisionParametersStaged export function handleOperatorSet(event: OperatorSet): void { let indexerGraphAccount = createOrLoadGraphAccount(event.params.serviceProvider, event.block.timestamp) - let operator = createOrLoadOperator(event.params.operator, event.params.verifier, event.params.serviceProvider) + 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 provisionedOperators list for extra context + // 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 @@ -190,12 +190,12 @@ export function handleOperatorSet(event: OperatorSet): void { } } - let provisionedOperators = indexerGraphAccount.provisionedOperators - let provisionedOperatorsIndex = provisionedOperators.indexOf(event.params.operator.toHexString()) - if (provisionedOperatorsIndex != -1) { + 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(provisionedOperatorsIndex, 1) + operators.splice(horizonOperatorsIndex, 1) } } else { // true - it did not exist before, and we say add, so add @@ -208,7 +208,7 @@ export function handleOperatorSet(event: OperatorSet): void { operator.allowed = event.params.allowed operator.save() indexerGraphAccount.operators = operators - indexerGraphAccount.provisionedOperators = provisionedOperators + indexerGraphAccount.horizonOperators = horizonOperators indexerGraphAccount.save() } @@ -230,14 +230,14 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void { 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) provision.tokensSlashedServiceProvider = provision.tokensSlashedServiceProvider.plus(event.params.tokens) provision.save() From bf89036babd2068e03489508a4ea4a6d5a56b65d Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 31 Mar 2025 00:11:02 -0300 Subject: [PATCH 39/57] fix: most of the feedback from ProvisionManagement PR --- schema.graphql | 4 +++- src/mappings/horizonStaking.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/schema.graphql b/schema.graphql index ee5c29b4..d744a4df 100644 --- a/schema.graphql +++ b/schema.graphql @@ -982,7 +982,9 @@ type ThawRequest @entity { thawingUntil: BigInt! - valid: Boolean + fulfilledAsValid: Boolean + + fulfilled: Boolean! } """ diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 26bc4d0a..554feb83 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -153,6 +153,7 @@ export function handleTokensDeprovisioned(event: TokensDeprovisioned): void { graphNetwork.save() provision.tokensProvisioned = provision.tokensProvisioned.minus(event.params.tokens) + provision.tokensThawing = provision.tokensThawing.plus(event.params.tokens) provision.save() } @@ -239,6 +240,7 @@ export function handleProvisionSlashed(event: ProvisionSlashed): void { 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() } @@ -255,13 +257,15 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { request.shares = event.params.shares request.tokens = BigInt.fromI32(0) request.thawingUntil = event.params.thawingUntil + request.fulfilled = false request.save() } export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { let request = ThawRequest.load(event.params.thawRequestId.toHexString())! request.tokens = event.params.tokens - request.valid = event.params.valid + request.fulfilledAsValid = event.params.valid + request.fulfilled = true request.save() } From 85124e5275fc3f7a2df012faeb6fcd3c1713be98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 14 Apr 2025 16:42:11 -0300 Subject: [PATCH 40/57] fix: use new nomenclature for staking contract in address book MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- config/arbitrumSepoliaAddressScript.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/arbitrumSepoliaAddressScript.ts b/config/arbitrumSepoliaAddressScript.ts index 35f7daf0..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}}', From 2c2cb315528260a4ef1e667799f230a2557b4a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 15 Apr 2025 16:28:44 -0300 Subject: [PATCH 41/57] fix: add missing properties to provision initializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/helpers/helpers.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 3665dd73..66076b23 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -215,14 +215,24 @@ export function createOrLoadProvision(indexerAddress: Bytes, verifierAddress: By 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.indexingRewardEffectiveCut = BigInt.fromI32(0).toBigDecimal() - provision.queryFeeEffectiveCut = 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() } From de21a8be242f8aa3e727e8f70fa506fabe6f4add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 16 Apr 2025 16:33:32 -0300 Subject: [PATCH 42/57] fix: proper decoding for ServiceProviderRegistered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- config/localNetworkAddressScript.ts | 64 +++++++++++++++++++++++++++++ package.json | 5 +-- schema.graphql | 2 + src/mappings/helpers/decoder.ts | 20 +++++++++ src/mappings/helpers/helpers.ts | 4 ++ src/mappings/subgraphService.ts | 21 ++++++++-- 6 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 config/localNetworkAddressScript.ts create mode 100644 src/mappings/helpers/decoder.ts diff --git a/config/localNetworkAddressScript.ts b/config/localNetworkAddressScript.ts new file mode 100644 index 00000000..f6e67b0a --- /dev/null +++ b/config/localNetworkAddressScript.ts @@ -0,0 +1,64 @@ +import * as fs from 'fs' +import * as mustache from 'mustache' +// Replace with proper imports once the packages are published +import * as networkAddresses from '/opt/contracts.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['localnetwork'] = networkAddresses['1337'] + +export let addresses: Addresses = { + controller: '{{localnetwork.Controller.address}}', + graphToken: '{{localnetwork.L2GraphToken.address}}', + epochManager: '{{localnetwork.EpochManager.address}}', + disputeManager: '{{localnetwork.DisputeManager.address}}', + staking: '{{localnetwork.HorizonStaking.address}}', + stakingExtension: '{{localnetwork.HorizonStaking.address}}', + curation: '{{localnetwork.L2Curation.address}}', + rewardsManager: '{{localnetwork.RewardsManager.address}}', + serviceRegistry: '0x0000000000000000000000000000000000000000', + gns: '{{localnetwork.L2GNS.address}}', + ens: '{{localnetwork.IENS.address}}', + ensPublicResolver: '{{localnetwork.IPublicResolver.address}}', + blockNumber: '', + bridgeBlockNumber: '', + network: '', + tokenLockManager: '', + subgraphNFT: '{{localnetwork.SubgraphNFT.address}}', + l1GraphTokenGateway: '', + l2GraphTokenGateway: '{{localnetwork.L2GraphTokenGateway.address}}', + ethereumDIDRegistry: '{{localnetwork.EthereumDIDRegistry.address}}', + subgraphService: '{{localnetwork.SubgraphService.address}}', + graphPayments: '{{localnetwork.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 + } + // 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}`) + } +} + +main() 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 d744a4df..59b08b53 100644 --- a/schema.graphql +++ b/schema.graphql @@ -693,6 +693,8 @@ 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 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 66076b23..087346e9 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -178,6 +178,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() diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 6efed72c..6a9f6978 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -3,15 +3,30 @@ import { AllocationClosed, AllocationCreated, AllocationResized, DelegationRatio import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" import { Allocation, GraphAccount, 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)', event.params.data) + 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 = tupleData[0].toString() - provision.geoHash = tupleData[1].toString() + 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 + indexer.save() } else { log.warning("ServiceProviderRegistered failed to decode: {}", [event.params.data.toHexString()]) } From f4b038c09841c937c9f50da7bfbdcc4a2b9bec2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 16 Apr 2025 16:49:51 -0300 Subject: [PATCH 43/57] fix: update indexer entity on RewardsDestinationSet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/subgraphService.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 6a9f6978..d3ad588d 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -33,9 +33,15 @@ export function handleServiceProviderRegistered(event: ServiceProviderRegistered } 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 { From 300c8df39ebc41c9df09773c567ab1380238b9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 16 Apr 2025 17:51:06 -0300 Subject: [PATCH 44/57] feat: add isLegacy boolean to indexer entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 3 +++ src/mappings/helpers/helpers.ts | 12 +++++++++++- src/mappings/serviceRegistry.ts | 4 ++-- src/mappings/staking.ts | 8 ++++---- src/mappings/subgraphService.ts | 3 +++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/schema.graphql b/schema.graphql index 59b08b53..da822f6d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -698,6 +698,9 @@ type Indexer @entity { "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! diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index 087346e9..e93f285f 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -129,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) { @@ -137,6 +137,9 @@ 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) @@ -197,6 +200,13 @@ 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) 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 db5551c2..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) @@ -177,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) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index d3ad588d..9d935b76 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -26,6 +26,9 @@ export function handleServiceProviderRegistered(event: ServiceProviderRegistered 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()]) From 32d94567e0d17ea45ed89155e1425498f88e0085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 17 Apr 2025 14:40:49 -0300 Subject: [PATCH 45/57] fix: couple fixes for thaw/deprovision flows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- abis/HorizonStaking.json | 6 ++++++ src/mappings/horizonStaking.ts | 6 +++++- subgraph.template.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/abis/HorizonStaking.json b/abis/HorizonStaking.json index 1b2a72f6..24ce6816 100644 --- a/abis/HorizonStaking.json +++ b/abis/HorizonStaking.json @@ -959,6 +959,12 @@ "internalType": "bytes32", "name": "thawRequestId", "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" } ], "name": "ThawRequestCreated", diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 554feb83..40f5bad5 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -144,16 +144,19 @@ export function handleTokensDeprovisioned(event: TokensDeprovisioned): void { 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.plus(event.params.tokens) + provision.tokensThawing = provision.tokensThawing.minus(event.params.tokens) provision.save() } @@ -258,6 +261,7 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { request.tokens = BigInt.fromI32(0) request.thawingUntil = event.params.thawingUntil request.fulfilled = false + request.fulfilledAsValid = false request.save() } diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 156c77a2..47591cd2 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -419,7 +419,7 @@ dataSources: handler: handleProvisionSlashed - event: ProvisionThawed(indexed address,indexed address,uint256) handler: handleProvisionThawed - - event: ThawRequestCreated(indexed uint8,indexed address,indexed address,address,uint256,uint64,bytes32) + - 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 From aaa98128c40034582652356122daffb949c4144c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 21 Apr 2025 15:51:34 -0300 Subject: [PATCH 46/57] fix: update data service entity on allo creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/subgraphService.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 9d935b76..d10e9894 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -79,6 +79,11 @@ export function handleAllocationCreated(event: AllocationCreated): void { 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) From 47c734a96457c45024b4acf2470e0f7d3339ea87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 21 Apr 2025 16:01:41 -0300 Subject: [PATCH 47/57] fix: update missing entities in allocation resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/subgraphService.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index d10e9894..bde792fa 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -206,6 +206,22 @@ export function handleAllocationResized(event: AllocationResized): void { 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 { From 2f1c688807e304ac0bed01b980eb790d011923a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 21 Apr 2025 16:35:41 -0300 Subject: [PATCH 48/57] fix: update allocation close to latest signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- abis/SubgraphService.json | 6 ++++++ src/mappings/subgraphService.ts | 15 ++++++++------- subgraph.template.yaml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json index 3fa424a0..92f1bfba 100644 --- a/abis/SubgraphService.json +++ b/abis/SubgraphService.json @@ -574,6 +574,12 @@ "internalType": "uint256", "name": "tokens", "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "forceClosed", + "type": "bool" } ], "name": "AllocationClosed", diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index bde792fa..f8a69688 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -133,16 +133,11 @@ 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.transaction.from == event.params.indexer - const closedByOperator = indexerAccount.operators.includes(event.transaction.from.toHexString()) - if (!closedByIndexer && !closedByOperator) { + if (event.params.forceClosed) { 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 indexer.save() @@ -154,6 +149,7 @@ export function handleAllocationClosed(event: AllocationClosed): void { provision.save() // update allocation + allocation.forceClosed = event.params.forceClosed allocation.poolClosedIn = graphNetwork.currentEpoch.toString() allocation.activeForIndexer = null allocation.closedAtEpoch = graphNetwork.currentEpoch @@ -185,6 +181,11 @@ export function handleAllocationClosed(event: AllocationClosed): void { 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 { diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 47591cd2..11f9629b 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -467,7 +467,7 @@ dataSources: handler: handleAllocationCreated - event: AllocationResized(indexed address,indexed address,indexed bytes32,uint256,uint256) handler: handleAllocationResized - - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256) + - event: AllocationClosed(indexed address,indexed address,indexed bytes32,uint256,bool) handler: handleAllocationClosed - event: IndexingRewardsCollected(indexed address,indexed address,indexed bytes32,uint256,uint256,uint256,bytes32,uint256) handler: handleIndexingRewardsCollected From 36148ac36d062e583d34cb8d26f4a077bdcef9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 21 Apr 2025 17:26:16 -0300 Subject: [PATCH 49/57] feat: add governance events handlers to horizon staking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 9 ++++++++- src/mappings/helpers/helpers.ts | 4 ++++ src/mappings/horizonStaking.ts | 28 ++++++++++++++++++++++++++-- subgraph.template.yaml | 8 ++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index da822f6d..145ee75b 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" @@ -250,6 +254,9 @@ type DataService @entity { delegationRatio: Int provisions: [Provision!]! @derivedFrom(field: "dataService") + + "True if allowed for usage with token lock wallets" + allowedWithTokenLockWallets: Boolean! } """ diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index e93f285f..d2d93418 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -261,6 +261,7 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { service.totalTokensAllocated = BigInt.fromI32(0) service.totalTokensProvisioned = BigInt.fromI32(0) service.totalTokensThawing = BigInt.fromI32(0) + service.allowedWithTokenLockWallets = false service.save() } @@ -769,6 +770,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) { diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 40f5bad5..b6151aff 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -1,6 +1,6 @@ import { BigInt } from '@graphprotocol/graph-ts' import { addresses } from '../../config/addresses' -import { DelegatedTokensWithdrawn, DelegationFeeCutSet, DelegationSlashed, HorizonStakeDeposited, HorizonStakeLocked, HorizonStakeWithdrawn, OperatorSet, StakeDelegatedWithdrawn, TokensDelegated, TokensDeprovisioned, TokensToDelegationPoolAdded, TokensUndelegated } from '../types/HorizonStaking/HorizonStaking' +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 { @@ -472,4 +472,28 @@ export function handleDelegatedTokensWithdrawn(event: DelegatedTokensWithdrawn): let delegatedStake = DelegatedStake.load(id)! delegatedStake.lockedTokens = delegatedStake.lockedTokens.minus(event.params.tokens) delegatedStake.save() -} \ No newline at end of file +} + +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/subgraph.template.yaml b/subgraph.template.yaml index 11f9629b..22cc671e 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -437,6 +437,14 @@ dataSources: 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}} From 0a219a3f0b6d1682b8c2c7951e925f0cedff4932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Mon, 21 Apr 2025 17:57:44 -0300 Subject: [PATCH 50/57] feat: more missing governance events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 2 ++ src/mappings/helpers/helpers.ts | 1 + src/mappings/subgraphService.ts | 8 +++++++- subgraph.template.yaml | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/schema.graphql b/schema.graphql index 145ee75b..61d8fedc 100644 --- a/schema.graphql +++ b/schema.graphql @@ -252,6 +252,8 @@ type DataService @entity { "Ratio of max staked delegation tokens to indexers stake that earns rewards" delegationRatio: Int + "Curation cut for this DataService" + curationCut: BigInt! provisions: [Provision!]! @derivedFrom(field: "dataService") diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index d2d93418..dd5c6d74 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -262,6 +262,7 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { service.totalTokensProvisioned = BigInt.fromI32(0) service.totalTokensThawing = BigInt.fromI32(0) service.allowedWithTokenLockWallets = false + service.curationCut = BigInt.fromI32(0) service.save() } diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index f8a69688..022175cd 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,5 +1,5 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" -import { AllocationClosed, AllocationCreated, AllocationResized, DelegationRatioSet, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +import { AllocationClosed, AllocationCreated, AllocationResized, CurationCutSet, DelegationRatioSet, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" import { batchUpdateSubgraphSignalledTokens, calculatePricePerShare, createOrLoadDataService, createOrLoadEpoch, createOrLoadGraphNetwork, createOrLoadIndexerQueryFeePaymentAggregation, createOrLoadPaymentSource, createOrLoadProvision, createOrLoadSubgraphDeployment, joinID, updateDelegationExchangeRate } from "./helpers/helpers" import { Allocation, GraphAccount, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" import { addresses } from "../../config/addresses" @@ -399,3 +399,9 @@ export function handleQueryFeesCollected(event: QueryFeesCollected): void { ) paymentSource.save() } + +export function handleCurationCutSet(event: CurationCutSet): void { + let dataService = createOrLoadDataService(event.address) + dataService.curationCut = event.params.curationCut + dataService.save() +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 22cc671e..bf95abb2 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -483,6 +483,8 @@ dataSources: handler: handleQueryFeesCollected - event: DelegationRatioSet(uint32) handler: handleDelegationRatioSet + - event: CurationCutSet(uint256) + handler: handleCurationCutSet - kind: ethereum/contract name: GraphPayments network: {{network}} From db7dac64fb74b0d6f59bbbd71f2a4bb4e52e58dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 22 Apr 2025 09:56:39 -0300 Subject: [PATCH 51/57] feat: add more missing events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 24 ++++++++++++++++++++-- src/mappings/helpers/helpers.ts | 8 ++++++++ src/mappings/subgraphService.ts | 35 ++++++++++++++++++++++++++++++++- subgraph.template.yaml | 10 ++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index 61d8fedc..4400c9ab 100644 --- a/schema.graphql +++ b/schema.graphql @@ -250,15 +250,35 @@ type DataService @entity { "Total GRT currently in allocations for this DataService" totalTokensAllocated: 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 - "Curation cut for this DataService" - curationCut: BigInt! 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! } """ diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index dd5c6d74..f7884a6e 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -263,6 +263,14 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { 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.save() } diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index 022175cd..f535a70d 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,5 +1,5 @@ import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts" -import { AllocationClosed, AllocationCreated, AllocationResized, CurationCutSet, DelegationRatioSet, IndexingRewardsCollected, QueryFeesCollected, RewardsDestinationSet, ServiceProviderRegistered } from "../types/SubgraphService/SubgraphService" +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, GraphAccount, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" import { addresses } from "../../config/addresses" @@ -405,3 +405,36 @@ export function handleCurationCutSet(event: CurationCutSet): void { 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 bf95abb2..56a57a34 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -485,6 +485,16 @@ dataSources: 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}} From 73c7da8d58b83f306efb42008751e1c989eb27d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 22 Apr 2025 11:12:27 -0300 Subject: [PATCH 52/57] fix: couple delegation fixes and additions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- schema.graphql | 9 +++++++++ src/mappings/helpers/helpers.ts | 1 + src/mappings/horizonStaking.ts | 31 ++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/schema.graphql b/schema.graphql index 4400c9ab..b4b5af8a 100644 --- a/schema.graphql +++ b/schema.graphql @@ -249,6 +249,8 @@ type DataService @entity { 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! @@ -999,9 +1001,16 @@ type Provision @entity { rewardsDestination: Bytes } +enum ThawRequestType { + Provision + Delegation +} + type ThawRequest @entity { id: ID! + type: ThawRequestType! + indexer: Indexer! dataService: DataService! diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index f7884a6e..c55665c0 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -271,6 +271,7 @@ export function createOrLoadDataService(verifierAddress: Bytes): DataService { service.maximumVerifierCut = BigInt.fromI32(0) service.minimumThawingPeriod = BigInt.fromI32(0) service.maximumThawingPeriod = BigInt.fromI32(0) + service.totalTokensDelegated = BigInt.fromI32(0) service.save() } diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index b6151aff..47cda7a9 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -262,6 +262,13 @@ export function handleThawRequestCreated(event: ThawRequestCreated): void { 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() } @@ -274,23 +281,29 @@ export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { } export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolAdded): void { - let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) - let indexer = Indexer.load(event.params.serviceProvider.toHexString())! 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 graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) graphNetwork.save() + + let dataService = createOrLoadDataService(event.params.verifier) + dataService.totalTokensDelegated = dataService.totalTokensDelegated.plus(event.params.tokens) + dataService.save() } // Delegation @@ -299,7 +312,7 @@ export function handleTokensDelegated(event: TokensDelegated): void { let zeroShares = event.params.shares.equals(BigInt.fromI32(0)) let dataService = createOrLoadDataService(event.params.verifier) - // Might want to track some stuff here in the future + dataService.totalTokensDelegated = dataService.totalTokensDelegated.plus(event.params.tokens) dataService.save() let provision = createOrLoadProvision(event.params.serviceProvider, event.params.verifier, event.block.timestamp) @@ -315,6 +328,10 @@ export function handleTokensDelegated(event: TokensDelegated): void { 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 @@ -416,6 +433,10 @@ export function handleTokensUndelegated(event: TokensUndelegated): void { 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 @@ -459,6 +480,10 @@ export function handleTokensUndelegated(event: TokensUndelegated): void { 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 { From 4c6d370e0b2d58cf7528549ae84912617eedeefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 22 Apr 2025 15:55:44 -0300 Subject: [PATCH 53/57] fix: few things about indexing rewards and pois MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- abis/SubgraphService.json | 6 ++++++ schema.graphql | 18 ++++++++++++++++++ src/mappings/subgraphService.ts | 16 +++++++++++++++- subgraph.template.yaml | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/abis/SubgraphService.json b/abis/SubgraphService.json index 92f1bfba..a99cd7d0 100644 --- a/abis/SubgraphService.json +++ b/abis/SubgraphService.json @@ -803,6 +803,12 @@ "name": "poi", "type": "bytes32" }, + { + "indexed": false, + "internalType": "bytes32", + "name": "publicPoi", + "type": "bytes32" + }, { "indexed": false, "internalType": "uint256", diff --git a/schema.graphql b/schema.graphql index b4b5af8a..f2146737 100644 --- a/schema.graphql +++ b/schema.graphql @@ -1092,8 +1092,12 @@ type Allocation @entity { poi: Bytes "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" @@ -1125,6 +1129,20 @@ type PoiSubmission @entity { poi: Bytes! submittedAtEpoch: Int! + + presentedAtTimestamp: Int! +} + +type PublicPoiSubmission @entity { + id: ID! + + allocation: Allocation! + + publicPoi: Bytes! + + submittedAtEpoch: Int! + + presentedAtTimestamp: Int! } enum AllocationStatus { diff --git a/src/mappings/subgraphService.ts b/src/mappings/subgraphService.ts index f535a70d..1555bc92 100644 --- a/src/mappings/subgraphService.ts +++ b/src/mappings/subgraphService.ts @@ -1,7 +1,7 @@ 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, GraphAccount, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" +import { Allocation, PublicPoiSubmission, Indexer, PoiSubmission, SubgraphDeployment } from "../types/schema" import { addresses } from "../../config/addresses" import { tuplePrefixBytes } from "./helpers/decoder" import { createOrLoadIndexer } from "./helpers/helpers" @@ -260,8 +260,22 @@ export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): 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) diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 56a57a34..ff162e26 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -477,7 +477,7 @@ dataSources: 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,uint256) + - 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 From 81eab58a033317d315c2b02077611a818cc2ecff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Wed, 23 Apr 2025 09:27:07 -0300 Subject: [PATCH 54/57] fix: load graph network first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/horizonStaking.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mappings/horizonStaking.ts b/src/mappings/horizonStaking.ts index 47cda7a9..1dee16e5 100644 --- a/src/mappings/horizonStaking.ts +++ b/src/mappings/horizonStaking.ts @@ -281,6 +281,10 @@ export function handleThawRequestFulfilled(event: ThawRequestFulfilled): void { } 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)) { @@ -297,10 +301,6 @@ export function handleTokensToDelegationPoolAdded(event: TokensToDelegationPoolA indexer = updateAdvancedIndexerMetrics(indexer as Indexer) indexer.save() - let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) - graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.tokens) - graphNetwork.save() - let dataService = createOrLoadDataService(event.params.verifier) dataService.totalTokensDelegated = dataService.totalTokensDelegated.plus(event.params.tokens) dataService.save() From f664900160bb26318bf96c538af058557817be41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 15 May 2025 09:49:47 -0300 Subject: [PATCH 55/57] fix: overdelegation dilution div by zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- src/mappings/helpers/helpers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mappings/helpers/helpers.ts b/src/mappings/helpers/helpers.ts index c55665c0..ac0966f5 100644 --- a/src/mappings/helpers/helpers.ts +++ b/src/mappings/helpers/helpers.ts @@ -984,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 { From f7342e5444e0593833c82d271d5f2c3f5bd5b186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 15 May 2025 10:58:30 -0300 Subject: [PATCH 56/57] chore: use split address book on localnetwork script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- config/localNetworkAddressScript.ts | 51 +++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/config/localNetworkAddressScript.ts b/config/localNetworkAddressScript.ts index f6e67b0a..74f08ce1 100644 --- a/config/localNetworkAddressScript.ts +++ b/config/localNetworkAddressScript.ts @@ -1,37 +1,40 @@ import * as fs from 'fs' import * as mustache from 'mustache' // Replace with proper imports once the packages are published -import * as networkAddresses from '/opt/contracts.json' +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 = networkAddresses -renameAddresses['localnetwork'] = networkAddresses['1337'] +let renameAddresses: any = { + horizon: horizonAddresses['1337'], + subgraphService: subgraphServiceAddresses['1337'], +} export let addresses: Addresses = { - controller: '{{localnetwork.Controller.address}}', - graphToken: '{{localnetwork.L2GraphToken.address}}', - epochManager: '{{localnetwork.EpochManager.address}}', - disputeManager: '{{localnetwork.DisputeManager.address}}', - staking: '{{localnetwork.HorizonStaking.address}}', - stakingExtension: '{{localnetwork.HorizonStaking.address}}', - curation: '{{localnetwork.L2Curation.address}}', - rewardsManager: '{{localnetwork.RewardsManager.address}}', + 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: '{{localnetwork.L2GNS.address}}', - ens: '{{localnetwork.IENS.address}}', - ensPublicResolver: '{{localnetwork.IPublicResolver.address}}', + gns: '{{horizon.L2GNS.address}}', + ens: '{{horizon.IENS.address}}', + ensPublicResolver: '{{horizon.IPublicResolver.address}}', blockNumber: '', bridgeBlockNumber: '', network: '', tokenLockManager: '', - subgraphNFT: '{{localnetwork.SubgraphNFT.address}}', + subgraphNFT: '{{horizon.SubgraphNFT.address}}', l1GraphTokenGateway: '', - l2GraphTokenGateway: '{{localnetwork.L2GraphTokenGateway.address}}', - ethereumDIDRegistry: '{{localnetwork.EthereumDIDRegistry.address}}', - subgraphService: '{{localnetwork.SubgraphService.address}}', - graphPayments: '{{localnetwork.GraphPayments.address}}', + l2GraphTokenGateway: '{{horizon.L2GraphTokenGateway.address}}', + ethereumDIDRegistry: '{{horizon.EthereumDIDRegistry.address}}', + subgraphService: '{{subgraphService.SubgraphService.address}}', + graphPayments: '{{horizon.GraphPayments.address}}', isL1: false, } @@ -48,12 +51,12 @@ 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 + // 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.graphPayments == '') { - output.graphPayments = '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) { From 182d0564547cf292453dd11bcb0e692e1e6fc7ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 May 2025 16:21:08 +0000 Subject: [PATCH 57/57] chore(deps): bump tar-fs from 1.16.3 to 1.16.4 Bumps [tar-fs](https://github.com/mafintosh/tar-fs) from 1.16.3 to 1.16.4. - [Commits](https://github.com/mafintosh/tar-fs/compare/v1.16.3...v1.16.4) --- updated-dependencies: - dependency-name: tar-fs dependency-version: 1.16.4 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6529da99..c0cf80ce 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" @@ -4361,6 +4361,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" @@ -5954,9 +5959,9 @@ table@^6.0.9: strip-ansi "^6.0.1" tar-fs@~1.16.3: - version "1.16.3" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" - integrity sha512-NvCeXpYx7OsmOh8zIOP/ebG55zZmxLE0etfWRbWok+q2Qo8x/vOR/IJT1taADXPe+jsiu9axDb3X4B+iIgNlKw== + version "1.16.4" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.4.tgz#d3f0e1edf164b821f086640b1f0596f004021dc8" + integrity sha512-u3XczWoYAIVXe5GOKK6+VeWaHjtc47W7hyuTo3+4cNakcCcuDmlkYiiHEsECwTkcI3h1VUgtwBQ54+RvY6cM4w== dependencies: chownr "^1.0.1" mkdirp "^0.5.1"