diff --git a/src/adapters/superverse-staking.adapter.ts b/src/adapters/superverse-staking.adapter.ts index d838e66..a6e2df4 100644 --- a/src/adapters/superverse-staking.adapter.ts +++ b/src/adapters/superverse-staking.adapter.ts @@ -26,10 +26,6 @@ export class SuperverseStakingContractAdapter extends BaseStakingContractAdapter name: 'SuperVerse', asset: 'ERC20:0xe53EC727dbDEB9E2d5456c3be40cFF031AB40A55', }, - { - name: 'SuperVersePower', - asset: 'ERC20:0xe53EC727dbDEB9E2d5456c3be40cFF031AB40A55', - }, ]; /** @@ -37,19 +33,13 @@ export class SuperverseStakingContractAdapter extends BaseStakingContractAdapter * @param owner - Owner address * @returns */ - async getStakedTokenBalance( - owner: string, - name = 'SuperVerse', - ): Promise { - name = name.toLowerCase(); + async getStakedTokenBalance(owner: string): Promise { const contract = SuperverseStaking__factory.connect( this.contractAddress, this.provider, ); const stakerInfo = await contract.stakerInfo(owner); - return name === 'superverse' - ? stakerInfo.stakedTokens - : stakerInfo.stakerPower; + return stakerInfo.stakerPower; } } diff --git a/src/adapters/xai-staking.adapter.ts b/src/adapters/xai-staking.adapter.ts new file mode 100644 index 0000000..8409fcf --- /dev/null +++ b/src/adapters/xai-staking.adapter.ts @@ -0,0 +1,66 @@ +import {BindingScope, extensionFor, injectable} from '@loopback/core'; +import {BigNumber} from 'ethers'; +import {STAKING_ADAPTERS_EXTENSION_POINT} from '../keys.js'; +import {BaseStakingContractAdapter, StakingAsset} from '../staking.js'; + +import {XaiPoolFactory__factory} from '../types/factories/XaiPoolFactory__factory.js'; +import {XaiStakingPool__factory} from '../types/factories/XaiStakingPool__factory.js'; + +@injectable( + { + scope: BindingScope.SINGLETON, // Mark the adapter as a singleton + }, + // Mark it as an extension to staking contracts service + extensionFor(STAKING_ADAPTERS_EXTENSION_POINT), +) +export class XaiStakingContractAdapter extends BaseStakingContractAdapter { + /** + * The contract address + */ + contractAddress = '0xF9E08660223E2dbb1c0b28c82942aB6B5E38b8E5'; + + /** + * Assets that can be staked to this contract: SuperVerse ERC20 + */ + supportedAssets: StakingAsset[] = [ + { + name: 'EsXai', + asset: 'ERC20:0x4C749d097832DE2FEcc989ce18fDc5f1BD76700c', + }, + ]; + + /** + * Chain id for the staking contract, default to `1` (Ethereum Mainnet) + */ + chainId = 42161; + + /** + * Get staked token ids for the given owner + * @param owner - Owner address + * @returns + */ + async getStakedTokenBalance(owner: string): Promise { + const poolFactoryContract = XaiPoolFactory__factory.connect( + this.contractAddress, + this.provider, + ); + const poolAddresses = await poolFactoryContract.getPoolIndicesOfUser(owner); + + if (poolAddresses.length === 0) { + return BigNumber.from('0'); + } + + let accumulatedBalance = BigNumber.from('0'); + + for (const poolAddress of poolAddresses) { + const stakingPoolContract = XaiStakingPool__factory.connect( + poolAddress, + this.provider, + ); + const stakerInfo = await stakingPoolContract.getStakedAmounts(owner); + accumulatedBalance = accumulatedBalance.add(stakerInfo); + } + + return accumulatedBalance; + } +} diff --git a/src/component.ts b/src/component.ts index 03cff9a..7e00909 100644 --- a/src/component.ts +++ b/src/component.ts @@ -76,6 +76,7 @@ import {SupremeKongStakingContractAdapter} from './adapters/supreme-kong-staking import {TtooStakingContractAdapter} from './adapters/ttoo-staking.adapter.js'; import {UwULendStakingContractAdapter} from './adapters/uwulend-staking.adapter.js'; import {WarriorsofankhStakingContractAdapter} from './adapters/warriorsofankh-staking.adapter.js'; +import {XaiStakingContractAdapter} from './adapters/xai-staking.adapter.js'; import {XenoStakingContractAdapter} from './adapters/xeno-mining.adapter.js'; import {STAKING_CONTRACTS_COMPONENT} from './keys.js'; import {StakingContractsService} from './services/staking-contracts.service.js'; @@ -145,6 +146,7 @@ export class StakingContractsComponent implements Component { RailgunBinanceGovernanceAdapter, RailgunEthereumGovernanceAdapter, RailgunPolygonGovernanceAdapter, + XaiStakingContractAdapter, RevenueCoinStakingContractAdapter, ]; constructor() { } diff --git a/src/contracts/xai-pool-factory.json b/src/contracts/xai-pool-factory.json new file mode 100644 index 0000000..17e25c0 --- /dev/null +++ b/src/contracts/xai-pool-factory.json @@ -0,0 +1,890 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "ClaimFromPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "poolIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "poolOwner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakedKeyCount", + "type": "uint256" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldDeployer", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newDeployer", + "type": "address" + } + ], + "name": "PoolProxyDeployerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUserEsXaiStaked", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalEsXaiStaked", + "type": "uint256" + } + ], + "name": "StakeEsXai", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUserKeysStaked", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalKeysStaked", + "type": "uint256" + } + ], + "name": "StakeKeys", + "type": "event" + }, + {"anonymous": false, "inputs": [], "name": "StakingEnabled", "type": "event"}, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUserEsXaiStaked", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalEsXaiStaked", + "type": "uint256" + } + ], + "name": "UnstakeEsXai", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalUserKeysStaked", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "totalKeysStaked", + "type": "uint256" + } + ], + "name": "UnstakeKeys", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "index", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isKey", + "type": "bool" + } + ], + "name": "UnstakeRequestStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "UpdateDelayPeriods", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "UpdateMetadata", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "UpdatePoolDelegate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "UpdateShares", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "bucketshareMaxValues", + "outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "uint256[]", "name": "keyIds", "type": "uint256[]"} + ], + "name": "checkKeysAreStaked", + "outputs": [ + {"internalType": "bool[]", "name": "isStaked", "type": "bool[]"} + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address[]", "name": "pools", "type": "address[]"} + ], + "name": "claimFromPools", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "_delegateOwner", "type": "address"}, + {"internalType": "uint256[]", "name": "_keyIds", "type": "uint256[]"}, + { + "internalType": "uint32[3]", + "name": "_shareConfig", + "type": "uint32[3]" + }, + { + "internalType": "string[3]", + "name": "_poolMetadata", + "type": "string[3]" + }, + {"internalType": "string[]", "name": "_poolSocials", "type": "string[]"}, + { + "internalType": "string[2][2]", + "name": "trackerDetails", + "type": "string[2][2]" + } + ], + "name": "createPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "createUnstakeEsXaiRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "uint256", "name": "keyAmount", "type": "uint256"} + ], + "name": "createUnstakeKeyRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "pool", "type": "address"}], + "name": "createUnstakeOwnerLastKeyRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "deployerAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enableStaking", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "esXaiAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "delegate", "type": "address"} + ], + "name": "getDelegatePools", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "uint256", "name": "poolIndex", "type": "uint256"} + ], + "name": "getPoolAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "user", "type": "address"}, + {"internalType": "uint256", "name": "index", "type": "uint256"} + ], + "name": "getPoolAddressOfUser", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getPoolIndicesOfUser", + "outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolsCount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getPoolsOfUserCount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32"}], + "name": "getRoleAdmin", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "uint256", "name": "index", "type": "uint256"} + ], + "name": "getRoleMember", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32"}], + "name": "getRoleMemberCount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "user", "type": "address"}, + {"internalType": "uint16", "name": "offset", "type": "uint16"}, + {"internalType": "uint16", "name": "pageLimit", "type": "uint16"} + ], + "name": "getUnstakedKeyIdsFromUser", + "outputs": [ + { + "internalType": "uint256[]", + "name": "unstakedKeyIds", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "hasRole", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "_refereeAddress", "type": "address"}, + {"internalType": "address", "name": "_esXaiAddress", "type": "address"}, + { + "internalType": "address", + "name": "_nodeLicenseAddress", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "uint256", "name": "", "type": "uint256"} + ], + "name": "interactedPoolsOfUser", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "delegate", "type": "address"}, + {"internalType": "address", "name": "pool", "type": "address"} + ], + "name": "isDelegateOfPoolOrOwner", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nodeLicenseAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "poolsCreatedViaFactory", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "uint256", "name": "", "type": "uint256"} + ], + "name": "poolsOfDelegate", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "poolsOfDelegateIndices", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "refereeAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "stakeEsXai", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "uint256[]", "name": "keyIds", "type": "uint256[]"} + ], + "name": "stakeKeys", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stakingEnabled", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "stakingPools", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes4", "name": "interfaceId", "type": "bytes4"} + ], + "name": "supportsInterface", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + { + "internalType": "uint256", + "name": "unstakeRequestIndex", + "type": "uint256" + }, + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "unstakeEsXai", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unstakeEsXaiDelayPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unstakeGenesisKeyDelayPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + { + "internalType": "uint256", + "name": "unstakeRequestIndex", + "type": "uint256" + }, + {"internalType": "uint256[]", "name": "keyIds", "type": "uint256[]"} + ], + "name": "unstakeKeys", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unstakeKeysDelayPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_unstakeKeysDelayPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unstakeGenesisKeyDelayPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_unstakeEsXaiDelayPeriod", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_updateRewardBreakdownDelayPeriod", + "type": "uint256" + } + ], + "name": "updateDelayPeriods", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "address", "name": "delegate", "type": "address"} + ], + "name": "updateDelegateOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + { + "internalType": "string[3]", + "name": "_poolMetadata", + "type": "string[3]" + }, + {"internalType": "string[]", "name": "_poolSocials", "type": "string[]"} + ], + "name": "updatePoolMetadata", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "newDeployer", "type": "address"} + ], + "name": "updatePoolProxyDeployer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateRewardBreakdownDelayPeriod", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "pool", "type": "address"}, + {"internalType": "uint32[3]", "name": "_shareConfig", "type": "uint32[3]"} + ], + "name": "updateShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "address", "name": "", "type": "address"} + ], + "name": "userToInteractedPoolIds", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/contracts/xai-staking-pool.json b/src/contracts/xai-staking-pool.json new file mode 100644 index 0000000..11608e3 --- /dev/null +++ b/src/contracts/xai-staking-pool.json @@ -0,0 +1,671 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "POOL_ADMIN", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "claimRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "user", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + {"internalType": "uint256", "name": "period", "type": "uint256"} + ], + "name": "createUnstakeEsXaiRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "user", "type": "address"}, + {"internalType": "uint256", "name": "keyAmount", "type": "uint256"}, + {"internalType": "uint256", "name": "period", "type": "uint256"} + ], + "name": "createUnstakeKeyRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + {"internalType": "uint256", "name": "period", "type": "uint256"} + ], + "name": "createUnstakeOwnerLastKeyRequest", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "delegateOwner", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "description", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "esXaiAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "esXaiStakeBucket", + "outputs": [ + {"internalType": "contract BucketTracker", "name": "", "type": "address"} + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDelegateOwner", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolInfo", + "outputs": [ + { + "components": [ + {"internalType": "address", "name": "poolAddress", "type": "address"}, + {"internalType": "address", "name": "owner", "type": "address"}, + { + "internalType": "address", + "name": "keyBucketTracker", + "type": "address" + }, + { + "internalType": "address", + "name": "esXaiBucketTracker", + "type": "address" + }, + {"internalType": "uint256", "name": "keyCount", "type": "uint256"}, + { + "internalType": "uint256", + "name": "totalStakedAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updateSharesTimestamp", + "type": "uint256" + }, + {"internalType": "uint32", "name": "ownerShare", "type": "uint32"}, + { + "internalType": "uint32", + "name": "keyBucketShare", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "stakedBucketShare", + "type": "uint32" + } + ], + "internalType": "struct StakingPool.PoolBaseInfo", + "name": "baseInfo", + "type": "tuple" + }, + {"internalType": "string", "name": "_name", "type": "string"}, + {"internalType": "string", "name": "_description", "type": "string"}, + {"internalType": "string", "name": "_logo", "type": "string"}, + {"internalType": "string[]", "name": "_socials", "type": "string[]"}, + { + "internalType": "uint32[]", + "name": "_pendingShares", + "type": "uint32[]" + }, + { + "internalType": "uint256", + "name": "_ownerStakedKeys", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_ownerRequestedUnstakeKeyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_ownerLatestUnstakeRequestLockTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolOwner", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "bytes32", "name": "role", "type": "bytes32"}], + "name": "getRoleAdmin", + "outputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getStakedAmounts", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStakedKeys", + "outputs": [{"internalType": "uint256[]", "name": "", "type": "uint256[]"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getStakedKeysCount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getStakedKeysCountForUser", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getUndistributedClaimAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "claimAmountFromKeys", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "claimAmountFromEsXai", + "type": "uint256" + }, + {"internalType": "uint256", "name": "claimAmount", "type": "uint256"}, + {"internalType": "uint256", "name": "ownerAmount", "type": "uint256"} + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"}, + {"internalType": "uint256", "name": "index", "type": "uint256"} + ], + "name": "getUnstakeRequest", + "outputs": [ + { + "components": [ + {"internalType": "bool", "name": "open", "type": "bool"}, + {"internalType": "bool", "name": "isKeyRequest", "type": "bool"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"}, + {"internalType": "uint256", "name": "lockTime", "type": "uint256"}, + { + "internalType": "uint256", + "name": "completeTime", + "type": "uint256" + }, + {"internalType": "uint256[5]", "name": "__gap", "type": "uint256[5]"} + ], + "internalType": "struct StakingPool.UnstakeRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "getUnstakeRequestCount", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getUserPoolData", + "outputs": [ + { + "internalType": "uint256", + "name": "userStakedEsXaiAmount", + "type": "uint256" + }, + {"internalType": "uint256", "name": "userClaimAmount", "type": "uint256"}, + { + "internalType": "uint256[]", + "name": "userStakedKeyIds", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "unstakeRequestkeyAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "unstakeRequestesXaiAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "getUserRequestedUnstakeAmounts", + "outputs": [ + {"internalType": "uint256", "name": "keyAmount", "type": "uint256"}, + {"internalType": "uint256", "name": "esXaiAmount", "type": "uint256"} + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "hasRole", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "uint32", "name": "_ownerShare", "type": "uint32"}, + {"internalType": "uint32", "name": "_keyBucketShare", "type": "uint32"}, + {"internalType": "uint32", "name": "_stakedBucketShare", "type": "uint32"} + ], + "name": "initShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "_refereeAddress", "type": "address"}, + {"internalType": "address", "name": "_esXaiAddress", "type": "address"}, + {"internalType": "address", "name": "_owner", "type": "address"}, + {"internalType": "address", "name": "_delegateOwner", "type": "address"}, + {"internalType": "address", "name": "_keyBucket", "type": "address"}, + { + "internalType": "address", + "name": "_esXaiStakeBucket", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "user", "type": "address"}], + "name": "isUserEngagedWithPool", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "keyBucket", + "outputs": [ + {"internalType": "contract BucketTracker", "name": "", "type": "address"} + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "keyBucketShare", + "outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "keyIdIndex", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "logo", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ownerShare", + "outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolOwner", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "poolOwnerClaimableRewards", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "refereeAddress", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes32", "name": "role", "type": "bytes32"}, + {"internalType": "address", "name": "account", "type": "address"} + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "socials", + "outputs": [{"internalType": "string", "name": "", "type": "string"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "stakeEsXai", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + {"internalType": "uint256[]", "name": "keyIds", "type": "uint256[]"} + ], + "name": "stakeKeys", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "", "type": "address"}], + "name": "stakedAmounts", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stakedBucketShare", + "outputs": [{"internalType": "uint32", "name": "", "type": "uint32"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "stakedKeys", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "name": "stakedKeysIndices", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "", "type": "address"}, + {"internalType": "uint256", "name": "", "type": "uint256"} + ], + "name": "stakedKeysOfOwner", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "bytes4", "name": "interfaceId", "type": "bytes4"} + ], + "name": "supportsInterface", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + { + "internalType": "uint256", + "name": "unstakeRequestIndex", + "type": "uint256" + }, + {"internalType": "uint256", "name": "amount", "type": "uint256"} + ], + "name": "unstakeEsXai", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "owner", "type": "address"}, + { + "internalType": "uint256", + "name": "unstakeRequestIndex", + "type": "uint256" + }, + {"internalType": "uint256[]", "name": "keyIds", "type": "uint256[]"} + ], + "name": "unstakeKeys", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "address", "name": "delegate", "type": "address"} + ], + "name": "updateDelegateOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "string[3]", "name": "_metaData", "type": "string[3]"}, + {"internalType": "string[]", "name": "_socials", "type": "string[]"} + ], + "name": "updateMetadata", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + {"internalType": "uint32", "name": "_ownerShare", "type": "uint32"}, + {"internalType": "uint32", "name": "_keyBucketShare", "type": "uint32"}, + { + "internalType": "uint32", + "name": "_stakedBucketShare", + "type": "uint32" + }, + {"internalType": "uint256", "name": "period", "type": "uint256"} + ], + "name": "updateShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +]