From eb3d23e497126d53cca4a78498b0109b70253326 Mon Sep 17 00:00:00 2001 From: mixplore <9848598+mixplore@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:48:51 +0200 Subject: [PATCH] chore: update viewer contracts deploy script and add ui data fetching script for claimable NXM --- .../assessment-and-nexus-viewer-deploy.js | 5 +- scripts/ui-data-fetching/get-claimable-nxm.js | 137 ++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 scripts/ui-data-fetching/get-claimable-nxm.js diff --git a/scripts/deploy/assessment-and-nexus-viewer-deploy.js b/scripts/deploy/assessment-and-nexus-viewer-deploy.js index a43cd471a..445ea10ba 100644 --- a/scripts/deploy/assessment-and-nexus-viewer-deploy.js +++ b/scripts/deploy/assessment-and-nexus-viewer-deploy.js @@ -2,6 +2,7 @@ const { ethers, network } = require('hardhat'); const STV = '0xcafea5E8a7a54dd14Bb225b66C7a016dfd7F236b'; // StakingViewer const MS = '0x01BFd82675DBCc7762C84019cA518e701C0cD07e'; // NXMaster +const NXM = '0xd7c49CEE7E9188cCa6AD8FF264C1DA2e69D4Cf3B'; // NXMToken const main = async () => { console.log(`Starting deploy script on ${network.name} network`); @@ -13,13 +14,15 @@ const main = async () => { const assessmentViewerImplementation = await ethers.deployContract('AssessmentViewer', [MS], signer); const nexusViewerImplementation = await ethers.deployContract( 'NexusViewer', - [MS, STV, assessmentViewerImplementation.address], + [MS, STV, assessmentViewerImplementation.address, NXM], signer, ); console.log('AssessmentViewer implementation address:', assessmentViewerImplementation.address); console.log('NexusViewer implementation address:', nexusViewerImplementation.address); console.log('NexusViewer ABI', nexusViewerImplementation.interface.format(ethers.utils.FormatTypes.json)); + + console.log('Done'); }; main() .then(() => process.exit(0)) diff --git a/scripts/ui-data-fetching/get-claimable-nxm.js b/scripts/ui-data-fetching/get-claimable-nxm.js new file mode 100644 index 000000000..412edd358 --- /dev/null +++ b/scripts/ui-data-fetching/get-claimable-nxm.js @@ -0,0 +1,137 @@ +require('dotenv').config(); +const { ethers } = require('hardhat'); + +const NexusViewerABI = [ + { + type: 'constructor', + payable: false, + inputs: [ + { type: 'address', name: '_master' }, + { type: 'address', name: '_stakingViewer' }, + { type: 'address', name: '_assessmentViewer' }, + { type: 'address', name: '_nxm' }, + ], + }, + { type: 'error', name: 'RevertedWithoutReason', inputs: [{ type: 'uint256', name: 'index' }] }, + { + type: 'function', + name: 'assessmentViewer', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [], + outputs: [{ type: 'address' }], + }, + { + type: 'function', + name: 'getClaimableNXM', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [ + { type: 'address', name: 'member' }, + { type: 'uint256[]', name: 'tokenIds' }, + ], + outputs: [ + { + type: 'tuple', + components: [ + { type: 'uint256', name: 'governanceRewards' }, + { type: 'uint256', name: 'assessmentRewards' }, + { type: 'uint256', name: 'assessmentStake' }, + { type: 'uint256', name: 'stakingPoolTotalRewards' }, + { type: 'uint256', name: 'stakingPoolTotalExpiredStake' }, + { type: 'uint256', name: 'stakingPoolManagerIsNXMLockedForMV' }, + { type: 'uint256', name: 'managerTotalRewards' }, + { type: 'uint256', name: 'legacyPooledStakeRewards' }, + { type: 'uint256', name: 'legacyPooledStakeDeposits' }, + { type: 'uint256', name: 'legacyClaimAssessmentTokens' }, + { type: 'uint256', name: 'legacyCoverNoteDeposits' }, + ], + }, + ], + }, + { + type: 'function', + name: 'getStakedNXM', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [ + { type: 'address', name: 'member' }, + { type: 'uint256[]', name: 'tokenIds' }, + ], + outputs: [ + { + type: 'tuple', + components: [ + { type: 'uint256', name: 'stakingPoolTotalActiveStake' }, + { type: 'uint256', name: 'assessmentStake' }, + { type: 'uint256', name: 'assessmentStakeLockupExpiry' }, + { type: 'uint256', name: 'assessmentRewards' }, + ], + }, + ], + }, + { + type: 'function', + name: 'master', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [], + outputs: [{ type: 'address' }], + }, + { + type: 'function', + name: 'multicall', + constant: false, + payable: false, + gas: 11000000, + inputs: [{ type: 'bytes[]', name: 'data' }], + outputs: [{ type: 'bytes[]', name: 'results' }], + }, + { + type: 'function', + name: 'nxm', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [], + outputs: [{ type: 'address' }], + }, + { + type: 'function', + name: 'stakingViewer', + constant: true, + stateMutability: 'view', + payable: false, + gas: 11000000, + inputs: [], + outputs: [{ type: 'address' }], + }, +]; +const NexusViewerAddress = '0xF62eEc897fa5ef36a957702AA4a45B58fE8Fe312'; + +const member = '0xd6CE9335f5A68e885271CdbE460b7A4FED5FeDA9'; +const tokenIds = [34, 35, 36, 103, 136]; + +async function main() { + const viewer = await ethers.getContractAt(NexusViewerABI, NexusViewerAddress); + + const claimableNXM = await viewer.getClaimableNXM(member, tokenIds); + + console.log('Claimable NXM:', claimableNXM); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); + });