import { BaseSignerWalletAdapter } from '@solana/wallet-adapter-base';
import { PublicKey as SolPubKey } from '@solana/web3.js';
import { ChainID, ExternalNetwork, PublicKey } from '@wireio/core';
import { ethers } from 'ethers';

export interface IStakingClient {
    pubKey: PublicKey;
    network: ExternalNetwork;

    /** Amount is in the chain's smallest unit (lamports/wei, etc.) */
    deposit(amount: bigint): Promise<string>;
    withdraw(amount: bigint): Promise<string>;
    stake(amount: bigint): Promise<string>;
    unstake(amount: bigint): Promise<string>;

    buy?(amount: bigint, purchaseAsset: PurchaseAsset): Promise<string>;

    // REMOVED from shared client, SOLANA ONLY
    /** Register any untracked LIQ staked tokens */
    // register(): Promise<string>;

    /** Fetch the portfolio for the LIQ stake user */
    getPortfolio(): Promise<Portfolio>;
}

// Enum describing which asset is being used to buy pretoken
export enum PurchaseAsset {
    SOL = "SOL",
    LIQSOL = "LIQSOL",
    ETH = "ETH",
    LIQETH = "LIQETH",
    YIELD = "YIELD",
}

export type StakerConfig = {
    network: ExternalNetwork;
    provider: BaseSignerWalletAdapter | ethers.providers.Web3Provider;
    pubKey: PublicKey;
}

export interface Portfolio {
    /** Native balance on chain: ETH, SOL */
    native: BalanceView;
    /** Actual Liquid  balance of LiqETH, LiqSOL*/
    liq: BalanceView;
    /** Outpost Staked balance */
    staked: BalanceView
    /** SOL ONLY!
     * Tracked liqSOL balance from distribution program */
    tracked?: BalanceView;
    /** Extra PDAs and account addresses */
    extras?: Record<string, any>;
    /** Chain ID of the network for which this portfolio is from */
    chainID: ChainID; 
}

export type BalanceView = {
    amount: bigint; // raw on-chain integer value
    decimals: number; // number of decimal places
    symbol?: string; // optional token symbol identifier
    ata?: SolPubKey; // associated token account address
};