import { ethers } from 'ethers' import { BaseProject } from './base' export const spheronChain = { id: 8453, name: 'Base', nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18, }, rpcUrls: { default: { http: [ 'https://g.w.lavanet.xyz:443/gateway/base/rpc-http/f470a5c4be79ac5bb070fa8e497d015e', ], }, }, blockExplorers: { default: { name: 'Base', url: 'https://basescan.org', }, }, } export const spheronTestnetChain = { id: 84532, name: 'Base Sepolia', nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18, }, rpcUrls: { default: { http: [ 'https://g.w.lavanet.xyz:443/gateway/bases/rpc-http/f470a5c4be79ac5bb070fa8e497d015e', ], }, }, blockExplorers: { default: { name: 'Base Sepolia', url: 'https://sepolia.basescan.org', }, }, testnet: true, } export const spheronContract = { core: '0x4E56Dd55F04D92E99191e75BFD2D2C415e38d83B', delegationPool: '0x859e98624786ae9f985d09E5653e8b80B1F62a3d', pToken: '0x662bd61b6cdCC25FcA7a8B32C92B9055c1634E75', miningToken: '0x080D43c2164AFdBc3712422CE78Ab902ccaB5CA1', thawing: '0x859e98624786ae9f985d09E5653e8b80B1F62a3d', } export const spheronTestnetContract = { core: '0xd1767111920e3D12003E4FBa6aD8d79dF90AEa50', // actual pool contract delegationPool: '0x8d2ed77c1bEb0CF717667d3459086AEbF8a88979', // fake thawing contract pToken: '0x9Be4c94A160FbF26988F0B36cC200B0DC67851D4', miningToken: '0x76e593392523243ACD38ceD87c2007F14483a86B', thawing: '0x8d2ed77c1bEb0CF717667d3459086AEbF8a88979', } export class SpheronProject extends BaseProject { name = 'Spheron' thawingEnabled = true minRequestAmount = 1 disableThawingCancel = true miningToken = { name: 'SPON', symbol: 'SPON', decimals: 18, isNative: false, icon: 'https://d135ugxgwtnu1c.cloudfront.net/spheron-b90d1811.png', } pToken = { name: 'stSPON', symbol: 'stSPON', decimals: 18, icon: 'https://d135ugxgwtnu1c.cloudfront.net/spheron-b90d1811.png', } wpToken = { name: 'wstSPON', symbol: 'wstSPON', decimals: 18, icon: 'https://d135ugxgwtnu1c.cloudfront.net/spheron-b90d1811.png', } chainConfig = spheronChain contracts: { delegationPool: string pToken: string miningToken: string thawing: string core: string } metadata = { guideLink: 'https://docs.parasail.network/delegation-guides/guide-for-spheron-users/', website: 'https://www.spheron.network', description: 'Spheron is a decentralized cloud computing platform that provides a range of services for developers and businesses. It offers a variety of services, including storage, compute, and networking, all of which are designed to be decentralized and secure.', about: 'Spheron is a decentralized cloud computing platform that provides a range of services for developers and businesses. It offers a variety of services, including storage, compute, and networking, all of which are designed to be decentralized and secure.', } constructor({ isTestnet, provider, contracts = {}, }: { isTestnet: boolean provider?: ethers.providers.JsonRpcProvider contracts?: { delegationPool?: string pToken?: string miningToken?: string thawing?: string core?: string } }) { super(provider) this.chainConfig = isTestnet ? spheronTestnetChain : spheronChain this.contracts = isTestnet ? { ...spheronTestnetContract, ...contracts } : { ...spheronContract, ...contracts } this.isTestnet = isTestnet } getThawingContract = () => { const provider = this.getProvider() return new ethers.Contract( this.contracts.thawing!, [ 'function withdrawRequests(address user) external view returns (uint256 shares, uint256 unlockTime)', 'function withdraw() external', 'function withdrawRequest(uint256 amount) external', ], provider ) } getPoolBalance = async () => { return this.getMiningTokenBalance(this.contracts.core!) } getThawingInfo = async (address: string) => { const thawingContract = this.getThawingContract() const [amount, unlockTime] = await thawingContract.withdrawRequests(address) return { amount: await this.convertToAssets( ethers.utils.formatUnits(amount, this.pToken.decimals) ), unlockTime: Number(unlockTime), } } withdraw = async (address: string, amount: string, signer: ethers.Signer) => { const contract = this.getThawingContract().connect(signer) const tx = await contract.withdraw() return tx } requestWithdraw = async (amount: string, signer: ethers.Signer) => { const pool = this.getThawingContract() const tx = await pool .connect(signer) .withdrawRequest(ethers.utils.parseUnits(amount, this.pToken.decimals)) return tx } getAssetsInfo = async () => { const totalSupply = await this.getTokenContract( this.contracts.pToken ).totalSupply() return { apy: 0.4366, lockedAssets: +ethers.utils.formatUnits( totalSupply, this.pToken.decimals ), } } }