import { ethers } from 'ethers' import { BaseProject } from './base' export const hivelloChain = { id: 4689, name: 'Iotex', nativeCurrency: { name: 'Iotex', symbol: 'IOTX', decimals: 8, }, rpcUrls: { default: { http: ['https://babel-api.mainnet.iotex.io'] }, }, blockExplorers: { default: { name: 'Iotex', url: 'https://explorer.iotex.io', }, }, } export const hivelloTestnetChain = { id: 4690, name: 'Iotex Testnet', nativeCurrency: { name: 'Iotex Testnet coin', symbol: 'tIOTX', decimals: 8, }, rpcUrls: { default: { http: ['https://babel-api.testnet.iotex.io'] }, }, blockExplorers: { default: { name: 'Testnet Iotex', url: 'https://explorer.testnet.iotex.io', }, }, testnet: true, } export const hivelloContract = { delegationPool: '0x4B95d5a42e9b82caFd009BbFe92301866B0951a3', pToken: '0xa091dfcf73d288EFB2042f272f012eBCa5b18a50', miningToken: '0xd7b56d5450222ef2513ebce92ea980859bcadf91', thawing: '0xc31f699a446A3eC59d8D1A82715997816348Cd30', vesting: '0xEAe9F8Eeda6Cc009614853793F9b94Eed32f689C', } export const hivelloTestnetContract = { delegationPool: '0x304ecEA262847F902Be52C2CA9E621DD54d181Ff', pToken: '0x184B5Af5ED92b3Df063FEC91DCeE5b50501bCd99', miningToken: '0xdC8402Dfd7285B264F19AF76EF983655B664c509', thawing: '0xd76AC8F4fb699a2F03658d77789F1571b9bd66b9', vesting: '0x1701E2e1d7f320176fdb62DFEA238030f049a4a9', } export class HivelloProject extends BaseProject { name = 'Hivello' thawingEnabled = true miningToken = { name: 'Hivello', symbol: 'HVLO', decimals: 8, isNative: false, icon: 'https://d135ugxgwtnu1c.cloudfront.net/hivello-e3564df0.svg', } pToken = { name: 'pHVLO', symbol: 'pHVLO', decimals: 8, icon: 'https://d135ugxgwtnu1c.cloudfront.net/hivello-e3564df0.svg', } chainConfig = hivelloChain contracts: { delegationPool: string pToken: string miningToken: string thawing: string vesting: string dataHelper?: string } metadata = { guideLink: 'https://docs.parasail.network/delegation-guides/guide-for-hivello-users', website: 'https://www.hivello.com', description: `Hivello is an aggregator of DePIN projects, enabling users to easily participate in multiple networks and earn passive income by utilizing their idle computer resources. With a radically simple app, users can contribute unused resources and start earning with just a few clicks—no technical knowledge required.`, about: `Hivello is an aggregator of DePIN projects, enabling users to easily participate in multiple networks and earn passive income by utilizing their idle computer resources. With a radically simple app, users can contribute unused resources and start earning with just a few clicks—no technical knowledge required.`, } constructor({ isTestnet, provider, contracts = {}, }: { isTestnet: boolean provider?: ethers.providers.JsonRpcProvider contracts?: { delegationPool?: string pToken?: string miningToken?: string dataHelper?: string thawing?: string vesting?: string } }) { super(provider) this.chainConfig = isTestnet ? hivelloTestnetChain : hivelloChain this.contracts = isTestnet ? { ...hivelloTestnetContract, ...contracts } : { ...hivelloContract, ...contracts } if (isTestnet) { this.miningToken.decimals = 18 this.pToken.decimals = 18 } this.isTestnet = isTestnet } getAssetsInfo = async () => { const vestingContract = this.getVestingContract() const [totalSupply, totalVestingAmount, vestingPeriod] = await Promise.all([ this.getTokenContract(this.contracts.pToken).totalSupply(), vestingContract.totalVestingAmount(), vestingContract.vestingPeriod(), ]) const rewardOneYear = (Number( ethers.utils.formatUnits(totalVestingAmount, this.miningToken.decimals) ) * (365 * 24 * 60 * 60)) / Number(vestingPeriod) const apy = totalSupply.eq(0) ? 0.5 : (rewardOneYear * 0.8) / Number(ethers.utils.formatUnits(totalSupply, this.pToken.decimals)) return { apy: Number(apy), lockedAssets: Number(ethers.utils.formatUnits(totalSupply, this.pToken.decimals)) + Number( ethers.utils.formatUnits( totalVestingAmount, this.miningToken.decimals ) ), } } }