diff --git a/.github/workflows/build-subgraph.yaml b/.github/workflows/build-subgraph.yaml index cb7db39..9db1d77 100644 --- a/.github/workflows/build-subgraph.yaml +++ b/.github/workflows/build-subgraph.yaml @@ -17,7 +17,7 @@ jobs: strategy: max-parallel: 4 matrix: - manifest: [subgraph.testnet_fast.yaml, subgraph.testnet.yaml,subgraph.devnet_fast.yaml, subgraph.devnet.yaml, subgraph.goerli_fast.yaml, subgraph.goerli.yaml, subgraph.mainnet_fast.yaml, subgraph.mainnet.yaml] + manifest: [subgraph.kurtosis.yaml, subgraph.testnet_fast.yaml, subgraph.testnet.yaml, subgraph.devnet.yaml, subgraph.goerli_fast.yaml, subgraph.goerli.yaml, subgraph.mainnet_fast.yaml, subgraph.mainnet.yaml] runs-on: ubuntu-latest steps: - name: Checkout diff --git a/abis/Liquid20A_2_2_0.json b/abis/Liquid20A_2_2_0.json new file mode 100644 index 0000000..f3f9994 --- /dev/null +++ b/abis/Liquid20A_2_2_0.json @@ -0,0 +1,2122 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "sanctionsOracle", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "SANCTIONS_ORACLE", + "outputs": [ + { + "internalType": "contract ISanctionsList", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "accountNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "accountRawRights", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "accountRights", + "outputs": [ + { + "internalType": "uint248", + "name": "", + "type": "uint248" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeBps", + "type": "uint256" + } + ], + "name": "addPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expiration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "authorize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "uint256", + "name": "expiration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "authorizeAndStake", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "authorizer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOfUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newFeeBps", + "type": "uint256" + } + ], + "name": "changeFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "splits", + "type": "uint256[]" + } + ], + "name": "changeSplit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "clearAuthorizations", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "defaultRights", + "outputs": [ + { + "internalType": "uint248", + "name": "", + "type": "uint248" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "depositsPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "ethAfterCommission", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "exitCommissionShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "forbid", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getCommissionPaid", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentSplit", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getExitedEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getInjectedEth", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getPoolActivation", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "getPoolShares", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "incrementNonce", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "admin", + "type": "address" + }, + { + "internalType": "address[]", + "name": "pools", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "poolFees", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "commissionRecipients", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "commissionDistribution", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "poolPercentages", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "maxCommissionBps", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "monoTicketThreshold", + "type": "uint256" + }, + { + "internalType": "uint248", + "name": "defaultRights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "authorizer", + "type": "address" + } + ], + "internalType": "struct Native20Configuration", + "name": "args", + "type": "tuple" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "integratorCommissionEarned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "integratorCommissionOwed", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isSanctionsListActive", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onvPoolSharesReceived", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isPaused", + "type": "bool" + } + ], + "name": "pauseDeposits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pendingAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pools", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "requestExit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_authorizer", + "type": "address" + } + ], + "name": "setAuthorizer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + } + ], + "name": "setDefaultRights", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "minTicketEthValue", + "type": "uint256" + } + ], + "name": "setMonoTicketThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "status", + "type": "bool" + }, + { + "internalType": "uint256[]", + "name": "newPoolPercentages", + "type": "uint256[]" + } + ], + "name": "setPoolActivation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "split", + "type": "uint256[]" + } + ], + "name": "setPoolPercentages", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "name": "setSanctionsActivation", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stake", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "stakeFor", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "stakedEthValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalUnderlyingSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "transferAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawCommission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "signer", + "type": "address" + } + ], + "name": "ClearedAccountRights", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "pSharesSold", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountSold", + "type": "uint256" + } + ], + "name": "CommissionSharesSold", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "withdrawer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountWithdrawn", + "type": "uint256" + } + ], + "name": "CommissionWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "exitedTokens", + "type": "uint128" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "poolId", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "exitedPoolShares", + "type": "uint128" + } + ], + "indexed": false, + "internalType": "struct PoolExitDetails[]", + "name": "exitDetails", + "type": "tuple[]" + } + ], + "name": "Exit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "weights", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + } + ], + "name": "ExitedCommissionShares", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "version", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "cdata", + "type": "bytes" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "recipients", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "splits", + "type": "uint256[]" + } + ], + "name": "NewCommissionSplit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "name": "PoolActivation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "name": "SanctionsActivationChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "SetAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "authorizer", + "type": "address" + } + ], + "name": "SetAuthorizer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rights", + "type": "uint256" + } + ], + "name": "SetDefaultRights", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "isPaused", + "type": "bool" + } + ], + "name": "SetDepositsPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "operatorFeeBps", + "type": "uint256" + } + ], + "name": "SetFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maxCommission", + "type": "uint256" + } + ], + "name": "SetMaxCommission", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + } + ], + "name": "SetName", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "pendingAdmin", + "type": "address" + } + ], + "name": "SetPendingAdmin", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "split", + "type": "uint256[]" + } + ], + "name": "SetPoolPercentages", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + } + ], + "name": "SetSymbol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "depositedEth", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "mintedTokens", + "type": "uint128" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "poolId", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "ethToPool", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "ethToIntegrator", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pSharesFromPool", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pSharesFromIntegrator", + "type": "uint128" + } + ], + "indexed": false, + "internalType": "struct PoolStakeDetails[]", + "name": "stakeDetails", + "type": "tuple[]" + } + ], + "name": "Stake", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rights", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "signer", + "type": "address" + } + ], + "name": "UpdatedAccountRights", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "vPool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "VPoolSharesReceived", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "AddressSanctioned", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "version", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentVersion", + "type": "uint256" + } + ], + "name": "AlreadyInitialized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expiration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "blockTimestamp", + "type": "uint256" + } + ], + "name": "AuthorizationExpired", + "type": "error" + }, + { + "inputs": [], + "name": "CallbackNotFromMinting", + "type": "error" + }, + { + "inputs": [], + "name": "CommissionPaidUnderflow", + "type": "error" + }, + { + "inputs": [], + "name": "DepositsPaused", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyPoolList", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maxFeeBps", + "type": "uint256" + } + ], + "name": "FeeOverMax", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Forbidden", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + } + ], + "name": "InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sum", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "msgValue", + "type": "uint256" + } + ], + "name": "InvalidAmounts", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "sumValue", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedSum", + "type": "uint256" + } + ], + "name": "InvalidBPSSum", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maximum", + "type": "uint256" + } + ], + "name": "InvalidBPSValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expectedNonce", + "type": "uint256" + } + ], + "name": "InvalidNonce", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidNullValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "InvalidPoolId", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "rights", + "type": "uint256" + } + ], + "name": "InvalidRightsValue", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expiration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "InvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "InvalidSignatureS", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + } + ], + "name": "InvalidSignatureV", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "expiration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "InvalidSignedAuthorization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "MathOverflowedMulDiv", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint248", + "name": "rights", + "type": "uint248" + }, + { + "internalType": "uint248", + "name": "expectedRights", + "type": "uint248" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "MissingAuthorizations", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "NoSharesToExit", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "NonZeroPercentageOnDeactivatedPool", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "NotARegisteredPool", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "NotPayable", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "ethLeft", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "OutstandingCommission", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPool", + "type": "address" + } + ], + "name": "PoolAlreadyRegistered", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "poolId", + "type": "uint256" + } + ], + "name": "PoolDisabled", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "name": "PoolTransferFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bytes", + "name": "returnData", + "type": "bytes" + } + ], + "name": "RecipientReverted", + "type": "error" + }, + { + "inputs": [], + "name": "Reentrancy", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintDowncast", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintToInt", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "address", + "name": "expected", + "type": "address" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "lengthA", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lengthB", + "type": "uint256" + } + ], + "name": "UnequalLengths", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroTokenMint", + "type": "error" + } +] + diff --git a/abis/Nexus.2_2_0.json b/abis/Nexus.2_2_0.json new file mode 100644 index 0000000..2e0b455 --- /dev/null +++ b/abis/Nexus.2_2_0.json @@ -0,0 +1,761 @@ +[ + { + "type": "function", + "name": "acceptAdmin", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "coreHatchers", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address[]", + "internalType": "address[]" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "depositContract", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "driver", + "inputs": [ + { + "name": "key", + "type": "string", + "internalType": "string" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "globalConsensusLayerSpec", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ctypes.ConsensusLayerSpec", + "components": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "globalOracle", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "globalRecipient", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "admin_", + "type": "address", + "internalType": "address" + }, + { + "name": "pluggableHatcherList", + "type": "address[8]", + "internalType": "address[8]" + }, + { + "name": "drivers", + "type": "address[1]", + "internalType": "address[1]" + }, + { + "name": "depositContract_", + "type": "address", + "internalType": "address" + }, + { + "name": "minimalRecipientImplementation_", + "type": "address", + "internalType": "address" + }, + { + "name": "globalRecipient_", + "type": "address", + "internalType": "address" + }, + { + "name": "globalOracle_", + "type": "address", + "internalType": "address" + }, + { + "name": "genesisTimestamp_", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal_", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch_", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot_", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "minimalRecipientImplementation", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pendingAdmin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "replaceCoreHatchers", + "inputs": [ + { + "name": "coreHatchers_", + "type": "address[8]", + "internalType": "address[8]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setDriver", + "inputs": [ + { + "name": "key", + "type": "string", + "internalType": "string" + }, + { + "name": "_driver", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setGlobalConsensusLayerSpec", + "inputs": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setGlobalOracle", + "inputs": [ + { + "name": "newGlobalOracle", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setGlobalRecipient", + "inputs": [ + { + "name": "newGlobalRecipient", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "spawnFactory", + "inputs": [ + { + "name": "fca", + "type": "tuple", + "internalType": "struct INexus.FactoryConstructionArguments", + "components": [ + { + "name": "treasuryFee", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "admin", + "type": "address", + "internalType": "address" + }, + { + "name": "operatorName", + "type": "string", + "internalType": "string" + } + ] + } + ], + "outputs": [ + { + "name": "spawned", + "type": "address[2]", + "internalType": "address[2]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "spawnPool", + "inputs": [ + { + "name": "pca", + "type": "tuple", + "internalType": "struct INexus.PoolConstructionArguments", + "components": [ + { + "name": "epochsPerFrame", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "operatorFeeBps", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "factory", + "type": "address", + "internalType": "address" + }, + { + "name": "reportBounds", + "type": "uint64[3]", + "internalType": "uint64[3]" + }, + { + "name": "initialExtraData", + "type": "string", + "internalType": "string" + }, + { + "name": "exitQueueImageUrl", + "type": "string", + "internalType": "string" + } + ] + } + ], + "outputs": [ + { + "name": "spawned", + "type": "address[6]", + "internalType": "address[6]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "spawnedFactory", + "inputs": [ + { + "name": "factory", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferAdmin", + "inputs": [ + { + "name": "newAdmin", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "cdata", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetAdmin", + "inputs": [ + { + "name": "admin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetCoreHatchers", + "inputs": [ + { + "name": "factory", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "pool", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "treasury", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "withdrawalRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "execLayerRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "coverageRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "oracleAggregator", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "exitQueue", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetDepositContract", + "inputs": [ + { + "name": "depositContractAddress", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetDriver", + "inputs": [ + { + "name": "key", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "driver", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetGlobalConsensusLayerSpec", + "inputs": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetGlobalOracle", + "inputs": [ + { + "name": "globalOracle", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetGlobalRecipient", + "inputs": [ + { + "name": "globalRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetMinimalRecipientImplementation", + "inputs": [ + { + "name": "minimalRecipientImplementationAddress", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetPendingAdmin", + "inputs": [ + { + "name": "pendingAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SpawnedFactory", + "inputs": [ + { + "name": "factory", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "treasury", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SpawnedPool", + "inputs": [ + { + "name": "factory", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "pool", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "withdrawalRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "execLayerRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "coverageRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "oracleAggregator", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "exitQueue", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentVersion", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidPluggableHatcherConfiguration", + "inputs": [ + { + "name": "pluggableHatcher", + "type": "address", + "internalType": "address" + }, + { + "name": "configuredNexus", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "InvalidZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "NotSpawnedFactory", + "inputs": [ + { + "name": "caller", + "type": "address", + "internalType": "address" + }, + { + "name": "invalidFactory", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "expected", + "type": "address", + "internalType": "address" + } + ] + } +] + diff --git a/abis/vFactory.2_2_0.json b/abis/vFactory.2_2_0.json new file mode 100644 index 0000000..7de1f88 --- /dev/null +++ b/abis/vFactory.2_2_0.json @@ -0,0 +1,1385 @@ +[ + { + "type": "function", + "name": "acceptAdmin", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "admin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "allowDepositor", + "inputs": [ + { + "name": "depositor", + "type": "address", + "internalType": "address" + }, + { + "name": "wc", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "autoClaimDetails", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "thresholdGwei", + "type": "uint96", + "internalType": "uint96" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claimable", + "inputs": [ + { + "name": "validatorIds", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "outputs": [ + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "deposit", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "d", + "type": "tuple", + "internalType": "struct ctypes.Deposit", + "components": [ + { + "name": "dedicatedRecipient", + "type": "address", + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "feeRecipient", + "type": "address", + "internalType": "address" + }, + { + "name": "thresholdGwei", + "type": "uint96", + "internalType": "uint96" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "depositContract", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "depositFromRoot", + "inputs": [ + { + "name": "$$", + "type": "tuple", + "internalType": "struct IvFactory.DepositFromRootParameters", + "components": [ + { + "name": "wc", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "validationKeys", + "type": "tuple[]", + "internalType": "struct IvFactory.ValidationKey[]", + "components": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "name": "feeRecipient", + "type": "address", + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "extradata", + "type": "string", + "internalType": "string" + }, + { + "name": "thresholdGwei", + "type": "uint96", + "internalType": "uint96" + }, + { + "name": "proof", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "flagCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "flags", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "outputs": [ + { + "name": "", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "depositors", + "inputs": [ + { + "name": "depositor", + "type": "address", + "internalType": "address" + }, + { + "name": "wc", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "exit", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "exitTotal", + "inputs": [ + { + "name": "totalExited", + "type": "uint32", + "internalType": "uint32" + } + ], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "fix", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "fundedValidators", + "inputs": [ + { + "name": "wc", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "depositContract_", + "type": "address", + "internalType": "address" + }, + { + "name": "admin_", + "type": "address", + "internalType": "address" + }, + { + "name": "treasury_", + "type": "address", + "internalType": "address" + }, + { + "name": "_minimalRecipientImplementation", + "type": "address", + "internalType": "address" + }, + { + "name": "hatcherRegistry", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "metadata", + "inputs": [], + "outputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "url", + "type": "string", + "internalType": "string" + }, + { + "name": "iconUrl", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "minimalRecipientImplementation", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "onRewards", + "inputs": [ + { + "name": "_validatorId", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "pendingAdmin", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "root", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ctypes.ValidationKeyRegistry", + "components": [ + { + "name": "root", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "ipfsHash", + "type": "string", + "internalType": "string" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setAutoClaimThreshold", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newThresholdGwei", + "type": "uint96", + "internalType": "uint96" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setExtraData", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "extradata", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setFeeRecipient", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newFeeRecipient", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMetadata", + "inputs": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "url", + "type": "string", + "internalType": "string" + }, + { + "name": "iconUrl", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setOwner", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRoot", + "inputs": [ + { + "name": "newRoot", + "type": "tuple", + "internalType": "struct ctypes.ValidationKeyRegistry", + "components": [ + { + "name": "root", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "ipfsHash", + "type": "string", + "internalType": "string" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferAdmin", + "inputs": [ + { + "name": "newAdmin", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "treasury", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "validatorId", + "inputs": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "withdraw", + "inputs": [ + { + "name": "ids", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { + "name": "revertOnEmpty", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawalAddress", + "inputs": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "withdrawalAddress", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "ActivatedValidator", + "inputs": [ + { + "name": "withdrawalChannel", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "depositor", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "withdrawalAddress", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "publicKey", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "id", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ApproveDepositor", + "inputs": [ + { + "name": "depositor", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "wc", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "allowed", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ChangedOperator", + "inputs": [ + { + "name": "operator", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ChangedTreasury", + "inputs": [ + { + "name": "treasury", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ExitRequestAboveFundedInChannel", + "inputs": [ + { + "name": "withdrawalChannel", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + }, + { + "name": "funded", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + }, + { + "name": "requestedTotal", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ExitValidator", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FundedValidator", + "inputs": [ + { + "name": "withdrawalChannel", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "depositor", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "withdrawalAddress", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "publicKey", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "id", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "validatorIndex", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "cdata", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetAdmin", + "inputs": [ + { + "name": "admin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetDepositContract", + "inputs": [ + { + "name": "depositContract", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetExitTotal", + "inputs": [ + { + "name": "withdrawalChannel", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "totalExited", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetHatcherRegistry", + "inputs": [ + { + "name": "hatcherRegistry", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetMetadata", + "inputs": [ + { + "name": "name", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "url", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "iconUrl", + "type": "string", + "indexed": false, + "internalType": "string" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetMinimalRecipientImplementation", + "inputs": [ + { + "name": "minimalRecipientImplementation", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetPendingAdmin", + "inputs": [ + { + "name": "pendingAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetProposedRoot", + "inputs": [ + { + "name": "newProposedRoot", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidationKeyRegistry", + "components": [ + { + "name": "root", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "ipfsHash", + "type": "string", + "internalType": "string" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetRoot", + "inputs": [ + { + "name": "newRoot", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidationKeyRegistry", + "components": [ + { + "name": "root", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "ipfsHash", + "type": "string", + "internalType": "string" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetValidatorExtraData", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "extraData", + "type": "string", + "indexed": false, + "internalType": "string" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetValidatorFeeRecipient", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "feeRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetValidatorOwner", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "owner", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetValidatorThreshold", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "thresholdGwei", + "type": "uint96", + "indexed": false, + "internalType": "uint96" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Withdraw", + "inputs": [ + { + "name": "id", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "recipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentVersion", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DepositError", + "inputs": [] + }, + { + "type": "error", + "name": "ERC1167FailedCreateClone", + "inputs": [] + }, + { + "type": "error", + "name": "EmptyArray", + "inputs": [] + }, + { + "type": "error", + "name": "EmptyWithdrawalRecipient", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidDepositSize", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidEmptyArray", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidEmptyString", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidMessageValue", + "inputs": [ + { + "name": "received", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "expected", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidNextRecipient", + "inputs": [ + { + "name": "nextRecipient", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "InvalidNullDedicatedRecipient", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidNullValue", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidPublicKeyLength", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidSignatureLength", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidValidationKey", + "inputs": [ + { + "name": "validationKey", + "type": "tuple", + "internalType": "struct IvFactory.ValidationKey", + "components": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ] + }, + { + "type": "error", + "name": "InvalidValidatorId", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "MerkleProofInvalidEndProofPointer", + "inputs": [] + }, + { + "type": "error", + "name": "MerkleProofInvalidMultiproof", + "inputs": [] + }, + { + "type": "error", + "name": "MerkleProofInvalidTotalHashes", + "inputs": [] + }, + { + "type": "error", + "name": "MinimalRecipientExecutionError", + "inputs": [ + { + "name": "rdata", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "RewardsForwardingFailed", + "inputs": [ + { + "name": "beneficiary", + "type": "address", + "internalType": "address" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "type": "error", + "name": "SafeCastOverflowedUintDowncast", + "inputs": [ + { + "name": "bits", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "SliceOutOfBounds", + "inputs": [] + }, + { + "type": "error", + "name": "SliceOverflow", + "inputs": [] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "expected", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ValidationKeyAlreadyActivated", + "inputs": [ + { + "name": "validationKey", + "type": "tuple", + "internalType": "struct IvFactory.ValidationKey", + "components": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ] + }, + { + "type": "error", + "name": "VerificationError", + "inputs": [ + { + "name": "validationKeys", + "type": "tuple[]", + "internalType": "struct IvFactory.ValidationKey[]", + "components": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "name": "proof", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "flagCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "flags", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } +] + diff --git a/abis/vOracleAggregator.2_2_0.json b/abis/vOracleAggregator.2_2_0.json new file mode 100644 index 0000000..7d5fe67 --- /dev/null +++ b/abis/vOracleAggregator.2_2_0.json @@ -0,0 +1,783 @@ +[ + { + "type": "function", + "name": "addMember", + "inputs": [ + { + "name": "member", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "factory", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "fix", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "globalMember", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "globalMemberEjected", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "highestReportedEpoch", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "vpool_", + "type": "address", + "internalType": "address" + }, + { + "name": "vfactory_", + "type": "address", + "internalType": "address" + }, + { + "name": "nexus_", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "members", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address[]", + "internalType": "address[]" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "nexus", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pool", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "quorum", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "ready", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "removeMember", + "inputs": [ + { + "name": "member", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reportingDetails", + "inputs": [], + "outputs": [ + { + "name": "reportVariants", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "reportVoteCount", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "reportVoteTracker", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setGlobalMemberEjectionStatus", + "inputs": [ + { + "name": "status", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "submitReport", + "inputs": [ + { + "name": "report", + "type": "tuple", + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "AddedOracleAggregatorMember", + "inputs": [ + { + "name": "member", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "GlobalMemberVoted", + "inputs": [ + { + "name": "globalMember", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "variant", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "report", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "cdata", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "MemberVoted", + "inputs": [ + { + "name": "member", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "variant", + "type": "bytes32", + "indexed": true, + "internalType": "bytes32" + }, + { + "name": "report", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RemovedOracleAggregatorMember", + "inputs": [ + { + "name": "member", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ReportingCleared", + "inputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "SetFactory", + "inputs": [ + { + "name": "factory", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetGlobalMemberEjectionStatus", + "inputs": [ + { + "name": "status", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetHighestReportedEpoch", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetNexus", + "inputs": [ + { + "name": "nexus", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetPool", + "inputs": [ + { + "name": "pool", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SubmittedReport", + "inputs": [ + { + "name": "report", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + }, + { + "name": "variant", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + }, + { + "name": "votes", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "variantCount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentVersion", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "AlreadyOracleAggregatorMember", + "inputs": [ + { + "name": "member", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "AlreadyReported", + "inputs": [ + { + "name": "member", + "type": "address", + "internalType": "address" + }, + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "EmptyMembersArray", + "inputs": [] + }, + { + "type": "error", + "name": "EpochInvalid", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "EpochTooOld", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "highestReportedEpoch", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "OracleNotReady", + "inputs": [] + }, + { + "type": "error", + "name": "SafeCastOverflowedIntToUint", + "inputs": [ + { + "name": "value", + "type": "int256", + "internalType": "int256" + } + ] + }, + { + "type": "error", + "name": "StatusNotChanged", + "inputs": [] + }, + { + "type": "error", + "name": "TooManyMembers", + "inputs": [] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "expected", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "UnknownOracleAggregatorMember", + "inputs": [ + { + "name": "member", + "type": "address", + "internalType": "address" + } + ] + } +] + diff --git a/abis/vPool.2_2_0.json b/abis/vPool.2_2_0.json new file mode 100644 index 0000000..7fa1b16 --- /dev/null +++ b/abis/vPool.2_2_0.json @@ -0,0 +1,2298 @@ +[ + { + "type": "function", + "name": "allowDepositor", + "inputs": [ + { + "name": "depositorAddress", + "type": "address", + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "consensusLayerSpec", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ctypes.ConsensusLayerSpec", + "components": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "coverInvalidActivations", + "inputs": [ + { + "name": "countToCover", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "coverageRecipient", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "coveredInvalidActivations", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint8", + "internalType": "uint8" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "decreaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "deposit", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "depositors", + "inputs": [ + { + "name": "depositorAddress", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "epochsPerFrame", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "ethers", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ctypes.Ethers", + "components": [ + { + "name": "deposited", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "committed", + "type": "uint128", + "internalType": "uint128" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "execLayerRecipient", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "exitQueue", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "factory", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "fix", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "increaseAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "addrs", + "type": "address[7]", + "internalType": "address[7]" + }, + { + "name": "epochsPerFrame_", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "consensusLayerSpec_", + "type": "tuple", + "internalType": "struct ctypes.ConsensusLayerSpec", + "components": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ] + }, + { + "name": "bounds_", + "type": "uint64[3]", + "internalType": "uint64[3]" + }, + { + "name": "operatorFeeBps_", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "extraData_", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "injectEther", + "inputs": [], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "isValidEpoch", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "lastEpoch", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "lastReport", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "onlyValidEpoch", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "view" + }, + { + "type": "function", + "name": "operatorFee", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "oracleAggregator", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "purchaseValidators", + "inputs": [ + { + "name": "$$", + "type": "tuple", + "internalType": "struct IvPoolDefinitions.PoolPurchaseFromRootParameters", + "components": [ + { + "name": "validationKeys", + "type": "tuple[]", + "internalType": "struct IvFactory.ValidationKey[]", + "components": [ + { + "name": "publicKey", + "type": "bytes", + "internalType": "bytes" + }, + { + "name": "signature", + "type": "bytes", + "internalType": "bytes" + } + ] + }, + { + "name": "proof", + "type": "bytes32[]", + "internalType": "bytes32[]" + }, + { + "name": "flagCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "flags", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "purchasedValidatorAtIndex", + "inputs": [ + { + "name": "idx", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "purchasedValidatorCount", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "purchasedValidators", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "rate", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "report", + "inputs": [ + { + "name": "rprt", + "type": "tuple", + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reportBounds", + "inputs": [], + "outputs": [ + { + "name": "maxAPRUpperBound", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxAPRUpperCoverageBoost", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxRelativeLowerBound", + "type": "uint64", + "internalType": "uint64" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "requestedExits", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "internalType": "uint32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setConsensusLayerSpec", + "inputs": [ + { + "name": "consensusLayerSpec_", + "type": "tuple", + "internalType": "struct ctypes.ConsensusLayerSpec", + "components": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setEpochsPerFrame", + "inputs": [ + { + "name": "newEpochsPerFrame", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setOperatorFee", + "inputs": [ + { + "name": "operatorFeeBps", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setReportBounds", + "inputs": [ + { + "name": "maxAPRUpperBound", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxAPRUpperCoverageBoost", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "maxRelativeLowerBound", + "type": "uint64", + "internalType": "uint64" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setValidatorGlobalExtraData", + "inputs": [ + { + "name": "extraData", + "type": "string", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalCovered", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupplies", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalUnderlyingSupply", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferShares", + "inputs": [ + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferSharesFrom", + "inputs": [ + { + "name": "from", + "type": "address", + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "uncoveredBalance", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "validatorGlobalExtraData", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "string", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "voidAllowance", + "inputs": [ + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "voidShares", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawalRecipient", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ApproveDepositor", + "inputs": [ + { + "name": "depositor", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "allowed", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Burn", + "inputs": [ + { + "name": "burner", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "totalSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Deposit", + "inputs": [ + { + "name": "sender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "mintedShares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "DistributedOperatorRewards", + "inputs": [ + { + "name": "operatorTreasury", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "sharesCount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "sharesValue", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "totalSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "totalUnderlyingSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "cdata", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "InjectedEther", + "inputs": [ + { + "name": "injecter", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "InvalidActivationCoveragePerformed", + "inputs": [ + { + "name": "newCoveredCount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "msgValueSent", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "pulledFromCoverageRecipient", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Mint", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "totalSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ProcessedReport", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "report", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ValidatorsReport", + "components": [ + { + "name": "balanceSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "skimmedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "slashedSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingSum", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxExitable", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "maxCommittable", + "type": "int256", + "internalType": "int256" + }, + { + "name": "epoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "activatedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "stoppedCount", + "type": "uint32", + "internalType": "uint32" + }, + { + "name": "invalidActivationCount", + "type": "uint32", + "internalType": "uint32" + } + ] + }, + { + "name": "traces", + "type": "tuple", + "indexed": false, + "internalType": "struct IvPoolDefinitions.ReportTraces", + "components": [ + { + "name": "preUnderlyingSupply", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "postUnderlyingSupply", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "preSupply", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "postSupply", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "newExitedEthers", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "newSkimmedEthers", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitBoostEthers", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitFedEthers", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitBurnedShares", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "exitingProjection", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "baseFulfillableDemand", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "extraFulfillableDemand", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "rewards", + "type": "int128", + "internalType": "int128" + }, + { + "name": "delta", + "type": "int128", + "internalType": "int128" + }, + { + "name": "increaseLimit", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "coverageIncreaseLimit", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "decreaseLimit", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "consensusLayerDelta", + "type": "int128", + "internalType": "int128" + }, + { + "name": "pulledCoverageFunds", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "pulledExecutionLayerRewards", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "pulledExitQueueUnclaimedFunds", + "type": "uint128", + "internalType": "uint128" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PurchasedValidators", + "inputs": [ + { + "name": "validators", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetCommittedEthers", + "inputs": [ + { + "name": "committedEthers", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetConsensusLayerSpec", + "inputs": [ + { + "name": "consensusLayerSpec", + "type": "tuple", + "indexed": false, + "internalType": "struct ctypes.ConsensusLayerSpec", + "components": [ + { + "name": "genesisTimestamp", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "epochsUntilFinal", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "slotsPerEpoch", + "type": "uint64", + "internalType": "uint64" + }, + { + "name": "secondsPerSlot", + "type": "uint64", + "internalType": "uint64" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetContractLinks", + "inputs": [ + { + "name": "factory", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "withdrawalRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "execLayerRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "coverageRecipient", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "oracleAggregator", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "exitQueue", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetCoveredInvalidActivationCount", + "inputs": [ + { + "name": "newCoveredInvalidActivationCount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetDepositedEthers", + "inputs": [ + { + "name": "depositedEthers", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetEpochsPerFrame", + "inputs": [ + { + "name": "epochsPerFrame", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetOperatorFee", + "inputs": [ + { + "name": "operatorFeeBps", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetReportBounds", + "inputs": [ + { + "name": "maxAPRUpperBound", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "maxAPRUpperCoverageBoost", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + }, + { + "name": "maxRelativeLowerBound", + "type": "uint64", + "indexed": false, + "internalType": "uint64" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetReportingDriver", + "inputs": [ + { + "name": "reportingDriver", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetRequestedExits", + "inputs": [ + { + "name": "newRequestedExits", + "type": "uint32", + "indexed": false, + "internalType": "uint32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetValidatorGlobalExtraData", + "inputs": [ + { + "name": "extraData", + "type": "string", + "indexed": false, + "internalType": "string" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "VoidedShares", + "inputs": [ + { + "name": "voider", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "AllowanceTooLow", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "operator", + "type": "address", + "internalType": "address" + }, + { + "name": "currentApproval", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "requiredAmount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "AlreadyInitialized", + "inputs": [ + { + "name": "version", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentVersion", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ApprovalAlreadyZero", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "BalanceTooLow", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "currentBalance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "requiredAmount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "BoostedBoundCrossed", + "inputs": [ + { + "name": "balanceIncrease", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximumAllowedBalanceIncrease", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximumAllowedCoverage", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "CoverageHigherThanLoss", + "inputs": [ + { + "name": "coverage", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "loss", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingExitedBalanceSum", + "inputs": [ + { + "name": "reportedExitedBalanceSum", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lastReportedExitedBalanceSum", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingInvalidActivationCount", + "inputs": [ + { + "name": "currentInvalidActivationCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "reportedInvalidActivationCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingSkimmedBalanceSum", + "inputs": [ + { + "name": "reportedSkimmedBalanceSum", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lastReportedSkimmedBalanceSum", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingSlashedBalanceSum", + "inputs": [ + { + "name": "reportedSlashedBalanceSum", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "lastReportedSlashedBalanceSum", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingStoppedValidatorCount", + "inputs": [ + { + "name": "previousStoppedValidatorCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "stoppedValidatorCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DecreasingValidatorCount", + "inputs": [ + { + "name": "previousValidatorCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "validatorCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "DepositTooLarge", + "inputs": [ + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "deposited", + "type": "uint128", + "internalType": "uint128" + } + ] + }, + { + "type": "error", + "name": "EmptyValidationKeyArray", + "inputs": [] + }, + { + "type": "error", + "name": "EpochNotFinal", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currentTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "finalTimestamp", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "EpochNotFrameFirst", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "EpochTooOld", + "inputs": [ + { + "name": "epoch", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "expectEpoch", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ExitingBalanceTooHigh", + "inputs": [ + { + "name": "exiting", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "balance", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InsufficientCoverageFunds", + "inputs": [ + { + "name": "amountToCover", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "coverageCapabilities", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidActivationCountTooHigh", + "inputs": [ + { + "name": "invalidActivationCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "activatedCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "depositedValidatorCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidActivationCoverageRequestTooHigh", + "inputs": [ + { + "name": "requested", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "available", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidBPSValue", + "inputs": [ + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximum", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidCoveredAmount", + "inputs": [ + { + "name": "covered", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidGenesisTimestamp", + "inputs": [ + { + "name": "genesisTimestamp", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "blockTimestamp", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "InvalidMessageValue", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidNullMint", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidNullValue", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidZeroAddress", + "inputs": [] + }, + { + "type": "error", + "name": "LowerBoundCrossed", + "inputs": [ + { + "name": "balanceDecrease", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximumAllowedBalanceDecrease", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "MathOverflowedMulDiv", + "inputs": [] + }, + { + "type": "error", + "name": "NotEnoughEthersForPurchase", + "inputs": [ + { + "name": "validatorCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "requiredEthers", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "availableEthers", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ReportingDriverNotContract", + "inputs": [ + { + "name": "driver", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ReportingDriverNotSet", + "inputs": [] + }, + { + "type": "error", + "name": "SafeCastOverflowedUintDowncast", + "inputs": [ + { + "name": "bits", + "type": "uint8", + "internalType": "uint8" + }, + { + "name": "value", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ShareReceiverError", + "inputs": [ + { + "name": "err", + "type": "string", + "internalType": "string" + } + ] + }, + { + "type": "error", + "name": "StoppedValidatorCountTooHigh", + "inputs": [ + { + "name": "stoppedValidatorsCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maxStoppedValidatorsCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "Unauthorized", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + }, + { + "name": "expected", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "UpperBoundCrossed", + "inputs": [ + { + "name": "balanceIncrease", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "maximumAllowedBalanceIncrease", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ValidatorCountTooHigh", + "inputs": [ + { + "name": "reportedValidatorCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "depositedValidatorCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "ValidatorsNotPurchased", + "inputs": [ + { + "name": "purchasedValidatorCount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "requestedValidatorPurchaseCount", + "type": "uint256", + "internalType": "uint256" + } + ] + } +] + diff --git a/schema.graphql b/schema.graphql index fe97171..61ebf7f 100644 --- a/schema.graphql +++ b/schema.graphql @@ -143,6 +143,20 @@ type Nexus @entity { oracleAggregatorHatcher: PluggableHatcher exitQueueHatcher: PluggableHatcher factories: [vFactory!]! @derivedFrom(field: "nexus") + drivers: [Driver!]! @derivedFrom(field: "nexus") + + createdAt: BigInt! + editedAt: BigInt! + createdAtBlock: BigInt! + editedAtBlock: BigInt! +} + +type Driver @entity { + id: String! + + address: Bytes! + name: String! + nexus: Nexus createdAt: BigInt! editedAt: BigInt! @@ -171,6 +185,9 @@ type vFactory @entity { operatorUrl: String! operatorIconUrl: String! + treeRoot: Bytes! + treeIPFSHash: String! + totalActivatedValidators: BigInt! cub: Cub! @@ -189,13 +206,10 @@ type WithdrawalChannel @entity { id: String! withdrawalChannel: Bytes! - total: BigInt! funded: BigInt! - limit: BigInt! keys: [ValidationKey!]! @derivedFrom(field: "withdrawalChannel") factory: vFactory! - lastValidatorRequest: ValidatorRequest depositors: [FactoryDepositor!]! @derivedFrom(field: "withdrawalChannel") lastExitTotal: BigInt! @@ -205,50 +219,6 @@ type WithdrawalChannel @entity { editedAtBlock: BigInt! } -type ValidatorRequest @entity { - id: String! - - requestedTotal: BigInt! - totalOnRequest: BigInt! - - withdrawalChannel: WithdrawalChannel! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type CommonValidationKeyEntry @entity { - id: String! - - publicKey: Bytes! - - validationKeyCount: BigInt! - validationKeys: [ValidationKey!]! @derivedFrom(field: "commonValidationKeyEntry") - - depositEventCount: BigInt! - depositEvents: [DepositEvent!]! @derivedFrom(field: "commonValidationKeyEntry") - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type PendingKeyValidationTracker @entity { - id: String! - - total: BigInt! - current: BigInt! -} - -type PendingKeyValidationRequest @entity { - id: String! - - key: String! -} - type ValidationKey @entity { id: String! @@ -256,34 +226,21 @@ type ValidationKey @entity { signature: Bytes! index: BigInt! - validSignature: Boolean - validationError: String - validationStatus: String - - commonValidationKeyEntry: CommonValidationKeyEntry! - - funded: FundedValidationKey - withdrawalChannel: WithdrawalChannel! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type FundedValidationKey @entity { - id: String! - validatorId: BigInt! - depositEvent: DepositEvent! - owner: Bytes depositor: FactoryDepositor! - withdrawalAddress: Bytes + withdrawalAddress: Bytes! feeRecipient: Bytes extraData: String + threshold: BigInt + owner: Bytes lastExitRequest: ExitRequest - validationKey: ValidationKey! + + validSignature: Boolean + validationError: String + validationStatus: String + + withdrawalChannel: WithdrawalChannel! createdAt: BigInt! editedAt: BigInt! @@ -296,7 +253,7 @@ type ExitRequest @entity { emitter: Bytes! - validator: FundedValidationKey! + validator: ValidationKey! createdAt: BigInt! editedAt: BigInt! @@ -309,7 +266,7 @@ type FactoryDepositor @entity { address: Bytes! withdrawalChannel: WithdrawalChannel! - fundedValidationKeys: [FundedValidationKey!]! @derivedFrom(field: "depositor") + validationKeys: [ValidationKey!]! @derivedFrom(field: "depositor") createdAt: BigInt! editedAt: BigInt! @@ -619,7 +576,7 @@ type PoolPurchasedValidator @entity { index: BigInt! pool: vPool! - fundedValidationKey: FundedValidationKey! + validationKey: ValidationKey! createdAt: BigInt! editedAt: BigInt! @@ -635,11 +592,12 @@ type Report @entity { exitedSum: BigInt! skimmedSum: BigInt! slashedSum: BigInt! - exiting: BigInt! + exitingSum: BigInt! maxExitable: BigInt! maxCommittable: BigInt! activatedCount: BigInt! stoppedCount: BigInt! + invalidActivationCount: BigInt! preUnderlyingSupply: BigInt! postUnderlyingSupply: BigInt! @@ -976,12 +934,13 @@ type OracleAggregatorReportVariant @entity { exitedSum: BigInt! skimmedSum: BigInt! slashedSum: BigInt! - exiting: BigInt! + exitingSum: BigInt! maxExitable: BigInt! maxCommittable: BigInt! epoch: BigInt! activatedCount: BigInt! stoppedCount: BigInt! + invalidActivationCount: BigInt! oracleAggregator: vOracleAggregator! @@ -1193,6 +1152,7 @@ type ERC20Deposit @entity { hash: Bytes! staker: Bytes! + recipient: Bytes! depositAmount: BigInt! mintedShares: BigInt! @@ -1253,299 +1213,7 @@ type ERC20Approval @entity { editedAtBlock: BigInt! } -# -# ███████ ██████ ██████ ██ ██ ███████ ███████ -# ██ ██ ██ ██ ███ ███ ██ ██ -# █████ ██████ ██ █████ ██ ██ ███████ ███████ -# ██ ██ ██ ██ ██ ██ ██ ██ -# ███████ ██ ██ ██████ ██ ██ ███████ ███████ -# - -type ERC1155Deposit @entity { - id: String! # txHash+integrationAddress+tokenId+stakerAddress - token: ERC1155! - - hash: Bytes! - - staker: Bytes! - depositAmount: BigInt! - # mintedShares: BigInt! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ERC1155Balance @entity { - id: String! # integrationAddress+tokenId+stakerAddress - token: ERC1155! - - staker: Bytes! - tokenBalance: BigInt! - totalDeposited: BigInt! - adjustedTotalDeposited: BigInt! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ERC1155Transfer @entity { - id: String! # eventLog+integrationAddress+tokenId - token: ERC1155! - - from: Bytes! - to: Bytes! - by: Bytes! - amount: BigInt! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ERC1155Approval @entity { - id: String! # integrationAddress+owner+spender - integration: ERC1155Integration! - - owner: Bytes! - operator: Bytes! - approval: Boolean! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ERC1155 @entity { - id: String! # integrationAddress+tokenId - - integration: ERC1155Integration! - tokenId: BigInt! - totalSupply: BigInt! - totalUnderlyingSupply: BigInt! - pool: MultiPool! - - deposits: [ERC1155Deposit!]! @derivedFrom(field: "token") - balances: [ERC1155Balance!]! @derivedFrom(field: "token") - transfers: [ERC1155Transfer!]! @derivedFrom(field: "token") - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ERC1155Integration implements vPoolIntegration & Integration @entity { - uriPrefix: String! - totalSupply: BigInt! - totalUnderlyingSupply: BigInt! - tokens: [ERC1155!]! @derivedFrom(field: "integration") - approvals: [ERC1155Approval!]! @derivedFrom(field: "integration") - - # vPoolIntegration - pools: [MultiPool!]! @derivedFrom(field: "integration") - commissions: [Commission!]! @derivedFrom(field: "vPoolIntegration") - maxCommission: BigInt! - - # Integration - id: Bytes! - address: Bytes! - channel: IntegrationChannel! - name: String! - symbol: String! - proxy: TUPProxy! - type: String! - - paused: Boolean! - admin: Bytes! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - - -# -# ██ ██ ███ ██ ███████ ████████ -# ██ ██ ████ ██ ██ ██ -# ██ ██ ██ ██ ██ █████ ██ -# ██ ██ ██ ██ ██ ██ ██ -# ████ ██ ████ ██ ██ -# - -type VaultClaim @entity { - id: String! # logIndex+vaultAddress - execLayerVault: MerkleVault! - - hash: Bytes! - - account: Bytes! - amount: BigInt! - totalClaimed: BigInt! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type MerkleVault @entity { - id: Bytes! - - root: Bytes! - frameSize: BigInt! - ipfsHash: String! - - integrations: [vNFTIntegration!]! @derivedFrom(field: "execLayerVault") - claims: [VaultClaim!]! @derivedFrom(field: "execLayerVault") - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type vNFTApprovals @entity { - id: String! # integrationAddress+owner+operator - integration: vNFTIntegration! - - owner: Bytes! - operator: Bytes! - approval: Boolean! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type vNFTIntegration implements Integration @entity { - vFactory: vFactory! - execLayerVault: MerkleVault! - operatorCommission: BigInt! - integratorCommission: BigInt! - integrator: Bytes! - proxy: TUPProxy! - type: String! - - soulboundMode: Boolean! - extraData: String! - uriPrefix: String! - supply: BigInt! - - vnfts: [vNFT!]! @derivedFrom(field: "integration") - approvals: [vNFTApprovals!]! @derivedFrom(field: "integration") - - # Integration - id: Bytes! - address: Bytes! - channel: IntegrationChannel! - name: String! - symbol: String! - - paused: Boolean! - admin: Bytes! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type vNFT @entity { - id: String! # integrationAddress+internalTokenId - tokenId: BigInt! - internalTokenId: BigInt! - integration: vNFTIntegration! - - owner: Bytes! - validator: FundedValidationKey! - - transfers: [vNFTTransfer!]! @derivedFrom(field: "vNFT") - user: vNFTUser @derivedFrom(field: "vNFT") - approval: Bytes - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type vNFTidsMapping @entity { - id: String! # integrationAddress+tokenId - - externalTokenId: BigInt! - internalTokenId: BigInt! -} - -type vNFTTransfer @entity { - id: String! # eventLog+integrationAddress+tokenId - vNFT: vNFT! - - from: Bytes! - to: Bytes! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type vNFTUser @entity { - id: String! # integrationAddress+tokenId - - vNFT: vNFT! - user: Bytes! - expiry: BigInt! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} - -type ExternalDepositLink @entity { - id: String! - - validationKey: ValidationKey! - depositEvent: DepositEvent! -} - -type DepositEvent @entity { - id: String! - - pubkey: Bytes! - withdrawalCredentials: Bytes! - amount: BigInt! - signature: Bytes! - index: BigInt! - - amountRaw: Bytes! - indexRaw: Bytes! - - validatorDepositIndex: BigInt! - - validationKeyActivation: [FundedValidationKey!]! @derivedFrom(field: "depositEvent") - commonValidationKeyEntry: CommonValidationKeyEntry! - - tx: Bytes! - logIndex: BigInt! - - validSignature: Boolean - validationError: String - verified: Boolean! - - createdAt: BigInt! - editedAt: BigInt! - createdAtBlock: BigInt! - editedAtBlock: BigInt! -} +# system events type G @entity { id: String! @@ -1645,7 +1313,7 @@ type FundedValidationKeySystemEvent implements SystemEvent @entity { count: BigInt! newTotal: BigInt! withdrawalChannel: WithdrawalChannel! - fundedValidationKeys: [FundedValidationKey!]! + validationKeys: [ValidationKey!]! createdAt: BigInt! createdAtBlock: BigInt! @@ -1693,7 +1361,7 @@ type ValidatorOwnerChangedSystemEvent implements SystemEvent @entity { oracleAggregator: vOracleAggregator exitQueue: vExitQueue - validator: FundedValidationKey! + validator: ValidationKey! oldOwner: Bytes! newOwner: Bytes! @@ -1701,32 +1369,7 @@ type ValidatorOwnerChangedSystemEvent implements SystemEvent @entity { createdAtBlock: BigInt! } -type ValidatorFeeRecipientChangedSystemEvent implements SystemEvent @entity { - id: String! - index: BigInt! - type: String! - - tx: Bytes! - who: Bytes! - - factory: vFactory - treasury: vTreasury - pool: vPool - withdrawalRecipient: vWithdrawalRecipient - execLayerRecipient: vExecLayerRecipient - coverageRecipient: vCoverageRecipient - oracleAggregator: vOracleAggregator - exitQueue: vExitQueue - - validator: FundedValidationKey! - oldFeeRecipient: Bytes! - newFeeRecipient: Bytes! - - createdAt: BigInt! - createdAtBlock: BigInt! -} - -type ValidatorExtraDataChangedSystemEvent implements SystemEvent @entity { +type ValidatorThresholdChangedSystemEvent implements SystemEvent @entity { id: String! index: BigInt! type: String! @@ -1743,15 +1386,15 @@ type ValidatorExtraDataChangedSystemEvent implements SystemEvent @entity { oracleAggregator: vOracleAggregator exitQueue: vExitQueue - validator: FundedValidationKey! - oldExtraData: String! - newExtraData: String! + validator: ValidationKey! + oldThreshold: BigInt! + newThreshold: BigInt! createdAt: BigInt! createdAtBlock: BigInt! } -type DuplicateKeySystemAlert implements SystemEvent @entity { +type ValidatorFeeRecipientChangedSystemEvent implements SystemEvent @entity { id: String! index: BigInt! type: String! @@ -1768,13 +1411,15 @@ type DuplicateKeySystemAlert implements SystemEvent @entity { oracleAggregator: vOracleAggregator exitQueue: vExitQueue - key: CommonValidationKeyEntry! + validator: ValidationKey! + oldFeeRecipient: Bytes! + newFeeRecipient: Bytes! createdAt: BigInt! createdAtBlock: BigInt! } -type ExternalFundingSystemAlert implements SystemEvent @entity { +type ValidatorExtraDataChangedSystemEvent implements SystemEvent @entity { id: String! index: BigInt! type: String! @@ -1791,8 +1436,9 @@ type ExternalFundingSystemAlert implements SystemEvent @entity { oracleAggregator: vOracleAggregator exitQueue: vExitQueue - key: CommonValidationKeyEntry! - logIndex: BigInt + validator: ValidationKey! + oldExtraData: String! + newExtraData: String! createdAt: BigInt! createdAtBlock: BigInt! @@ -2144,6 +1790,7 @@ type ERC20DepositSystemEvent implements SystemEvent @entity { depositedAmount: BigInt! mintedShares: BigInt! staker: Bytes! + recipient: Bytes! createdAt: BigInt! createdAtBlock: BigInt! diff --git a/src/DepositContract.mapping.ts b/src/DepositContract.mapping.ts deleted file mode 100644 index f40bffa..0000000 --- a/src/DepositContract.mapping.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { DepositEvent } from '../generated/DepositContract/DepositContract'; -import { DepositEvent as DepositEventEntity, CommonValidationKeyEntry } from '../generated/schema'; -import { verify } from './bls12_381_verify'; -import { - FORK_VERSIONS, - generateDepositDomain, - hashTreeRootDepositMessage, - hashTreeRootSigningData -} from './ssz_deposit_message'; -import { BigInt, dataSource } from '@graphprotocol/graph-ts'; -import { createExternalFundingSystemAlert } from './utils/utils'; - -export function handleDepositEvent(event: DepositEvent): void { - let depositIndex = 0; - let depositEventId = `${event.params.pubkey.toHexString()}-${depositIndex.toString()}`; - let depositEvent = DepositEventEntity.load(depositEventId); - while (depositEvent != null) { - depositIndex++; - depositEventId = `${event.params.pubkey.toHexString()}-${depositIndex.toString()}`; - depositEvent = DepositEventEntity.load(depositEventId); - } - - const deposit = new DepositEventEntity(depositEventId); - - deposit.tx = event.transaction.hash; - deposit.logIndex = event.logIndex; - deposit.validatorDepositIndex = BigInt.fromI32(depositIndex); - - deposit.pubkey = event.params.pubkey; - deposit.withdrawalCredentials = event.params.withdrawal_credentials; - deposit.signature = event.params.signature; - - let amountU64: u64; - { - const dataview = new DataView(event.params.amount.buffer); - amountU64 = dataview.getUint64(0, true); - deposit.amount = BigInt.fromU64(amountU64); - deposit.amountRaw = event.params.amount; - } - { - const dataview = new DataView(event.params.index.buffer); - const indexU64 = dataview.getUint64(0, true); - deposit.index = BigInt.fromU64(indexU64); - deposit.indexRaw = event.params.index; - } - - deposit.commonValidationKeyEntry = event.params.pubkey.toHexString(); - deposit.verified = false; - - deposit.createdAt = event.block.timestamp; - deposit.createdAtBlock = event.block.number; - deposit.editedAt = event.block.timestamp; - deposit.editedAtBlock = event.block.number; - - let commonValidationKeyEntry = CommonValidationKeyEntry.load(event.params.pubkey.toHexString()); - if (commonValidationKeyEntry == null) { - commonValidationKeyEntry = new CommonValidationKeyEntry(event.params.pubkey.toHexString()); - commonValidationKeyEntry.depositEventCount = BigInt.fromI32(0); - commonValidationKeyEntry.validationKeyCount = BigInt.fromI32(0); - commonValidationKeyEntry.publicKey = event.params.pubkey; - commonValidationKeyEntry.createdAt = event.block.timestamp; - commonValidationKeyEntry.createdAtBlock = event.block.number; - commonValidationKeyEntry.editedAt = event.block.timestamp; - commonValidationKeyEntry.editedAtBlock = event.block.number; - } - - commonValidationKeyEntry.depositEventCount = commonValidationKeyEntry.depositEventCount.plus(BigInt.fromI32(1)); - commonValidationKeyEntry.save(); - - if (commonValidationKeyEntry.validationKeyCount.gt(BigInt.zero())) { - const depositMessageRoot = hashTreeRootDepositMessage({ - pubkey: deposit.pubkey, - withdrawalCredentials: deposit.withdrawalCredentials, - amount: deposit.amount.toI64() - }); - - const forkVersion: Uint8Array = FORK_VERSIONS[dataSource.network() == 'mainnet' ? 0 : 1]; - const depositDomain: Uint8Array = generateDepositDomain(forkVersion); - - const signingRoot = hashTreeRootSigningData({ - objectRoot: depositMessageRoot, - domain: depositDomain - }); - - const signature_verification = verify(deposit.signature, signingRoot, deposit.pubkey); - - if (signature_verification.error != null || signature_verification.value == false) { - deposit.validSignature = false; - deposit.validationError = signature_verification.error; - } else { - deposit.validSignature = true; - const se = createExternalFundingSystemAlert(event, event.params.pubkey); - se.key = event.params.pubkey.toHexString(); - se.logIndex = event.logIndex; - se.save(); - } - deposit.verified = true; - } - - deposit.save(); -} diff --git a/src/ERC1155.mapping.ts b/src/ERC1155.mapping.ts deleted file mode 100644 index b40c02b..0000000 --- a/src/ERC1155.mapping.ts +++ /dev/null @@ -1,491 +0,0 @@ -import { Address, BigInt, ethereum } from '@graphprotocol/graph-ts'; -import { - ERC1155Integration, - MultiPool, - Commission, - ERC1155, - ERC1155Deposit, - ERC1155Balance, - ERC1155Transfer, - ERC1155Approval -} from '../generated/schema'; -import { Stake as Stake_1_0_0_rc4 } from '../generated/templates/ERC1155_1_0_0_rc4/Liquid1155'; -import { - ApprovalForAll, - CommissionWithdrawn, - NewCommissionSplit, - PoolActivation, - PoolAdded, - SetDepositsPaused, - SetFee, - SetMaxCommission, - SetName, - SetSymbol, - SetURIPrefix, - Stake, - TransferBatch, - TransferSingle, - VPoolSharesReceived, - SetAdmin, - CommissionSharesSold -} from '../generated/templates/ERC1155/Liquid1155'; -import { - eventUUID, - entityUUID, - getOrCreateUnassignedCommissionSold, - _computeIntegratorCommissionOwed -} from './utils/utils'; -import { getOrCreateBalance } from './vPool.mapping'; - -export function handleSetName(event: SetName): void { - const erc1155 = ERC1155Integration.load(event.address); - - erc1155!.name = event.params.name; - - erc1155!.editedAt = event.block.timestamp; - erc1155!.editedAtBlock = event.block.number; - - erc1155!.save(); -} - -export function handleSetURIPrefix(event: SetURIPrefix): void { - const erc1155 = ERC1155Integration.load(event.address); - - erc1155!.uriPrefix = event.params.uri; - - erc1155!.editedAt = event.block.timestamp; - erc1155!.editedAtBlock = event.block.number; - - erc1155!.save(); -} - -export function handleSetSymbol(event: SetSymbol): void { - const erc1155 = ERC1155Integration.load(event.address); - erc1155!.symbol = event.params.symbol; - - erc1155!.editedAt = event.block.timestamp; - erc1155!.editedAtBlock = event.block.number; - - erc1155!.save(); -} - -export function handleSetDepositsPaused(event: SetDepositsPaused): void { - const erc1155 = ERC1155Integration.load(event.address); - erc1155!.paused = event.params.isPaused; - - erc1155!.editedAt = event.block.timestamp; - erc1155!.editedAtBlock = event.block.number; - - erc1155!.save(); -} - -export function handleCommissionSharesSold(event: CommissionSharesSold): void { - const erc1155 = ERC1155Integration.load(event.address); - const multiPool = MultiPool.load(entityUUID(event, [event.params.id.toString()])); - multiPool!.soldEth = multiPool!.soldEth.plus(event.params.amountSold); - multiPool!.commissionPaid = multiPool!.commissionPaid.plus(event.params.amountSold); - const ucs = getOrCreateUnassignedCommissionSold(); - ucs.amount = event.params.amountSold; - ucs.tx = event.transaction.hash; - ucs.logIndex = event.logIndex; - ucs.active = true; - ucs.save(); -} - -export function handlePoolAdded(event: PoolAdded): void { - const vPool = event.params.poolAddress; - const poolId = event.params.id; - - const ts = event.block.timestamp; - const blockId = event.block.number; - - const tokenAndPoolId = entityUUID(event, [poolId.toString()]); - const multiPool = new MultiPool(tokenAndPoolId); - multiPool.number = poolId; - multiPool.pool = vPool; - multiPool.active = true; - multiPool.fees = BigInt.zero(); - multiPool.commissionPaid = BigInt.zero(); - multiPool.injectedEth = BigInt.zero(); - multiPool.exitedEth = BigInt.zero(); - multiPool.integration = event.address; - multiPool.poolAllocation = BigInt.zero(); - multiPool.soldEth = BigInt.zero(); - const poolBalance = getOrCreateBalance( - event.params.poolAddress, - event.address, - event.block.timestamp, - event.block.number - ); - poolBalance.editedAt = ts; - poolBalance.editedAtBlock = blockId; - multiPool.shares = poolBalance.id; - poolBalance.save(); - - multiPool.createdAt = ts; - multiPool.editedAt = ts; - multiPool.createdAtBlock = blockId; - multiPool.editedAtBlock = blockId; - - multiPool.save(); - - const erc1155 = new ERC1155(tokenAndPoolId); - erc1155.pool = tokenAndPoolId; - erc1155.integration = event.address; - erc1155.tokenId = poolId; - erc1155.totalSupply = BigInt.zero(); - erc1155.totalUnderlyingSupply = BigInt.zero(); - - erc1155.createdAt = ts; - erc1155.editedAt = ts; - erc1155.createdAtBlock = blockId; - erc1155.editedAtBlock = blockId; - - erc1155.save(); -} - -export function handleSetFee(event: SetFee): void { - const poolId = event.params.poolId; - const multiPool = MultiPool.load(entityUUID(event, [poolId.toString()])); - - multiPool!.fees = event.params.operatorFeeBps; - - multiPool!.editedAt = event.block.timestamp; - multiPool!.editedAtBlock = event.block.number; - - multiPool!.save(); -} - -export function handlePoolActivation(event: PoolActivation): void { - const poolId = event.params.id; - const multiPool = MultiPool.load(entityUUID(event, [poolId.toString()])); - - multiPool!.active = event.params.isActive; - - multiPool!.editedAt = event.block.timestamp; - multiPool!.editedAtBlock = event.block.number; - - multiPool!.save(); -} - -export function handleNewCommissionSplit(event: NewCommissionSplit): void { - const erc1155 = ERC1155Integration.load(event.address); - const recipients = event.params.recipients; - const splits = event.params.splits; - const ts = event.block.timestamp; - const blockId = event.block.number; - - for (let i = 0; i < recipients.length; i++) { - const recipient = recipients[i]; - const split = splits[i]; - - const id = entityUUID(event, [recipient.toHexString()]); - let commission = Commission.load(id); - - if (!commission) { - commission = new Commission(id); - commission.vPoolIntegration = erc1155!.id; - commission.withdrawnCommission = BigInt.fromI32(0); - commission.createdAt = ts; - commission.createdAtBlock = blockId; - } - - commission.commission = split; - commission.recipient = recipient; - - commission.editedAt = ts; - commission.editedAtBlock = blockId; - commission.save(); - } - - erc1155!.editedAt = ts; - erc1155!.editedAtBlock = blockId; - erc1155!.save(); -} - -export function handleCommissionWithdrawn(event: CommissionWithdrawn): void { - const erc1155 = ERC1155Integration.load(event.address); - const ts = event.block.timestamp; - const blockId = event.block.number; - - const id = entityUUID(event, [event.params.withdrawer.toHexString()]); - const commission = Commission.load(id); - commission!.withdrawnCommission = commission!.withdrawnCommission.plus(event.params.amountWithdrawn); - commission!.editedAt = ts; - commission!.editedAtBlock = blockId; - commission!.save(); - - erc1155!.editedAt = ts; - erc1155!.editedAtBlock = blockId; - erc1155!.save(); -} - -export function handleStake_1_0_0_rc4(event: Stake_1_0_0_rc4): void { - const tokenId = event.params.id; - const erc1155 = ERC1155.load(entityUUID(event, [tokenId.toString()])); - const erc1155Integration = ERC1155Integration.load(event.address); - - const ts = event.block.timestamp; - const blockId = event.block.number; - const staker = event.params.staker; - const value = event.params.ethValue; - - const depositId = eventUUID(event, [event.address.toHexString(), tokenId.toString(), staker.toHexString()]); - const deposit = new ERC1155Deposit(depositId); - deposit.token = erc1155!.id; - deposit.depositAmount = BigInt.zero(); - // deposit.mintedShares = BigInt.zero(); - deposit.hash = event.transaction.hash; - deposit.staker = staker; - - deposit.depositAmount = value; - - deposit.editedAt = ts; - deposit.editedAtBlock = blockId; - deposit.createdAt = ts; - deposit.createdAtBlock = blockId; - - erc1155!.totalUnderlyingSupply = erc1155!.totalUnderlyingSupply.plus(value); - erc1155Integration!.totalUnderlyingSupply = erc1155Integration!.totalUnderlyingSupply.plus(value); - - deposit.save(); - erc1155!.save(); - erc1155Integration!.save(); - - let balance = ERC1155Balance.load(entityUUID(event, [staker.toHexString()])); - if (balance == null) { - balance = new ERC1155Balance(entityUUID(event, [staker.toHexString()])); - balance.token = entityUUID(event, [tokenId.toString()]); - balance.staker = staker; - balance.tokenBalance = BigInt.zero(); - balance.totalDeposited = BigInt.zero(); - balance.adjustedTotalDeposited = BigInt.zero(); - balance.createdAt = ts; - balance.createdAtBlock = blockId; - balance.editedAt = ts; - balance.editedAtBlock = blockId; - balance.save(); - } - balance.totalDeposited = balance.totalDeposited.plus(event.params.ethValue); - balance.adjustedTotalDeposited = balance.adjustedTotalDeposited.plus(event.params.ethValue); - - const ucs = getOrCreateUnassignedCommissionSold(); - if (ucs.active && ucs.tx == event.transaction.hash) { - balance.totalDeposited = balance.totalDeposited.plus(ucs.amount); - balance.adjustedTotalDeposited = balance.adjustedTotalDeposited.plus(ucs.amount); - ucs.active = false; - ucs.save(); - } - - const poolId = event.params.id; - const multiPool = MultiPool.load(entityUUID(event, [poolId.toString()])); - multiPool!.injectedEth = multiPool!.injectedEth.plus(event.params.ethValue); - multiPool!.editedAt = ts; - multiPool!.editedAtBlock = blockId; - multiPool!.save(); - - balance.save(); -} - -export function handleStake(event: Stake): void { - const tokenId = event.params.stakeDetails[0].poolId; - const erc1155 = ERC1155.load(entityUUID(event, [tokenId.toString()])); - const erc1155Integration = ERC1155Integration.load(event.address); - - const ts = event.block.timestamp; - const blockId = event.block.number; - const staker = event.params.staker; - const value = event.params.depositedEth; - - const depositId = eventUUID(event, [event.address.toHexString(), tokenId.toString(), staker.toHexString()]); - const deposit = new ERC1155Deposit(depositId); - deposit.token = erc1155!.id; - deposit.depositAmount = BigInt.zero(); - // deposit.mintedShares = BigInt.zero(); - deposit.hash = event.transaction.hash; - deposit.staker = staker; - - deposit.depositAmount = value; - - deposit.editedAt = ts; - deposit.editedAtBlock = blockId; - deposit.createdAt = ts; - deposit.createdAtBlock = blockId; - - erc1155!.totalUnderlyingSupply = erc1155!.totalUnderlyingSupply.plus(value); - erc1155Integration!.totalUnderlyingSupply = erc1155Integration!.totalUnderlyingSupply.plus(value); - - deposit.save(); - erc1155!.save(); - erc1155Integration!.save(); - - let balance = ERC1155Balance.load(entityUUID(event, [staker.toHexString()])); - if (balance == null) { - balance = new ERC1155Balance(entityUUID(event, [staker.toHexString()])); - balance.token = entityUUID(event, [tokenId.toString()]); - balance.staker = staker; - balance.tokenBalance = BigInt.zero(); - balance.totalDeposited = BigInt.zero(); - balance.adjustedTotalDeposited = BigInt.zero(); - balance.createdAt = ts; - balance.createdAtBlock = blockId; - balance.editedAt = ts; - balance.editedAtBlock = blockId; - balance.save(); - } - balance.totalDeposited = balance.totalDeposited.plus(event.params.depositedEth); - balance.adjustedTotalDeposited = balance.adjustedTotalDeposited.plus(event.params.depositedEth); - - const ucs = getOrCreateUnassignedCommissionSold(); - if (ucs.active && ucs.tx == event.transaction.hash) { - balance.totalDeposited = balance.totalDeposited.plus(ucs.amount); - balance.adjustedTotalDeposited = balance.adjustedTotalDeposited.plus(ucs.amount); - ucs.active = false; - ucs.save(); - } - - const poolId = event.params.stakeDetails[0].poolId; - const multiPool = MultiPool.load(entityUUID(event, [poolId.toString()])); - multiPool!.injectedEth = multiPool!.injectedEth.plus(event.params.depositedEth); - multiPool!.editedAt = ts; - multiPool!.editedAtBlock = blockId; - multiPool!.save(); - - balance.save(); -} - -function _transfer( - event: ethereum.Event, - operator: Address, - from: Address, - to: Address, - tokenId: BigInt, - amount: BigInt -): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const erc1155 = ERC1155.load(entityUUID(event, [tokenId.toString()])); - const balanceFromId = entityUUID(event, [tokenId.toString(), from.toHexString()]); - const balanceToId = entityUUID(event, [tokenId.toString(), to.toHexString()]); - - if (from.equals(Address.zero())) { - erc1155!.totalSupply = erc1155!.totalSupply.plus(amount); - if (!ERC1155Balance.load(balanceToId)) { - const balanceTo = new ERC1155Balance(balanceToId); - balanceTo.token = erc1155!.id; - balanceTo.staker = to; - balanceTo.tokenBalance = BigInt.zero(); - balanceTo.totalDeposited = BigInt.zero(); - balanceTo.adjustedTotalDeposited = BigInt.zero(); - balanceTo.createdAt = ts; - balanceTo.createdAtBlock = blockId; - balanceTo.editedAt = ts; - balanceTo.editedAtBlock = blockId; - balanceTo.save(); - } - } - if (to.equals(Address.zero())) { - erc1155!.totalSupply = erc1155!.totalSupply.minus(amount); - } - erc1155!.save(); - - const balanceFrom = ERC1155Balance.load(balanceFromId); - const balanceTo = ERC1155Balance.load(balanceToId); - if (balanceFrom) { - const balanceBefore = balanceFrom.tokenBalance; - balanceFrom.tokenBalance = balanceFrom.tokenBalance.minus(amount); - balanceFrom.editedAt = ts; - balanceFrom.editedAtBlock = blockId; - balanceFrom.adjustedTotalDeposited = balanceFrom.adjustedTotalDeposited - .times(balanceFrom.tokenBalance) - .div(balanceBefore); - balanceFrom.save(); - } - - if (balanceTo) { - // in the case of a regular transfer (not mint), we need to adjust the total deposited values - if (from.notEqual(Address.zero())) { - const totalSupply = erc1155!.totalSupply; - const totalUnderlyingSupply = erc1155!.totalUnderlyingSupply; - balanceTo.totalDeposited = balanceTo.totalDeposited.plus(amount.times(totalUnderlyingSupply).div(totalSupply)); - balanceTo.adjustedTotalDeposited = balanceTo.adjustedTotalDeposited.plus( - amount.times(totalUnderlyingSupply).div(totalSupply) - ); - } - - balanceTo.tokenBalance = balanceTo.tokenBalance.plus(amount); - balanceTo.editedAt = ts; - balanceTo.editedAtBlock = blockId; - balanceTo.save(); - } - - const transferId = eventUUID(event, [tokenId.toString()]); - const transfer = new ERC1155Transfer(transferId); - transfer.token = erc1155!.id; - transfer.by = operator; - transfer.from = from; - transfer.to = to; - transfer.amount = amount; - transfer.createdAt = ts; - transfer.createdAtBlock = blockId; - transfer.editedAt = ts; - transfer.editedAtBlock = blockId; - - transfer.save(); -} - -export function handleTransferSingle(event: TransferSingle): void { - _transfer(event, event.params.operator, event.params.from, event.params.to, event.params.id, event.params.value); -} - -export function handleTransferBatch(event: TransferBatch): void { - for (let i = 0; i < event.params.ids.length; i++) { - _transfer( - event, - event.params.operator, - event.params.from, - event.params.to, - event.params.ids[i], - event.params.values[i] - ); - } -} - -export function handleApprovalForAll(event: ApprovalForAll): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const id = entityUUID(event, [event.params.account.toHexString(), event.params.operator.toHexString()]); - let approval = ERC1155Approval.load(id); - if (!approval) { - approval = new ERC1155Approval(id); - approval.owner = event.params.account; - approval.operator = event.params.operator; - approval.createdAt = ts; - approval.createdAtBlock = blockId; - } - - approval.approval = event.params.approved; - approval.editedAt = ts; - approval.editedAtBlock = blockId; - approval.save(); -} - -export function handleVPoolSharesReceived(event: VPoolSharesReceived): void {} - -export function handleSetAdmin(event: SetAdmin): void { - const erc1155Integration = ERC1155Integration.load(event.address); - erc1155Integration!.admin = event.params.admin; - erc1155Integration!.editedAt = event.block.timestamp; - erc1155Integration!.editedAtBlock = event.block.number; - erc1155Integration!.save(); -} - -export function handleSetMaxCommission(event: SetMaxCommission): void { - const erc1155Integration = ERC1155Integration.load(event.address); - erc1155Integration!.maxCommission = event.params.maxCommission; - erc1155Integration!.editedAt = event.block.timestamp; - erc1155Integration!.editedAtBlock = event.block.number; - erc1155Integration!.save(); -} diff --git a/src/ERC20.mapping.ts b/src/ERC20.mapping.ts index 3999dc1..b0fef6a 100644 --- a/src/ERC20.mapping.ts +++ b/src/ERC20.mapping.ts @@ -17,6 +17,7 @@ import { Ticket } from '../generated/schema'; import { Stake as Stake_1_0_0_rc4 } from '../generated/templates/ERC20_1_0_0_rc4/Native20'; +import { Stake as Stake_2_2_0 } from '../generated/templates/ERC20_2_2_0/Native20'; import { Approval, CommissionWithdrawn, @@ -46,7 +47,7 @@ import { createERC20DepositSystemEvent, createERC20ExitSystemEvent } from './utils/utils'; -import { CommissionSharesSold, ExitedCommissionShares } from '../generated/templates/ERC1155/Liquid1155'; +import { CommissionSharesSold, ExitedCommissionShares } from '../generated/templates/ERC20/Native20'; import { getOrCreateBalance } from './vPool.mapping'; import { pushEntryToSummaries } from './utils/rewards'; @@ -241,9 +242,9 @@ export function handleSetFee(event: SetFee): void { if (multiPool != null) { const poolBalance = PoolBalance.load(multiPool.shares); - if (poolBalance != null && poolBalance!.amount.gt(BigInt.zero())) { + if (poolBalance != null && poolBalance.amount.gt(BigInt.zero())) { const earnedBeforeFeeUpdate = _computeIntegratorCommissionEarned( - poolBalance!.amount, + poolBalance.amount, pool!.totalSupply, pool!.totalUnderlyingSupply, multiPool.injectedEth, @@ -251,7 +252,7 @@ export function handleSetFee(event: SetFee): void { multiPool.fees ); const earnedAfterFeeUpdate = _computeIntegratorCommissionEarned( - poolBalance!.amount, + poolBalance.amount, pool!.totalSupply, pool!.totalUnderlyingSupply, multiPool.injectedEth, @@ -384,6 +385,7 @@ export function handleStake_1_0_0_rc4(event: Stake_1_0_0_rc4): void { event, event.address, event.params.staker, + event.params.staker, event.params.ethValue.plus(ucs.amount), event.params.sharesBought ); @@ -392,6 +394,7 @@ export function handleStake_1_0_0_rc4(event: Stake_1_0_0_rc4): void { event, event.address, event.params.staker, + event.params.staker, event.params.ethValue, event.params.sharesBought ); @@ -399,6 +402,7 @@ export function handleStake_1_0_0_rc4(event: Stake_1_0_0_rc4): void { deposit.mintedShares = event.params.sharesBought; deposit.hash = event.transaction.hash; deposit.staker = staker; + deposit.recipient = staker; deposit.createdAt = ts; deposit.createdAtBlock = blockId; @@ -468,13 +472,96 @@ export function handleStake(event: Stake): void { const blockId = event.block.number; const staker = event.params.staker; - createERC20DepositSystemEvent(event, event.address, staker, event.params.depositedEth, event.params.mintedTokens); + createERC20DepositSystemEvent( + event, + event.address, + staker, + staker, + event.params.depositedEth, + event.params.mintedTokens + ); const deposit = new ERC20Deposit(eventUUID(event, [event.address.toHexString(), staker.toHexString()])); deposit.integration = event.address; deposit.mintedShares = event.params.mintedTokens; deposit.hash = event.transaction.hash; deposit.staker = staker; + deposit.recipient = staker; + deposit.createdAt = ts; + deposit.createdAtBlock = blockId; + deposit.depositAmount = event.params.depositedEth; + erc20!.totalUnderlyingSupply = erc20!.totalUnderlyingSupply.plus(event.params.depositedEth); + + deposit.editedAt = ts; + deposit.editedAtBlock = blockId; + + deposit.save(); + erc20!.save(); + + let balance = ERC20Balance.load(entityUUID(event, [staker.toHexString()])); + if (balance == null) { + balance = new ERC20Balance(entityUUID(event, [staker.toHexString()])); + balance.integration = event.address; + balance.staker = staker; + balance.sharesBalance = BigInt.zero(); + balance.totalDeposited = BigInt.zero(); + balance.adjustedTotalDeposited = BigInt.zero(); + balance.createdAt = ts; + balance.createdAtBlock = blockId; + balance.editedAt = ts; + balance.editedAtBlock = blockId; + } + balance.totalDeposited = balance.totalDeposited.plus(event.params.depositedEth); + balance.adjustedTotalDeposited = balance.adjustedTotalDeposited.plus(event.params.depositedEth); + + for (let i = 0; i < event.params.stakeDetails.length; i++) { + const stakeDetail = event.params.stakeDetails[i]; + const poolId = stakeDetail.poolId; + const multiPool = MultiPool.load(entityUUID(event, [poolId.toString()])); + multiPool!.injectedEth = multiPool!.injectedEth.plus(stakeDetail.ethToPool); + multiPool!.editedAt = ts; + multiPool!.editedAtBlock = blockId; + multiPool!.save(); + } + + balance.save(); + + erc20!.totalUnderlyingSupply = _recomputeERC20TotalUnderlyingSupply(Address.fromBytes(erc20!.address)); + erc20!.save(); + + const depositDataEntry = new DepositDataEntry(eventUUID(event, ['DepositDataEntry'])); + depositDataEntry.type = 'DepositDataEntry'; + depositDataEntry.depositedEth = event.params.depositedEth; + depositDataEntry.createdAt = event.block.timestamp; + depositDataEntry.editedAt = event.block.timestamp; + depositDataEntry.createdAtBlock = event.block.number; + depositDataEntry.editedAtBlock = event.block.number; + depositDataEntry.save(); + pushEntryToSummaries(event, Address.fromBytes(event.address), depositDataEntry); +} + +export function handleStake_2_2_0(event: Stake_2_2_0): void { + const erc20 = ERC20.load(event.address); + + const ts = event.block.timestamp; + const blockId = event.block.number; + const staker = event.params.recipient; + + createERC20DepositSystemEvent( + event, + event.address, + event.params.staker, + event.params.recipient, + event.params.depositedEth, + event.params.mintedTokens + ); + + const deposit = new ERC20Deposit(eventUUID(event, [event.address.toHexString(), staker.toHexString()])); + deposit.integration = event.address; + deposit.mintedShares = event.params.mintedTokens; + deposit.hash = event.transaction.hash; + deposit.staker = event.params.staker; + deposit.recipient = event.params.recipient; deposit.createdAt = ts; deposit.createdAtBlock = blockId; deposit.depositAmount = event.params.depositedEth; diff --git a/src/MerkleVault.mapping.ts b/src/MerkleVault.mapping.ts deleted file mode 100644 index 6afe30e..0000000 --- a/src/MerkleVault.mapping.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { MerkleVault, VaultClaim } from '../generated/schema'; -import { Claimed, SetFrameSize, SetRootAndIpfsHash } from '../generated/templates/MerkleVault/MerkleVault'; -import { eventUUID } from './utils/utils'; - -export function handleSetFrameSize(event: SetFrameSize): void { - const merkleVault = MerkleVault.load(event.address); - merkleVault!.frameSize = event.params.frameSize; - - merkleVault!.editedAt = event.block.timestamp; - merkleVault!.editedAtBlock = event.block.number; - merkleVault!.save(); -} - -export function handleSetRootAndIpfshash(event: SetRootAndIpfsHash): void { - const merkleVault = MerkleVault.load(event.address); - merkleVault!.root = event.params.root; - merkleVault!.ipfsHash = event.params.ipfsHash; - - merkleVault!.editedAt = event.block.timestamp; - merkleVault!.editedAtBlock = event.block.number; - merkleVault!.save(); -} - -export function handleClaimed(event: Claimed): void { - const merkleVault = MerkleVault.load(event.address); - - const claim = new VaultClaim(eventUUID(event, [])); - claim.execLayerVault = merkleVault!.id; - claim.hash = event.transaction.hash; - claim.account = event.params.account; - claim.amount = event.params.amount; - claim.totalClaimed = event.params.totalClaimed; - - claim.createdAt = event.block.timestamp; - claim.createdAtBlock = event.block.number; - claim.editedAt = event.block.timestamp; - claim.editedAtBlock = event.block.number; - - merkleVault!.editedAt = event.block.timestamp; - merkleVault!.editedAtBlock = event.block.number; - merkleVault!.save(); -} diff --git a/src/Nexus.mapping.ts b/src/Nexus.mapping.ts index 24a1eae..67fdfee 100644 --- a/src/Nexus.mapping.ts +++ b/src/Nexus.mapping.ts @@ -9,14 +9,18 @@ import { SetMinimalRecipientImplementation, SpawnedFactory, SpawnedPool, - SetAdmin + SetAdmin, + SetDriver } from '../generated/Nexus/Nexus'; import { vOracleAggregator as vOracleAggregatorTemplate, + vOracleAggregator_2_2_0 as vOracleAggregatorTemplate_2_2_0, vCoverageRecipient as vCoverageRecipientTemplate, vExecLayerRecipient as vExecLayerRecipientTemplate, vFactory as vFactoryTemplate, + vFactory_2_2_0 as vFactoryTemplate_2_2_0, vPool as vPoolTemplate, + vPool_2_2_0 as vPoolTemplate_2_2_0, vExitQueue as vExitQueueTemplate, vTreasury as vTreasuryTemplate } from '../generated/templates'; @@ -30,123 +34,12 @@ import { vWithdrawalRecipient, vOracleAggregator, vExitQueue, - PendingKeyValidationRequest, - ValidationKey, - WithdrawalChannel, - PendingKeyValidationTracker + Driver } from '../generated/schema'; -import { - FORK_VERSIONS, - generateDepositDomain, - hashTreeRootDepositMessage, - hashTreeRootSigningData -} from './ssz_deposit_message/index'; -import { Address, BigInt, ByteArray, Bytes, ethereum, log, crypto, dataSource } from '@graphprotocol/graph-ts'; +import { Address, BigInt, Bytes, ethereum } from '@graphprotocol/graph-ts'; import { getOrCreateRewardSummaries } from './utils/rewards'; -import { verify } from './bls12_381_verify'; import { getOrCreateTUPProxy } from './TUPProxy.mapping'; -function concat(b: ByteArray[]): ByteArray { - let res = new ByteArray(0); - for (let i = 0; i < b.length; i++) { - res = res.concat(b[i]); - } - return res; -} - -// due to an issue with the heap when verify a lot of signatures, we need this -// workaround to very the keys in an async manner. This is suboptimal and an -// alternative should be found as it slows down the whole indexing process -export function handleBlock(block: ethereum.Block): void { - const verificationTracker = getOrLoadVerificationTracker(); - - if (verificationTracker.current.lt(verificationTracker.total)) { - log.info('Found pending verifications !', []); - const from = verificationTracker.current; - let to = verificationTracker.total; - if (to.minus(from).gt(BigInt.fromI32(10))) { - to = from.plus(BigInt.fromI32(10)); - } - for (let i = from; i.lt(to); i = i.plus(BigInt.fromI32(1))) { - const keyReq = PendingKeyValidationRequest.load(i.toString()); - const key = ValidationKey.load(keyReq!.key); - const wc = WithdrawalChannel.load(key!.withdrawalChannel); - const factory = vFactory.load(wc!.factory); - let withdrawalCredentials: Bytes; - if (wc!.withdrawalChannel.toHexString() == '0x0000000000000000000000000000000000000000000000000000000000000000') { - withdrawalCredentials = Bytes.fromByteArray( - concat([ - ByteArray.fromHexString('0x010000000000000000000000'), - Bytes.fromUint8Array( - crypto - .keccak256( - concat([ - Bytes.fromHexString('0xff'), - factory!.address, - crypto.keccak256(key!.publicKey), - crypto.keccak256( - concat([ - Bytes.fromHexString('0x3d602d80600a3d3981f3363d3d373d3d3d363d73'), - factory!.minimalRecipientImplementation as Bytes, - Bytes.fromHexString('0x5af43d82803e903d91602b57fd5bf3') - ]) - ) - ]) - ) - .slice(12, 32) - ) - ]) - ); - } else { - withdrawalCredentials = wc!.withdrawalChannel; - } - - log.info('Starting verification for {}', [key!.publicKey.toHexString()]); - - const depositMessageRoot = hashTreeRootDepositMessage({ - pubkey: key!.publicKey, - withdrawalCredentials: withdrawalCredentials, - amount: 32000000000 - }); - - const forkVersion: Uint8Array = FORK_VERSIONS[dataSource.network() == 'mainnet' ? 0 : 1]; - const depositDomain: Uint8Array = generateDepositDomain(forkVersion); - - const signingRoot = hashTreeRootSigningData({ - objectRoot: depositMessageRoot, - domain: depositDomain - }); - - const signature_verification = verify(key!.signature, signingRoot, key!.publicKey); - - if (signature_verification.error != null || signature_verification.value == false) { - key!.validSignature = false; - key!.validationError = signature_verification.error; - } else { - key!.validSignature = true; - } - - key!.validationStatus = 'done'; - key!.save(); - - log.info('Finished verification for {}', [key!.publicKey.toHexString()]); - } - verificationTracker.current = to; - verificationTracker.save(); - } -} - -export function getOrLoadVerificationTracker(): PendingKeyValidationTracker { - let tracker = PendingKeyValidationTracker.load('global'); - if (tracker == null) { - tracker = new PendingKeyValidationTracker('global'); - tracker.total = BigInt.fromI32(0); - tracker.current = BigInt.fromI32(0); - tracker.save(); - } - return tracker; -} - function _getOrCreateNexus(addr: Bytes, event: ethereum.Event): Nexus { let nexus = Nexus.load(addr); if (nexus == null) { @@ -202,6 +95,8 @@ export function handleSpawnedFactory(event: SpawnedFactory): void { factory.cub = event.params.factory; factory.treasury = Address.zero(); factory.totalActivatedValidators = BigInt.zero(); + factory.treeRoot = Bytes.fromHexString('0x'); + factory.treeIPFSHash = ''; factory.operatorName = ''; factory.operatorUrl = ''; factory.operatorIconUrl = ''; @@ -213,6 +108,7 @@ export function handleSpawnedFactory(event: SpawnedFactory): void { factory.save(); vFactoryTemplate.create(event.params.factory); + vFactoryTemplate_2_2_0.create(event.params.factory); } export function handleSpawnedPool(event: SpawnedPool): void { { @@ -257,6 +153,7 @@ export function handleSpawnedPool(event: SpawnedPool): void { pool.save(); vPoolTemplate.create(event.params.pool); + vPoolTemplate_2_2_0.create(event.params.pool); } { const eq = new vExitQueue(event.params.exitQueue); @@ -352,7 +249,27 @@ export function handleSpawnedPool(event: SpawnedPool): void { oa.save(); vOracleAggregatorTemplate.create(event.params.oracleAggregator); + vOracleAggregatorTemplate_2_2_0.create(event.params.oracleAggregator); + } +} + +export function handleSetDriver(event: SetDriver): void { + const nexus = _getOrCreateNexus(event.address, event); + + let driver = Driver.load(event.params.key); + if (driver == null) { + driver = new Driver(event.params.key); + driver.name = event.params.key; + driver.createdAt = event.block.timestamp; + driver.createdAtBlock = event.block.number; + driver.nexus = nexus.id; } + driver.address = event.params.driver; + + driver.editedAt = event.block.timestamp; + driver.editedAtBlock = event.block.number; + + driver.save(); } export function handleSetCoreHatchers(event: SetCoreHatchers): void { diff --git a/src/ProxyFactory.mapping.ts b/src/ProxyFactory.mapping.ts index 5c9cb7b..a93a64d 100644 --- a/src/ProxyFactory.mapping.ts +++ b/src/ProxyFactory.mapping.ts @@ -2,6 +2,7 @@ import { ERC20 } from '../generated/schema'; import { ERC20 as ERC20Template, ERC20_1_0_0_rc4 as ERC20_1_0_0_rc4Template, + ERC20_2_2_0 as ERC20_2_2_0Template, Native20_Fix_09_12_Oracle_Report } from '../generated/templates'; import { DeployedProxy } from '../generated/templates/ProxyFactory/ProxyFactory'; @@ -37,6 +38,7 @@ export function handleDeployedProxy(event: DeployedProxy): void { } ERC20Template.create(event.params.proxy); ERC20_1_0_0_rc4Template.create(event.params.proxy); + ERC20_2_2_0Template.create(event.params.proxy); Native20_Fix_09_12_Oracle_Report.create(event.params.proxy); const integration = new ERC20(event.params.proxy); @@ -68,65 +70,4 @@ export function handleDeployedProxy(event: DeployedProxy): void { integration.save(); } - // else if ( - // channel.equals(CHANNEL_NATIVE_1155_vPOOL_BYTES32) || - // channel.equals(CHANNEL_LIQUID_1155_vPOOL_vPOOL_BYTES32) - // ) { - // ERC1155Template.create(event.params.proxy); - // ERC1155_1_0_0_rc4Template.create(event.params.proxy); - - // const integration = new ERC1155Integration(event.params.proxy); - // integration.proxy = getOrCreateTUPProxy(event, event.params.proxy).id; - // integration.address = event.params.proxy; - // integration.channel = channel; - // integration.paused = false; - // integration.name = ''; - // integration.symbol = ''; - // integration.uriPrefix = ''; - // integration.totalSupply = BigInt.zero(); - // integration.totalUnderlyingSupply = BigInt.zero(); - - // integration.createdAt = event.block.timestamp; - // integration.editedAt = event.block.timestamp; - // integration.createdAtBlock = event.block.number; - // integration.editedAtBlock = event.block.number; - // integration.admin = Address.zero(); - // integration.maxCommission = BigInt.zero(); - // if (channel.equals(CHANNEL_NATIVE_1155_vPOOL_BYTES32)) { - // integration.type = 'Native1155'; - // } else if (channel.equals(CHANNEL_LIQUID_1155_vPOOL_vPOOL_BYTES32)) { - // integration.type = 'Liquid1155'; - // } - - // integration.save(); - // } else if (channel.equals(CHANNEL_VNFT_BYTES32)) { - // vNFTTemplate.create(event.params.proxy); - - // const vnft = new vNFTIntegration(event.params.proxy); - // vnft.proxy = getOrCreateTUPProxy(event, event.params.proxy).id; - // vnft.address = event.params.proxy; - // vnft.channel = channel; - // vnft.paused = false; - // vnft.name = ''; - // vnft.symbol = ''; - // vnft.uriPrefix = ''; - // vnft.supply = BigInt.zero(); - // vnft.operatorCommission = BigInt.zero(); - // vnft.integratorCommission = BigInt.zero(); - // vnft.integrator = Address.zero(); - // vnft.vFactory = Address.zero(); - // vnft.extraData = ''; - // vnft.execLayerVault = Address.zero(); - // vnft.soulboundMode = false; - // vnft.admin = Address.zero(); - // vnft.type = 'vNFT'; - - // vnft.createdAt = event.block.timestamp; - // vnft.editedAt = event.block.timestamp; - // vnft.createdAtBlock = event.block.number; - // vnft.editedAtBlock = event.block.number; - - // vnft.save(); - // } - // else if () {} } diff --git a/src/bls12_381_verify/index.ts b/src/bls12_381_verify/index.ts deleted file mode 100644 index 246a784..0000000 --- a/src/bls12_381_verify/index.ts +++ /dev/null @@ -1,2603 +0,0 @@ -// manual transpilation of https://github.com/paulmillr/noble-bls12-381 -import { log } from 'matchstick-as'; -import { BigInt as BI, Bytes } from '@graphprotocol/graph-ts'; -import { Sha256 } from '../sha256'; - -class Curve { - P: BI; - r: BI; - h: BI; - Gx: BI; - Gy: BI; - b: BI; - P2: BI; - h2: BI; - G2x: BI[]; - G2y: BI[]; - b2: BI[]; - x: BI; - h2Eff: BI; -} - -class Htf { - DST: string; - p: BI; - m: i32; - k: f64; - expand: boolean; - hash: Hash; -} - -class Reim { - re: BI; - im: BI; -} - -class Fp4SquareResult { - first: Fp2; - second: Fp2; -} - -class SqrtResult { - success: boolean; - sqrtCandidateOrGamma: Fp2; -} - -class FporError { - value: Fp | null; - error: string | null; -} - -class Fp2orError { - value: Fp2 | null; - error: string | null; -} - -class Fp6orError { - value: Fp6 | null; - error: string | null; -} - -class Fp12orError { - value: Fp12 | null; - error: string | null; -} -class PointG1orError { - value: PointG1 | null; - error: string | null; -} - -class FPArrayorError { - value: Array | null; - error: string | null; -} - -class FP2ArrayorError { - value: Array | null; - error: string | null; -} - -class PointG2orError { - value: PointG2 | null; - error: string | null; -} - -class BooleanOrError { - value: boolean; - error: string | null; -} - -class FP2_2DArrayorError { - value: Array> | null; - error: string | null; -} - -class BIorError { - value: BI | null; - error: string | null; -} - -class U8AorError { - value: Uint8Array | null; - error: string | null; -} - -class BI_2DArrayorError { - value: Array> | null; - error: string | null; -} - -type Hash = (msg: Uint8Array) => Uint8Array; -type Fp2_4 = Array; - -const CURVE: Curve = { - P: biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab'), - r: biFromHex('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001'), - h: biFromHex('0x396c8c005555e1568c00aaab0000aaab'), - Gx: biFromHex('0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb'), - Gy: biFromHex('0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1'), - b: biFromHex('0x04'), - P2: biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab') - .pow(2) - .minus(BI.fromI32(1)), - h2: biFromHex( - '0x05d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5' - ), - G2x: [ - biFromHex('0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8'), - biFromHex('0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e') - ], - G2y: [ - biFromHex('0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801'), - biFromHex('0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be') - ], - b2: [biFromHex('0x04'), biFromHex('0x04')], - x: biFromHex('0xd201000000010000'), - h2Eff: biFromHex( - '0x0bc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551' - ) -}; - -const sha256 = (msg: Uint8Array): Uint8Array => { - const st = new Sha256(); - for (let i = 0; i < msg.length; i += 64) { - st.update(msg.slice(i, i + 64)); - } - return st.final(); -}; - -const htfDefaults: Htf = { - // DST: a domain separation tag - // defined in section 2.2.5 - // Use utils.getDSTLabel(), utils.setDSTLabel(value) - DST: 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_', - // p: the characteristic of F - // where F is a finite field of characteristic p and order q = p^m - p: CURVE.P, - // m: the extension degree of F, m >= 1 - // where F is a finite field of characteristic p and order q = p^m - m: 2, - // k: the target security level for the suite in bits - // defined in section 5.1 - k: 128, - // option to use a message that has already been processed by - // expand_message_xmd - expand: true, - // Hash functions for: expand_message_xmd is appropriate for use with a - // wide range of hash functions, including SHA-2, SHA-3, BLAKE2, and others. - // BBS+ uses blake2: https://github.com/hyperledger/aries-framework-go/issues/2247 - hash: sha256 -}; - -class Fp { - static readonly ORDER: BI = CURVE.P; - static readonly ZERO: Fp = new Fp(BI.zero()); - static readonly ONE: Fp = new Fp(BI.fromI32(1)); - - readonly value: BI; - - constructor(value: BI) { - this.value = mod(value, Fp.ORDER); - } - - log(name: string, depth: i32): void { - log.info(genZeroes(depth) + 'fp ' + name, []); - log.info(genZeroes(depth + 2) + 'value: ' + this.value.toString(), []); - } - - pow(n: BI): FporError { - const pm_res = powMod(this.value, n, Fp.ORDER); - if (pm_res.error != null) { - return { - value: null, - error: pm_res.error - }; - } - return { - value: new Fp(pm_res.value!), - error: null - }; - } - - plus(rhs: Fp): Fp { - return new Fp(this.value.plus(rhs.value)); - } - - sqrt(): FporError | null { - const root_res = this.pow(Fp.ORDER.plus(BI.fromI32(1)).div(BI.fromI32(4))); - if (root_res.error != null) { - return { - value: null, - error: root_res.error - }; - } - const root = root_res.value!; - if (!root.square().equals(this)) return null; - return { - value: root, - error: null - }; - } - - square(): Fp { - return new Fp(this.value.times(this.value)); - } - - equals(rhs: Fp): boolean { - return this.value.equals(rhs.value); - } - - negate(): Fp { - return new Fp(this.value.times(BI_neg_one)); - } - - isZero(): boolean { - return this.value.equals(BI.zero()); - } - - multiply(rhs: Fp): Fp { - return new Fp(this.value.times(rhs.value)); - } - - multiplyBI(rhs: BI): Fp { - return new Fp(this.value.times(rhs)); - } - - subtract(rhs: Fp): Fp { - return new Fp(this.value.minus(rhs.value)); - } - - invert(): FporError { - const res = invert(this.value, Fp.ORDER); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - return { - value: new Fp(res.value!), - error: null - }; - } - - add(rhs: Fp): Fp { - return new Fp(this.value.plus(rhs.value)); - } -} - -class Fp2 { - static readonly ORDER: BI = CURVE.P2; - static readonly MAX_BITS: i32 = bitLen(CURVE.P); - static readonly BYTES_LEN: i32 = i32(Math.ceil(Fp2.MAX_BITS / 8)); - static readonly ZERO: Fp2 = new Fp2(Fp.ZERO, Fp.ZERO); - static readonly ONE: Fp2 = new Fp2(Fp.ONE, Fp.ZERO); - - constructor(readonly c0: Fp, readonly c1: Fp) {} - mulByNonresidue(): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - return new Fp2(c0.subtract(c1), c0.plus(c1)); - } - isZero(): boolean { - return this.c0.isZero() && this.c1.isZero(); - } - static fromBigTuple(tuple: BI[]): Fp2 { - return new Fp2(new Fp(tuple[0]), new Fp(tuple[1])); - } - pow(n: BI): Fp2 { - return powMod_FQP(this, Fp2.ONE, n); - } - - log(name: string, depth: i32): void { - log.info(genZeroes(depth) + 'fp2 ' + name, []); - this.c0.log(name, depth + 2); - this.c1.log(name, depth + 2); - } - - multiply(rhs: Fp2): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - const r0 = rhs.c0; - const r1 = rhs.c1; - // (a+bi)(c+di) = (ac−bd) + (ad+bc)i - let t1 = c0.multiply(r0); // c0 * o0 - let t2 = c1.multiply(r1); // c1 * o1 - // (T1 - T2) + ((c0 + c1) * (r0 + r1) - (T1 + T2))*i - return new Fp2(t1.subtract(t2), c0.plus(c1).multiply(r0.plus(r1)).subtract(t1.plus(t2))); - } - - multiplyBI(rhs: BI): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - return new Fp2(c0.multiplyBI(rhs), c1.multiplyBI(rhs)); - } - - square(): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - const a = c0.plus(c1); - const b = c0.subtract(c1); - const c = c0.plus(c0); - return new Fp2(a.multiply(b), c.multiply(c1)); - } - - add(rhs: Fp2): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - const r0 = rhs.c0; - const r1 = rhs.c1; - return new Fp2(c0.plus(r0), c1.plus(r1)); - } - - negate(): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - return new Fp2(c0.negate(), c1.negate()); - } - - subtract(rhs: Fp2): Fp2 { - const c0 = this.c0; - const c1 = this.c1; - const r0 = rhs.c0; - const r1 = rhs.c1; - return new Fp2(c0.subtract(r0), c1.subtract(r1)); - } - - sqrt(): Fp2orError | null { - // TODO: Optimize this line. It's extremely slow. - // Speeding this up would boost aggregateSignatures. - // https://eprint.iacr.org/2012/685.pdf applicable? - // https://github.com/zkcrypto/bls12_381/blob/080eaa74ec0e394377caa1ba302c8c121df08b07/src/fp2.rs#L250 - // https://github.com/supranational/blst/blob/aae0c7d70b799ac269ff5edf29d8191dbd357876/src/exp2.c#L1 - // Inspired by https://github.com/dalek-cryptography/curve25519-dalek/blob/17698df9d4c834204f83a3574143abacb4fc81a5/src/field.rs#L99 - const candidateSqrt = this.pow(Fp2.ORDER.plus(BI.fromI32(8)).div(BI.fromI32(16))); - const check_res = candidateSqrt.square().div(this); - if (check_res.error != null) { - return { - value: null, - error: check_res.error - }; - } - const check = check_res.value!; - const R = FP2_ROOTS_OF_UNITY; - // const divisor = [R[0], R[2], R[4], R[6]].find((r) => r.equals(check)); - let divisor: Fp2; - let index: i32; - if (check.equals(R[0])) { - divisor = R[0]; - index = 0; - } else if (check.equals(R[2])) { - divisor = R[2]; - index = 2; - } else if (check.equals(R[4])) { - divisor = R[4]; - index = 4; - } else if (check.equals(R[6])) { - divisor = R[6]; - index = 6; - } else { - return null; - } - const root = R[index / 2]; - if (!root) { - return { - value: null, - error: 'Invalid root' - }; - } - const x1_res = candidateSqrt.div(root); - if (x1_res.error != null) { - return { - value: null, - error: x1_res.error - }; - } - const x1 = x1_res.value!; - const x2 = x1.negate(); - const reim1 = x1.reim(); - const re1 = reim1.re; - const im1 = reim1.im; - const reim2 = x2.reim(); - const re2 = reim2.re; - const im2 = reim2.im; - if (im1.gt(im2) || (im1.equals(im2) && re1.gt(re2))) - return { - value: x1, - error: null - }; - return { - value: x2, - error: null - }; - } - reim(): Reim { - return { re: this.c0.value, im: this.c1.value }; - } - - invert(): Fp2orError { - const reim = this.reim(); - - const a = reim.re; - const b = reim.im; - const res = new Fp(a.times(a).plus(b.times(b))).invert(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const factor = res.value!; - return { - value: new Fp2(factor.multiply(new Fp(a)), factor.multiply(new Fp(b.times(BI_neg_one)))), - error: null - }; - } - - div(rhs: Fp2): Fp2orError { - const res = rhs.invert(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const inv = res.value!; - return { - value: this.multiply(inv), - error: null - }; - } - - divBI(rhs: BI): Fp2orError { - const res = new Fp(rhs).invert(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const inv = res.value!; - return { - value: this.multiplyBI(inv.value), - error: null - }; - } - - equals(rhs: Fp2): boolean { - const c0 = this.c0; - const c1 = this.c1; - const r0 = rhs.c0; - const r1 = rhs.c1; - return c0.equals(r0) && c1.equals(r1); - } - - // Raises to q**i -th power - frobeniusMap(power: i32): Fp2 { - return new Fp2(this.c0, this.c1.multiply(FP2_FROBENIUS_COEFFICIENTS[power % 2])); - } - - multiplyByB(): Fp2 { - let c0 = this.c0; - let c1 = this.c1; - let t0 = c0.multiplyBI(BI.fromI32(4)); // 4 * c0 - let t1 = c1.multiplyBI(BI.fromI32(4)); // 4 * c1 - // (T0-T1) + (T0+T1)*i - return new Fp2(t0.subtract(t1), t0.add(t1)); - } -} - -class Fp6 { - static readonly ZERO: Fp6 = new Fp6(Fp2.ZERO, Fp2.ZERO, Fp2.ZERO); - static readonly ONE: Fp6 = new Fp6(Fp2.ONE, Fp2.ZERO, Fp2.ZERO); - static readonly BYTES_LEN: i32 = 3 * Fp2.BYTES_LEN; - constructor(readonly c0: Fp2, readonly c1: Fp2, readonly c2: Fp2) {} - multiply(rhs: Fp6): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - const r0 = rhs.c0; - const r1 = rhs.c1; - const r2 = rhs.c2; - let t0 = c0.multiply(r0); // c0 * o0 - let t1 = c1.multiply(r1); // c1 * o1 - let t2 = c2.multiply(r2); // c2 * o2 - return new Fp6( - // t0 + (c1 + c2) * (r1 * r2) - (T1 + T2) * (u + 1) - t0.add(c1.add(c2).multiply(r1.add(r2)).subtract(t1.add(t2)).mulByNonresidue()), - // (c0 + c1) * (r0 + r1) - (T0 + T1) + T2 * (u + 1) - c0.add(c1).multiply(r0.add(r1)).subtract(t0.add(t1)).add(t2.mulByNonresidue()), - // T1 + (c0 + c2) * (r0 + r2) - T0 + T2 - t1.add(c0.add(c2).multiply(r0.add(r2)).subtract(t0.add(t2))) - ); - } - multiplyBI(rhs: BI): Fp6 { - return new Fp6(this.c0.multiplyBI(rhs), this.c1.multiplyBI(rhs), this.c2.multiplyBI(rhs)); - } - - log(name: string, depth: i32): void { - log.info(genZeroes(depth) + 'fp6 ' + name, []); - this.c0.log(name, depth + 2); - this.c1.log(name, depth + 2); - this.c2.log(name, depth + 2); - } - - plus(rhs: Fp6): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - const r0 = rhs.c0; - const r1 = rhs.c1; - const r2 = rhs.c2; - return new Fp6(c0.add(r0), c1.add(r1), c2.add(r2)); - } - - subtract(rhs: Fp6): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - const r0 = rhs.c0; - const r1 = rhs.c1; - const r2 = rhs.c2; - return new Fp6(c0.subtract(r0), c1.subtract(r1), c2.subtract(r2)); - } - - equals(rhs: Fp6): boolean { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - const r0 = rhs.c0; - const r1 = rhs.c1; - const r2 = rhs.c2; - return c0.equals(r0) && c1.equals(r1) && c2.equals(r2); - } - - mulByNonresidue(): Fp6 { - return new Fp6(this.c2.mulByNonresidue(), this.c0, this.c1); - } - - isZero(): boolean { - return this.c0.isZero() && this.c1.isZero() && this.c2.isZero(); - } - - square(): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - let t0 = c0.square(); // c0² - let t1 = c0.multiply(c1).multiplyBI(BI.fromI32(2)); // 2 * c0 * c1 - let t3 = c1.multiply(c2).multiplyBI(BI.fromI32(2)); // 2 * c1 * c2 - let t4 = c2.square(); // c2² - return new Fp6( - t3.mulByNonresidue().add(t0), // T3 * (u + 1) + T0 - t4.mulByNonresidue().add(t1), // T4 * (u + 1) + T1 - // T1 + (c0 - c1 + c2)² + T3 - T0 - T4 - t1.add(c0.subtract(c1).add(c2).square()).add(t3).subtract(t0).subtract(t4) - ); - } - - invert(): Fp6orError { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - let t0 = c0.square().subtract(c2.multiply(c1).mulByNonresidue()); // c0² - c2 * c1 * (u + 1) - let t1 = c2.square().mulByNonresidue().subtract(c0.multiply(c1)); // c2² * (u + 1) - c0 * c1 - let t2 = c1.square().subtract(c0.multiply(c2)); // c1² - c0 * c2 - // 1/(((c2 * T1 + c1 * T2) * v) + c0 * T0) - const t4_res = c2.multiply(t1).add(c1.multiply(t2)).mulByNonresidue().add(c0.multiply(t0)).invert(); - if (t4_res.error != null) { - return { - value: null, - error: t4_res.error - }; - } - const t4 = t4_res.value!; - - return { - value: new Fp6(t4.multiply(t0), t4.multiply(t1), t4.multiply(t2)), - error: null - }; - } - - negate(): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - return new Fp6(c0.negate(), c1.negate(), c2.negate()); - } - - multiplyByFp2(rhs: Fp2): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - return new Fp6(c0.multiply(rhs), c1.multiply(rhs), c2.multiply(rhs)); - } - - frobeniusMap(power: i32): Fp6 { - return new Fp6( - this.c0.frobeniusMap(power), - this.c1.frobeniusMap(power).multiply(FP6_FROBENIUS_COEFFICIENTS_1[power % 6]), - this.c2.frobeniusMap(power).multiply(FP6_FROBENIUS_COEFFICIENTS_2[power % 6]) - ); - } - - multiplyBy1(b1: Fp2): Fp6 { - return new Fp6(this.c2.multiply(b1).mulByNonresidue(), this.c0.multiply(b1), this.c1.multiply(b1)); - } - // Sparse multiplication - multiplyBy01(b0: Fp2, b1: Fp2): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - let t0 = c0.multiply(b0); // c0 * b0 - let t1 = c1.multiply(b1); // c1 * b1 - return new Fp6( - // ((c1 + c2) * b1 - T1) * (u + 1) + T0 - c1.add(c2).multiply(b1).subtract(t1).mulByNonresidue().add(t0), - // (b0 + b1) * (c0 + c1) - T0 - T1 - b0.add(b1).multiply(c0.add(c1)).subtract(t0).subtract(t1), - // (c0 + c2) * b0 - T0 + T1 - c0.add(c2).multiply(b0).subtract(t0).add(t1) - ); - } - - add(rhs: Fp6): Fp6 { - const c0 = this.c0; - const c1 = this.c1; - const c2 = this.c2; - const r0 = rhs.c0; - const r1 = rhs.c1; - const r2 = rhs.c2; - return new Fp6(c0.add(r0), c1.add(r1), c2.add(r2)); - } -} - -class Fp12 { - static readonly ZERO: Fp12 = new Fp12(Fp6.ZERO, Fp6.ZERO); - static readonly ONE: Fp12 = new Fp12(Fp6.ONE, Fp6.ZERO); - static readonly BYTES_LEN: i32 = 2 * Fp6.BYTES_LEN; - - constructor(readonly c0: Fp6, readonly c1: Fp6) {} - - multiply(other: Fp12): Fp12 { - const c0 = this.c0; - const c1 = this.c1; - const r0 = other.c0; - const r1 = other.c1; - const t1 = c0.multiply(r0); - const t2 = c1.multiply(r1); - return new Fp12(t1.plus(t2.mulByNonresidue()), c0.plus(c1).multiply(r0.plus(r1)).subtract(t1.plus(t2))); - } - - log(name: string, depth: i32): void { - log.info(genZeroes(depth) + 'fp12 ' + name, []); - this.c0.log(name, depth + 2); - this.c0.log(name, depth + 2); - } - - multiplyBI(rhs: BI): Fp12 { - return new Fp12(this.c0.multiplyBI(rhs), this.c1.multiplyBI(rhs)); - } - - private Fp4Square(a: Fp2, b: Fp2): Fp4SquareResult { - const a2 = a.square(); - const b2 = b.square(); - return { - first: b2.mulByNonresidue().add(a2), // b² * Nonresidue + a² - second: a.add(b).square().subtract(a2).subtract(b2) // (a + b)² - a² - b² - }; - } - - private cyclotomicSquare(): Fp12 { - const c0c0 = this.c0.c0; - const c0c1 = this.c0.c1; - const c0c2 = this.c0.c2; - const c1c0 = this.c1.c0; - const c1c1 = this.c1.c1; - const c1c2 = this.c1.c2; - const fp4s0 = this.Fp4Square(c0c0, c1c1); - const fp4s1 = this.Fp4Square(c1c0, c0c2); - const fp4s2 = this.Fp4Square(c0c1, c1c2); - const t3 = fp4s0.first; - const t4 = fp4s0.second; - const t5 = fp4s1.first; - const t6 = fp4s1.second; - const t7 = fp4s2.first; - const t8 = fp4s2.second; - let t9 = t8.mulByNonresidue(); // T8 * (u + 1) - return new Fp12( - new Fp6( - t3.subtract(c0c0).multiplyBI(BI.fromI32(2)).add(t3), // 2 * (T3 - c0c0) + T3 - t5.subtract(c0c1).multiplyBI(BI.fromI32(2)).add(t5), // 2 * (T5 - c0c1) + T5 - t7.subtract(c0c2).multiplyBI(BI.fromI32(2)).add(t7) - ), // 2 * (T7 - c0c2) + T7 - new Fp6( - t9.add(c1c0).multiplyBI(BI.fromI32(2)).add(t9), // 2 * (T9 + c1c0) + T9 - t4.add(c1c1).multiplyBI(BI.fromI32(2)).add(t4), // 2 * (T4 + c1c1) + T4 - t6.add(c1c2).multiplyBI(BI.fromI32(2)).add(t6) - ) - ); // 2 * (T6 + c1c2) + T6 - } - - private cyclotomicExp(n: BI): Fp12 { - let z = Fp12.ONE; - for (let i = BLS_X_LEN - 1; i >= 0; i--) { - z = z.cyclotomicSquare(); - if (bitGet(n, u8(i))) z = z.multiply(this); - } - return z; - } - - finalExponentiate(): Fp12orError { - const x = CURVE.x; - // this^(q⁶) / this - const t0_res = this.frobeniusMap(6).div(this); - if (t0_res.error != null) { - return { - value: null, - error: t0_res.error - }; - } - const t0 = t0_res.value!; - // t0^(q²) * t0 - const t1 = t0.frobeniusMap(2).multiply(t0); - const t2 = t1.cyclotomicExp(x).conjugate(); - const t3 = t1.cyclotomicSquare().conjugate().multiply(t2); - const t4 = t3.cyclotomicExp(x).conjugate(); - const t5 = t4.cyclotomicExp(x).conjugate(); - const t6 = t5.cyclotomicExp(x).conjugate().multiply(t2.cyclotomicSquare()); - const t7 = t6.cyclotomicExp(x).conjugate(); - const t2_t5_pow_q2 = t2.multiply(t5).frobeniusMap(2); - const t4_t1_pow_q3 = t4.multiply(t1).frobeniusMap(3); - const t6_t1c_pow_q1 = t6.multiply(t1.conjugate()).frobeniusMap(1); - const t7_t3c_t1 = t7.multiply(t3.conjugate()).multiply(t1); - // (t2 * t5)^(q²) * (t4 * t1)^(q³) * (t6 * t1.conj)^(q^1) * t7 * t3.conj * t1 - return { - value: t2_t5_pow_q2.multiply(t4_t1_pow_q3).multiply(t6_t1c_pow_q1).multiply(t7_t3c_t1), - error: null - }; - } - - div(rhs: Fp12): Fp12orError { - const res = rhs.invert(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const inv = res.value!; - return { - value: this.multiply(inv), - error: null - }; - } - - divBI(rhs: BI): Fp12orError { - const res = new Fp(rhs).invert(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const inv = res.value!.value; - return { - value: this.multiplyBI(inv), - error: null - }; - } - - equals(rhs: Fp12): boolean { - const c0 = this.c0; - const c1 = this.c1; - const r0 = rhs.c0; - const r1 = rhs.c1; - return c0.equals(r0) && c1.equals(r1); - } - - isZero(): boolean { - return this.c0.isZero() && this.c1.isZero(); - } - - invert(): Fp12orError { - const c0 = this.c0; - const c1 = this.c1; - const t_res = c0.square().subtract(c1.square().mulByNonresidue()).invert(); // 1 / (c0² - c1² * v) - if (t_res.error != null) { - return { - value: null, - error: t_res.error - }; - } - const t = t_res.value!; - return { - value: new Fp12(c0.multiply(t), c1.multiply(t).negate()), // (C0 * T) + (-C1 * T) * w - error: null - }; - } - - multiplyByFp2(rhs: Fp2): Fp12 { - return new Fp12(this.c0.multiplyByFp2(rhs), this.c1.multiplyByFp2(rhs)); - } - - frobeniusMap(power: i32): Fp12 { - const r0 = this.c0.frobeniusMap(power); - const c0_c1_c2 = this.c1.frobeniusMap(power); - const c0 = c0_c1_c2.c0; - const c1 = c0_c1_c2.c1; - const c2 = c0_c1_c2.c2; - const coeff: Fp2 = FP12_FROBENIUS_COEFFICIENTS[power % 12]; - return new Fp12(r0, new Fp6(c0.multiply(coeff), c1.multiply(coeff), c2.multiply(coeff))); - } - - // Sparse multiplication - multiplyBy014(o0: Fp2, o1: Fp2, o4: Fp2): Fp12 { - const c0 = this.c0; - const c1 = this.c1; - let t0 = c0.multiplyBy01(o0, o1); - let t1 = c1.multiplyBy1(o4); - return new Fp12( - t1.mulByNonresidue().add(t0), // T1 * v + T0 - // (c1 + c0) * [o0, o1+o4] - T0 - T1 - c1.add(c0).multiplyBy01(o0, o1.add(o4)).subtract(t0).subtract(t1) - ); - } - - square(): Fp12 { - const c0 = this.c0; - const c1 = this.c1; - let ab = c0.multiply(c1); // c0 * c1 - return new Fp12( - // (c1 * v + c0) * (c0 + c1) - AB - AB * v - c1.mulByNonresidue().add(c0).multiply(c0.add(c1)).subtract(ab).subtract(ab.mulByNonresidue()), - ab.add(ab) - ); // AB + AB - } - - conjugate(): Fp12 { - return new Fp12(this.c0, this.c1.negate()); - } -} - -class PointG1 { - static BASE: PointG1 = new PointG1(new Fp(CURVE.Gx), new Fp(CURVE.Gy), Fp.ONE); - static ZERO: PointG1 = new PointG1(Fp.ONE, Fp.ONE, Fp.ZERO); - - constructor(public readonly x: Fp, public readonly y: Fp, public readonly z: Fp = Fp.ONE) {} - - static fromHex(bytes: Uint8Array): PointG1orError { - let point: PointG1; - if (bytes.length == 48) { - const P = CURVE.P; - const compressedValue = bytesToNumberBE(bytes); - const bflag = mod(compressedValue, POW_2_383).div(POW_2_382); - if (bflag.equals(BI.fromI32(1))) { - return { - value: PointG1.ZERO, - error: null - }; - } - const x = new Fp(mod(compressedValue, POW_2_381)); - const x_pow_res = x.pow(BI.fromI32(3)); - if (x_pow_res.error != null) { - return { - value: null, - error: x_pow_res.error - }; - } - const x_pow = x_pow_res.value!; - const right = x_pow.plus(new Fp(CURVE.b)); - let y_res = right.sqrt(); - if (y_res == null) { - return { - value: null, - error: 'Invalid compressed G1 point' - }; - } - if (y_res.error != null) { - return { - value: null, - error: y_res.error - }; - } - let y = y_res.value!; - const aflag = mod(compressedValue, POW_2_382).div(POW_2_381); - if (!y.value.times(BI.fromI32(2)).div(P).equals(aflag)) { - y = y.negate(); - } - point = new PointG1(x, y); - } else { - return { - value: null, - error: 'Invalid G1 point, expected 48 bytes' - }; - } - return { - value: point, - error: null - }; - } - - createPoint(x: Fp, y: Fp, z: Fp): PointG1 { - return new PointG1(x, y, z); - } - - negate(): PointG1 { - return this.createPoint(this.x, this.y.negate(), this.z); - } - - isZero(): boolean { - return this.z.isZero(); - } - - assertValidity(): PointG1orError { - if (this.isZero()) { - return { - value: this, - error: null - }; - } - const isOnCurve = this.isOnCurve(); - if (isOnCurve.error != null) { - return { - value: null, - error: isOnCurve.error - }; - } - if (!isOnCurve.value) { - return { - value: null, - error: 'Invalid G1 point: not on curve Fp' - }; - } - const isTorsionFree = this.isTorsionFree(); - if (isTorsionFree.error != null) { - return { - value: null, - error: isTorsionFree.error - }; - } - - if (!isTorsionFree.value) { - return { - value: null, - error: 'Invalid G1 point: must be of prime-order subgroup' - }; - } - return { - value: this, - error: null - }; - } - - // [-0xd201000000010000]P - - getZero(): PointG1 { - return this.createPoint(Fp.ONE, Fp.ONE, Fp.ZERO); - } - - private validateScalar(n: BI): BIorError { - if (n.le(BI.zero()) || n.gt(CURVE.r)) { - return { - value: null, - error: `Point#multiply: invalid scalar, expected positive integer < CURVE.r. Got: ${n}` - }; - } - return { - value: n, - error: null - }; - } - - double(): PointG1 { - const x = this.x; - const y = this.y; - const z = this.z; - const W = x.multiply(x).multiplyBI(BI.fromI32(3)); - const S = y.multiply(z); - const SS = S.multiply(S); - const SSS = SS.multiply(S); - const B = x.multiply(y).multiply(S); - const H = W.multiply(W).subtract(B.multiplyBI(BI.fromI32(8))); - const X3 = H.multiply(S).multiplyBI(BI.fromI32(2)); - // W * (4 * B - H) - 8 * y * y * S_squared - const Y3 = W.multiply(B.multiplyBI(BI.fromI32(4)).subtract(H)).subtract( - y.multiply(y).multiplyBI(BI.fromI32(8)).multiply(SS) - ); - const Z3 = SSS.multiplyBI(BI.fromI32(8)); - return this.createPoint(X3, Y3, Z3); - } - - add(rhs: PointG1): PointG1 { - const p1 = this; - const p2 = rhs; - if (p1.isZero()) return p2; - if (p2.isZero()) return p1; - const X1 = p1.x; - const Y1 = p1.y; - const Z1 = p1.z; - const X2 = p2.x; - const Y2 = p2.y; - const Z2 = p2.z; - const U1 = Y2.multiply(Z1); - const U2 = Y1.multiply(Z2); - const V1 = X2.multiply(Z1); - const V2 = X1.multiply(Z2); - if (V1.equals(V2) && U1.equals(U2)) return this.double(); - if (V1.equals(V2)) return this.getZero(); - const U = U1.subtract(U2); - const V = V1.subtract(V2); - const VV = V.multiply(V); - const VVV = VV.multiply(V); - const V2VV = V2.multiply(VV); - const W = Z1.multiply(Z2); - const A = U.multiply(U) - .multiply(W) - .subtract(VVV) - .subtract(V2VV.multiplyBI(BI.fromI32(2))); - const X3 = V.multiply(A); - const Y3 = U.multiply(V2VV.subtract(A)).subtract(VVV.multiply(U2)); - const Z3 = VVV.multiply(W); - return this.createPoint(X3, Y3, Z3); - } - - multiplyUnsafe(scalar: BI): PointG1orError { - const n_res = this.validateScalar(scalar); - if (n_res.error != null) { - return { - value: null, - error: n_res.error - }; - } - let n = n_res.value!; - let point = this.getZero(); - let d: PointG1 = this; - while (n.gt(BI.zero())) { - if (n.bitAnd(BI_one).equals(BI_one)) point = point.add(d); - d = d.double(); - n = n.rightShift(1); - } - return { - value: point, - error: null - }; - } - - private mulCurveMinusX(): PointG1orError { - return this.multiplyUnsafe(CURVE.x); - } - - private mulCurveX(): PointG1orError { - const mulu_res = this.multiplyUnsafe(CURVE.x); - if (mulu_res.error != null) { - return { - value: null, - error: mulu_res.error - }; - } - const mulu = mulu_res.value!; - return { - value: mulu.negate(), - error: null - }; - } - - equals(rhs: PointG1): boolean { - const a = this; - const b = rhs; - // Ax * Bz == Bx * Az - const xe = a.x.multiply(b.z).equals(b.x.multiply(a.z)); - // Ay * Bz == By * Az - const ye = a.y.multiply(b.z).equals(b.y.multiply(a.z)); - return xe && ye; - } - - private phi(): PointG1 { - return new PointG1(this.x.multiplyBI(cubicRootOfUnityModP), this.y, this.z); - } - - // Checks is the point resides in prime-order subgroup. - // point.isTorsionFree() should return true for valid points - // It returns false for shitty points. - // https://eprint.iacr.org/2021/1130.pdf - private isTorsionFree(): BooleanOrError { - // todo: unroll - const xP_res = this.mulCurveX(); // [x]P - if (xP_res.error != null) { - return { - value: false, - error: xP_res.error - }; - } - const xP = xP_res.value!; - const u2P_res = xP.mulCurveMinusX(); // [u2]P - if (u2P_res.error != null) { - return { - value: false, - error: u2P_res.error - }; - } - const u2P = u2P_res.value!; - return { - value: u2P.equals(this.phi()), - error: null - }; - - // https://eprint.iacr.org/2019/814.pdf - // (z² − 1)/3 - // const c1 = 0x396c8c005555e1560000000055555555n; - // const P = this; - // const S = P.sigma(); - // const Q = S.double(); - // const S2 = S.sigma(); - // // [(z² − 1)/3](2σ(P) − P − σ²(P)) − σ²(P) = O - // const left = Q.subtract(P).subtract(S2).multiplyUnsafe(c1); - // const C = left.subtract(S2); - // return C.isZero(); - } - - private isOnCurve(): BooleanOrError { - const b = new Fp(CURVE.b); - const x = this.x; - const y = this.y; - const z = this.z; - const y_pow_res = y.pow(BI.fromI32(2)); - if (y_pow_res.error != null) { - return { - value: false, - error: y_pow_res.error - }; - } - const y_pow = y_pow_res.value!; - const x_pow_res = x.pow(BI.fromI32(3)); - if (x_pow_res.error != null) { - return { - value: false, - error: x_pow_res.error - }; - } - const x_pow = x_pow_res.value!; - const left = y_pow.multiply(z).subtract(x_pow); - const z_pow_res = z.pow(BI.fromI32(3)); - if (z_pow_res.error != null) { - return { - value: false, - error: z_pow_res.error - }; - } - const z_pow = z_pow_res.value!; - const right = b.multiply(z_pow); - return { - value: left.subtract(right).isZero(), - error: null - }; - } - - millerLoop(P: PointG2): Fp12orError { - const res = this.toAffine(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - const pp_res = P.pairingPrecomputes(); - if (pp_res.error != null) { - return { - value: null, - error: pp_res.error - }; - } - const pp = pp_res.value!; - return { - value: millerLoop(pp, res.value!), - error: null - }; - } - - toAffine(invZ: Fp | null = null): FPArrayorError { - const x = this.x; - const y = this.y; - const z = this.z; - const is0 = this.isZero(); - if (invZ == null) { - if (is0) { - invZ = x; - } else { - const z_res = z.invert(); - if (z_res.error != null) { - return { - value: null, - error: z_res.error - }; - } - invZ = z_res.value!; - } - } - const ax = x.multiply(invZ); - const ay = y.multiply(invZ); - if (is0) { - return { - value: [Fp.ZERO, Fp.ZERO], - error: null - }; - } - if (invZ.isZero()) { - return { - value: null, - error: 'Invalid inverted z' - }; - } - return { - value: [ax, ay], - error: null - }; - } -} - -class PointG2 { - static BASE: PointG2 = new PointG2(Fp2.fromBigTuple(CURVE.G2x), Fp2.fromBigTuple(CURVE.G2y), Fp2.ONE); - static ZERO: PointG2 = new PointG2(Fp2.ONE, Fp2.ONE, Fp2.ZERO); - constructor(public readonly x: Fp2, public readonly y: Fp2, public readonly z: Fp2 = Fp2.ONE) {} - - static fromSignature(hex: Uint8Array): PointG2orError { - const P = CURVE.P; - const half = hex.length / 2; - if (half !== 48 && half !== 96) { - return { - value: null, - error: 'Invalid compressed signature length, must be 96 or 192' - }; - } - const z1 = bytesToNumberBE(hex.slice(0, half)); - const z2 = bytesToNumberBE(hex.slice(half)); - // Indicates the infinity point - const bflag1 = mod(z1, POW_2_383).div(POW_2_382); - if (bflag1.equals(BI_one)) { - return { - value: PointG2.ZERO, - error: null - }; - } - - const x1 = new Fp(z1.mod(POW_2_381)); - const x2 = new Fp(z2); - const x = new Fp2(x2, x1); - const y2 = x.pow(BI.fromI32(3)).add(Fp2.fromBigTuple(CURVE.b2)); // y² = x³ + 4 - // The slow part - const y_res = y2.sqrt(); - if (y_res == null) { - return { - value: null, - error: 'Failed to find a square root' - }; - } - if (y_res.error != null) { - return { - value: null, - error: y_res.error - }; - } - let y = y_res.value!; - - // Choose the y whose leftmost bit of the imaginary part is equal to the a_flag1 - // If y1 happens to be zero, then use the bit of y0 - const reim = y.reim(); - const y0 = reim.re; - const y1 = reim.im; - const aflag1 = z1.mod(POW_2_382).div(POW_2_381); - const isGreater = y1.gt(BI.zero()) && y1.times(BI.fromI32(2)).div(P).notEqual(aflag1); - const isZero = y1.equals(BI.zero()) && y0.times(BI.fromI32(2)).div(P).notEqual(aflag1); - if (isGreater || isZero) y = y.multiplyBI(BI_neg_one); - const point = new PointG2(x, y, Fp2.ONE); - const res = point.assertValidity(); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - return { - value: point, - error: null - }; - } - - static hashToCurve(msg: Uint8Array): PointG2orError { - const u_res = hash_to_field(msg, 2); - if (u_res.error != null) { - return { - value: null, - error: u_res.error - }; - } - const u = u_res.value!; - const x0xy_res = map_to_curve_simple_swu_9mod16(Fp2.fromBigTuple(u[0])); - if (x0xy_res.error != null) { - return { - value: null, - error: x0xy_res.error - }; - } - const x0xy = x0xy_res.value!; - const x0 = x0xy[0]; - const y0 = x0xy[1]; - const x1y1_res = map_to_curve_simple_swu_9mod16(Fp2.fromBigTuple(u[1])); - if (x1y1_res.error != null) { - return { - value: null, - error: x1y1_res.error - }; - } - const x1y1 = x1y1_res.value!; - const x1 = x1y1[0]; - const y1 = x1y1[1]; - const x2y2_res = new PointG2(x0, y0).plus(new PointG2(x1, y1)).toAffine(null); - if (x2y2_res.error != null) { - return { - value: null, - error: x2y2_res.error - }; - } - const x2y2 = x2y2_res.value!; - const x2 = x2y2[0]; - const y2 = x2y2[1]; - const x3y3_res = isogenyMapG2(x2, y2); - if (x3y3_res.error != null) { - return { - value: null, - error: x3y3_res.error - }; - } - const x3y3 = x3y3_res.value!; - const x3 = x3y3[0]; - const y3 = x3y3[1]; - return new PointG2(x3, y3).clearCofactor(); - } - - private psi(): PointG2orError { - const res = this.toAffine(null); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - return { - value: this.fromAffineTuple(psi(res.value![0], res.value![1])), - error: null - }; - } - - private psi2(): PointG2orError { - const res = this.toAffine(null); - if (res.error != null) { - return { - value: null, - error: res.error - }; - } - return { - value: this.fromAffineTuple(psi2(res.value![0], res.value![1])), - error: null - }; - } - - fromAffineTuple(xy: Array): PointG2 { - return this.createPoint(xy[0], xy[1], Fp2.ONE); - } - - createPoint(x: Fp2, y: Fp2, z: Fp2): PointG2 { - return new PointG2(x, y, z); - } - - private validateScalar(n: BI): BIorError { - if (n.le(BI.zero()) || n.gt(CURVE.r)) { - return { - value: null, - error: `Point#multiply: invalid scalar, expected positive integer < CURVE.r. Got: ${n}` - }; - } - return { - value: n, - error: null - }; - } - - getZero(): PointG2 { - return this.createPoint(Fp2.ONE, Fp2.ONE, Fp2.ZERO); - } - - double(): PointG2 { - const x = this.x; - const y = this.y; - const z = this.z; - const W = x.multiply(x).multiplyBI(BI.fromI32(3)); - const S = y.multiply(z); - const SS = S.multiply(S); - const SSS = SS.multiply(S); - const B = x.multiply(y).multiply(S); - const H = W.multiply(W).subtract(B.multiplyBI(BI.fromI32(8))); - const X3 = H.multiply(S).multiplyBI(BI.fromI32(2)); - // W * (4 * B - H) - 8 * y * y * S_squared - const Y3 = W.multiply(B.multiplyBI(BI.fromI32(4)).subtract(H)).subtract( - y.multiply(y).multiplyBI(BI.fromI32(8)).multiply(SS) - ); - const Z3 = SSS.multiplyBI(BI.fromI32(8)); - return this.createPoint(X3, Y3, Z3); - } - - multiplyUnsafe(scalar: BI): PointG2orError { - const n_res = this.validateScalar(scalar); - if (n_res.error != null) { - return { - value: null, - error: n_res.error - }; - } - let n = n_res.value!; - let point = this.getZero(); - let d: PointG2 = this; - while (n.gt(BI.zero())) { - if (n.bitAnd(BI_one).equals(BI_one)) point = point.plus(d); - d = d.double(); - n = n.rightShift(1); - } - return { - value: point, - error: null - }; - } - - negate(): PointG2 { - return this.createPoint(this.x, this.y.negate(), this.z); - } - - private mulCurveX(): PointG2orError { - const mulu_res = this.multiplyUnsafe(CURVE.x); - - if (mulu_res.error != null) { - return { - value: null, - error: mulu_res.error - }; - } - return { - value: mulu_res.value!.negate(), - error: null - }; - } - - subtract(rhs: PointG2): PointG2 { - return this.plus(rhs.negate()); - } - - clearCofactor(): PointG2orError { - const P = this; - const t1_res = P.mulCurveX(); // [-x]P - if (t1_res.error != null) { - return { - value: null, - error: t1_res.error - }; - } - const t1 = t1_res.value!; - const t2_res = P.psi(); // Ψ(P) - if (t2_res.error != null) { - return { - value: null, - error: t2_res.error - }; - } - let t2 = t2_res.value!; - let t3 = P.double(); // 2P - const t3_psi2_res = t3.psi2(); // Ψ²(2P) - if (t3_psi2_res.error != null) { - return { - value: null, - error: t3_psi2_res.error - }; - } - t3 = t3_psi2_res.value!; - t3 = t3.subtract(t2); // Ψ²(2P) - Ψ(P) - t2 = t1.plus(t2); // [-x]P + Ψ(P) - const t2_mcx_res = t2.mulCurveX(); // [x²]P - [x]Ψ(P) - if (t2_mcx_res.error != null) { - return { - value: null, - error: t2_mcx_res.error - }; - } - t2 = t2_mcx_res.value!; - t3 = t3.plus(t2); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) - t3 = t3.subtract(t1); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - const Q = t3.subtract(P); // Ψ²(2P) - Ψ(P) + [x²]P - [x]Ψ(P) + [x]P - 1P => - return { - value: Q, - error: null - }; - } - - toAffine(invZ: Fp2 | null): FP2ArrayorError { - const x = this.x; - const y = this.y; - const z = this.z; - const is0 = this.isZero(); - if (invZ == null) { - if (is0) { - invZ = x; - } else { - const z_res = z.invert(); - if (z_res.error != null) { - return { - value: null, - error: z_res.error - }; - } - invZ = z_res.value!; - } - } - const ax = x.multiply(invZ); - const ay = y.multiply(invZ); - if (is0) { - return { - value: [Fp2.ZERO, Fp2.ZERO], - error: null - }; - } - if (invZ.isZero()) { - return { - value: null, - error: 'Invalid inverted z' - }; - } - return { - value: [ax, ay], - error: null - }; - } - - isZero(): boolean { - return this.z.isZero(); - } - - private isOnCurve(): boolean { - const b = Fp2.fromBigTuple(CURVE.b2); - const x = this.x; - const y = this.y; - const z = this.z; - const left = y - .pow(BI.fromI32(2)) - .multiply(z) - .subtract(x.pow(BI.fromI32(3))); - const right = b.multiply(z.pow(BI.fromI32(3)) as Fp2); - return left.subtract(right).isZero(); - } - - equals(rhs: PointG2): boolean { - const a = this; - const b = rhs; - // Ax * Bz == Bx * Az - const xe = a.x.multiply(b.z).equals(b.x.multiply(a.z)); - // Ay * Bz == By * Az - const ye = a.y.multiply(b.z).equals(b.y.multiply(a.z)); - return xe && ye; - } - - private isTorsionFree(): BooleanOrError { - const P = this; - const P_psi_res = P.psi(); - if (P_psi_res.error != null) { - return { - value: false, - error: P_psi_res.error - }; - } - const P_mcx_res = P.mulCurveX(); - if (P_mcx_res.error != null) { - return { - value: false, - error: P_mcx_res.error - }; - } - return { - value: P_mcx_res.value!.equals(P_psi_res.value!), // ψ(P) == [u](P) - error: null - }; - // https://eprint.iacr.org/2019/814.pdf - // const psi2 = P.psi2(); // Ψ²(P) - // const psi3 = psi2.psi(); // Ψ³(P) - // const zPsi3 = psi3.mulNegX(); // [z]Ψ³(P) where z = -x - // return zPsi3.subtract(psi2).add(P).isZero(); // [z]Ψ³(P) - Ψ²(P) + P == O - } - - assertValidity(): PointG2orError { - if (this.isZero()) { - return { - value: this, - error: null - }; - } - if (!this.isOnCurve()) { - return { - value: null, - error: 'Invalid G2 point: not on curve Fp2' - }; - } - const torsionFree_res = this.isTorsionFree(); - if (torsionFree_res.error != null) { - return { - value: null, - error: torsionFree_res.error - }; - } - if (!torsionFree_res.value) { - return { - value: null, - error: 'Invalid G2 point: must be of prime-order subgroup' - }; - } - return { - value: this, - error: null - }; - } - - plus(rhs: PointG2): PointG2 { - const p1 = this; - const p2 = rhs; - if (p1.isZero()) return p2; - if (p2.isZero()) return p1; - const X1 = p1.x; - const Y1 = p1.y; - const Z1 = p1.z; - const X2 = p2.x; - const Y2 = p2.y; - const Z2 = p2.z; - const U1 = Y2.multiply(Z1); - const U2 = Y1.multiply(Z2); - const V1 = X2.multiply(Z1); - const V2 = X1.multiply(Z2); - if (V1.equals(V2) && U1.equals(U2)) return this.double(); - if (V1.equals(V2)) return this.getZero(); - const U = U1.subtract(U2); - const V = V1.subtract(V2); - const VV = V.multiply(V); - const VVV = VV.multiply(V); - const V2VV = V2.multiply(VV); - const W = Z1.multiply(Z2); - const A = U.multiply(U) - .multiply(W) - .subtract(VVV) - .subtract(V2VV.multiplyBI(BI.fromI32(2))); - const X3 = V.multiply(A); - const Y3 = U.multiply(V2VV.subtract(A)).subtract(VVV.multiply(U2)); - const Z3 = VVV.multiply(W); - return this.createPoint(X3, Y3, Z3); - } - - private _PPRECOMPUTES: Array> | null = null; - - pairingPrecomputes(): FP2_2DArrayorError { - if (this._PPRECOMPUTES != null) { - return { - value: this._PPRECOMPUTES as Array>, - error: null - }; - } - const affines_res = this.toAffine(null); - if (affines_res.error != null) { - return { - value: null, - error: affines_res.error - }; - } - const affines = affines_res.value!; - const precomputes_res = calcPairingPrecomputes(affines[0], affines[1]); - if (precomputes_res.error != null) { - return { - value: null, - error: precomputes_res.error - }; - } - this._PPRECOMPUTES = precomputes_res.value!; - return { - value: this._PPRECOMPUTES as Array>, - error: null - }; - } -} - -const xnum: Fp2_4 = [ - [ - biFromHex('0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1'), - biFromHex('0x00') - ], - [ - biFromHex('0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e'), - biFromHex('0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d') - ], - [ - biFromHex('0x00'), - biFromHex('0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a') - ], - [ - biFromHex('0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6'), - biFromHex('0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6') - ] -].map((pair) => Fp2.fromBigTuple(pair)); -const xden: Fp2_4 = [ - [biFromHex('0x00'), biFromHex('0x00')], - [biFromHex('0x01'), biFromHex('0x00')], - [ - biFromHex('0x0c'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f') - ], - [ - biFromHex('0x00'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63') - ] -].map((pair) => Fp2.fromBigTuple(pair)); -const ynum: Fp2_4 = [ - [ - biFromHex('0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10'), - biFromHex('0x00') - ], - [ - biFromHex('0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c'), - biFromHex('0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f') - ], - [ - biFromHex('0x00'), - biFromHex('0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be') - ], - [ - biFromHex('0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706'), - biFromHex('0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706') - ] -].map((pair) => Fp2.fromBigTuple(pair)); -const yden: Fp2_4 = [ - [biFromHex('0x01'), biFromHex('0x00')], - [ - biFromHex('0x12'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99') - ], - [ - biFromHex('0x00'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3') - ], - [ - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb') - ] -].map((pair) => Fp2.fromBigTuple(pair)); - -const BI_one = BI.fromI32(1); -const BI_neg_one = BI.fromI32(-1); -const POW_2_381 = BI.fromString( - '4925250774549309901534880012517951725634967408808180833493536675530715221437151326426783281860614455100828498788352' -); -const POW_2_382 = POW_2_381.times(BI.fromI32(2)); -const POW_2_383 = POW_2_382.times(BI.fromI32(2)); -const hexes = initHexes(); -const BLS_X_LEN = bitLen(CURVE.x); -const cubicRootOfUnityModP = biFromHex( - '0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe' -); -const P_MINUS_9_DIV_16: BI = CURVE.P.pow(2).minus(BI.fromI32(9)).div(BI.fromI32(16)); -const ISOGENY_COEFFICIENTS_G2: Array = [xnum, xden, ynum, yden]; -const ut_root = new Fp6(Fp2.ZERO, Fp2.ONE, Fp2.ZERO); -const wsq = new Fp12(ut_root, Fp6.ZERO); -const wcu = new Fp12(Fp6.ZERO, ut_root); -const wsq_inv_wcu_inv = genInvertBatchFp12([wsq, wcu]); -const wsq_inv = wsq_inv_wcu_inv.value![0]; -const wcu_inv = wsq_inv_wcu_inv.value![1]; - -const FP2_FROBENIUS_COEFFICIENTS: Array = [ - biFromHex('0x01'), - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa') -].map((item) => new Fp(item)); - -const FP6_FROBENIUS_COEFFICIENTS_1: Array = [ - [biFromHex('0x01'), biFromHex('0x00')], - [ - biFromHex('0x00'), - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac') - ], - [ - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - biFromHex('0x00') - ], - [biFromHex('0x00'), biFromHex('0x01')], - [ - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - biFromHex('0x00') - ], - [ - biFromHex('0x00'), - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe') - ] -].map((pair) => Fp2.fromBigTuple(pair)); - -const FP6_FROBENIUS_COEFFICIENTS_2: Array = [ - [biFromHex('0x01'), biFromHex('0x00')], - [ - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - biFromHex('0x00') - ], - [ - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - biFromHex('0x00') - ], - [ - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - biFromHex('0x00') - ], - [ - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - biFromHex('0x00') - ], - [ - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - biFromHex('0x00') - ] -].map((pair) => Fp2.fromBigTuple(pair)); - -const FP12_FROBENIUS_COEFFICIENTS: Array = [ - [biFromHex('0x01'), biFromHex('0x00')], - [ - biFromHex('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8'), - biFromHex('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3') - ], - [ - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff'), - biFromHex('0x00') - ], - [ - biFromHex('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2'), - biFromHex('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09') - ], - [ - biFromHex('0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe'), - biFromHex('0x00') - ], - [ - biFromHex('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995'), - biFromHex('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116') - ], - [ - biFromHex('0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa'), - biFromHex('0x00') - ], - [ - biFromHex('0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3'), - biFromHex('0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8') - ], - [ - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac'), - biFromHex('0x00') - ], - [ - biFromHex('0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09'), - biFromHex('0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2') - ], - [ - biFromHex('0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad'), - biFromHex('0x00') - ], - [ - biFromHex('0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116'), - biFromHex('0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995') - ] -].map((n) => Fp2.fromBigTuple(n)); - -const rv1 = biFromHex( - '0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09' -); -const ev1 = biFromHex( - '0x699be3b8c6870965e5bf892ad5d2cc7b0e85a117402dfd83b7f4a947e02d978498255a2aaec0ac627b5afbdf1bf1c90' -); -const ev2 = biFromHex( - '0x8157cd83046453f5dd0972b6e3949e4288020b5b8a9cc99ca07e27089a2ce2436d965026adad3ef7baba37f2183e9b5' -); -const ev3 = biFromHex( - '0xab1c2ffdd6c253ca155231eb3e71ba044fd562f6f72bc5bad5ec46a0b7a3b0247cf08ce6c6317f40edbc653a72dee17' -); -const ev4 = biFromHex( - '0xaa404866706722864480885d68ad0ccac1967c7544b447873cc37e0181271e006df72162a3d3e0287bf597fbf7f8fc1' -); - -const FP2_ROOTS_OF_UNITY: Array = [ - [BI_one, BI.zero()], - [rv1, rv1.times(BI_neg_one)], - [BI.zero(), BI_one], - [rv1, rv1], - [BI_neg_one, BI.zero()], - [rv1.times(BI_neg_one), rv1], - [BI.zero(), BI_neg_one], - [rv1.times(BI_neg_one), rv1.times(BI_neg_one)] -].map((pair) => Fp2.fromBigTuple(pair)); - -const FP2_ETAs: Array = [ - [ev1, ev2], - [ev2.times(BI_neg_one), ev1], - [ev3, ev4], - [ev4.times(BI_neg_one), ev3] -].map((pair) => Fp2.fromBigTuple(pair)); - -const PSI2_C1 = biFromHex( - '0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac' -); - -export function biFromHex(hex: string): BI { - if (hex.startsWith('0x')) hex = hex.substr(2); - if (hex.length % 2 == 1) { - hex = '0' + hex; - } - return BI.fromUnsignedBytes(Bytes.fromHexString(hex).reverse() as Bytes); -} - -function invert(num: BI, modulo: BI = CURVE.P): BIorError { - const _0n = BI.zero(); - const _1n = BI_one; - if (num.equals(_0n) || modulo.le(_0n)) { - return { - value: null, - error: `invert: expected positive integers, got n=${num} mod=${modulo}` - }; - } - let a = mod(num, modulo); - let b = modulo; - // prettier-ignore - let x = _0n, y = _1n, u = _1n, v = _0n; - while (!a.equals(_0n)) { - const q = b.div(a); - const r = b.mod(a); - const m = x.minus(u.times(q)); - const n = y.minus(v.times(q)); - // prettier-ignore - b = a, a = r, x = u, y = v, u = m, v = n; - } - const gcd = b; - if (!gcd.equals(_1n)) { - return { - value: null, - error: 'invert: does not exist' - }; - } - return { - value: mod(x, modulo), - error: null - }; -} - -function bitLen(n: BI): i32 { - let len: i32; - for (len = 0; n.gt(BI.zero()); n = n.rightShift(1), len += 1); - return len; -} - -function powMod_FQP(fqp: Fp2, fqpOne: Fp2, n: BI): Fp2 { - const elm = fqp; - if (n.equals(BI.zero())) return fqpOne; - if (n.equals(BI_one)) return elm; - let p = fqpOne; - let d = elm; - while (n.gt(BI.zero())) { - if (n.bitAnd(BI_one).equals(BI_one)) p = p.multiply(d); - n = n.rightShift(1); - d = d.square(); - } - return p; -} - -function initHexes(): Array { - const hexes = new Array(256); - for (let i = 0; i < 256; i++) { - const hex = (i + 0x100).toString(16).substr(1); - hexes[i] = hex; - } - return hexes; -} - -function bytesToHex(uint8a: Uint8Array): string { - let hex = ''; - for (let i = 0; i < uint8a.length; i++) { - hex += hexes[uint8a[i]]; - } - return hex; -} - -function bytesToNumberBE(bytes: Uint8Array): BI { - return biFromHex('0x' + bytesToHex(bytes)); -} - -function mod(a: BI, b: BI): BI { - const res = a.mod(b); - return res.ge(BI.zero()) ? res : res.plus(b); -} - -function powMod(num: BI, power: BI, modulo: BI): BIorError { - if (modulo.le(BI.zero()) || power.lt(BI.zero())) { - return { - value: null, - error: `powMod: expected positive integers, got n=${num} power=${power} mod=${modulo}` - }; - } - if (modulo.equals(BI_one)) { - return { - value: BI.zero(), - error: null - }; - } - let res = BI_one; - while (power.gt(BI.zero())) { - if (power.bitAnd(BI.fromI32(1)).equals(BI.fromI32(1))) { - res = res.times(num).mod(modulo); - } - num = num.times(num).mod(modulo); - power = power.rightShift(1); - } - return { - value: res, - error: null - }; -} - -function genZeroes(nb: i32): string { - return ' '.repeat(nb); -} - -function bitGet(n: BI, pos: u8): boolean { - return n.rightShift(pos).bitAnd(BI_one).equals(BI_one); -} - -function millerLoop(ell: Array>, g1: Array): Fp12 { - const Px = g1[0].value; - const Py = g1[1].value; - let f12 = Fp12.ONE; - for (let j = 0, i = BLS_X_LEN - 2; i >= 0; i--, j++) { - const E = ell[j]; - f12 = f12.multiplyBy014(E[0], E[1].multiplyBI(Px), E[2].multiplyBI(Py)); - if (bitGet(CURVE.x, u8(i))) { - j += 1; - const F = ell[j]; - f12 = f12.multiplyBy014(F[0], F[1].multiplyBI(Px), F[2].multiplyBI(Py)); - } - if (i !== 0) f12 = f12.square(); - } - return f12.conjugate(); -} - -function concatBytes(arrays: Uint8Array[]): Uint8Array { - if (arrays.length === 1) return arrays[0]; - const length = arrays.reduce((a, arr) => a + arr.length, 0); - const result = new Uint8Array(length); - for (let i = 0, pad = 0; i < arrays.length; i++) { - const arr = arrays[i]; - result.set(arr, pad); - pad += arr.length; - } - return result; -} - -function stringToBytes(str: string): Uint8Array { - const bytes = new Uint8Array(str.length); - for (let i = 0; i < str.length; i++) { - bytes[i] = str.charCodeAt(i); - } - return bytes; -} - -function i2osp(value: i32, length: i32): U8AorError { - if (value < 0 || value >= 1 << (8 * length)) { - return { - value: null, - error: `bad I2OSP call: value=${value} length=${length}` - }; - } - const res = new Uint8Array(length).fill(0); - for (let i = length - 1; i >= 0; i--) { - res[i] = value & 0xff; - value >>>= 8; - } - return { - value: res, - error: null - }; -} - -function os2ip(bytes: Uint8Array): BI { - let result = BI.zero(); - for (let i = 0; i < bytes.length; i++) { - result = result.leftShift(8); - result = result.plus(BI.fromI32(bytes[i])); - } - return result; -} - -function strxor(a: Uint8Array, b: Uint8Array): Uint8Array { - const arr = new Uint8Array(a.length); - for (let i = 0; i < a.length; i++) { - arr[i] = a[i] ^ b[i]; - } - return arr; -} - -function expand_message_xmd(msg: Uint8Array, DST: Uint8Array, lenInBytes: f64, H: Hash = sha256): U8AorError { - // https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-16#section-5.3.3 - if (DST.length > 255) DST = H(concatBytes([stringToBytes('H2C-OVERSIZE-DST-'), DST])); - const b_in_bytes = f64(32); - const r_in_bytes = b_in_bytes * 2; - const ell: i32 = i32(Math.ceil(lenInBytes / b_in_bytes)); - if (ell > 255) { - return { - value: null, - error: 'Invalid xmd length' - }; - } - const i2osp_res_1 = i2osp(DST.length, 1); - if (i2osp_res_1.error != null) { - return { - value: null, - error: i2osp_res_1.error - }; - } - const i2osp_1 = i2osp_res_1.value!; - const DST_prime = concatBytes([DST, i2osp_1]); - const Z_pad_res = i2osp(0, i32(r_in_bytes)); - if (Z_pad_res.error != null) { - return { - value: null, - error: Z_pad_res.error - }; - } - const Z_pad = Z_pad_res.value!; - const l_i_b_str_res = i2osp(i32(lenInBytes), 2); - if (l_i_b_str_res.error != null) { - return { - value: null, - error: l_i_b_str_res.error - }; - } - const l_i_b_str = l_i_b_str_res.value!; - const b = new Array(ell); - const i2osp_res_2 = i2osp(0, 1); - if (i2osp_res_2.error != null) { - return { - value: null, - error: i2osp_res_2.error - }; - } - const b_0 = H(concatBytes([Z_pad, msg, l_i_b_str, i2osp_res_2.value!, DST_prime])); - const i2osp_res_3 = i2osp(1, 1); - if (i2osp_res_3.error != null) { - return { - value: null, - error: i2osp_res_3.error - }; - } - b[0] = H(concatBytes([b_0, i2osp_res_3.value!, DST_prime])); - for (let i = 1; i <= ell; i++) { - const i2osp_loop_res = i2osp(i + 1, 1); - if (i2osp_loop_res.error != null) { - return { - value: null, - error: i2osp_loop_res.error - }; - } - const args = [strxor(b_0, b[i - 1]), i2osp_loop_res.value!, DST_prime]; - b[i] = H(concatBytes(args)); - } - const pseudo_random_bytes = concatBytes(b); - return { - value: pseudo_random_bytes.slice(0, i32(lenInBytes)), - error: null - }; -} - -function hash_to_field(msg: Uint8Array, count: number): BI_2DArrayorError { - // if options is provided but incomplete, fill any missing fields with the - // value in hftDefaults (ie hash to G2). - const htfOptions: Htf = htfDefaults; - // const log2p = htfOptions.p.toString(2).length; - let clone = htfOptions.p; - let bitCount = 0; - for (; clone.gt(BI.zero()); bitCount += 1) { - clone = clone.rightShift(1); - } - const L = i32(Math.ceil((bitCount + htfOptions.k) / f64(8))); // section 5.1 of ietf draft link above - const len_in_bytes = count * htfOptions.m * L; - const DST = stringToBytes(htfOptions.DST); - - let pseudo_random_bytes = msg; - if (htfOptions.expand) { - const prb_res = expand_message_xmd(msg, DST, len_in_bytes, htfOptions.hash); - if (prb_res.error != null) { - return { - value: null, - error: prb_res.error - }; - } - pseudo_random_bytes = prb_res.value!; - } - const u = new Array>(i32(count)); - for (let i = 0; i < count; i++) { - const e = new Array(htfOptions.m); - for (let j = 0; j < htfOptions.m; j++) { - const elm_offset = L * (j + i * htfOptions.m); - const tv = pseudo_random_bytes.subarray(elm_offset, elm_offset + L); - e[j] = mod(os2ip(tv), htfOptions.p); - } - u[i] = e; - } - return { - value: u, - error: null - }; -} - -function sqrt_div_fp2(u: Fp2, v: Fp2): SqrtResult { - const v7 = v.pow(BI.fromI32(7)); - const uv7 = u.multiply(v7); - const uv15 = uv7.multiply(v7.multiply(v)); - // gamma = uv⁷ * (uv¹⁵)^((p² - 9) / 16) - const gamma = uv15.pow(P_MINUS_9_DIV_16).multiply(uv7); - let success = false; - let result = gamma; - // Constant-time routine, so we do not early-return. - for (let i = 0; i < 4; i++) { - const root = FP2_ROOTS_OF_UNITY[i]; - const candidate = root.multiply(gamma); - if (candidate.pow(BI.fromI32(2)).multiply(v).subtract(u).isZero() && !success) { - success = true; - result = candidate; - } - } - return { success, sqrtCandidateOrGamma: result }; -} - -function sgn0_fp2(x: Fp2): BI { - const reim = x.reim(); - const x0 = reim.re; - const x1 = reim.im; - const sign_0 = x0.mod(BI.fromI32(2)).equals(BI_one); - const zero_0 = x0.equals(BI.zero()); - const sign_1 = x1.mod(BI.fromI32(2)).equals(BI_one); - return BI.fromI32(sign_0 || (zero_0 && sign_1) ? 1 : 0); -} - -function map_to_curve_simple_swu_9mod16(t: Fp2): FP2ArrayorError { - const iso_3_a = new Fp2(new Fp(BI.zero()), new Fp(BI.fromI32(240))); - const iso_3_b = new Fp2(new Fp(BI.fromI32(1012)), new Fp(BI.fromI32(1012))); - const iso_3_z = new Fp2(new Fp(BI.fromI32(-2)), new Fp(BI.fromI32(-1))); - // if (Array.isArray(t)) t = Fp2.fromBigTuple(t); - - const t2 = t.pow(BI.fromI32(2)); - const iso_3_z_t2 = iso_3_z.multiply(t2); - const ztzt = iso_3_z_t2.add(iso_3_z_t2.pow(BI.fromI32(2))); // (Z * t² + Z² * t⁴) - let denominator = iso_3_a.multiply(ztzt).negate(); // -a(Z * t² + Z² * t⁴) - let numerator = iso_3_b.multiply(ztzt.add(Fp2.ONE)); // b(Z * t² + Z² * t⁴ + 1) - - // Exceptional case - if (denominator.isZero()) denominator = iso_3_z.multiply(iso_3_a); - - // v = D³ - let v = denominator.pow(BI.fromI32(3)); - // u = N³ + a * N * D² + b * D³ - let u = numerator - .pow(BI.fromI32(3)) - .add(iso_3_a.multiply(numerator).multiply(denominator.pow(BI.fromI32(2)))) - .add(iso_3_b.multiply(v)); - // Attempt y = sqrt(u / v) - const success_sqrtCandidateOrGamma = sqrt_div_fp2(u, v); - const success = success_sqrtCandidateOrGamma.success; - const sqrtCandidateOrGamma = success_sqrtCandidateOrGamma.sqrtCandidateOrGamma; - let y: Fp2 | null = null; - if (success) y = sqrtCandidateOrGamma; - // Handle case where (u / v) is not square - // sqrt_candidate(x1) = sqrt_candidate(x0) * t³ - const sqrtCandidateX1 = sqrtCandidateOrGamma.multiply(t.pow(BI.fromI32(3))); - - // u(x1) = Z³ * t⁶ * u(x0) - u = iso_3_z_t2.pow(BI.fromI32(3)).multiply(u); - let success2 = false; - for (let i = 0; i < FP2_ETAs.length; i++) { - const eta = FP2_ETAs[i]; - const etaSqrtCandidate = eta.multiply(sqrtCandidateX1); - const temp = etaSqrtCandidate.pow(BI.fromI32(2)).multiply(v).subtract(u); - if (temp.isZero() && !success && !success2) { - y = etaSqrtCandidate; - success2 = true; - } - } - if (!success && !success2) { - return { - value: null, - error: 'Hash to Curve - Optimized SWU failure' - }; - } - if (success2) numerator = numerator.multiply(iso_3_z_t2); - y = y as Fp2; - if (sgn0_fp2(t).notEqual(sgn0_fp2(y))) y = y.negate(); - const div_res = numerator.div(denominator); - if (div_res.error !== null) { - return { - value: null, - error: div_res.error - }; - } - return { - value: [div_res.value!, y], - error: null - }; -} - -function isogenyMap(COEFF: Array, x: Fp2, y: Fp2): FP2ArrayorError { - const res = new Array(0); - for (let idx = 0; idx < COEFF.length; idx++) { - const val = COEFF[idx]; - let acc = val[0]; - for (let i = 1; i < val.length; i++) { - acc = acc.multiply(x).add(val[i]); - } - res.push(acc); - } - const xNum: Fp2 = res[0]; - const xDen: Fp2 = res[1]; - const yNum: Fp2 = res[2]; - const yDen: Fp2 = res[3]; - const x_res = xNum.div(xDen); - if (x_res.error !== null) { - return { - value: null, - error: x_res.error - }; - } - x = x_res.value!; - const y_div_res = yNum.div(yDen); - if (y_div_res.error !== null) { - return { - value: null, - error: y_div_res.error - }; - } - y = y.multiply(y_div_res.value!); // y * (yNum / yDev) - return { - value: [x, y], - error: null - }; -} -const isogenyMapG2 = (x: Fp2, y: Fp2): FP2ArrayorError => isogenyMap(ISOGENY_COEFFICIENTS_G2, x, y); - -class Fp12ArrayorError { - value: Array | null; - error: string | null; -} - -function genInvertBatchFp12(nums: Fp12[]): Fp12ArrayorError { - const tmp = new Array(nums.length); - // Walk from first to last, multiply them by each other MOD p - let racc = Fp12.ONE; - for (let i = 0; i < nums.length; i++) { - if (nums[i].isZero()) { - continue; - } - tmp[i] = racc; - racc = racc.multiply(nums[i]); - } - const lastMultiplied = racc; - - // Invert last element - const inv_res = lastMultiplied.invert(); - if (inv_res.error !== null) { - return { - value: null, - error: inv_res.error - }; - } - const inverted = inv_res.value!; - // Walk from last to first, multiply them by inverted each other MOD p - let rracc = inverted; - for (let i = nums.length - 1; i >= 0; i--) { - if (nums[i].isZero()) { - continue; - } - tmp[i] = rracc.multiply(tmp[i]); - rracc = rracc.multiply(nums[i]); - } - return { - value: tmp, - error: null - }; -} - -function psi(x: Fp2, y: Fp2): Array { - // Untwist Fp2->Fp12 && frobenius(1) && twist back - const x2 = wsq_inv.multiplyByFp2(x).frobeniusMap(1).multiply(wsq).c0.c0; - const y2 = wcu_inv.multiplyByFp2(y).frobeniusMap(1).multiply(wcu).c0.c0; - return [x2, y2]; -} - -function psi2(x: Fp2, y: Fp2): Array { - return [x.multiplyBI(PSI2_C1), y.negate()]; -} - -function calcPairingPrecomputes(x: Fp2, y: Fp2): FP2_2DArrayorError { - // prettier-ignore - const Qx = x, Qy = y, Qz = Fp2.ONE; - // prettier-ignore - let Rx = Qx, Ry = Qy, Rz = Qz; - let ell_coeff: Array> = []; - for (let i = BLS_X_LEN - 2; i >= 0; i--) { - // Double - let t0 = Ry.square(); // Ry² - let t1 = Rz.square(); // Rz² - let t2 = t1.multiplyBI(BI.fromI32(3)).multiplyByB(); // 3 * T1 * B - let t3 = t2.multiplyBI(BI.fromI32(3)); // 3 * T2 - let t4 = Ry.add(Rz).square().subtract(t1).subtract(t0); // (Ry + Rz)² - T1 - T0 - ell_coeff.push([ - t2.subtract(t0), // T2 - T0 - Rx.square().multiplyBI(BI.fromI32(3)), // 3 * Rx² - t4.negate() // -T4 - ]); - const Rx_div_res = t0.subtract(t3).multiply(Rx).multiply(Ry).divBI(BI.fromI32(2)); - if (Rx_div_res.error !== null) { - return { - value: null, - error: Rx_div_res.error - }; - } - Rx = Rx_div_res.value!; // ((T0 - T3) * Rx * Ry) / 2 - const Ry_div_res = t0.add(t3).divBI(BI.fromI32(2)); - if (Ry_div_res.error !== null) { - return { - value: null, - error: Ry_div_res.error - }; - } - Ry = Ry_div_res.value!.square().subtract(t2.square().multiplyBI(BI.fromI32(3))); // ((T0 + T3) / 2)² - 3 * T2² - Rz = t0.multiply(t4); // T0 * T4 - if (bitGet(CURVE.x, u8(i))) { - // Addition - let t0 = Ry.subtract(Qy.multiply(Rz)); // Ry - Qy * Rz - let t1 = Rx.subtract(Qx.multiply(Rz)); // Rx - Qx * Rz - ell_coeff.push([ - t0.multiply(Qx).subtract(t1.multiply(Qy)), // T0 * Qx - T1 * Qy - t0.negate(), // -T0 - t1 // T1 - ]); - let t2 = t1.square(); // T1² - let t3 = t2.multiply(t1); // T2 * T1 - let t4 = t2.multiply(Rx); // T2 * Rx - let t5 = t3.subtract(t4.multiplyBI(BI.fromI32(2))).add(t0.square().multiply(Rz)); // T3 - 2 * T4 + T0² * Rz - Rx = t1.multiply(t5); // T1 * T5 - Ry = t4.subtract(t5).multiply(t0).subtract(t3.multiply(Ry)); // (T4 - T5) * T0 - T3 * Ry - Rz = Rz.multiply(t3); // Rz * T3 - } - } - return { - value: ell_coeff, - error: null - }; -} - -function normP1(point: Uint8Array): PointG1orError { - return PointG1.fromHex(point); -} -function normP2(point: Uint8Array): PointG2orError { - return PointG2.fromSignature(point); -} -function normP2Hash(point: Uint8Array): PointG2orError { - return PointG2.hashToCurve(point); -} - -function pairing(P: PointG1, Q: PointG2, withFinalExponent: boolean = true): Fp12orError { - if (P.isZero() || Q.isZero()) { - return { - value: null, - error: 'No pairings at point of Infinity' - }; - } - const res_P_validity = P.assertValidity(); - if (res_P_validity.error !== null) { - return { - value: null, - error: res_P_validity.error - }; - } - const res_Q_validity = Q.assertValidity(); - if (res_Q_validity.error !== null) { - return { - value: null, - error: res_Q_validity.error - }; - } - const looped_res = P.millerLoop(Q); - if (looped_res.error !== null) { - return { - value: null, - error: looped_res.error - }; - } - const looped = looped_res.value!; - if (!withFinalExponent) { - const fe_res = looped.finalExponentiate(); - if (fe_res.error !== null) { - return { - value: null, - error: fe_res.error - }; - } - return { - value: fe_res.value!, - error: null - }; - } - return { - value: looped, - error: null - }; -} - -class VerifyResult { - value: boolean; - error: string | null; -} - -export function verify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): VerifyResult { - const P_res = normP1(publicKey); - if (P_res.error !== null) { - return { - value: false, - error: P_res.error - }; - } - const P = P_res.value!; - const Hm_res = normP2Hash(message); - if (Hm_res.error !== null) { - return { - value: false, - error: Hm_res.error - }; - } - const Hm = Hm_res.value!; - const G = PointG1.BASE; - const S_res = normP2(signature); - if (S_res.error !== null) { - return { - value: false, - error: S_res.error - }; - } - const S = S_res.value!; - const ePHm_res = pairing(P.negate(), Hm, false); - if (ePHm_res.error !== null) { - return { - value: false, - error: ePHm_res.error - }; - } - const ePHm = ePHm_res.value!; - const eGS_res = pairing(G, S, false); - if (eGS_res.error !== null) { - return { - value: false, - error: eGS_res.error - }; - } - const eGS = eGS_res.value!; - const exp_res = eGS.multiply(ePHm).finalExponentiate(); - if (exp_res.error !== null) { - return { - value: false, - error: exp_res.error - }; - } - const exp = exp_res.value!; - return { - value: exp.equals(Fp12.ONE), - error: null - }; -} diff --git a/src/sha256/index.ts b/src/sha256/index.ts deleted file mode 100644 index 479da90..0000000 --- a/src/sha256/index.ts +++ /dev/null @@ -1,259 +0,0 @@ -// source: https://github.com/jedisct1/as-hmac-sha2 -type aisize = i32; - -function setU8(t: Uint8Array, s: Uint8Array, o: isize = 0): void { - memory.copy(t.dataStart + o, s.dataStart, s.length); -} - -function store64_be(x: Uint8Array, offset: isize, u: u64): void { - store(changetype(x.buffer) + offset, bswap(u)); -} - -function load32_be(x: Uint8Array, offset: isize): u32 { - return bswap(load(changetype(x.buffer) + offset)); -} - -function store32_be(x: Uint8Array, offset: isize, u: u32): void { - store(changetype(x.buffer) + offset, bswap(u)); -} - -class Internal { - @inline static Sigma0(x: u32): u32 { - return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22); - } - - @inline static Sigma1(x: u32): u32 { - return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25); - } - - @inline static sigma0(x: u32): u32 { - return rotr(x, 7) ^ rotr(x, 18) ^ (x >> 3); - } - - @inline static sigma1(x: u32): u32 { - return rotr(x, 17) ^ rotr(x, 19) ^ (x >> 10); - } - - @inline static Ch(x: u32, y: u32, z: u32): u32 { - return z ^ (x & (y ^ z)); - } - - @inline static Maj(x: u32, y: u32, z: u32): u32 { - return (x & (y ^ z)) ^ (y & z); - } - - static expand(w: StaticArray): void { - for (let i = 0; i < 16; i++) { - unchecked((w[i] += w[(i + 9) & 15] + Internal.sigma1(w[(i + 14) & 15]) + Internal.sigma0(w[(i + 1) & 15]))); - } - } - - static handle(r: StaticArray, w: StaticArray, c: u32[]): void { - for (let i = 0; i < 16; i++) { - var x = r[7 & (7 - i)] + w[i] + c[i]; - x += unchecked(Internal.Sigma1(r[7 & (4 - i)])); - x += unchecked(Internal.Ch(r[7 & (4 - i)], r[7 & (5 - i)], r[7 & (6 - i)])); - unchecked((r[7 & (3 - i)] += x)); - x += unchecked(Internal.Sigma0(r[7 & (0 - i)])); - x += unchecked(Internal.Maj(r[7 & (0 - i)], r[7 & (1 - i)], r[7 & (2 - i)])); - unchecked((r[7 & (7 - i)] = x)); - } - } - - static K: u32[] = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, - 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, - 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, - 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, - 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, - 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, - 0xc67178f2 - ]; - - static _hashblocks(st: Uint8Array, m: Uint8Array, n_: isize): isize { - let z = new StaticArray(8), - r = new StaticArray(8), - w = new StaticArray(16); - for (let i = 0; i < 8; ++i) { - unchecked((z[i] = r[i] = load32_be(st, i << 2))); - } - let pos = 0, - n = n_; - while (n >= 64) { - for (let i = 0; i < 16; ++i) { - w[i] = load32_be(m, (i << 2) + pos); - } - Internal.handle(r, w, Internal.K.slice(0)); - Internal.expand(w); - Internal.handle(r, w, Internal.K.slice(16)); - Internal.expand(w); - Internal.handle(r, w, Internal.K.slice(32)); - Internal.expand(w); - Internal.handle(r, w, Internal.K.slice(48)); - for (let i = 0; i < 8; ++i) { - let x = unchecked(r[i] + z[i]); - unchecked((z[i] = x)); - unchecked((r[i] = x)); - } - pos += 64; - n -= 64; - } - for (let i = 0; i < 8; ++i) { - store32_be(st, i << 2, unchecked(z[i])); - } - return n; - } - - static iv: u8[] = [ - 0x6a, 0x09, 0xe6, 0x67, 0xbb, 0x67, 0xae, 0x85, 0x3c, 0x6e, 0xf3, 0x72, 0xa5, 0x4f, 0xf5, 0x3a, 0x51, 0x0e, 0x52, - 0x7f, 0x9b, 0x05, 0x68, 0x8c, 0x1f, 0x83, 0xd9, 0xab, 0x5b, 0xe0, 0xcd, 0x19 - ]; - - static _hashInit(): Uint8Array { - let st = new Uint8Array(32 + 64); - - for (let i = 0; i < 32; ++i) { - st[i] = Internal.iv[i]; - } - return st; - } - - static _hashUpdate(st: Uint8Array, m: Uint8Array, n: isize, r: isize): isize { - let obuffered = st.subarray(32); - let buffered = new Uint8Array(64); - setU8(buffered, obuffered.subarray(0, 64)); - - let still_available_in_buffer = 64 - r; - let copiable_to_buffer = min(n, still_available_in_buffer); - setU8(buffered, m.subarray(0, copiable_to_buffer), r); - r += copiable_to_buffer; - n -= copiable_to_buffer; - let pos: isize = 0; - if (r === 64) { - Internal._hashblocks(st, buffered, 64); - r = 0; - pos = copiable_to_buffer; - } - if (n == 0) { - setU8(obuffered, buffered); - return r; - } - let left = m.subarray(pos); - r = Internal._hashblocks(st, left, left.length); - if (r > 0) { - setU8(obuffered, left.subarray(left.length - r)); - } - return r; - } - - static _hashFinal(st: Uint8Array, out: Uint8Array, t: isize, r: isize): void { - let buffered = st.subarray(32); - let padded = new Uint8Array(128); - setU8(padded, buffered.subarray(0, r)); - padded[r] = 0x80; - if (r < 56) { - store64_be(padded, 64 - 8, t << 3); - Internal._hashblocks(st, padded, 64); - } else { - store64_be(padded, 128 - 8, t << 3); - Internal._hashblocks(st, padded, 128); - } - for (let i = 0; i < 32; ++i) { - out[i] = st[i]; - } - } - - static _hash(out: Uint8Array, m: Uint8Array, n: isize): void { - let st = Internal._hashInit(); - let r = Internal._hashUpdate(st, m, n, 0); - - Internal._hashFinal(st, out, n, r); - } - - static _hmac(m: Uint8Array, k: Uint8Array): Uint8Array { - if (k.length > 64) { - k = Sha256.hash(k); - } - let b = new Uint8Array(64); - setU8(b, k); - for (let i = 0; i < b.length; ++i) { - b[i] ^= 0x36; - } - let out = new Uint8Array(32); - let st = Internal._hashInit(); - let r = Internal._hashUpdate(st, b, b.length, 0); - r = Internal._hashUpdate(st, m, m.length, r); - Internal._hashFinal(st, out, b.length + m.length, r); - for (let i = 0; i < b.length; ++i) { - b[i] ^= 0x6a; - } - st = Internal._hashInit(); - r = Internal._hashUpdate(st, b, b.length, 0); - r = Internal._hashUpdate(st, out, out.length, r); - Internal._hashFinal(st, out, b.length + out.length, r); - return out; - } -} - -/** - * Hash function output size, in bytes - */ -export const SHA256_HASH_BYTES: isize = 32; - -export class Sha256 { - r: u64 = 0; - t: u64 = 0; - st: Uint8Array; - - /** - * Initialize a multipart hash computation - * @returns A hash function state - */ - constructor() { - let st = Internal._hashInit(); - this.st = st; - } - - /** - * Absorb data to be hashed - * @param m (partial) message - */ - update(m: Uint8Array): Sha256 { - let n = m.length; - this.t += n; - this.r = Internal._hashUpdate(this.st, m, n, this.r as isize); - return this; - } - - /** - * Finalize a hash computation - * @returns Hash - */ - final(): Uint8Array { - let h = new Uint8Array(SHA256_HASH_BYTES); - Internal._hashFinal(this.st, h, this.t as isize, this.r as isize); - return h; - } - - /** - * Compute a hash for a single-part message - * @param m Message - * @returns Hash - */ - static hash(m: Uint8Array): Uint8Array { - let h = new Uint8Array(SHA256_HASH_BYTES); - Internal._hash(h, m, m.length); - return h; - } - - /** - * HMAC-SHA-256 - * @param m Message - * @param k Key - * @returns `HMAC-SHA-256(m, k)` - */ - static hmac(m: Uint8Array, k: Uint8Array): Uint8Array { - return Internal._hmac(m, k); - } -} diff --git a/src/ssz_deposit_message/index.ts b/src/ssz_deposit_message/index.ts deleted file mode 100644 index 7198bcf..0000000 --- a/src/ssz_deposit_message/index.ts +++ /dev/null @@ -1,213 +0,0 @@ -import { Sha256 } from '../sha256'; - -const zeroHashes = [new Uint8Array(32)]; - -function digest64(a: Uint8Array, b: Uint8Array): Uint8Array { - return new Sha256().update(a).update(b).final(); -} - -function zeroHash(depth: i32): Uint8Array { - if (depth >= zeroHashes.length) { - for (let i = zeroHashes.length; i <= depth; i++) { - zeroHashes[i] = digest64(zeroHashes[i - 1], zeroHashes[i - 1]); - } - } - return zeroHashes[depth]; -} - -export function bitLength(i: i32): i32 { - if (i === 0) { - return 0; - } - - return i32(Math.floor(Math.log2(i)) + 1); -} - -export function nextPowerOf2(n: i32): i32 { - return n <= 0 ? 1 : i32(Math.pow(2, bitLength(n - 1))); -} - -export function merkleize(chunks: Uint8Array[], padFor: i32): Uint8Array { - const layerCount = bitLength(nextPowerOf2(padFor) - 1); - if (chunks.length == 0) { - return zeroHash(layerCount); - } - - let chunkCount = chunks.length; - - // Instead of pushing on all padding zero chunks at the leaf level - // we push on zero hash chunks at the highest possible level to avoid over-hashing - for (let l = 0; l < layerCount; l++) { - const padCount = chunkCount % 2; - const paddedChunkCount = chunkCount + padCount; - - // if the chunks.length is odd - // we need to push on the zero-hash of that level to merkleize that level - for (let i = 0; i < padCount; i++) { - chunks[chunkCount + i] = zeroHash(l); - } - - for (let i = 0; i < paddedChunkCount; i += 2) { - chunks[i / 2] = digest64(chunks[i], chunks[i + 1]); - } - - chunkCount = paddedChunkCount / 2; - } - - return chunks[0]; -} - -class DepositMessage { - pubkey: Uint8Array; - withdrawalCredentials: Uint8Array; - amount: i64; -} - -export function splitIntoRootChunks(longChunk: Uint8Array): Uint8Array[] { - const chunkCount = i32(Math.ceil(f32(longChunk.length) / 32)); - const chunks = new Array(chunkCount); - - for (let i = 0; i < chunkCount; i++) { - const chunk = new Uint8Array(32); - chunk.set(longChunk.slice(i * 32, (i + 1) * 32)); - chunks[i] = chunk; - } - - return chunks; -} - -function hashTreeRootPubkey(pubkey: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(pubkey); - return merkleize(roots, roots.length); -} - -function hashTreeRootWithdrawalCredentials(withdrawalCredentials: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(withdrawalCredentials); - return merkleize(roots, roots.length); -} - -const NUMBER_2_POW_32: i64 = 2 ** 32; - -function hashTreeRootAmount(amount: i64): Uint8Array { - const uint8Array = new Uint8Array(32); - const dataView = new DataView(uint8Array.buffer, uint8Array.byteOffset, uint8Array.byteLength); - dataView.setUint32(0, u32(amount & 0xffffffff), true); - dataView.setUint32(4, u32((amount / NUMBER_2_POW_32) & 0xffffffff), true); - return uint8Array; -} - -export function hashTreeRootDepositMessage(value: DepositMessage): Uint8Array { - const roots = new Array(3); - - roots[0] = hashTreeRootPubkey(value.pubkey); - roots[1] = hashTreeRootWithdrawalCredentials(value.withdrawalCredentials); - roots[2] = hashTreeRootAmount(value.amount); - - const root = merkleize(roots, 3); - - return root; -} - -class SigningData { - objectRoot: Uint8Array; - domain: Uint8Array; -} - -function hashTreeRootObjectRoot(objectRoot: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(objectRoot); - return merkleize(roots, roots.length); -} - -function hashTreeRootDomain(domain: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(domain); - return merkleize(roots, roots.length); -} - -export function hashTreeRootSigningData(value: SigningData): Uint8Array { - const roots = new Array(2); - - roots[0] = hashTreeRootObjectRoot(value.objectRoot); - roots[1] = hashTreeRootDomain(value.domain); - - const root = merkleize(roots, 2); - - return root; -} - -class ForkData { - currentVersion: Uint8Array; - genesisValidatorsRoot: Uint8Array; -} - -function hashTreeRootCurrentVersion(currentVersion: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(currentVersion); - return merkleize(roots, roots.length); -} - -function hashTreeRootGenesisValidatorsRoot(genesisValidatorsRoot: Uint8Array): Uint8Array { - const roots = splitIntoRootChunks(genesisValidatorsRoot); - return merkleize(roots, roots.length); -} - -function hashTreeRootForkData(value: ForkData): Uint8Array { - const roots = new Array(2); - - roots[0] = hashTreeRootCurrentVersion(value.currentVersion); - roots[1] = hashTreeRootGenesisValidatorsRoot(value.genesisValidatorsRoot); - - const root = merkleize(roots, 2); - - return root; -} - -function hexStringToUint8Array(hexString: string): Uint8Array { - if (hexString.length % 2 !== 0) { - throw 'Invalid hexString'; - } /*from w w w. j av a 2s . c o m*/ - var arrayBuffer = new Uint8Array(hexString.length / 2); - - for (var i = 0; i < hexString.length; i += 2) { - var byteValue = parseInt(hexString.substr(i, 2), 16); - if (isNaN(byteValue)) { - throw 'Invalid hexString'; - } - arrayBuffer[i / 2] = u8(byteValue); - } - - return arrayBuffer; -} - -function concatBytes(arrays: Uint8Array[]): Uint8Array { - if (arrays.length === 1) return arrays[0]; - const length = arrays.reduce((a, arr) => a + arr.length, 0); - const result = new Uint8Array(length); - for (let i = 0, pad = 0; i < arrays.length; i++) { - const arr = arrays[i]; - result.set(arr, pad); - pad += arr.length; - } - return result; -} - -const generateForkData = (forkVersion: Uint8Array): ForkData => { - return { - currentVersion: forkVersion, - genesisValidatorsRoot: GENESIS_VALIDATOR_ROOT - }; -}; - -export const generateDepositDomain = (forkVersion: Uint8Array): Uint8Array => { - const forkData = generateForkData(forkVersion); - - return concatBytes([DOMAIN_DEPOSIT, hashTreeRootForkData(forkData).slice(0, 28)]); -}; - -export const DOMAIN_DEPOSIT = hexStringToUint8Array('03000000'); -export const FORK_VERSIONS: Array = [ - hexStringToUint8Array('00000000'), // mainnet - hexStringToUint8Array('00001020'), // prater - hexStringToUint8Array('00002009') // pyrmont -]; -export const GENESIS_VALIDATOR_ROOT = hexStringToUint8Array( - '0000000000000000000000000000000000000000000000000000000000000000' -); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 07380bc..256ea47 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -8,10 +8,8 @@ import { ClaimedExitQueueTicketSystemEvent, CoverageRecipientUpdatedEthSystemEvent, CoverageRecipientUpdatedSharesSystemEvent, - DuplicateKeySystemAlert, ERC20DepositSystemEvent, ERC20ExitSystemEvent, - ExternalFundingSystemAlert, FundedValidationKeySystemEvent, G, NewExitQueueCaskSystemEvent, @@ -25,7 +23,8 @@ import { UpdatedLimitSystemEvent, ValidatorExtraDataChangedSystemEvent, ValidatorFeeRecipientChangedSystemEvent, - ValidatorOwnerChangedSystemEvent + ValidatorOwnerChangedSystemEvent, + ValidatorThresholdChangedSystemEvent } from '../../generated/schema'; // an event is not unique per transaction @@ -183,19 +182,19 @@ export function createValidatorOwnerChangedSystemEvent( return systemEvent; } -export function createValidatorFeeRecipientChangedSystemEvent( +export function createValidatorThresholdChangedSystemEvent( event: ethereum.Event, factoryAddress: Address, validatorId: BigInt -): ValidatorFeeRecipientChangedSystemEvent { +): ValidatorThresholdChangedSystemEvent { const g = getOrCreateG(); - const id = `ValidatorFeeRecipientChangedSystemEvent/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${validatorId.toString()}`; - let systemEvent = ValidatorFeeRecipientChangedSystemEvent.load(id); + const id = `ValidatorThresholdChangedSystemEvent/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${validatorId.toString()}`; + let systemEvent = ValidatorThresholdChangedSystemEvent.load(id); if (systemEvent == null) { - systemEvent = new ValidatorFeeRecipientChangedSystemEvent(id); + systemEvent = new ValidatorThresholdChangedSystemEvent(id); systemEvent.index = g.systemLogIndex; - systemEvent.type = 'ValidatorFeeRecipientChangedSystemEvent'; + systemEvent.type = 'ValidatorThresholdChangedSystemEvent'; systemEvent.tx = event.transaction.hash; systemEvent.who = event.transaction.from; @@ -213,19 +212,19 @@ export function createValidatorFeeRecipientChangedSystemEvent( return systemEvent; } -export function createValidatorExtraDataChangedSystemEvent( +export function createValidatorFeeRecipientChangedSystemEvent( event: ethereum.Event, factoryAddress: Address, validatorId: BigInt -): ValidatorExtraDataChangedSystemEvent { +): ValidatorFeeRecipientChangedSystemEvent { const g = getOrCreateG(); - const id = `ValidatorExtraDataChangedSystemEvent/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${validatorId.toString()}`; - let systemEvent = ValidatorExtraDataChangedSystemEvent.load(id); + const id = `ValidatorFeeRecipientChangedSystemEvent/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${validatorId.toString()}`; + let systemEvent = ValidatorFeeRecipientChangedSystemEvent.load(id); if (systemEvent == null) { - systemEvent = new ValidatorExtraDataChangedSystemEvent(id); + systemEvent = new ValidatorFeeRecipientChangedSystemEvent(id); systemEvent.index = g.systemLogIndex; - systemEvent.type = 'ValidatorExtraDataChangedSystemEvent'; + systemEvent.type = 'ValidatorFeeRecipientChangedSystemEvent'; systemEvent.tx = event.transaction.hash; systemEvent.who = event.transaction.from; @@ -243,47 +242,25 @@ export function createValidatorExtraDataChangedSystemEvent( return systemEvent; } -export function createDuplicateKeySystemAlert( +export function createValidatorExtraDataChangedSystemEvent( event: ethereum.Event, factoryAddress: Address, - publicKey: Bytes -): DuplicateKeySystemAlert { + validatorId: BigInt +): ValidatorExtraDataChangedSystemEvent { const g = getOrCreateG(); - const id = `DuplicateKeySystemAlert/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${publicKey.toHexString()}`; - let systemEvent = DuplicateKeySystemAlert.load(id); + const id = `ValidatorExtraDataChangedSystemEvent/${event.transaction.hash.toHexString()}/${factoryAddress.toHexString()}/${validatorId.toString()}`; + let systemEvent = ValidatorExtraDataChangedSystemEvent.load(id); if (systemEvent == null) { - systemEvent = new DuplicateKeySystemAlert(id); + systemEvent = new ValidatorExtraDataChangedSystemEvent(id); systemEvent.index = g.systemLogIndex; - systemEvent.type = 'DuplicateKeySystemAlert'; + systemEvent.type = 'ValidatorExtraDataChangedSystemEvent'; systemEvent.tx = event.transaction.hash; systemEvent.who = event.transaction.from; systemEvent.factory = factoryAddress; - - systemEvent.createdAt = event.block.timestamp; - systemEvent.createdAtBlock = event.block.number; - - g.systemLogIndex = g.systemLogIndex.plus(BigInt.fromI32(1)); - g.save(); - } - - return systemEvent; -} - -export function createExternalFundingSystemAlert(event: ethereum.Event, publicKey: Bytes): ExternalFundingSystemAlert { - const g = getOrCreateG(); - - const id = `ExternalFundingSystemAlert/${event.transaction.hash.toHexString()}/${publicKey.toHexString()}`; - let systemEvent = ExternalFundingSystemAlert.load(id); - if (systemEvent == null) { - systemEvent = new ExternalFundingSystemAlert(id); - systemEvent.index = g.systemLogIndex; - systemEvent.type = 'ExternalFundingSystemAlert'; - - systemEvent.tx = event.transaction.hash; - systemEvent.who = event.transaction.from; + systemEvent.validator = externalEntityUUID(factoryAddress, [validatorId.toString()]); systemEvent.createdAt = event.block.timestamp; systemEvent.createdAtBlock = event.block.number; @@ -318,7 +295,7 @@ export function createFundedValidationKeySystemEvent( systemEvent.withdrawalChannel = externalEntityUUID(factoryAddress, [withdrawalChannel.toHexString()]); systemEvent.count = BigInt.fromI32(0); systemEvent.newTotal = BigInt.fromI32(0); - systemEvent.fundedValidationKeys = []; + systemEvent.validationKeys = []; systemEvent.createdAt = event.block.timestamp; systemEvent.createdAtBlock = event.block.number; @@ -867,13 +844,14 @@ export function _computeEthAfterCommission( export function createERC20DepositSystemEvent( event: ethereum.Event, erc20Address: Address, - depositor: Address, + staker: Address, + recipient: Address, amount: BigInt, shares: BigInt ): void { const g = getOrCreateG(); - const id = `ERC20DepositSystemEvent/${event.transaction.hash.toHexString()}/${event.logIndex.toString()}/${erc20Address.toHexString()}/${depositor.toHexString()}`; + const id = `ERC20DepositSystemEvent/${event.transaction.hash.toHexString()}/${event.logIndex.toString()}/${erc20Address.toHexString()}/${staker.toHexString()}/${recipient.toHexString()}`; let systemEvent = ERC20DepositSystemEvent.load(id); if (systemEvent == null) { systemEvent = new ERC20DepositSystemEvent(id); @@ -884,7 +862,8 @@ export function createERC20DepositSystemEvent( systemEvent.who = event.transaction.from; systemEvent.integration = erc20Address; - systemEvent.staker = depositor; + systemEvent.staker = staker; + systemEvent.recipient = recipient; systemEvent.depositedAmount = amount; systemEvent.mintedShares = shares; diff --git a/src/vFactory.mapping.ts b/src/vFactory.mapping.ts index 187ce1d..bf89022 100644 --- a/src/vFactory.mapping.ts +++ b/src/vFactory.mapping.ts @@ -1,25 +1,8 @@ -import { Bytes, store, BigInt, dataSource, Address } from '@graphprotocol/graph-ts'; +import { Bytes, store, BigInt, Address } from '@graphprotocol/graph-ts'; +import { WithdrawalChannel, ValidationKey, vFactory, FactoryDepositor, ExitRequest } from '../generated/schema'; import { - WithdrawalChannel, - ValidationKey, - FundedValidationKey, - ExitRequest, - ValidatorRequest as ValidatorRequestEntity, - vFactory, - FactoryDepositor, - CommonValidationKeyEntry, - DepositEvent, - PendingKeyValidationRequest -} from '../generated/schema'; -import { - AddedValidators, - RemovedValidator, - FundedValidator, SetValidatorOwner, SetValidatorFeeRecipient, - UpdatedLimit, - ExitValidator, - ValidatorRequest, SetMetadata, SetAdmin, ChangedOperator, @@ -28,295 +11,69 @@ import { ApproveDepositor, SetExitTotal } from '../generated/templates/vFactory/vFactory'; +import { + ActivatedValidator, + SetRoot, + ExitValidator, + SetValidatorThreshold +} from '../generated/templates/vFactory_2_2_0/vFactory_2_2_0'; import { SetMinimalRecipientImplementation } from '../generated/Nexus/Nexus'; import { SetValidatorExtraData } from '../generated/templates/vFactory/vFactory'; import { - cancelSystemEvent, - createAddedValidationKeysSystemEvent, createChangedFactoryParameterSystemEvent, - createDuplicateKeySystemAlert, - createExternalFundingSystemAlert, createFundedValidationKeySystemEvent, - createRemovedValidationKeysSystemEvent, - createUpdatedLimitSystemEvent, createValidatorExtraDataChangedSystemEvent, createValidatorFeeRecipientChangedSystemEvent, createValidatorOwnerChangedSystemEvent, + createValidatorThresholdChangedSystemEvent, entityUUID, - eventUUID, - externalEntityUUID + eventUUID } from './utils/utils'; -import { verify } from './bls12_381_verify'; -import { getOrLoadVerificationTracker } from './Nexus.mapping'; -import { - FORK_VERSIONS, - generateDepositDomain, - hashTreeRootDepositMessage, - hashTreeRootSigningData -} from './ssz_deposit_message/index'; - -const PUBLIC_KEY_LENGTH = 48; -const SIGNATURE_LENGTH = 96; -const KEY_PACK_LENGTH = PUBLIC_KEY_LENGTH + SIGNATURE_LENGTH; -export function handleAddedValidators(event: AddedValidators): void { - const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); - let entity = WithdrawalChannel.load(channelId); - - if (entity == null) { - entity = new WithdrawalChannel(channelId); - entity.withdrawalChannel = event.params.withdrawalChannel; - entity.factory = event.address; - entity.total = BigInt.fromI32(0); - entity.funded = BigInt.fromI32(0); - entity.limit = BigInt.fromI32(0); - entity.lastExitTotal = BigInt.fromI32(0); - entity.createdAt = event.block.timestamp; - entity.createdAtBlock = event.block.number; - } - - entity.editedAt = event.block.timestamp; - entity.editedAtBlock = event.block.number; - const keyCount = entity.total.toI32(); - - const keys = event.params.keys; - - const verificationTracker = getOrLoadVerificationTracker(); - - for (let idx = 0; idx < keys.length / KEY_PACK_LENGTH; ++idx) { - const signature = Bytes.fromUint8Array(keys.slice(idx * KEY_PACK_LENGTH, idx * KEY_PACK_LENGTH + SIGNATURE_LENGTH)); - const publicKey = Bytes.fromUint8Array( - keys.slice(idx * KEY_PACK_LENGTH + SIGNATURE_LENGTH, (idx + 1) * KEY_PACK_LENGTH) - ); - const keyId = entityUUID(event, [event.params.withdrawalChannel.toHexString(), (keyCount + idx).toString()]); - const keyEntity = new ValidationKey(keyId); - keyEntity.signature = signature; - keyEntity.publicKey = publicKey; - keyEntity.withdrawalChannel = channelId; - keyEntity.index = BigInt.fromI32(keyCount + idx); - - keyEntity.validationStatus = 'pending'; - - const verificationRequest = new PendingKeyValidationRequest( - verificationTracker.total.plus(BigInt.fromI32(idx)).toString() - ); - verificationRequest.key = keyId; - verificationRequest.save(); - - let commonValidationKeyEntry = CommonValidationKeyEntry.load(publicKey.toHexString()); - if (commonValidationKeyEntry == null) { - commonValidationKeyEntry = new CommonValidationKeyEntry(publicKey.toHexString()); - commonValidationKeyEntry.depositEventCount = BigInt.fromI32(0); - commonValidationKeyEntry.validationKeyCount = BigInt.fromI32(0); - commonValidationKeyEntry.publicKey = publicKey; - commonValidationKeyEntry.createdAt = event.block.timestamp; - commonValidationKeyEntry.createdAtBlock = event.block.number; - } - commonValidationKeyEntry.editedAt = event.block.timestamp; - commonValidationKeyEntry.editedAtBlock = event.block.number; - commonValidationKeyEntry.validationKeyCount = commonValidationKeyEntry.validationKeyCount.plus(BigInt.fromI32(1)); - commonValidationKeyEntry.save(); - - if (commonValidationKeyEntry.validationKeyCount.gt(BigInt.fromI32(1))) { - const se = createDuplicateKeySystemAlert(event, event.address, publicKey); - se.key = publicKey.toHexString(); - se.save(); - } - - let depositIndex = 0; - let depositEventId = `${publicKey.toHexString()}-${depositIndex.toString()}`; - let depositEvent = DepositEvent.load(depositEventId); - while (depositEvent != null) { - const depositMessageRoot = hashTreeRootDepositMessage({ - pubkey: depositEvent.pubkey, - withdrawalCredentials: depositEvent.withdrawalCredentials, - amount: depositEvent.amount.toI64() - }); - - const forkVersion: Uint8Array = FORK_VERSIONS[dataSource.network() == 'mainnet' ? 0 : 1]; - const depositDomain: Uint8Array = generateDepositDomain(forkVersion); - - const signingRoot = hashTreeRootSigningData({ - objectRoot: depositMessageRoot, - domain: depositDomain - }); - - const signature_verification = verify(depositEvent.signature, signingRoot, depositEvent.pubkey); - - if (signature_verification.error != null || signature_verification.value == false) { - depositEvent.validSignature = false; - depositEvent.validationError = signature_verification.error; - } else { - depositEvent.validSignature = true; - const se = createExternalFundingSystemAlert(event, publicKey); - se.key = publicKey.toHexString(); - se.save(); - } - depositEvent.verified = true; - depositEvent.editedAt = event.block.timestamp; - depositEvent.editedAtBlock = event.block.number; - depositEvent.save(); - - depositIndex++; - depositEventId = `${publicKey.toHexString()}-${depositIndex.toString()}`; - depositEvent = DepositEvent.load(depositEventId); - } - - keyEntity.commonValidationKeyEntry = publicKey.toHexString(); - keyEntity.createdAt = event.block.timestamp; - keyEntity.createdAtBlock = event.block.number; - keyEntity.editedAt = event.block.timestamp; - keyEntity.editedAtBlock = event.block.number; - keyEntity.save(); - } - - verificationTracker.total = verificationTracker.total.plus(BigInt.fromI32(keys.length / KEY_PACK_LENGTH)); - verificationTracker.save(); - - entity.total = BigInt.fromI32(entity.total.toI32() + keys.length / KEY_PACK_LENGTH); - - entity.save(); - - const se = createAddedValidationKeysSystemEvent(event, event.address, event.params.withdrawalChannel); - se.count = se.count.plus(BigInt.fromI32(keys.length / KEY_PACK_LENGTH)); - se.newTotal = entity.total; - se.save(); - - dataSource.create; -} - -export function handleValidatorRequest(event: ValidatorRequest): void { +export function handleActivatedValidator_2_2_0(event: ActivatedValidator): void { const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); + let channel = WithdrawalChannel.load(channelId); - let entity = WithdrawalChannel.load(channelId); - - if (entity == null) { - entity = new WithdrawalChannel(channelId); - entity.withdrawalChannel = event.params.withdrawalChannel; - entity.factory = event.address; - entity.total = BigInt.fromI32(0); - entity.funded = BigInt.fromI32(0); - entity.limit = BigInt.fromI32(0); - entity.lastExitTotal = BigInt.fromI32(0); - entity.createdAt = event.block.timestamp; - entity.createdAtBlock = event.block.number; + if (channel == null) { + channel = new WithdrawalChannel(channelId); + channel.withdrawalChannel = event.params.withdrawalChannel; + channel.factory = event.address; + channel.funded = BigInt.fromI32(0); + channel.lastExitTotal = BigInt.fromI32(0); + channel.createdAt = event.block.timestamp; + channel.createdAtBlock = event.block.number; } - const validatorRequestId = eventUUID(event, [event.params.withdrawalChannel.toHexString()]); - - const validatorRequest = new ValidatorRequestEntity(validatorRequestId); - - validatorRequest.withdrawalChannel = channelId; - validatorRequest.requestedTotal = event.params.total; - validatorRequest.totalOnRequest = entity.total; - validatorRequest.createdAt = event.block.timestamp; - validatorRequest.createdAtBlock = event.block.number; - validatorRequest.editedAt = event.block.timestamp; - validatorRequest.editedAtBlock = event.block.number; + const keyId = entityUUID(event, [event.params.id.toString()]); - entity.lastValidatorRequest = validatorRequestId; - entity.editedAt = event.block.timestamp; - entity.editedAtBlock = event.block.number; + const keyEntity = new ValidationKey(keyId); - entity.save(); - validatorRequest.save(); -} - -export function handleRemovedValidator(event: RemovedValidator): void { - const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); - - const channel = WithdrawalChannel.load(channelId); - - const keyId = entityUUID(event, [ + const depositorId = entityUUID(event, [ event.params.withdrawalChannel.toHexString(), - event.params.validatorIndex.toString() + event.params.depositor.toHexString() ]); - const keyIndex = event.params.validatorIndex.toI32(); - const keyToDelete = ValidationKey.load(keyId); + keyEntity.signature = event.params.signature; + keyEntity.publicKey = event.params.publicKey; + keyEntity.withdrawalChannel = channelId; + keyEntity.index = channel.funded; - if (keyIndex == channel!.total.toI32() - 1) { - store.remove('ValidationKey', keyId); - } else { - const lastKeyId = entityUUID(event, [ - event.params.withdrawalChannel.toHexString(), - (channel!.total.toI32() - 1).toString() - ]); - const lastKey = ValidationKey.load(lastKeyId); - keyToDelete!.publicKey = lastKey!.publicKey; - keyToDelete!.signature = lastKey!.signature; - keyToDelete!.save(); - store.remove('ValidationKey', lastKeyId); - } + keyEntity.validationStatus = 'pending'; + keyEntity.validatorId = event.params.id; + keyEntity.depositor = depositorId; + keyEntity.withdrawalAddress = event.params.withdrawalAddress; + keyEntity.createdAt = event.block.timestamp; + keyEntity.createdAtBlock = event.block.number; + keyEntity.editedAt = event.block.timestamp; + keyEntity.editedAtBlock = event.block.number; - let commonValidationKeyEntry = CommonValidationKeyEntry.load(keyToDelete!.publicKey.toHexString()); - commonValidationKeyEntry!.validationKeyCount = commonValidationKeyEntry!.validationKeyCount.minus(BigInt.fromI32(1)); - commonValidationKeyEntry!.editedAt = event.block.timestamp; - commonValidationKeyEntry!.editedAtBlock = event.block.number; - commonValidationKeyEntry!.save(); - - channel!.total = BigInt.fromI32(channel!.total.toI32() - 1); - channel!.editedAt = event.block.timestamp; - channel!.editedAtBlock = event.block.number; - channel!.save(); - - const se = createRemovedValidationKeysSystemEvent(event, event.address, event.params.withdrawalChannel); - se.count = se.count.plus(BigInt.fromI32(1)); - se.newTotal = channel!.total; - se.save(); -} + keyEntity.save(); -export function handleFundedValidator(event: FundedValidator): void { - const keyId = entityUUID(event, [ - event.params.withdrawalChannel.toHexString(), - event.params.validatorIndex.toString() - ]); - const key = ValidationKey.load(keyId); - const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); - const channel = WithdrawalChannel.load(channelId); - const fundedKeyId = entityUUID(event, [event.params.id.toString()]); - const fundedKey = new FundedValidationKey(fundedKeyId); - const depositorId = entityUUID(event, [ - event.params.withdrawalChannel.toHexString(), - event.params.depositor.toHexString() - ]); + channel.funded = BigInt.fromI32(channel.funded.toI32() + 1); + channel.editedAt = event.block.timestamp; + channel.editedAtBlock = event.block.number; - key!.funded = fundedKeyId; - key!.editedAt = event.block.timestamp; - key!.editedAtBlock = event.block.number; - - let depositIndex = 1; - let depositEventId = `${key!.publicKey.toHexString()}-${depositIndex.toString()}`; - let depositEvent = DepositEvent.load(depositEventId); - while (depositEvent != null) { - depositIndex++; - depositEventId = `${key!.publicKey.toHexString()}-${depositIndex.toString()}`; - depositEvent = DepositEvent.load(depositEventId); - } - depositEventId = `${key!.publicKey.toHexString()}-${(depositIndex - 1).toString()}`; - - fundedKey.depositEvent = depositEventId; - fundedKey.validationKey = keyId; - fundedKey.validatorId = event.params.id; - fundedKey.depositor = depositorId; - fundedKey.withdrawalAddress = event.params.withdrawalAddress; - fundedKey.createdAt = event.block.timestamp; - fundedKey.createdAtBlock = event.block.number; - fundedKey.editedAt = event.block.timestamp; - fundedKey.editedAtBlock = event.block.number; - - channel!.funded = BigInt.fromI32(channel!.funded.toI32() + 1); - channel!.editedAt = event.block.timestamp; - channel!.editedAtBlock = event.block.number; - - key!.save(); - channel!.save(); - fundedKey.save(); - - const se = createExternalFundingSystemAlert(event, key!.publicKey); - if (se.logIndex !== null && (se.logIndex as BigInt).equals(event.logIndex.minus(BigInt.fromI32(1)))) { - cancelSystemEvent(se.id, 'ExternalFundingSystemAlert'); - } + channel.save(); const systemEvent = createFundedValidationKeySystemEvent( event, @@ -325,10 +82,10 @@ export function handleFundedValidator(event: FundedValidator): void { event.params.depositor ); systemEvent.count = systemEvent.count.plus(BigInt.fromI32(1)); - systemEvent.newTotal = channel!.funded; - const fundedKeys = systemEvent.fundedValidationKeys; - fundedKeys.push(fundedKeyId); - systemEvent.fundedValidationKeys = fundedKeys; + systemEvent.newTotal = channel.funded; + const activatedKeys = systemEvent.validationKeys; + activatedKeys.push(keyId); + systemEvent.validationKeys = activatedKeys; systemEvent.save(); const factory = vFactory.load(event.address); @@ -336,16 +93,86 @@ export function handleFundedValidator(event: FundedValidator): void { factory!.save(); } -export function handleExitValidator(event: ExitValidator): void { - const fundedKeyId = entityUUID(event, [event.params.id.toString()]); - const fundedKey = FundedValidationKey.load(fundedKeyId); +// export function handleFundedValidator(event: FundedValidator): void { +// const keyId = entityUUID(event, [ +// event.params.withdrawalChannel.toHexString(), +// event.params.validatorIndex.toString() +// ]); +// const key = ValidationKey.load(keyId); +// const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); +// const channel = WithdrawalChannel.load(channelId); +// const fundedKeyId = entityUUID(event, [event.params.id.toString()]); +// const fundedKey = new FundedValidationKey(fundedKeyId); +// const depositorId = entityUUID(event, [ +// event.params.withdrawalChannel.toHexString(), +// event.params.depositor.toHexString() +// ]); +// +// key!.funded = fundedKeyId; +// key!.editedAt = event.block.timestamp; +// key!.editedAtBlock = event.block.number; +// +// let depositIndex = 1; +// let depositEventId = `${key!.publicKey.toHexString()}-${depositIndex.toString()}`; +// let depositEvent = DepositEvent.load(depositEventId); +// while (depositEvent != null) { +// depositIndex++; +// depositEventId = `${key!.publicKey.toHexString()}-${depositIndex.toString()}`; +// depositEvent = DepositEvent.load(depositEventId); +// } +// depositEventId = `${key!.publicKey.toHexString()}-${(depositIndex - 1).toString()}`; +// +// fundedKey.depositEvent = depositEventId; +// fundedKey.validationKey = keyId; +// fundedKey.validatorId = event.params.id; +// fundedKey.depositor = depositorId; +// fundedKey.withdrawalAddress = event.params.withdrawalAddress; +// fundedKey.createdAt = event.block.timestamp; +// fundedKey.createdAtBlock = event.block.number; +// fundedKey.editedAt = event.block.timestamp; +// fundedKey.editedAtBlock = event.block.number; +// +// channel!.funded = BigInt.fromI32(channel!.funded.toI32() + 1); +// channel!.editedAt = event.block.timestamp; +// channel!.editedAtBlock = event.block.number; +// +// key!.save(); +// channel!.save(); +// fundedKey.save(); +// +// const se = createExternalFundingSystemAlert(event, key!.publicKey); +// if (se.logIndex !== null && (se.logIndex as BigInt).equals(event.logIndex.minus(BigInt.fromI32(1)))) { +// cancelSystemEvent(se.id, 'ExternalFundingSystemAlert'); +// } +// +// const systemEvent = createFundedValidationKeySystemEvent( +// event, +// event.address, +// event.params.withdrawalChannel, +// event.params.depositor +// ); +// systemEvent.count = systemEvent.count.plus(BigInt.fromI32(1)); +// systemEvent.newTotal = channel!.funded; +// const fundedKeys = systemEvent.fundedValidationKeys; +// fundedKeys.push(fundedKeyId); +// systemEvent.fundedValidationKeys = fundedKeys; +// systemEvent.save(); +// +// const factory = vFactory.load(event.address); +// factory!.totalActivatedValidators = factory!.totalActivatedValidators.plus(BigInt.fromI32(1)); +// factory!.save(); +// } + +export function handleExitValidator_2_2_0(event: ExitValidator): void { + const keyId = entityUUID(event, [event.params.id.toString()]); + const key = ValidationKey.load(keyId); - if (fundedKey != null) { + if (key != null) { const exitRequestId = eventUUID(event, [event.params.id.toString()]); const exitRequest = new ExitRequest(exitRequestId); - exitRequest.validator = fundedKeyId; - exitRequest.emitter = fundedKey.owner as Bytes; + exitRequest.validator = keyId; + exitRequest.emitter = key.owner as Bytes; exitRequest.createdAt = event.block.timestamp; exitRequest.createdAtBlock = event.block.number; exitRequest.editedAt = event.block.timestamp; @@ -353,51 +180,66 @@ export function handleExitValidator(event: ExitValidator): void { exitRequest.save(); - fundedKey.lastExitRequest = exitRequestId; - fundedKey.editedAt = event.block.timestamp; - fundedKey.editedAtBlock = event.block.number; + key.lastExitRequest = exitRequestId; + key.editedAt = event.block.timestamp; + key.editedAtBlock = event.block.number; - fundedKey.save(); + key.save(); } } -export function handleUpdatedLimit(event: UpdatedLimit): void { - const channelId = entityUUID(event, [event.params.withdrawalChannel.toHexString()]); - const channel = WithdrawalChannel.load(channelId); +export function handleSetRoot_2_2_0(event: SetRoot): void { + const factory = vFactory.load(event.address); + + factory!.treeRoot = event.params.newRoot.root; + factory!.treeIPFSHash = event.params.newRoot.ipfsHash; + + factory!.editedAt = event.block.timestamp; + factory!.editedAtBlock = event.block.number; - const oldLimit = channel!.limit; + factory!.save(); +} + +export function handleSetValidatorThreshold_2_2_0(event: SetValidatorThreshold): void { + const keyId = entityUUID(event, [event.params.id.toString()]); + const key = ValidationKey.load(keyId); + + if (key != null) { + let oldThreshold = key.threshold; + if (oldThreshold === null) { + oldThreshold = BigInt.zero(); + } + key.threshold = event.params.thresholdGwei; - channel!.limit = event.params.limit; - channel!.editedAt = event.block.timestamp; - channel!.editedAtBlock = event.block.number; + key.editedAt = event.block.timestamp; + key.editedAtBlock = event.block.number; - channel!.save(); + key.save(); - if (oldLimit.notEqual(event.params.limit)) { - const se = createUpdatedLimitSystemEvent(event, event.address, event.params.withdrawalChannel); - if (se.oldLimit === null) { - se.oldLimit = oldLimit; + if (oldThreshold.notEqual(event.params.thresholdGwei)) { + const se = createValidatorThresholdChangedSystemEvent(event, event.address, event.params.id); + se.oldThreshold = oldThreshold; + se.newThreshold = event.params.thresholdGwei; + se.save(); } - se.newLimit = event.params.limit; - se.save(); } } export function handleSetValidatorOwner(event: SetValidatorOwner): void { - const fundedKeyId = entityUUID(event, [event.params.id.toString()]); - const fundedKey = FundedValidationKey.load(fundedKeyId); + const keyId = entityUUID(event, [event.params.id.toString()]); + const key = ValidationKey.load(keyId); - if (fundedKey != null) { - let oldOwner = fundedKey.owner; + if (key != null) { + let oldOwner = key.owner; if (oldOwner === null) { oldOwner = Address.zero(); } - fundedKey.owner = event.params.owner; + key.owner = event.params.owner; - fundedKey.editedAt = event.block.timestamp; - fundedKey.editedAtBlock = event.block.number; + key.editedAt = event.block.timestamp; + key.editedAtBlock = event.block.number; - fundedKey.save(); + key.save(); if (oldOwner != event.params.owner) { const se = createValidatorOwnerChangedSystemEvent(event, event.address, event.params.id); @@ -409,20 +251,20 @@ export function handleSetValidatorOwner(event: SetValidatorOwner): void { } export function handleSetValidatorFeeRecipient(event: SetValidatorFeeRecipient): void { - const fundedKeyId = entityUUID(event, [event.params.id.toString()]); - const fundedKey = FundedValidationKey.load(fundedKeyId); + const keyId = entityUUID(event, [event.params.id.toString()]); + const key = ValidationKey.load(keyId); - if (fundedKey != null) { - let oldFeeRecipient = fundedKey.feeRecipient; + if (key != null) { + let oldFeeRecipient = key.feeRecipient; if (oldFeeRecipient === null) { oldFeeRecipient = Address.zero(); } - fundedKey.feeRecipient = event.params.feeRecipient; + key.feeRecipient = event.params.feeRecipient; - fundedKey.editedAt = event.block.timestamp; - fundedKey.editedAtBlock = event.block.number; + key.editedAt = event.block.timestamp; + key.editedAtBlock = event.block.number; - fundedKey.save(); + key.save(); if (oldFeeRecipient != event.params.feeRecipient) { const se = createValidatorFeeRecipientChangedSystemEvent(event, event.address, event.params.id); @@ -434,20 +276,20 @@ export function handleSetValidatorFeeRecipient(event: SetValidatorFeeRecipient): } export function handleSetValidatorExtraData(event: SetValidatorExtraData): void { - const fundedKeyId = entityUUID(event, [event.params.id.toString()]); - const fundedKey = FundedValidationKey.load(fundedKeyId); + const keyId = entityUUID(event, [event.params.id.toString()]); + const key = ValidationKey.load(keyId); - if (fundedKey != null) { - let oldExtraData = fundedKey.extraData; + if (key != null) { + let oldExtraData = key.extraData; if (oldExtraData === null) { oldExtraData = ''; } - fundedKey.extraData = event.params.extraData; + key.extraData = event.params.extraData; - fundedKey.editedAt = event.block.timestamp; - fundedKey.editedAtBlock = event.block.number; + key.editedAt = event.block.timestamp; + key.editedAtBlock = event.block.number; - fundedKey.save(); + key.save(); if (oldExtraData != event.params.extraData) { const se = createValidatorExtraDataChangedSystemEvent(event, event.address, event.params.id); se.oldExtraData = oldExtraData; @@ -639,9 +481,7 @@ export function handleSetExitTotal(event: SetExitTotal): void { channel = new WithdrawalChannel(channelId); channel.withdrawalChannel = event.params.withdrawalChannel; channel.factory = event.address; - channel.total = BigInt.fromI32(0); channel.funded = BigInt.fromI32(0); - channel.limit = BigInt.fromI32(0); channel.createdAt = event.block.timestamp; channel.createdAtBlock = event.block.number; } @@ -662,9 +502,7 @@ export function handleApproveDepositor(event: ApproveDepositor): void { channel = new WithdrawalChannel(channelId); channel.withdrawalChannel = event.params.wc; channel.factory = event.address; - channel.total = BigInt.fromI32(0); channel.funded = BigInt.fromI32(0); - channel.limit = BigInt.fromI32(0); channel.lastExitTotal = BigInt.fromI32(0); channel.editedAt = event.block.timestamp; channel.editedAtBlock = event.block.number; diff --git a/src/vNFT.mapping.ts b/src/vNFT.mapping.ts deleted file mode 100644 index 06fc646..0000000 --- a/src/vNFT.mapping.ts +++ /dev/null @@ -1,333 +0,0 @@ -import { Address, BigInt, Bytes } from '@graphprotocol/graph-ts'; -import { - MerkleVault, - vFactory, - vNFT, - vNFTApprovals, - vNFTIntegration, - vNFTTransfer, - vNFTUser, - vNFTidsMapping -} from '../generated/schema'; -import { - Approval, - ApprovalForAll, - PurchasedValidator, - SetExecLayerVault, - SetExtraData, - SetFactory, - SetIntegrator, - SetIntegratorCommission, - SetName, - SetOperatorCommission, - SetPurchasePause, - SetSoulboundMode, - SetSymbol, - SetURIPrefix, - TokenIdUpdated, - Transfer, - UpdateUser, - UsershipCleared, - SetAdmin -} from '../generated/templates/vNFT/vNFT'; -import { MerkleVault as MerkleVaultTemplate } from '../generated/templates'; -import { entityUUID, eventUUID, externalEntityUUID } from './utils/utils'; - -function getInternalTokenId(vnftIntegrationAddress: Address, externalTokenId: BigInt): BigInt { - const mapping = vNFTidsMapping.load(externalEntityUUID(vnftIntegrationAddress, [externalTokenId.toString()])); - return mapping!.internalTokenId; -} - -export function handleSetName(event: SetName): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.name = event.params.name; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetSymbol(event: SetSymbol): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.symbol = event.params.symbol; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetExtraData(event: SetExtraData): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.extraData = event.params.extraData; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetURIPrefix(event: SetURIPrefix): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.uriPrefix = event.params.uriPrefix; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetPaused(event: SetPurchasePause): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.paused = event.params.isPaused; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetFactory(event: SetFactory): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.vFactory = event.params.factory; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetOperatorCommission(event: SetOperatorCommission): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.operatorCommission = event.params.operatorCommission; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetIntegratorCommission(event: SetIntegratorCommission): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.integratorCommission = event.params.integratorCommission; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handleSetIntegrator(event: SetIntegrator): void { - const vnftIntegration = vNFTIntegration.load(event.address); - - vnftIntegration!.integrator = event.params.integrator; - - vnftIntegration!.editedAt = event.block.timestamp; - vnftIntegration!.editedAtBlock = event.block.number; - vnftIntegration!.save(); -} - -export function handlePurchasedValidator(event: PurchasedValidator): void { - const tokenId = event.params.tokenId; - const internalTokenId = event.params.validatorId; - const ts = event.block.timestamp; - const blockId = event.block.number; - const vnftIntegration = vNFTIntegration.load(event.address); - - const vFactoryAddres = vFactory.load(vnftIntegration!.vFactory)!.address; - - const id = entityUUID(event, [internalTokenId.toString()]); - const vnft = new vNFT(id); - vnft.tokenId = tokenId; - vnft.internalTokenId = internalTokenId; - vnft.integration = event.address; - vnft.owner = event.params.owner; - vnft.validator = externalEntityUUID(Address.fromBytes(vFactoryAddres), [internalTokenId.toString()]); - - vnft.editedAt = ts; - vnft.editedAtBlock = blockId; - vnft.createdAt = ts; - vnft.createdAtBlock = blockId; - - vnft.save(); - - vnftIntegration!.supply = vnftIntegration!.supply.plus(BigInt.fromI32(1)); - vnftIntegration!.editedAt = ts; - vnftIntegration!.editedAtBlock = blockId; - vnftIntegration!.save(); - - const mapping = new vNFTidsMapping(entityUUID(event, [tokenId.toString()])); - mapping.internalTokenId = internalTokenId; - mapping.externalTokenId = tokenId; - mapping.save(); -} - -export function handleTransfer(event: Transfer): void { - if (event.params.to.equals(Address.zero()) || event.params.from.equals(Address.zero())) { - return; - } - - const internalTokenId = getInternalTokenId(event.address, event.params.tokenId); - const ts = event.block.timestamp; - const blockId = event.block.number; - - const id = eventUUID(event, [internalTokenId.toString()]); - const transfer = new vNFTTransfer(id); - transfer.from = event.params.from; - transfer.to = event.params.to; - - transfer.editedAt = ts; - transfer.editedAtBlock = blockId; - transfer.createdAt = ts; - transfer.createdAtBlock = blockId; - - const vnft = vNFT.load(entityUUID(event, [internalTokenId.toString()])); - vnft!.owner = event.params.to; - vnft!.editedAt = ts; - vnft!.editedAtBlock = blockId; - vnft!.approval = null; - - transfer.vNFT = vnft!.id; - - vnft!.save(); - transfer.save(); -} - -export function handleUpdateUser(event: UpdateUser): void { - const tokenId = event.params.tokenId; - const id = entityUUID(event, [getInternalTokenId(event.address, tokenId).toString()]); - const ts = event.block.timestamp; - const blockId = event.block.number; - - let user = vNFTUser.load(id); - if (!user) { - user = new vNFTUser(id); - user.createdAt = ts; - user.createdAtBlock = blockId; - user.vNFT = id; - } - user.user = event.params.user; - user.expiry = event.params.expires; - user.editedAt = ts; - user.editedAtBlock = blockId; - - user.save(); -} - -export function handleApproval(event: Approval): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const vnft = vNFT.load(entityUUID(event, [getInternalTokenId(event.address, event.params.tokenId).toString()])); - vnft!.editedAt = ts; - vnft!.editedAtBlock = blockId; - vnft!.approval = event.params.approved; - vnft!.save(); -} - -export function handleUsershipCleared(event: UsershipCleared): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const vnftUser = vNFTUser.load( - entityUUID(event, [getInternalTokenId(event.address, event.params.tokenId).toString()]) - ); - vnftUser!.user = Address.zero(); - vnftUser!.expiry = BigInt.zero(); - - vnftUser!.editedAt = ts; - vnftUser!.editedAtBlock = blockId; - vnftUser!.save(); -} - -export function handleSetExecLayerVault(event: SetExecLayerVault): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const merkleVaultAddress = event.params.execLayerVault; - let merkleVault = MerkleVault.load(merkleVaultAddress); - if (!merkleVault) { - merkleVault = new MerkleVault(merkleVaultAddress); - merkleVault.root = Bytes.empty(); - merkleVault.frameSize = BigInt.zero(); - merkleVault.ipfsHash = ''; - - merkleVault.createdAt = ts; - merkleVault.createdAtBlock = blockId; - merkleVault.editedAt = ts; - merkleVault.editedAtBlock = blockId; - merkleVault.save(); - - MerkleVaultTemplate.create(merkleVaultAddress); - } - const vnftIntegration = vNFTIntegration.load(event.address); - vnftIntegration!.execLayerVault = merkleVaultAddress; - - vnftIntegration!.editedAt = ts; - vnftIntegration!.editedAtBlock = blockId; - vnftIntegration!.save(); -} - -export function handleApprovalForAll(event: ApprovalForAll): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const id = entityUUID(event, [event.params.owner.toHexString(), event.params.operator.toHexString()]); - let approval = vNFTApprovals.load(id); - if (!approval) { - approval = new vNFTApprovals(id); - approval.owner = event.params.owner; - approval.operator = event.params.operator; - approval.createdAt = ts; - approval.createdAtBlock = blockId; - approval.integration = event.address; - } - - approval.approval = event.params.approved; - approval.editedAt = ts; - approval.editedAtBlock = blockId; - - approval.save(); -} - -export function handleTokenIdUpdated(event: TokenIdUpdated): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const vnft = vNFT.load(entityUUID(event, [event.params.validatorId.toString()])); - vnft!.tokenId = event.params.newTokenId; - - vnft!.editedAt = ts; - vnft!.editedAtBlock = blockId; - vnft!.save(); - - const mapping = new vNFTidsMapping(entityUUID(event, [event.params.newTokenId.toString()])); - mapping.internalTokenId = event.params.validatorId; - mapping.externalTokenId = event.params.newTokenId; - mapping.save(); -} - -export function handleSetSoulboundMode(event: SetSoulboundMode): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const vnftIntegration = vNFTIntegration.load(event.address); - vnftIntegration!.soulboundMode = event.params.active; - - vnftIntegration!.editedAt = ts; - vnftIntegration!.editedAtBlock = blockId; - vnftIntegration!.save(); -} - -export function handleSetAdmin(event: SetAdmin): void { - const ts = event.block.timestamp; - const blockId = event.block.number; - - const vnftIntegration = vNFTIntegration.load(event.address); - vnftIntegration!.admin = event.params.admin; - - vnftIntegration!.editedAt = ts; - vnftIntegration!.editedAtBlock = blockId; - vnftIntegration!.save(); -} diff --git a/src/vOracleAggregator.mapping.ts b/src/vOracleAggregator.mapping.ts index b3578d5..c25b2be 100644 --- a/src/vOracleAggregator.mapping.ts +++ b/src/vOracleAggregator.mapping.ts @@ -2,12 +2,15 @@ import { AddedOracleAggregatorMember, GlobalMemberVoted, MemberVoted, - MemberVotedReportStruct, - GlobalMemberVotedReportStruct, RemovedOracleAggregatorMember, SetHighestReportedEpoch, SubmittedReport } from '../generated/templates/vOracleAggregator/vOracleAggregator'; +import { + MemberVoted as MemberVoted_2_2_0, + GlobalMemberVoted as GlobalMemberVoted_2_2_0, + SubmittedReport as SubmittedReport_2_2_0 +} from '../generated/templates/vOracleAggregator_2_2_0/vOracleAggregator_2_2_0'; import { vOracleAggregator, OracleAggregatorMember, @@ -28,6 +31,20 @@ function getQuorum(memberCount: BigInt): BigInt { return memberCount.plus(BigInt.fromI32(1)).times(BigInt.fromI32(3)).div(BigInt.fromI32(4)).plus(BigInt.fromI32(1)); } +class ReportStruct { + balanceSum: BigInt; + exitedSum: BigInt; + skimmedSum: BigInt; + slashedSum: BigInt; + exitingSum: BigInt; + maxExitable: BigInt; + maxCommittable: BigInt; + epoch: BigInt; + activatedCount: BigInt; + stoppedCount: BigInt; + invalidActivationCount: BigInt; +} + export function handleAddedOracleAggregatorMember(event: AddedOracleAggregatorMember): void { const oa = vOracleAggregator.load(event.address); @@ -153,12 +170,7 @@ function timeSinceLastVariant(epoch: BigInt, oracleAggregatorAddress: Bytes): Bi return BigInt.zero(); } -export function handleGlobalVote( - event: ethereum.Event, - voter: Bytes, - variant: Bytes, - report: GlobalMemberVotedReportStruct -): void { +export function handleGlobalVote(event: ethereum.Event, voter: Bytes, variant: Bytes, report: ReportStruct): void { const oa = vOracleAggregator.load(event.address); const variantId = entityUUID(event, [variant.toHexString()]); @@ -173,11 +185,12 @@ export function handleGlobalVote( _variant.exitedSum = report.exitedSum; _variant.skimmedSum = report.skimmedSum; _variant.slashedSum = report.slashedSum; - _variant.exiting = report.exiting; + _variant.exitingSum = report.exitingSum; _variant.maxExitable = report.maxExitable; _variant.maxCommittable = report.maxCommittable; _variant.activatedCount = report.activatedCount; _variant.stoppedCount = report.stoppedCount; + _variant.invalidActivationCount = report.invalidActivationCount; _variant.oracleAggregator = event.address; _variant.createdAt = event.block.timestamp; @@ -222,7 +235,7 @@ export function handleGlobalVote( systemEvent.save(); } -export function handleVote(event: ethereum.Event, voter: Bytes, variant: Bytes, report: MemberVotedReportStruct): void { +export function handleVote(event: ethereum.Event, voter: Bytes, variant: Bytes, report: ReportStruct): void { const oa = vOracleAggregator.load(event.address); const variantId = entityUUID(event, [variant.toHexString()]); @@ -237,11 +250,12 @@ export function handleVote(event: ethereum.Event, voter: Bytes, variant: Bytes, _variant.exitedSum = report.exitedSum; _variant.skimmedSum = report.skimmedSum; _variant.slashedSum = report.slashedSum; - _variant.exiting = report.exiting; + _variant.exitingSum = report.exitingSum; _variant.maxExitable = report.maxExitable; _variant.maxCommittable = report.maxCommittable; _variant.activatedCount = report.activatedCount; _variant.stoppedCount = report.stoppedCount; + _variant.invalidActivationCount = report.invalidActivationCount; _variant.oracleAggregator = event.address; _variant.createdAt = event.block.timestamp; @@ -287,11 +301,75 @@ export function handleVote(event: ethereum.Event, voter: Bytes, variant: Bytes, } export function handleMemberVoted(event: MemberVoted): void { - handleVote(event, event.params.member, event.params.variant, event.params.report); + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exiting, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: BigInt.zero() + }; + + handleVote(event, event.params.member, event.params.variant, reportStruct); } export function handlerGlobalMemberVoted(event: GlobalMemberVoted): void { - handleGlobalVote(event, event.params.globalMember, event.params.variant, event.params.report); + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exiting, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: BigInt.zero() + }; + + handleGlobalVote(event, event.params.globalMember, event.params.variant, reportStruct); +} + +export function handleMemberVoted_2_2_0(event: MemberVoted_2_2_0): void { + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exitingSum, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: event.params.report.invalidActivationCount + }; + + handleVote(event, event.params.member, event.params.variant, reportStruct); +} + +export function handlerGlobalMemberVoted_2_2_0(event: GlobalMemberVoted_2_2_0): void { + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exitingSum, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: event.params.report.invalidActivationCount + }; + + handleGlobalVote(event, event.params.globalMember, event.params.variant, reportStruct); } export function handleSubmittedReport(event: SubmittedReport): void { @@ -312,6 +390,24 @@ export function handleSubmittedReport(event: SubmittedReport): void { oa!.save(); } +export function handleSubmittedReport_2_2_0(event: SubmittedReport_2_2_0): void { + const oa = vOracleAggregator.load(event.address); + const blockId = event.block.timestamp; + const ts = event.block.timestamp; + + const variantId = entityUUID(event, [event.params.variant.toHexString()]); + + const variant = OracleAggregatorReportVariant.load(variantId); + + variant!.submitted = true; + variant!.save(); + + oa!.lastVariant = variantId; + oa!.editedAt = ts; + oa!.editedAtBlock = blockId; + oa!.save(); +} + export function handleSetHighestReportedEpoch(event: SetHighestReportedEpoch): void { const oa = vOracleAggregator.load(event.address); oa!.highestReportedEpoch = event.params.epoch; diff --git a/src/vPool.mapping.ts b/src/vPool.mapping.ts index b470509..16decb0 100644 --- a/src/vPool.mapping.ts +++ b/src/vPool.mapping.ts @@ -15,6 +15,7 @@ import { SetContractLinks, SetConsensusLayerSpec } from '../generated/templates/vPool/vPool'; +import { ProcessedReport as ProcessedReport_2_2_0 } from '../generated/templates/vPool_2_2_0/vPool_2_2_0'; import { PoolBalance, PoolPurchasedValidator, @@ -29,8 +30,7 @@ import { vExitQueue, vPoolRewardEntry, IntegrationRewardEntry, - DepositDataEntry, - ERC1155Integration + DepositDataEntry } from '../generated/schema'; import { Bytes, BigInt, Address, store, dataSource } from '@graphprotocol/graph-ts'; import { ethereum } from '@graphprotocol/graph-ts/chain/ethereum'; @@ -198,13 +198,8 @@ export function handleTransfer(event: Transfer): void { const exitQueue = vExitQueue.load(event.params.to); const erc20Integration = ERC20.load(event.params.from); - const erc1155Integration = ERC1155Integration.load(event.params.from); - if ( - exitQueue != null && - exitQueue.id == pool!.exitQueue && - (erc20Integration != null || erc1155Integration != null) - ) { + if (exitQueue != null && exitQueue.id == pool!.exitQueue && erc20Integration != null) { const stakedValueBefore = _computeStakedEthValue( fromBalance.amount, pool!.totalSupply, @@ -266,13 +261,13 @@ export function handlePurchasedValidators(event: PurchasedValidators): void { ]); validators.push(poolPurchasedValidatorId); const poolPurchasedValidator = new PoolPurchasedValidator(poolPurchasedValidatorId); - const fundedKeyId = externalEntityUUID(Address.fromBytes(vFactory.load(pool!.factory)!.address), [ + const keyId = externalEntityUUID(Address.fromBytes(vFactory.load(pool!.factory)!.address), [ event.params.validators[idx].toString() ]); poolPurchasedValidator.pool = pool!.id; poolPurchasedValidator.index = BigInt.fromI32(validatorCount + idx); - poolPurchasedValidator.fundedValidationKey = fundedKeyId; + poolPurchasedValidator.validationKey = keyId; poolPurchasedValidator.createdAt = event.block.timestamp; poolPurchasedValidator.editedAt = event.block.timestamp; poolPurchasedValidator.createdAtBlock = event.block.number; @@ -340,78 +335,206 @@ function _computeTotalUnderlyingSupply(pool: vPool, lastReport: Report | null): return totalUnderlyingSupply; } +class ReportStruct { + balanceSum: BigInt; + exitedSum: BigInt; + skimmedSum: BigInt; + slashedSum: BigInt; + exitingSum: BigInt; + maxExitable: BigInt; + maxCommittable: BigInt; + epoch: BigInt; + activatedCount: BigInt; + stoppedCount: BigInt; + invalidActivationCount: BigInt; +} + +class TracesStruct { + preUnderlyingSupply: BigInt; + postUnderlyingSupply: BigInt; + preSupply: BigInt; + postSupply: BigInt; + newExitedEthers: BigInt; + newSkimmedEthers: BigInt; + exitBoostEthers: BigInt; + exitFedEthers: BigInt; + exitBurnedShares: BigInt; + exitingProjection: BigInt; + baseFulfillableDemand: BigInt; + extraFulfillableDemand: BigInt; + rewards: BigInt; + delta: BigInt; + increaseLimit: BigInt; + coverageIncreaseLimit: BigInt; + decreaseLimit: BigInt; + consensusLayerDelta: BigInt; + pulledCoverageFunds: BigInt; + pulledExecutionLayerRewards: BigInt; + pulledExitQueueUnclaimedFunds: BigInt; +} + export function handleProcessedReport(event: ProcessedReport): void { + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exiting, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: BigInt.zero() + }; + + const traces: TracesStruct = { + preUnderlyingSupply: event.params.traces.preUnderlyingSupply, + postUnderlyingSupply: event.params.traces.postUnderlyingSupply, + preSupply: event.params.traces.preSupply, + postSupply: event.params.traces.postSupply, + newExitedEthers: event.params.traces.newExitedEthers, + newSkimmedEthers: event.params.traces.newSkimmedEthers, + exitBoostEthers: event.params.traces.exitBoostEthers, + exitFedEthers: event.params.traces.exitFedEthers, + exitBurnedShares: event.params.traces.exitBurnedShares, + exitingProjection: event.params.traces.exitingProjection, + baseFulfillableDemand: event.params.traces.baseFulfillableDemand, + extraFulfillableDemand: event.params.traces.extraFulfillableDemand, + rewards: event.params.traces.rewards, + delta: event.params.traces.delta, + increaseLimit: event.params.traces.increaseLimit, + coverageIncreaseLimit: event.params.traces.coverageIncreaseLimit, + decreaseLimit: event.params.traces.decreaseLimit, + consensusLayerDelta: event.params.traces.consensusLayerDelta, + pulledCoverageFunds: event.params.traces.pulledCoverageFunds, + pulledExecutionLayerRewards: event.params.traces.pulledExecutionLayerRewards, + pulledExitQueueUnclaimedFunds: event.params.traces.pulledExitQueueUnclaimedFunds + }; + + processedReportLogic(event, event.params.epoch, reportStruct, traces); +} + +export function handleProcessedReport_2_2_0(event: ProcessedReport_2_2_0): void { + const reportStruct: ReportStruct = { + balanceSum: event.params.report.balanceSum, + exitedSum: event.params.report.exitedSum, + skimmedSum: event.params.report.skimmedSum, + slashedSum: event.params.report.slashedSum, + exitingSum: event.params.report.exitingSum, + maxExitable: event.params.report.maxExitable, + maxCommittable: event.params.report.maxCommittable, + epoch: event.params.report.epoch, + activatedCount: event.params.report.activatedCount, + stoppedCount: event.params.report.stoppedCount, + invalidActivationCount: event.params.report.invalidActivationCount + }; + + const traces: TracesStruct = { + preUnderlyingSupply: event.params.traces.preUnderlyingSupply, + postUnderlyingSupply: event.params.traces.postUnderlyingSupply, + preSupply: event.params.traces.preSupply, + postSupply: event.params.traces.postSupply, + newExitedEthers: event.params.traces.newExitedEthers, + newSkimmedEthers: event.params.traces.newSkimmedEthers, + exitBoostEthers: event.params.traces.exitBoostEthers, + exitFedEthers: event.params.traces.exitFedEthers, + exitBurnedShares: event.params.traces.exitBurnedShares, + exitingProjection: event.params.traces.exitingProjection, + baseFulfillableDemand: event.params.traces.baseFulfillableDemand, + extraFulfillableDemand: event.params.traces.extraFulfillableDemand, + rewards: event.params.traces.rewards, + delta: event.params.traces.delta, + increaseLimit: event.params.traces.increaseLimit, + coverageIncreaseLimit: event.params.traces.coverageIncreaseLimit, + decreaseLimit: event.params.traces.decreaseLimit, + consensusLayerDelta: event.params.traces.consensusLayerDelta, + pulledCoverageFunds: event.params.traces.pulledCoverageFunds, + pulledExecutionLayerRewards: event.params.traces.pulledExecutionLayerRewards, + pulledExitQueueUnclaimedFunds: event.params.traces.pulledExitQueueUnclaimedFunds + }; + + processedReportLogic(event, event.params.epoch, reportStruct, traces); +} + +export function processedReportLogic( + event: ethereum.Event, + epoch: BigInt, + report: ReportStruct, + traces: TracesStruct +): void { if (shouldSkip(event)) { return; } const pool = vPool.load(event.address); - const reportId = entityUUID(event, [event.params.epoch.toString()]); + const reportId = entityUUID(event, [epoch.toString()]); if (Report.load(reportId) != null) { // if we have the same epoch twice, it's most probably due to a manual fix return; } - const report = new Report(reportId); + const reportEntity = new Report(reportId); const lastEpoch = pool!.lastEpoch; - report.pool = pool!.id; - report.epoch = event.params.epoch; - report.balanceSum = event.params.report.balanceSum; - report.exitedSum = event.params.report.exitedSum; - report.skimmedSum = event.params.report.skimmedSum; - report.slashedSum = event.params.report.slashedSum; - report.exiting = event.params.report.exiting; - report.maxExitable = event.params.report.maxExitable; - report.maxCommittable = event.params.report.maxCommittable; - report.activatedCount = event.params.report.activatedCount; - report.stoppedCount = event.params.report.stoppedCount; - - report.preUnderlyingSupply = event.params.traces.preUnderlyingSupply; - report.postUnderlyingSupply = event.params.traces.postUnderlyingSupply; - report.preSupply = event.params.traces.preSupply; - report.postSupply = event.params.traces.postSupply; - report.newExitedEthers = event.params.traces.newExitedEthers; - report.newSkimmedEthers = event.params.traces.newSkimmedEthers; - report.exitBoostEthers = event.params.traces.exitBoostEthers; - report.exitFedEthers = event.params.traces.exitFedEthers; - report.exitBurnedShares = event.params.traces.exitBurnedShares; - report.rewards = event.params.traces.rewards; - report.delta = event.params.traces.delta; - report.increaseLimit = event.params.traces.increaseLimit; - report.coverageIncreaseLimit = event.params.traces.coverageIncreaseLimit; - report.decreaseLimit = event.params.traces.decreaseLimit; - report.consensusLayerDelta = event.params.traces.consensusLayerDelta; - report.pulledCoverageFunds = event.params.traces.pulledCoverageFunds; - report.pulledExecutionLayerRewards = event.params.traces.pulledExecutionLayerRewards; - report.pulledExitQueueUnclaimedFunds = event.params.traces.pulledExitQueueUnclaimedFunds; - - report.createdAt = event.block.timestamp; - report.editedAt = event.block.timestamp; - report.createdAtBlock = event.block.number; - report.editedAtBlock = event.block.number; - report.save(); + reportEntity.pool = pool!.id; + reportEntity.epoch = epoch; + reportEntity.balanceSum = report.balanceSum; + reportEntity.exitedSum = report.exitedSum; + reportEntity.skimmedSum = report.skimmedSum; + reportEntity.slashedSum = report.slashedSum; + reportEntity.exitingSum = report.exitingSum; + reportEntity.maxExitable = report.maxExitable; + reportEntity.maxCommittable = report.maxCommittable; + reportEntity.activatedCount = report.activatedCount; + reportEntity.stoppedCount = report.stoppedCount; + reportEntity.invalidActivationCount = report.invalidActivationCount; + + reportEntity.preUnderlyingSupply = traces.preUnderlyingSupply; + reportEntity.postUnderlyingSupply = traces.postUnderlyingSupply; + reportEntity.preSupply = traces.preSupply; + reportEntity.postSupply = traces.postSupply; + reportEntity.newExitedEthers = traces.newExitedEthers; + reportEntity.newSkimmedEthers = traces.newSkimmedEthers; + reportEntity.exitBoostEthers = traces.exitBoostEthers; + reportEntity.exitFedEthers = traces.exitFedEthers; + reportEntity.exitBurnedShares = traces.exitBurnedShares; + reportEntity.rewards = traces.rewards; + reportEntity.delta = traces.delta; + reportEntity.increaseLimit = traces.increaseLimit; + reportEntity.coverageIncreaseLimit = traces.coverageIncreaseLimit; + reportEntity.decreaseLimit = traces.decreaseLimit; + reportEntity.consensusLayerDelta = traces.consensusLayerDelta; + reportEntity.pulledCoverageFunds = traces.pulledCoverageFunds; + reportEntity.pulledExecutionLayerRewards = traces.pulledExecutionLayerRewards; + reportEntity.pulledExitQueueUnclaimedFunds = traces.pulledExitQueueUnclaimedFunds; + + reportEntity.createdAt = event.block.timestamp; + reportEntity.editedAt = event.block.timestamp; + reportEntity.createdAtBlock = event.block.number; + reportEntity.editedAtBlock = event.block.number; + reportEntity.save(); if (dataSource.network() === 'mainnet') { - if (pool!.totalUnderlyingSupply != event.params.traces.preUnderlyingSupply) { + if (pool!.totalUnderlyingSupply != traces.preUnderlyingSupply) { throw new Error( 'Invalid pool.totalUnderlyingSupply ' + pool!.totalUnderlyingSupply.toString() + ' ' + - event.params.traces.preUnderlyingSupply.toString() + traces.preUnderlyingSupply.toString() ); } - if (pool!.totalSupply.plus(event.params.traces.exitBurnedShares) != event.params.traces.preSupply) { + if (pool!.totalSupply.plus(traces.exitBurnedShares) != traces.preSupply) { throw new Error( 'Invalid pool.totalSupply + traces.exitBurnedShares ' + - pool!.totalSupply.plus(event.params.traces.exitBurnedShares).toString() + + pool!.totalSupply.plus(traces.exitBurnedShares).toString() + ' ' + - event.params.traces.preSupply.toString() + traces.preSupply.toString() ); } } - const pool_pre_supply = event.params.traces.preSupply; - const pool_pre_underlying_supply = event.params.traces.preUnderlyingSupply; + const pool_pre_supply = traces.preSupply; + const pool_pre_underlying_supply = traces.preUnderlyingSupply; let pool_post_supply: BigInt; if ( event.block.number.lt(BigInt.fromI64(9305795)) && @@ -419,63 +542,65 @@ export function handleProcessedReport(event: ProcessedReport): void { event.address.equals(Address.fromString('0x182e3d45efc4436edb183f4278838505a1847e21'))) ) { // edge case for testnet pools before the traces fix was introduces - pool_post_supply = event.params.traces.postSupply.minus(report.exitBurnedShares); + pool_post_supply = traces.postSupply.minus(reportEntity.exitBurnedShares); } else { - pool_post_supply = event.params.traces.postSupply; + pool_post_supply = traces.postSupply; } - const pool_post_underlying_supply = _computeTotalUnderlyingSupply(pool!, report); + const pool_post_underlying_supply = _computeTotalUnderlyingSupply(pool!, reportEntity); if (dataSource.network() === 'mainnet') { - if (pool_post_underlying_supply != event.params.traces.postUnderlyingSupply) { + if (pool_post_underlying_supply != traces.postUnderlyingSupply) { throw new Error( 'Invalid pool_post_underlying_supply ' + pool_post_underlying_supply.toString() + ' ' + - event.params.traces.postUnderlyingSupply.toString() + traces.postUnderlyingSupply.toString() ); } } pool!.totalSupply = pool_post_supply; pool!.totalUnderlyingSupply = pool_post_underlying_supply; - pool!.lastEpoch = event.params.epoch; - pool!.expectedEpoch = event.params.epoch.plus(pool!.epochsPerFrame); + pool!.lastEpoch = epoch; + pool!.expectedEpoch = epoch.plus(pool!.epochsPerFrame); pool!.editedAt = event.block.timestamp; pool!.editedAtBlock = event.block.number; pool!.save(); - const period = event.params.epoch.minus(lastEpoch).times(pool!.slotsPerEpoch).times(pool!.secondsPerSlot); + const period = epoch.minus(lastEpoch).times(pool!.slotsPerEpoch).times(pool!.secondsPerSlot); const vpoolRewardEntry = new vPoolRewardEntry(eventUUID(event, ['vPoolRewardEntry'])); vpoolRewardEntry.type = 'vPoolRewardEntry'; - vpoolRewardEntry.grossReward = report.delta.gt(BigInt.fromI32(0)) ? report.delta : BigInt.fromI32(0); - vpoolRewardEntry.netReward = (report.delta.gt(BigInt.fromI32(0)) ? report.delta : BigInt.fromI32(0)).minus( - report.rewards.times(pool!.operatorFee).div(BigInt.fromI32(10000)) - ); - vpoolRewardEntry.coverage = report.pulledCoverageFunds; - vpoolRewardEntry.grossELRewards = report.pulledExecutionLayerRewards; - vpoolRewardEntry.grossCLRewards = report.consensusLayerDelta; - vpoolRewardEntry.netELRewards = report.pulledExecutionLayerRewards.minus( - report.pulledExecutionLayerRewards.times(pool!.operatorFee).div(BigInt.fromI32(10000)) + vpoolRewardEntry.grossReward = reportEntity.delta.gt(BigInt.fromI32(0)) ? reportEntity.delta : BigInt.fromI32(0); + vpoolRewardEntry.netReward = ( + reportEntity.delta.gt(BigInt.fromI32(0)) ? reportEntity.delta : BigInt.fromI32(0) + ).minus(reportEntity.rewards.times(pool!.operatorFee).div(BigInt.fromI32(10000))); + vpoolRewardEntry.coverage = reportEntity.pulledCoverageFunds; + vpoolRewardEntry.grossELRewards = reportEntity.pulledExecutionLayerRewards; + vpoolRewardEntry.grossCLRewards = reportEntity.consensusLayerDelta; + vpoolRewardEntry.netELRewards = reportEntity.pulledExecutionLayerRewards.minus( + reportEntity.pulledExecutionLayerRewards.times(pool!.operatorFee).div(BigInt.fromI32(10000)) ); - vpoolRewardEntry.netCLRewards = report.consensusLayerDelta.gt(BigInt.fromI32(0)) - ? report.consensusLayerDelta.minus(report.consensusLayerDelta.times(pool!.operatorFee).div(BigInt.fromI32(10000))) - : report.consensusLayerDelta; + vpoolRewardEntry.netCLRewards = reportEntity.consensusLayerDelta.gt(BigInt.fromI32(0)) + ? reportEntity.consensusLayerDelta.minus( + reportEntity.consensusLayerDelta.times(pool!.operatorFee).div(BigInt.fromI32(10000)) + ) + : reportEntity.consensusLayerDelta; - if (report.preUnderlyingSupply.gt(BigInt.fromI32(0))) { + if (reportEntity.preUnderlyingSupply.gt(BigInt.fromI32(0))) { vpoolRewardEntry.netRewardRate = vpoolRewardEntry.netReward .times(BigInt.fromString('1000000000000000000')) .times(BigInt.fromI64(YEAR)) - .div(report.preUnderlyingSupply.times(period)); + .div(reportEntity.preUnderlyingSupply.times(period)); vpoolRewardEntry.grossRewardRate = vpoolRewardEntry.grossReward .times(BigInt.fromString('1000000000000000000')) .times(BigInt.fromI64(YEAR)) - .div(report.preUnderlyingSupply.times(period)); + .div(reportEntity.preUnderlyingSupply.times(period)); } else { vpoolRewardEntry.netRewardRate = BigInt.fromI32(0); vpoolRewardEntry.grossRewardRate = BigInt.fromI32(0); } - vpoolRewardEntry.report = report.id; + vpoolRewardEntry.report = reportEntity.id; vpoolRewardEntry.createdAt = event.block.timestamp; vpoolRewardEntry.editedAt = event.block.timestamp; vpoolRewardEntry.createdAtBlock = event.block.number; @@ -505,9 +630,9 @@ export function handleProcessedReport(event: ProcessedReport): void { commission = rewards.times(multipool!.fees).div(BigInt.fromI32(10000)); rewards = rewards.minus(commission); - grossElRewards = report.pulledExecutionLayerRewards.times(multiPoolBalance!.amount).div(pool_pre_supply); - grossClRewards = report.consensusLayerDelta.times(multiPoolBalance!.amount).div(pool_pre_supply); - coverage = report.pulledCoverageFunds.times(multiPoolBalance!.amount).div(pool_pre_supply); + grossElRewards = reportEntity.pulledExecutionLayerRewards.times(multiPoolBalance!.amount).div(pool_pre_supply); + grossClRewards = reportEntity.consensusLayerDelta.times(multiPoolBalance!.amount).div(pool_pre_supply); + coverage = reportEntity.pulledCoverageFunds.times(multiPoolBalance!.amount).div(pool_pre_supply); netElRewards = grossElRewards.minus(grossElRewards.times(multipool!.fees).div(BigInt.fromI32(10000))); netClRewards = grossClRewards.minus(grossClRewards.times(multipool!.fees).div(BigInt.fromI32(10000))); @@ -555,7 +680,7 @@ export function handleProcessedReport(event: ProcessedReport): void { integrationRewardEntry.netCLRewards = netClRewards; integrationRewardEntry.netRewardRate = netAPY; integrationRewardEntry.grossRewardRate = grossAPY; - integrationRewardEntry.report = report.id; + integrationRewardEntry.report = reportEntity.id; integrationRewardEntry.createdAt = event.block.timestamp; integrationRewardEntry.editedAt = event.block.timestamp; integrationRewardEntry.createdAtBlock = event.block.number; @@ -578,7 +703,7 @@ export function handleProcessedReport(event: ProcessedReport): void { integrationRewardEntry.netCLRewards = BigInt.zero(); integrationRewardEntry.netRewardRate = BigInt.zero(); integrationRewardEntry.grossRewardRate = BigInt.zero(); - integrationRewardEntry.report = report.id; + integrationRewardEntry.report = reportEntity.id; integrationRewardEntry.createdAt = event.block.timestamp; integrationRewardEntry.editedAt = event.block.timestamp; integrationRewardEntry.createdAtBlock = event.block.number; @@ -588,7 +713,7 @@ export function handleProcessedReport(event: ProcessedReport): void { } const multiPoolRewardsSnapshot = new MultiPoolRewardsSnapshot( - eventUUID(event, [multipool!.id, report.epoch.toString()]) + eventUUID(event, [multipool!.id, reportEntity.epoch.toString()]) ); multiPoolRewardsSnapshot.multiPool = multipool!.id; multiPoolRewardsSnapshot.report = reportId; @@ -612,7 +737,7 @@ export function handleProcessedReport(event: ProcessedReport): void { event, Address.fromBytes(vFactory.load(pool!.factory)!.address), event.address, - report.epoch + reportEntity.epoch ); systemEvent.report = reportId; systemEvent.save(); diff --git a/subgraph.devnet.yaml b/subgraph.devnet.yaml index 3dd3d9d..8237a5d 100644 --- a/subgraph.devnet.yaml +++ b/subgraph.devnet.yaml @@ -2,27 +2,6 @@ specVersion: 0.0.5 schema: file: ./schema.graphql dataSources: - - kind: ethereum - name: DepositContract - network: holesky - source: - address: "0x4242424242424242424242424242424242424242" - abi: DepositContract - startBlock: 180000 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - vFactory - - vTreasury - abis: - - name: DepositContract - file: ./abis/DepositContract.json - eventHandlers: - - event: DepositEvent(bytes,bytes,bytes,bytes,bytes) - handler: handleDepositEvent - file: ./src/DepositContract.mapping.ts - kind: ethereum name: Nexus network: holesky @@ -39,7 +18,7 @@ dataSources: - vTreasury abis: - name: Nexus - file: ./abis/Nexus.json + file: ./abis/Nexus.2_2_0.json eventHandlers: - event: SpawnedFactory(indexed address,address) handler: handleSpawnedFactory @@ -61,8 +40,8 @@ dataSources: handler: handlerSetGlobalConsensusLayerSpec - event: SetAdmin(address) handler: handleSetAdmin - blockHandlers: - - handler: handleBlock + - event: SetDriver(string,address) + handler: handleSetDriver file: ./src/Nexus.mapping.ts - kind: ethereum @@ -416,7 +395,7 @@ dataSources: source: address: "0x8f2789A79C0494981373ceF711406585dA93DF43" abi: IntegrationRouter - startBlock: 180000 + startBlock: 180000 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -494,18 +473,19 @@ templates: - name: vFactory file: ./abis/vFactory.json eventHandlers: + # - event: AddedValidators(indexed bytes32,bytes) + # handler: handleAddedValidators + # - event: ExitValidator(indexed bytes32,bytes,uint256) + # handler: handleExitValidator + # - event: ValidatorRequest(indexed bytes32,uint256) + # handler: handleValidatorRequest + # - event: FundedValidator(indexed bytes32,indexed address,indexed address,bytes,uint256,uint256) + # handler: handleFundedValidator + # - event: UpdatedLimit(indexed bytes32,uint256) + # handler: handleUpdatedLimit + # removed with 2.2.0 - event: SetExitTotal(indexed bytes32,uint32) handler: handleSetExitTotal - - event: AddedValidators(indexed bytes32,bytes) - handler: handleAddedValidators - - event: UpdatedLimit(indexed bytes32,uint256) - handler: handleUpdatedLimit - - event: FundedValidator(indexed bytes32,indexed address,indexed address,bytes,uint256,uint256) - handler: handleFundedValidator - - event: ExitValidator(indexed bytes32,bytes,uint256) - handler: handleExitValidator - - event: ValidatorRequest(indexed bytes32,uint256) - handler: handleValidatorRequest - event: SetValidatorOwner(indexed uint256,address) handler: handleSetValidatorOwner - event: SetValidatorFeeRecipient(indexed uint256,address) @@ -526,6 +506,31 @@ templates: handler: handleSetHatcherRegistry - event: ApproveDepositor(indexed address,indexed bytes32,bool) handler: handleApproveDepositor + - name: vFactory_2_2_0 + kind: ethereum/contract + network: holesky + source: + abi: vFactory_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vFactory.mapping.ts + entities: + - vFactory + abis: + - name: vFactory_2_2_0 + file: ./abis/vFactory.2_2_0.json + eventHandlers: + - event: ExitValidator(uint256) + handler: handleExitValidator_2_2_0 + - event: ActivatedValidator(indexed bytes32,indexed address,indexed address,bytes,bytes,uint256) + handler: handleActivatedValidator_2_2_0 + - event: SetRoot((bytes32,string)) + handler: handleSetRoot_2_2_0 + - event: SetValidatorThreshold(indexed uint256,uint96) + handler: handleSetValidatorThreshold_2_2_0 + - name: vTreasury kind: ethereum/contract network: holesky @@ -599,6 +604,24 @@ templates: handler: handleSetDepositedEthers - event: SetRequestedExits(uint32) handler: handleSetRequestedExits + - name: vPool_2_2_0 + kind: ethereum/contract + network: holesky + source: + abi: vPool_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vPool.mapping.ts + entities: + - vPool + abis: + - name: vPool_2_2_0 + file: ./abis/vPool.2_2_0.json + eventHandlers: + - event: ProcessedReport(indexed uint256,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32),(uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,int128,int128,uint128,uint128,uint128,int128,uint128,uint128,uint128)) + handler: handleProcessedReport_2_2_0 - name: vExitQueue kind: ethereum/contract @@ -707,6 +730,29 @@ templates: handler: handleSubmittedReport - event: SetHighestReportedEpoch(uint256) handler: handleSetHighestReportedEpoch + - name: vOracleAggregator_2_2_0 + kind: ethereum/contract + network: holesky + source: + abi: vOracleAggregator_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vOracleAggregator.mapping.ts + entities: + - vOracleAggregator + abis: + - name: vOracleAggregator_2_2_0 + file: ./abis/vOracleAggregator.2_2_0.json + eventHandlers: + - event: MemberVoted(indexed address,indexed bytes32,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32)) + handler: handleMemberVoted_2_2_0 + - event: GlobalMemberVoted(indexed address,indexed bytes32,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32)) + handler: handlerGlobalMemberVoted_2_2_0 + - event: SubmittedReport((uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32),bytes32,uint256,uint256) + handler: handleSubmittedReport_2_2_0 + - name: ERC20_1_0_0_rc4 kind: ethereum/contract @@ -728,6 +774,25 @@ templates: - event: Stake(indexed address,uint256,uint256,uint256) handler: handleStake_1_0_0_rc4 + - name: ERC20_2_2_0 + kind: ethereum/contract + network: holesky + source: + abi: Native20 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/ERC20.mapping.ts + entities: + - ERC20 + abis: + - name: Native20 + file: ./abis/Liquid20A_2_2_0.json + eventHandlers: + - event: Stake(indexed address,indexed address,uint128,uint128,(uint128,uint128,uint128,uint128,uint128)[]) + handler: handleStake_2_2_0 + - name: ERC20 kind: ethereum/contract network: holesky @@ -780,131 +845,6 @@ templates: handler: handleSetPoolPercentages - event: ExitedCommissionShares(indexed uint256,uint256,uint256[],address[]) handler: handleExitedCommissionShares - - name: ERC1155_1_0_0_rc4 - kind: ethereum/contract - network: holesky - source: - abi: Liquid1155 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - file: ./src/ERC1155.mapping.ts - entities: - - ERC1155 - abis: - - name: Liquid1155 - file: ./abis/Liquid1155_1_0_0_rc4.json - eventHandlers: - - event: Stake(indexed address,uint256,uint256,uint256) - handler: handleStake_1_0_0_rc4 - - name: ERC1155 - kind: ethereum/contract - network: holesky - source: - abi: Liquid1155 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - file: ./src/ERC1155.mapping.ts - entities: - - ERC1155 - abis: - - name: Liquid1155 - file: ./abis/Liquid1155.json - eventHandlers: - - event: Stake(indexed address,uint128,uint128,(uint128,uint128,uint128,uint128,uint128)[]) - handler: handleStake - - event: SetURIPrefix(string) - handler: handleSetURIPrefix - - event: SetName(string) - handler: handleSetName - - event: SetSymbol(string) - handler: handleSetSymbol - - event: SetDepositsPaused(bool) - handler: handleSetDepositsPaused - - event: PoolAdded(address,uint256) - handler: handlePoolAdded - - event: SetFee(uint256,uint256) - handler: handleSetFee - - event: PoolActivation(address,uint256,bool) - handler: handlePoolActivation - - event: VPoolSharesReceived(address,uint256,uint256) - handler: handleVPoolSharesReceived - - event: NewCommissionSplit(address[],uint256[]) - handler: handleNewCommissionSplit - - event: CommissionSharesSold(uint256,uint256,uint256) - handler: handleCommissionSharesSold - - event: CommissionWithdrawn(indexed address,uint256) - handler: handleCommissionWithdrawn - - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) - handler: handleTransferSingle - - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) - handler: handleTransferBatch - - event: ApprovalForAll(indexed address,indexed address,bool) - handler: handleApprovalForAll - - event: SetAdmin(address) - handler: handleSetAdmin - - event: SetMaxCommission(uint256) - handler: handleSetMaxCommission - - kind: ethereum - name: vNFT - network: holesky - source: - abi: vNFT - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - vNFT - - vNFTIntegration - - vNFTTransfer - - vNFTUser - abis: - - name: vNFT - file: ./abis/vNFT.json - eventHandlers: - - event: TokenIdUpdated(indexed uint256,indexed uint256,uint256) - handler: handleTokenIdUpdated - - event: SetName(string) - handler: handleSetName - - event: SetSymbol(string) - handler: handleSetSymbol - - event: SetExtraData(string) - handler: handleSetExtraData - - event: SetURIPrefix(string) - handler: handleSetURIPrefix - - event: SetPurchasePause(bool) - handler: handleSetDepositsPaused - - event: SetFactory(address) - handler: handleSetFactory - - event: PurchasedValidator(indexed address,uint256,uint256) - handler: handlePurchasedValidator - - event: Transfer(indexed address,indexed address,indexed uint256) - handler: handleTransfer - - event: SetOperatorCommission(uint256) - handler: handleSetOperatorCommission - - event: SetIntegratorCommission(uint256) - handler: handleSetIntegratorCommission - - event: SetIntegrator(address) - handler: handleSetIntegrator - - event: UpdateUser(indexed uint256,indexed address,uint64) - handler: handleUpdateUser - - event: Approval(indexed address,indexed address,indexed uint256) - handler: handleApproval - - event: UsershipCleared(indexed uint256) - handler: handleUsershipCleared - - event: ApprovalForAll(indexed address,indexed address,bool) - handler: handleApprovalForAll - - event: SetExecLayerVault(address) - handler: handleSetExecLayerVault - - event: SetSoulboundMode(bool) - handler: handleSetSoulboundMode - - event: SetAdmin(address) - handler: handleSetAdmin - file: ./src/vNFT.mapping.ts - kind: ethereum name: ProxyFactory network: holesky @@ -925,28 +865,6 @@ templates: - event: DeployedProxy(bytes32,address,address,bytes,address) handler: handleDeployedProxy file: ./src/ProxyFactory.mapping.ts - - kind: ethereum - name: MerkleVault - network: holesky - source: - abi: MerkleVault - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - MerkleVault - abis: - - name: MerkleVault - file: ./abis/MerkleVault.json - eventHandlers: - - event: SetFrameSize(uint256) - handler: handleSetFrameSize - - event: SetRootAndIpfsHash(bytes32,string) - handler: handleSetRootAndIpfshash - - event: Claimed(address,uint256,uint256) - handler: handleClaimed - file: ./src/MerkleVault.mapping.ts - kind: ethereum name: Native20_Fix_09_12_Oracle_Report network: holesky diff --git a/subgraph.devnet_fast.yaml b/subgraph.kurtosis.yaml similarity index 78% rename from subgraph.devnet_fast.yaml rename to subgraph.kurtosis.yaml index 642b999..3247980 100644 --- a/subgraph.devnet_fast.yaml +++ b/subgraph.kurtosis.yaml @@ -2,34 +2,13 @@ specVersion: 0.0.5 schema: file: ./schema.graphql dataSources: - # - kind: ethereum - # name: DepositContract - # network: holesky - # source: - # address: "0x4242424242424242424242424242424242424242" - # abi: DepositContract - # startBlock: 180000 - # mapping: - # kind: ethereum/events - # apiVersion: 0.0.7 - # language: wasm/assemblyscript - # entities: - # - vFactory - # - vTreasury - # abis: - # - name: DepositContract - # file: ./abis/DepositContract.json - # eventHandlers: - # - event: DepositEvent(bytes,bytes,bytes,bytes,bytes) - # handler: handleDepositEvent - # file: ./src/DepositContract.mapping.ts - kind: ethereum name: Nexus - network: holesky + network: ethereum source: - address: "0x68c249b5426cacc858390db3014bd6ef87041207" + address: "0x49974804239685b3cb5c8424ac3965d416de55c6" abi: Nexus - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -39,7 +18,7 @@ dataSources: - vTreasury abis: - name: Nexus - file: ./abis/Nexus.json + file: ./abis/Nexus.2_2_0.json eventHandlers: - event: SpawnedFactory(indexed address,address) handler: handleSpawnedFactory @@ -61,17 +40,17 @@ dataSources: handler: handlerSetGlobalConsensusLayerSpec - event: SetAdmin(address) handler: handleSetAdmin - # blockHandlers: - # - handler: handleBlock + - event: SetDriver(string,address) + handler: handleSetDriver file: ./src/Nexus.mapping.ts - kind: ethereum name: FactoryHatcher - network: holesky + network: ethereum source: - address: "0x34B94291a116d29F68DC05D1A0Df1274d0844c7a" + address: "0x4822e2D4bc6c001FC79D0020f73A8Ffff535E7A4" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -110,11 +89,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: TreasuryHatcher - network: holesky + network: ethereum source: - address: "0x14aAad550Ae72a096cBf878626930436bF171475" + address: "0x08CF4ecfB623F8C4eDe4D01aDe77d517b64871B0" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -153,11 +132,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: PoolHatcher - network: holesky + network: ethereum source: - address: "0x6703D266aAd4052b91941942B935C05724cE06d2" + address: "0x7293b38a3162e425136d96225ee8984468372D6A" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -196,11 +175,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: WithdrawalRecipientHatcher - network: holesky + network: ethereum source: - address: "0x2dB69DEF1C2D7905503F697359F53c50A78228a6" + address: "0x2522c1cE45DB11821b4f65Ff06AEd8fdFa47B571" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -239,11 +218,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: ExecLayerRecipientHatcher - network: holesky + network: ethereum source: - address: "0x5850eBdf9d5cFd7297d8eD7D4eA47ed8959eF6EE" + address: "0x7E3430E29602A27b93616a88f37574A020e0c580" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -282,11 +261,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: CoverageRecipientHatcher - network: holesky + network: ethereum source: - address: "0x8D8Df85902F4E8E25a2E7E75233640DC524e099F" + address: "0x631087D1D49348A65b947E2CDf753F6F428Adf5e" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -325,11 +304,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: OracleAggregatorHatcher - network: holesky + network: ethereum source: - address: "0xbCA08B6db787d78E97F7a89AC353D0B92C1E3B4A" + address: "0x06ef7366c7f897fAaed3DBFbb8bd2E229af8d098" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -368,11 +347,11 @@ dataSources: file: ./src/PluggableHatcher.mapping.ts - kind: ethereum name: ExitQueueHatcher - network: holesky + network: ethereum source: - address: "0x60448aAAF3F729c25bD7b11959E1A2f30E521Ab5" + address: "0xab67F8Bcc56b6a96CCe5e52A7b0A81f9E2317eB9" abi: PluggableHatcher - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -412,11 +391,11 @@ dataSources: - kind: ethereum name: IntegrationRouter - network: holesky + network: ethereum source: - address: "0x8f2789A79C0494981373ceF711406585dA93DF43" + address: "0xA927b32de5E2eDC55C7E5452c1d74106aE65d75C" abi: IntegrationRouter - startBlock: 180000 + startBlock: 0 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -436,7 +415,7 @@ dataSources: templates: - name: TUPProxy kind: ethereum/contract - network: holesky + network: ethereum source: abi: TUPProxy mapping: @@ -462,7 +441,7 @@ templates: handler: handleUpgraded - name: Cub kind: ethereum/contract - network: holesky + network: ethereum source: abi: Cub mapping: @@ -480,7 +459,7 @@ templates: handler: handleAppliedFixes - name: vFactory kind: ethereum/contract - network: holesky + network: ethereum source: abi: vFactory mapping: @@ -494,18 +473,19 @@ templates: - name: vFactory file: ./abis/vFactory.json eventHandlers: + # - event: AddedValidators(indexed bytes32,bytes) + # handler: handleAddedValidators + # - event: ExitValidator(indexed bytes32,bytes,uint256) + # handler: handleExitValidator + # - event: ValidatorRequest(indexed bytes32,uint256) + # handler: handleValidatorRequest + # - event: FundedValidator(indexed bytes32,indexed address,indexed address,bytes,uint256,uint256) + # handler: handleFundedValidator + # - event: UpdatedLimit(indexed bytes32,uint256) + # handler: handleUpdatedLimit + # removed with 2.2.0 - event: SetExitTotal(indexed bytes32,uint32) handler: handleSetExitTotal - - event: AddedValidators(indexed bytes32,bytes) - handler: handleAddedValidators - - event: UpdatedLimit(indexed bytes32,uint256) - handler: handleUpdatedLimit - - event: FundedValidator(indexed bytes32,indexed address,indexed address,bytes,uint256,uint256) - handler: handleFundedValidator - - event: ExitValidator(indexed bytes32,bytes,uint256) - handler: handleExitValidator - - event: ValidatorRequest(indexed bytes32,uint256) - handler: handleValidatorRequest - event: SetValidatorOwner(indexed uint256,address) handler: handleSetValidatorOwner - event: SetValidatorFeeRecipient(indexed uint256,address) @@ -526,9 +506,34 @@ templates: handler: handleSetHatcherRegistry - event: ApproveDepositor(indexed address,indexed bytes32,bool) handler: handleApproveDepositor + - name: vFactory_2_2_0 + kind: ethereum/contract + network: ethereum + source: + abi: vFactory_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vFactory.mapping.ts + entities: + - vFactory + abis: + - name: vFactory_2_2_0 + file: ./abis/vFactory.2_2_0.json + eventHandlers: + - event: ExitValidator(uint256) + handler: handleExitValidator_2_2_0 + - event: ActivatedValidator(indexed bytes32,indexed address,indexed address,bytes,bytes,uint256) + handler: handleActivatedValidator_2_2_0 + - event: SetRoot((bytes32,string)) + handler: handleSetRoot_2_2_0 + - event: SetValidatorThreshold(indexed uint256,uint96) + handler: handleSetValidatorThreshold_2_2_0 + - name: vTreasury kind: ethereum/contract - network: holesky + network: ethereum source: abi: vTreasury mapping: @@ -555,7 +560,7 @@ templates: - name: vPool kind: ethereum/contract - network: holesky + network: ethereum source: abi: vPool mapping: @@ -599,10 +604,28 @@ templates: handler: handleSetDepositedEthers - event: SetRequestedExits(uint32) handler: handleSetRequestedExits + - name: vPool_2_2_0 + kind: ethereum/contract + network: ethereum + source: + abi: vPool_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vPool.mapping.ts + entities: + - vPool + abis: + - name: vPool_2_2_0 + file: ./abis/vPool.2_2_0.json + eventHandlers: + - event: ProcessedReport(indexed uint256,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32),(uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,uint128,int128,int128,uint128,uint128,uint128,int128,uint128,uint128,uint128)) + handler: handleProcessedReport_2_2_0 - name: vExitQueue kind: ethereum/contract - network: holesky + network: ethereum source: abi: vExitQueue mapping: @@ -635,7 +658,7 @@ templates: - name: vExecLayerRecipient kind: ethereum/contract - network: holesky + network: ethereum source: abi: vExecLayerRecipient mapping: @@ -654,7 +677,7 @@ templates: - name: vCoverageRecipient kind: ethereum/contract - network: holesky + network: ethereum source: abi: vCoverageRecipient mapping: @@ -681,7 +704,7 @@ templates: - name: vOracleAggregator kind: ethereum/contract - network: holesky + network: ethereum source: abi: vOracleAggregator mapping: @@ -707,10 +730,33 @@ templates: handler: handleSubmittedReport - event: SetHighestReportedEpoch(uint256) handler: handleSetHighestReportedEpoch + - name: vOracleAggregator_2_2_0 + kind: ethereum/contract + network: ethereum + source: + abi: vOracleAggregator_2_2_0 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/vOracleAggregator.mapping.ts + entities: + - vOracleAggregator + abis: + - name: vOracleAggregator_2_2_0 + file: ./abis/vOracleAggregator.2_2_0.json + eventHandlers: + - event: MemberVoted(indexed address,indexed bytes32,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32)) + handler: handleMemberVoted_2_2_0 + - event: GlobalMemberVoted(indexed address,indexed bytes32,(uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32)) + handler: handlerGlobalMemberVoted_2_2_0 + - event: SubmittedReport((uint128,uint128,uint128,uint128,uint128,uint128,int256,uint64,uint32,uint32,uint32),bytes32,uint256,uint256) + handler: handleSubmittedReport_2_2_0 + - name: ERC20_1_0_0_rc4 kind: ethereum/contract - network: holesky + network: ethereum source: abi: Native20 mapping: @@ -728,9 +774,28 @@ templates: - event: Stake(indexed address,uint256,uint256,uint256) handler: handleStake_1_0_0_rc4 + - name: ERC20_2_2_0 + kind: ethereum/contract + network: ethereum + source: + abi: Native20 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + file: ./src/ERC20.mapping.ts + entities: + - ERC20 + abis: + - name: Native20 + file: ./abis/Liquid20A_2_2_0.json + eventHandlers: + - event: Stake(indexed address,indexed address,uint128,uint128,(uint128,uint128,uint128,uint128,uint128)[]) + handler: handleStake_2_2_0 + - name: ERC20 kind: ethereum/contract - network: holesky + network: ethereum source: abi: Native20 mapping: @@ -780,134 +845,9 @@ templates: handler: handleSetPoolPercentages - event: ExitedCommissionShares(indexed uint256,uint256,uint256[],address[]) handler: handleExitedCommissionShares - - name: ERC1155_1_0_0_rc4 - kind: ethereum/contract - network: holesky - source: - abi: Liquid1155 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - file: ./src/ERC1155.mapping.ts - entities: - - ERC1155 - abis: - - name: Liquid1155 - file: ./abis/Liquid1155_1_0_0_rc4.json - eventHandlers: - - event: Stake(indexed address,uint256,uint256,uint256) - handler: handleStake_1_0_0_rc4 - - name: ERC1155 - kind: ethereum/contract - network: holesky - source: - abi: Liquid1155 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - file: ./src/ERC1155.mapping.ts - entities: - - ERC1155 - abis: - - name: Liquid1155 - file: ./abis/Liquid1155.json - eventHandlers: - - event: Stake(indexed address,uint128,uint128,(uint128,uint128,uint128,uint128,uint128)[]) - handler: handleStake - - event: SetURIPrefix(string) - handler: handleSetURIPrefix - - event: SetName(string) - handler: handleSetName - - event: SetSymbol(string) - handler: handleSetSymbol - - event: SetDepositsPaused(bool) - handler: handleSetDepositsPaused - - event: PoolAdded(address,uint256) - handler: handlePoolAdded - - event: SetFee(uint256,uint256) - handler: handleSetFee - - event: PoolActivation(address,uint256,bool) - handler: handlePoolActivation - - event: VPoolSharesReceived(address,uint256,uint256) - handler: handleVPoolSharesReceived - - event: NewCommissionSplit(address[],uint256[]) - handler: handleNewCommissionSplit - - event: CommissionSharesSold(uint256,uint256,uint256) - handler: handleCommissionSharesSold - - event: CommissionWithdrawn(indexed address,uint256) - handler: handleCommissionWithdrawn - - event: TransferSingle(indexed address,indexed address,indexed address,uint256,uint256) - handler: handleTransferSingle - - event: TransferBatch(indexed address,indexed address,indexed address,uint256[],uint256[]) - handler: handleTransferBatch - - event: ApprovalForAll(indexed address,indexed address,bool) - handler: handleApprovalForAll - - event: SetAdmin(address) - handler: handleSetAdmin - - event: SetMaxCommission(uint256) - handler: handleSetMaxCommission - - kind: ethereum - name: vNFT - network: holesky - source: - abi: vNFT - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - vNFT - - vNFTIntegration - - vNFTTransfer - - vNFTUser - abis: - - name: vNFT - file: ./abis/vNFT.json - eventHandlers: - - event: TokenIdUpdated(indexed uint256,indexed uint256,uint256) - handler: handleTokenIdUpdated - - event: SetName(string) - handler: handleSetName - - event: SetSymbol(string) - handler: handleSetSymbol - - event: SetExtraData(string) - handler: handleSetExtraData - - event: SetURIPrefix(string) - handler: handleSetURIPrefix - - event: SetPurchasePause(bool) - handler: handleSetDepositsPaused - - event: SetFactory(address) - handler: handleSetFactory - - event: PurchasedValidator(indexed address,uint256,uint256) - handler: handlePurchasedValidator - - event: Transfer(indexed address,indexed address,indexed uint256) - handler: handleTransfer - - event: SetOperatorCommission(uint256) - handler: handleSetOperatorCommission - - event: SetIntegratorCommission(uint256) - handler: handleSetIntegratorCommission - - event: SetIntegrator(address) - handler: handleSetIntegrator - - event: UpdateUser(indexed uint256,indexed address,uint64) - handler: handleUpdateUser - - event: Approval(indexed address,indexed address,indexed uint256) - handler: handleApproval - - event: UsershipCleared(indexed uint256) - handler: handleUsershipCleared - - event: ApprovalForAll(indexed address,indexed address,bool) - handler: handleApprovalForAll - - event: SetExecLayerVault(address) - handler: handleSetExecLayerVault - - event: SetSoulboundMode(bool) - handler: handleSetSoulboundMode - - event: SetAdmin(address) - handler: handleSetAdmin - file: ./src/vNFT.mapping.ts - kind: ethereum name: ProxyFactory - network: holesky + network: ethereum source: abi: ProxyFactory mapping: @@ -925,31 +865,9 @@ templates: - event: DeployedProxy(bytes32,address,address,bytes,address) handler: handleDeployedProxy file: ./src/ProxyFactory.mapping.ts - - kind: ethereum - name: MerkleVault - network: holesky - source: - abi: MerkleVault - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - MerkleVault - abis: - - name: MerkleVault - file: ./abis/MerkleVault.json - eventHandlers: - - event: SetFrameSize(uint256) - handler: handleSetFrameSize - - event: SetRootAndIpfsHash(bytes32,string) - handler: handleSetRootAndIpfshash - - event: Claimed(address,uint256,uint256) - handler: handleClaimed - file: ./src/MerkleVault.mapping.ts - kind: ethereum name: Native20_Fix_09_12_Oracle_Report - network: holesky + network: ethereum source: abi: Native20_Fix_09_12_Oracle_Report mapping: