diff --git a/src/adapters/meltdown-1.adapter.ts b/src/adapters/meltdown-1.adapter.ts new file mode 100644 index 0000000..5922f6f --- /dev/null +++ b/src/adapters/meltdown-1.adapter.ts @@ -0,0 +1,43 @@ +import {BindingScope, extensionFor, injectable} from '@loopback/core'; +import {BigNumber} from 'ethers'; +import {STAKING_ADAPTERS_EXTENSION_POINT} from '../keys'; +import {BaseStakingContractAdapter, StakingAsset} from '../staking'; +// Use the full path to import instead of `../types` +import {MeltdownChildren__factory} from '../types/factories/MeltdownChildren__factory'; + +@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 MeltdownContractAdapter extends BaseStakingContractAdapter { + /** + * The contract address + */ + contractAddress = '0xC0c5670D9052D0ee524d7C932382805645Ab3479'; + chainId = 137; + /** + * Assets that can be staked to this contract + */ + supportedAssets: StakingAsset[] = [ + { + asset: 'ERC721:0xc47d3EF164FB3f3C3D6cfAF259f09f6AA9aa7C03', + }, + ]; + + /** + * Get staked token ids for the given owner + * @param owner - Owner address + * @returns + */ + async getStakedTokenIds(owner: string): Promise { + const contract = MeltdownChildren__factory.connect( + this.contractAddress, + this.provider, + ); + const data = await contract.getStakeInfo(owner); + return data._tokensStaked; + } +} diff --git a/src/component.ts b/src/component.ts index 6a4ad34..849e20b 100644 --- a/src/component.ts +++ b/src/component.ts @@ -22,6 +22,8 @@ import {PerionCreditsStakingContractAdapter} from './adapters/erc20-staking.adap import {IdolMarketplaceContractAdapter} from './adapters/idol-marketplace.adapter'; import {LifestoryPlanetStakingAdapter} from './adapters/lifestory-planet-staking.adapter'; import {Meltdown03ContractAdapter} from './adapters/meltdown.adapter'; +import {MeltdownContractAdapter} from './adapters/meltdown-1.adapter'; + import {MtgStakingContractAdapter} from './adapters/mtg.adapter'; import {RandomStakingContractAdapter} from './adapters/random-staking.adapter'; import {RDStakingContractAdapter} from './adapters/rd-staking.adapter'; @@ -73,6 +75,7 @@ export class StakingContractsComponent implements Component { ReNFTPolygonSylvesterV1StakingContractAdapter, ReplicantXStakingContractAdapter, CbzGrowStakingContractAdapter, + MeltdownContractAdapter, ]; constructor() {} } diff --git a/src/contracts/meltdown-children.json b/src/contracts/meltdown-children.json new file mode 100644 index 0000000..d82e041 --- /dev/null +++ b/src/contracts/meltdown-children.json @@ -0,0 +1,909 @@ +[ + { + "type": "constructor", + "name": "", + "inputs": [ + { + "type": "address", + "name": "_nativeTokenWrapper", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "ContractURIUpdated", + "inputs": [ + { + "type": "string", + "name": "prevURI", + "indexed": false, + "internalType": "string" + }, + { + "type": "string", + "name": "newURI", + "indexed": false, + "internalType": "string" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "type": "uint8", + "name": "version", + "indexed": false, + "internalType": "uint8" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RewardTokensDepositedByAdmin", + "inputs": [ + { + "type": "uint256", + "name": "_amount", + "indexed": false, + "internalType": "uint256" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RewardTokensWithdrawnByAdmin", + "inputs": [ + { + "type": "uint256", + "name": "_amount", + "indexed": false, + "internalType": "uint256" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RewardsClaimed", + "inputs": [ + { + "type": "address", + "name": "staker", + "indexed": true, + "internalType": "address" + }, + { + "type": "uint256", + "name": "rewardAmount", + "indexed": false, + "internalType": "uint256" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RoleAdminChanged", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "indexed": true, + "internalType": "bytes32" + }, + { + "type": "bytes32", + "name": "previousAdminRole", + "indexed": true, + "internalType": "bytes32" + }, + { + "type": "bytes32", + "name": "newAdminRole", + "indexed": true, + "internalType": "bytes32" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RoleGranted", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "indexed": true, + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "indexed": true, + "internalType": "address" + }, + { + "type": "address", + "name": "sender", + "indexed": true, + "internalType": "address" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "RoleRevoked", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "indexed": true, + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "indexed": true, + "internalType": "address" + }, + { + "type": "address", + "name": "sender", + "indexed": true, + "internalType": "address" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "TokensStaked", + "inputs": [ + { + "type": "address", + "name": "staker", + "indexed": true, + "internalType": "address" + }, + { + "type": "uint256[]", + "name": "tokenIds", + "indexed": true, + "internalType": "uint256[]" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "TokensWithdrawn", + "inputs": [ + { + "type": "address", + "name": "staker", + "indexed": true, + "internalType": "address" + }, + { + "type": "uint256[]", + "name": "tokenIds", + "indexed": true, + "internalType": "uint256[]" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "UpdatedRewardsPerUnitTime", + "inputs": [ + { + "type": "uint256", + "name": "oldRewardsPerUnitTime", + "indexed": false, + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "newRewardsPerUnitTime", + "indexed": false, + "internalType": "uint256" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "event", + "name": "UpdatedTimeUnit", + "inputs": [ + { + "type": "uint256", + "name": "oldTimeUnit", + "indexed": false, + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "newTimeUnit", + "indexed": false, + "internalType": "uint256" + } + ], + "outputs": [], + "anonymous": false + }, + { + "type": "function", + "name": "DEFAULT_ADMIN_ROLE", + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "claimRewards", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "contractType", + "inputs": [], + "outputs": [ + { + "type": "bytes32", + "name": "", + "internalType": "bytes32" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "contractURI", + "inputs": [], + "outputs": [ + { + "type": "string", + "name": "", + "internalType": "string" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "contractVersion", + "inputs": [], + "outputs": [ + { + "type": "uint8", + "name": "", + "internalType": "uint8" + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "depositRewardTokens", + "inputs": [ + { + "type": "uint256", + "name": "_amount", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "getRewardTokenBalance", + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRewardsPerUnitTime", + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "_rewardsPerUnitTime", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRoleAdmin", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "type": "bytes32", + "name": "", + "internalType": "bytes32" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRoleMember", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "uint256", + "name": "index", + "internalType": "uint256" + } + ], + "outputs": [ + { + "type": "address", + "name": "member", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRoleMemberCount", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "count", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getStakeInfo", + "inputs": [ + { + "type": "address", + "name": "_staker", + "internalType": "address" + } + ], + "outputs": [ + { + "type": "uint256[]", + "name": "_tokensStaked", + "internalType": "uint256[]" + }, + { + "type": "uint256", + "name": "_rewards", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getTimeUnit", + "inputs": [], + "outputs": [ + { + "type": "uint256", + "name": "_timeUnit", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "grantRole", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "hasRole", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "internalType": "address" + } + ], + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "hasRoleWithSwitch", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "internalType": "address" + } + ], + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "indexedTokens", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "type": "address", + "name": "_defaultAdmin", + "internalType": "address" + }, + { + "type": "string", + "name": "_contractURI", + "internalType": "string" + }, + { + "type": "address[]", + "name": "_trustedForwarders", + "internalType": "address[]" + }, + { + "type": "address", + "name": "_rewardToken", + "internalType": "address" + }, + { + "type": "address", + "name": "_stakingToken", + "internalType": "address" + }, + { + "type": "uint256", + "name": "_timeUnit", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "_rewardsPerUnitTime", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isIndexed", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isTrustedForwarder", + "inputs": [ + { + "type": "address", + "name": "forwarder", + "internalType": "address" + } + ], + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "multicall", + "inputs": [ + { + "type": "bytes[]", + "name": "data", + "internalType": "bytes[]" + } + ], + "outputs": [ + { + "type": "bytes[]", + "name": "results", + "internalType": "bytes[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "onERC721Received", + "inputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + }, + { + "type": "address", + "name": "", + "internalType": "address" + }, + { + "type": "uint256", + "name": "", + "internalType": "uint256" + }, + { + "type": "bytes", + "name": "", + "internalType": "bytes" + } + ], + "outputs": [ + { + "type": "bytes4", + "name": "", + "internalType": "bytes4" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "renounceRole", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "revokeRole", + "inputs": [ + { + "type": "bytes32", + "name": "role", + "internalType": "bytes32" + }, + { + "type": "address", + "name": "account", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "rewardToken", + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setContractURI", + "inputs": [ + { + "type": "string", + "name": "_uri", + "internalType": "string" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRewardsPerUnitTime", + "inputs": [ + { + "type": "uint256", + "name": "_rewardsPerUnitTime", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setTimeUnit", + "inputs": [ + { + "type": "uint256", + "name": "_timeUnit", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stake", + "inputs": [ + { + "type": "uint256[]", + "name": "_tokenIds", + "internalType": "uint256[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "stakerAddress", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stakers", + "inputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "outputs": [ + { + "type": "uint256", + "name": "amountStaked", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "timeOfLastUpdate", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "unclaimedRewards", + "internalType": "uint256" + }, + { + "type": "uint256", + "name": "conditionIdOflastUpdate", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stakersArray", + "inputs": [ + { + "type": "uint256", + "name": "", + "internalType": "uint256" + } + ], + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "stakingToken", + "inputs": [], + "outputs": [ + { + "type": "address", + "name": "", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "supportsInterface", + "inputs": [ + { + "type": "bytes4", + "name": "interfaceId", + "internalType": "bytes4" + } + ], + "outputs": [ + { + "type": "bool", + "name": "", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "withdraw", + "inputs": [ + { + "type": "uint256[]", + "name": "_tokenIds", + "internalType": "uint256[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "withdrawRewardTokens", + "inputs": [ + { + "type": "uint256", + "name": "_amount", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "receive", + "name": "", + "inputs": [], + "outputs": [], + "stateMutability": "payable" + } +]