From 1b14546498d14d9f1cb594b03c947238e214e35f Mon Sep 17 00:00:00 2001 From: Gonzalo D'elia Date: Tue, 25 Feb 2025 20:40:31 -0300 Subject: [PATCH] Update stake contracts for hemi mainnet --- .../contracts/stakeManager.ts | 1023 +++++++++++++++-- 1 file changed, 921 insertions(+), 102 deletions(-) diff --git a/hemi-viem-stake-actions/contracts/stakeManager.ts b/hemi-viem-stake-actions/contracts/stakeManager.ts index e86f8ab1..9e1c115f 100644 --- a/hemi-viem-stake-actions/contracts/stakeManager.ts +++ b/hemi-viem-stake-actions/contracts/stakeManager.ts @@ -1,18 +1,14 @@ -import { hemiSepolia } from 'hemi-viem' +import { hemi, hemiSepolia } from 'hemi-viem' import { type Address, type Chain } from 'viem' export const stakeManagerAddresses: Record = { + [hemi.id]: '0x4F5E928763CBFaF5fFD8907ebbB0DAbd5f78bA83', [hemiSepolia.id]: '0x935CC431313C52427ccf45385138a136580bf59f', } export const stakeManagerAbi = [ { inputs: [ - { - internalType: 'address', - name: '_signer', - type: 'address', - }, { internalType: 'address[]', name: '_tokensAllowed', @@ -27,6 +23,32 @@ export const stakeManagerAbi = [ stateMutability: 'nonpayable', type: 'constructor', }, + { + inputs: [], + name: 'ArrayLengthCannotBeZero', + type: 'error', + }, + { + inputs: [], + name: 'ArrayLengthNotMatch', + type: 'error', + }, + { + inputs: [], + name: 'ArrayLengthsDoNotMatch', + type: 'error', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + name: 'CallExecutionFailed', + type: 'error', + }, { inputs: [], name: 'CannotDepositForZeroAddress', @@ -37,6 +59,11 @@ export const stakeManagerAbi = [ name: 'CannotRenounceOwnership', type: 'error', }, + { + inputs: [], + name: 'ContractAddressCannotBeZeroAddress', + type: 'error', + }, { inputs: [], name: 'DepositAmountCannotBeZero', @@ -57,6 +84,16 @@ export const stakeManagerAbi = [ name: 'ExpectedPause', type: 'error', }, + { + inputs: [], + name: 'FunctionAlreadyWhitelisted', + type: 'error', + }, + { + inputs: [], + name: 'FunctionNotWhitelisted', + type: 'error', + }, { inputs: [ { @@ -73,6 +110,11 @@ export const stakeManagerAbi = [ name: 'InvalidAccountNonce', type: 'error', }, + { + inputs: [], + name: 'InvalidMerkleProof', + type: 'error', + }, { inputs: [], name: 'InvalidShortString', @@ -80,17 +122,42 @@ export const stakeManagerAbi = [ }, { inputs: [], - name: 'MigratorAlreadyAllowedOrBlocked', + name: 'LeafAlreadyClaimed', + type: 'error', + }, + { + inputs: [], + name: 'LeafAmountCannotBeZero', + type: 'error', + }, + { + inputs: [], + name: 'MerkleRootAlreadySet', + type: 'error', + }, + { + inputs: [], + name: 'MerkleRootCannotBeSetToZero', + type: 'error', + }, + { + inputs: [], + name: 'MerkleRootDisabledForClaiming', + type: 'error', + }, + { + inputs: [], + name: 'MerkleRootIndexCannotBeZero', type: 'error', }, { inputs: [], - name: 'MigratorBlocked', + name: 'MerkleRootNotSet', type: 'error', }, { inputs: [], - name: 'MigratorCannotBeZeroAddress', + name: 'MerkleRootStatusAlreadySet', type: 'error', }, { @@ -115,6 +182,32 @@ export const stakeManagerAbi = [ name: 'OwnableUnauthorizedAccount', type: 'error', }, + { + inputs: [], + name: 'ReentrancyGuardReentrantCall', + type: 'error', + }, + { + inputs: [ + { + internalType: 'address', + name: 'user', + type: 'address', + }, + { + internalType: 'uint256', + name: 'requestedTokens', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalBalance', + type: 'uint256', + }, + ], + name: 'RemainingTokensLessThanTotalBalance', + type: 'error', + }, { inputs: [ { @@ -136,16 +229,6 @@ export const stakeManagerAbi = [ name: 'SignatureInvalid', type: 'error', }, - { - inputs: [], - name: 'SignerAlreadySetToAddress', - type: 'error', - }, - { - inputs: [], - name: 'SignerCannotBeZeroAddress', - type: 'error', - }, { inputs: [ { @@ -177,6 +260,21 @@ export const stakeManagerAbi = [ name: 'TokenNotAllowedForStaking', type: 'error', }, + { + inputs: [], + name: 'TransferAmountCannotBeMoreThanLeafAmount', + type: 'error', + }, + { + inputs: [], + name: 'TransferAmountCannotBeZero', + type: 'error', + }, + { + inputs: [], + name: 'UserArrayCannotBeEmpty', + type: 'error', + }, { inputs: [], name: 'UserDoesNotHaveStake', @@ -253,16 +351,85 @@ export const stakeManagerAbi = [ inputs: [ { indexed: true, + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + ], + name: 'FunctionAdded', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + ], + name: 'FunctionRemoved', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, internalType: 'uint256', - name: 'eventId', + name: 'index', type: 'uint256', }, + { + indexed: false, + internalType: 'bytes32', + name: 'merkleRoot', + type: 'bytes32', + }, + ], + name: 'MerkleRootSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ { indexed: true, internalType: 'address', name: 'user', type: 'address', }, + { + indexed: true, + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + indexed: false, + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, { indexed: false, internalType: 'address[]', @@ -271,24 +438,85 @@ export const stakeManagerAbi = [ }, { indexed: false, + internalType: 'uint256[]', + name: 'amountsSpent', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint256', + name: 'eventId', + type: 'uint256', + }, + ], + name: 'MoveToDapp', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, internalType: 'address', - name: 'destination', + name: 'user', type: 'address', }, { - indexed: false, + indexed: true, internalType: 'address', - name: 'migrator', + name: 'contractAddress', type: 'address', }, + { + indexed: false, + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + indexed: false, + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + indexed: false, + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'amountsSpent', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint256', + name: 'eventId', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint256', + name: 'rootIndex', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'leafAmounts', + type: 'uint256[]', + }, { indexed: false, internalType: 'uint256[]', - name: 'amounts', + name: 'migrationEventIds', type: 'uint256[]', }, ], - name: 'Migrate', + name: 'MoveToDappMerkle', type: 'event', }, { @@ -345,14 +573,39 @@ export const stakeManagerAbi = [ { anonymous: false, inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, { indexed: false, - internalType: 'address', - name: 'newSigner', - type: 'address', + internalType: 'bool', + name: 'disabled', + type: 'bool', + }, + ], + name: 'RootStatusSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + { + indexed: false, + internalType: 'bytes32', + name: 'leaf', + type: 'bytes32', }, ], - name: 'SignerChanged', + name: 'SetLeafClaimed', type: 'event', }, { @@ -419,54 +672,176 @@ export const stakeManagerAbi = [ type: 'event', }, { - inputs: [], - name: 'acceptOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', - name: '', + name: 'user', type: 'address', }, { - internalType: 'address', - name: '', - type: 'address', + indexed: true, + internalType: 'uint256', + name: 'rootIndex', + type: 'uint256', + }, + { + indexed: false, + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'leafAmounts', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'transferAmounts', + type: 'uint256[]', + }, + { + indexed: false, + internalType: 'uint256[]', + name: 'migrationEventIds', + type: 'uint256[]', }, - ], - name: 'balance', - outputs: [ { + indexed: false, internalType: 'uint256', - name: '', + name: 'eventId', type: 'uint256', }, ], + name: 'WithdrawMerkle', + type: 'event', + }, + { + inputs: [], + name: 'MOVE_TO_DAPP_MERKLE_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], stateMutability: 'view', type: 'function', }, + { + inputs: [], + name: 'MOVE_TO_DAPP_TYPEHASH', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'acceptOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { internalType: 'address', - name: '_migrator', + name: '_contractAddress', type: 'address', }, { - internalType: 'bool', - name: '_blocklisted', - type: 'bool', + internalType: 'bytes4', + name: '_functionSignature', + type: 'bytes4', }, ], - name: 'blockMigrator', + name: 'addFunction', outputs: [], stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'balance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address[]', + name: '_tokens', + type: 'address[]', + }, + { + internalType: 'address[]', + name: '_for', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: '_amounts', + type: 'uint256[]', + }, + ], + name: 'batchDepositFor', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + name: 'claimed', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -547,93 +922,414 @@ export const stakeManagerAbi = [ type: 'function', }, { - inputs: [ + inputs: [], + name: 'eventId', + outputs: [ { - internalType: 'address[]', - name: '_tokens', - type: 'address[]', + internalType: 'uint256', + name: '', + type: 'uint256', }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ { internalType: 'address', - name: '_migratorContract', + name: '', type: 'address', }, { - internalType: 'address', - name: '_destination', - type: 'address', + internalType: 'bytes4', + name: '', + type: 'bytes4', + }, + ], + name: 'functionAllowlist', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ { internalType: 'uint256', - name: '_signatureExpiry', + name: '', type: 'uint256', }, + ], + name: 'merkleRootDisabled', + outputs: [ { - internalType: 'bytes', - name: '_authorizationSignatureFromZircuit', - type: 'bytes', + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'merkleRoots', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + internalType: 'struct ILaunchPool.ContractCall', + name: '_contractCall', + type: 'tuple', + }, + ], + name: 'moveToDapp', + outputs: [ + { + components: [ + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + internalType: 'struct ILaunchPool.CallResult', + name: 'result', + type: 'tuple', }, ], - name: 'migrate', - outputs: [], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { - internalType: 'address', - name: '_user', - type: 'address', + components: [ + { + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + components: [ + { + internalType: 'uint256', + name: 'rootIndex', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'leafAmounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'transferAmounts', + type: 'uint256[]', + }, + { + internalType: 'bytes32[][]', + name: 'proofs', + type: 'bytes32[][]', + }, + { + internalType: 'uint256[]', + name: 'migrationEventIds', + type: 'uint256[]', + }, + ], + internalType: 'struct ILaunchPool.MerkleClaim', + name: 'claim', + type: 'tuple', + }, + ], + internalType: 'struct ILaunchPool.ContractCallMerkle', + name: '_contractCall', + type: 'tuple', }, + ], + name: 'moveToDappMerkle', + outputs: [ + { + components: [ + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + internalType: 'struct ILaunchPool.CallResult', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ { internalType: 'address[]', - name: '_tokens', + name: '_users', type: 'address[]', }, { - internalType: 'address', - name: '_migratorContract', - type: 'address', + components: [ + { + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + components: [ + { + internalType: 'uint256', + name: 'rootIndex', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'leafAmounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'transferAmounts', + type: 'uint256[]', + }, + { + internalType: 'bytes32[][]', + name: 'proofs', + type: 'bytes32[][]', + }, + { + internalType: 'uint256[]', + name: 'migrationEventIds', + type: 'uint256[]', + }, + ], + internalType: 'struct ILaunchPool.MerkleClaim', + name: 'claim', + type: 'tuple', + }, + ], + internalType: 'struct ILaunchPool.ContractCallMerkle[]', + name: '_contractCalls', + type: 'tuple[]', }, { - internalType: 'address', - name: '_destination', - type: 'address', + internalType: 'uint256[]', + name: '_signatureExpiries', + type: 'uint256[]', }, { - internalType: 'uint256', - name: '_signatureExpiry', - type: 'uint256', + internalType: 'bytes[]', + name: '_signatures', + type: 'bytes[]', }, + ], + name: 'moveToDappMerkleWithSig', + outputs: [ { - internalType: 'bytes', - name: '_stakerSignature', - type: 'bytes', + components: [ + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + internalType: 'struct ILaunchPool.CallResult[]', + name: '', + type: 'tuple[]', }, ], - name: 'migrateWithSig', - outputs: [], stateMutability: 'nonpayable', type: 'function', }, { inputs: [ { - internalType: 'address', - name: '', - type: 'address', + internalType: 'address[]', + name: '_users', + type: 'address[]', + }, + { + components: [ + { + internalType: 'address', + name: 'contractAddress', + type: 'address', + }, + { + internalType: 'bytes4', + name: 'functionSignature', + type: 'bytes4', + }, + { + internalType: 'bytes', + name: 'data', + type: 'bytes', + }, + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + ], + internalType: 'struct ILaunchPool.ContractCall[]', + name: '_contractCalls', + type: 'tuple[]', + }, + { + internalType: 'uint256[]', + name: '_signatureExpiries', + type: 'uint256[]', + }, + { + internalType: 'bytes[]', + name: '_signatures', + type: 'bytes[]', }, ], - name: 'migratorBlocklist', + name: 'moveToDappWithSig', outputs: [ { - internalType: 'bool', + components: [ + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'amounts', + type: 'uint256[]', + }, + { + internalType: 'bytes', + name: 'result', + type: 'bytes', + }, + ], + internalType: 'struct ILaunchPool.CallResult[]', name: '', - type: 'bool', + type: 'tuple[]', }, ], - stateMutability: 'view', + stateMutability: 'nonpayable', type: 'function', }, { @@ -701,6 +1397,24 @@ export const stakeManagerAbi = [ stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + internalType: 'address', + name: '_contractAddress', + type: 'address', + }, + { + internalType: 'bytes4', + name: '_functionSignature', + type: 'bytes4', + }, + ], + name: 'removeFunction', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [], name: 'renounceOwnership', @@ -711,17 +1425,53 @@ export const stakeManagerAbi = [ { inputs: [ { - internalType: 'address', - name: '_token', - type: 'address', + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: '_leaf', + type: 'bytes32', + }, + ], + name: 'setLeafClaimed', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_index', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: '_merkleRoot', + type: 'bytes32', + }, + ], + name: 'setMerkleRoot', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '_index', + type: 'uint256', }, { internalType: 'bool', - name: '_canStake', + name: '_disabled', type: 'bool', }, ], - name: 'setStakable', + name: 'setRootStatus', outputs: [], stateMutability: 'nonpayable', type: 'function', @@ -730,11 +1480,16 @@ export const stakeManagerAbi = [ inputs: [ { internalType: 'address', - name: '_signer', + name: '_token', type: 'address', }, + { + internalType: 'bool', + name: '_canStake', + type: 'bool', + }, ], - name: 'setZircuitSigner', + name: 'setStakable', outputs: [], stateMutability: 'nonpayable', type: 'function', @@ -758,6 +1513,25 @@ export const stakeManagerAbi = [ stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + name: 'totalBalance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -778,6 +1552,19 @@ export const stakeManagerAbi = [ stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [], + name: 'weth', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -797,16 +1584,48 @@ export const stakeManagerAbi = [ type: 'function', }, { - inputs: [], - name: 'zircuitSigner', - outputs: [ + inputs: [ { - internalType: 'address', - name: '', - type: 'address', + components: [ + { + internalType: 'uint256', + name: 'rootIndex', + type: 'uint256', + }, + { + internalType: 'address[]', + name: 'tokens', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'leafAmounts', + type: 'uint256[]', + }, + { + internalType: 'uint256[]', + name: 'transferAmounts', + type: 'uint256[]', + }, + { + internalType: 'bytes32[][]', + name: 'proofs', + type: 'bytes32[][]', + }, + { + internalType: 'uint256[]', + name: 'migrationEventIds', + type: 'uint256[]', + }, + ], + internalType: 'struct ILaunchPool.MerkleClaim', + name: '_claim', + type: 'tuple', }, ], - stateMutability: 'view', + name: 'withdrawMerkle', + outputs: [], + stateMutability: 'nonpayable', type: 'function', }, ] as const