import type { Transaction } from "@sovereign-sdk/types";
import { type StandardRollup, type TransactionResult } from "@sovereign-sdk/web3";
import Decimal from "decimal.js";
import type { EquityType, MarginType } from "./bullet-wasm";
import { type Endpoints } from "./constants";
import type { Orderbook } from "./orderbook";
import type { RuntimeCall } from "./rollupTypes";
import type { Address, AssetId, AssetName, MarketMetadata, MarketName, MarkPriceUpdateArgs, Network, NewOrderArgs, OraclePriceUpdateArgs, OrderType, Side, SpotCollateralTransferDirection, TokenId, TpslPair } from "./types";
import type { Wallet } from "./wallet";
import { WebSocketManager } from "./websocket";
import { type AccountAddresses, type BorrowLendPool, type ExchangeAssets, type ExchangeInfo, type ExecutionIds, type OrderbookL2, type PerpMarket, type RiskEngine, type SpotMarket, type UserAccount } from "./zod-types/rest";
export interface TransactionOpts {
    maxPriorityFeeBps: number;
    maxFee: string;
    gasLimit: number[] | null;
}
type AmendOrderOptions = {
    existingOrderId: bigint;
    existingClientOrderId?: never;
    newOrderArgs: NewOrderArgs;
} | {
    existingOrderId?: never;
    existingClientOrderId: bigint;
    newOrderArgs: NewOrderArgs;
};
type CancelOrderOptions = {
    orderId: bigint;
    clientOrderId?: never;
} | {
    orderId?: never;
    clientOrderId: bigint;
};
export declare class ReadOnlyClient {
    rollup: StandardRollup<RuntimeCall>;
    readonly endpoint: string;
    protected readonly wsManager?: WebSocketManager;
    protected exchangeInfo?: ExchangeInfo;
    protected assetInfoRegistry?: Map<string, {
        id: number;
        name: string;
        token_id: string | null;
        decimals: number;
        withdraw_fee: string;
    }>;
    protected assetInfoRegistryReverse?: Map<number, {
        id: number;
        name: string;
        token_id: string | null;
        decimals: number;
        withdraw_fee: string;
    }>;
    protected marketRegistry?: Map<string, MarketMetadata>;
    protected marketRegistryReverse?: Map<number, string>;
    protected generationOverride?: () => number;
    /**
     * @internal
     * Do not construct directly. Use Client.fromNetwork() or Client.fromEndpoints()
     */
    constructor(endpoints: Endpoints, rollup: StandardRollup<RuntimeCall>);
    static fromEndpoints(endpoints: Endpoints): Promise<ReadOnlyClient>;
    static fromNetwork(network: Network): Promise<ReadOnlyClient>;
    setGenerationOverride(generation: (() => number) | undefined): void;
    private fetchApiResource;
    private fetchBulkApiResource;
    /**
     * @internal
     * Initializes exchange info and registries. Called automatically by factory methods.
     */
    initializeExchangeInfo(): Promise<void>;
    getExchangeInfo(): Promise<ExchangeInfo | null>;
    private getMarketMapping;
    getAssetId(asset: AssetName): number;
    getAssetName(assetId: number): AssetName;
    getTokenAddress(assetName: AssetName): string;
    getTokenAddresses(): Record<string, string>;
    getMarketId(market: MarketName): number;
    getMarketMeta(market: MarketName): MarketMetadata;
    getMarketName(marketId: number): string;
    getOrderbookL2(market: MarketName, levels?: number): Promise<OrderbookL2>;
    getOrderbookL2s(markets: MarketName[], levels?: number): Promise<Map<number, OrderbookL2>>;
    getChainId(): Promise<number>;
    getUserAccountAddresses(offset?: number, limit?: number): Promise<AccountAddresses>;
    getUserAccount(address: Address): Promise<UserAccount>;
    getUserAccounts(addresses: Address[]): Promise<Map<string, UserAccount>>;
    getExchangeAssets(): Promise<ExchangeAssets | null>;
    getRiskEngine(): Promise<RiskEngine | null>;
    getPerpMarket(market: MarketName): Promise<PerpMarket>;
    getPerpMarkets(markets: MarketName[]): Promise<Map<number, PerpMarket>>;
    getSpotMarket(market: MarketName): Promise<SpotMarket>;
    getSpotMarkets(markets: MarketName[]): Promise<Map<number, SpotMarket>>;
    getExecutionIds(): Promise<ExecutionIds | null>;
    getTokenBalance(tokenId: string, address: Address): Promise<bigint>;
    getTotalSupply(tokenId: TokenId): Promise<bigint>;
    getGasTokenAddress(): Promise<TokenId>;
    calculateOrderbookMidpoint(orderbook: OrderbookL2): Decimal | undefined;
    calculateEntryPrice(market: MarketName, userAccount: UserAccount): Decimal;
    calculateTotalPerpUnrealizedPnl(userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateAccountEquity(equityType: EquityType, conservative: boolean, userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateAccountLeverage(userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateAvailableMargin(marginType: MarginType, conservative: boolean, userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateUsedMargin(withdrawal: boolean, marginType: MarginType, userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateUsedPerpMargin(userAccount: UserAccount, marginType: MarginType, riskEngine: RiskEngine): Decimal;
    calculateUsedSpotMargin(userAccount: UserAccount, marginType: MarginType, riskEngine: RiskEngine): Decimal;
    calculateWithdrawableAmountOfAsset(asset: AssetName, userAccount: UserAccount, riskEngine: RiskEngine): Promise<Decimal>;
    calculateEstimatedLiquidationPrice(market: MarketName, asset: AssetName, userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateLiquidationRiskPercentage(userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateMarginBalance(userAccount: UserAccount, riskEngine: RiskEngine): {
        collateral_value: Decimal;
        assets: Decimal;
        liabilities: Decimal;
        pnl: Decimal;
    };
    calculateTotalPerpMarginRequirement(userAccount: UserAccount, marginType: MarginType, withdrawal: boolean, riskEngine: RiskEngine): Decimal;
    calculateForceCancelRiskPercentage(userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateMaxBorrowAmount(asset: AssetName, userAccount: UserAccount, riskEngine: RiskEngine): Decimal;
    calculateMaxOrderSize(market: MarketName, price: Decimal, side: Side, order_type: OrderType, reduce_only: boolean, userAccount: UserAccount, riskEngine: RiskEngine, orderbook: OrderbookL2, n_iterations?: number, error_tolerance?: Decimal): Decimal;
    calculateMaxWithdrawableAmountOfAsset(asset: AssetName, forTransferSpotCollateral: boolean, userAccount: UserAccount, riskEngine: RiskEngine, exchangeInfo: ExchangeInfo): Decimal;
    simulateUsedMarginOnBorrow(asset: AssetName, borrowAmount: Decimal, userAccount: UserAccount, marginType: MarginType, riskEngine: RiskEngine): {
        current: Decimal;
        updated: Decimal;
    };
    simulateUsedMarginOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, userAccount: UserAccount, riskEngine: RiskEngine, orderbook: OrderbookL2): {
        current: Decimal;
        updated: Decimal;
    };
    simulateEstimatedLiquidationPriceOnOrder(market: MarketName, newOrderArgs: NewOrderArgs, baseAsset: AssetName, userAccount: UserAccount, riskEngine: RiskEngine, orderbook: OrderbookL2): {
        current: Decimal;
        updated: Decimal;
    };
    calculatePositionsAdditionalMetadata(userAccount: UserAccount, riskEngine: RiskEngine): Map<number, {
        projected_funding_payment: Decimal;
        unrealized_pnl: Decimal;
        liquidation_price: Decimal;
        liquidation_risk_percentage: Decimal;
        max_leverage_to_use: number;
    }>;
    calculateBorrowLendPoolAdditionalMetadata(borrowLendPools: Map<AssetId, BorrowLendPool>, asset: AssetName): {
        utilisation_rate: Decimal;
        current_deposit_rate: Decimal;
        current_borrow_rate: Decimal;
    };
    calculateAccountSummaryBatch(userAccounts: UserAccount[], riskEngine: RiskEngine, useWeightedEquity?: boolean): {
        address: string;
        equity: Decimal;
        unrealized_pnl: Decimal;
        available_initial_margin: Decimal;
        available_maintenance_margin: Decimal;
        leverage: Decimal;
        account_variant?: string | undefined;
    }[];
    private getWebSocketManager;
    subscribeOrderbook(market: MarketName, signal?: AbortSignal): AsyncIterable<Orderbook>;
    unsubscribeOrderbook(market: MarketName): Promise<void>;
    /**
     * Dispose of all resources: WebSocket connections, Maps, and references
     * Call this when the client is no longer needed to prevent memory leaks
     */
    dispose(): void;
}
export declare class AuthenticatedClient extends ReadOnlyClient {
    readonly address: Address;
    private readonly wallet;
    /**
     * @internal
     * Do not construct directly. Use Client.fromNetwork() or Client.fromEndpoints()
     */
    constructor(endpoints: Endpoints, rollup: StandardRollup<RuntimeCall>, wallet: Wallet, delegatorAddress?: Address);
    getUserAccount(address?: Address): Promise<UserAccount>;
    getTokenBalance(tokenId: string, address?: Address): Promise<bigint>;
    getNonce(): Promise<number>;
    submitTransaction(runtimeCall: RuntimeCall): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    transfer(to: Address, amount: bigint, tokenId: TokenId): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    mint(to: Address, amount: bigint, tokenId: TokenId): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    deposit(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    depositToVault(vaultAddress: Address, asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    withdraw(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    borrowSpot(asset: AssetName, amount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    depositSpotCollateral(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    withdrawSpotCollateral(asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    transferSpotCollateral(direction: SpotCollateralTransferDirection, asset: AssetName, amount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    placeOrders(market: MarketName, newOrders: NewOrderArgs[], replace?: boolean, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    createPerpPositionTpsl(market: MarketName, tpslPair: TpslPair, size?: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    amendOrders(market: MarketName, options: AmendOrderOptions[], subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    cancelTriggerOrders(market: MarketName, triggerOrderIds: bigint[], subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    cancelOrders(market: MarketName, options: CancelOrderOptions[], subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminCancelOrders(address: Address, market: MarketName, orderId: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminCancelTriggerOrder(address: Address, market: MarketName, triggerOrderId: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    cancelAllOrders(market: MarketName, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateOraclePrices(pricesToUpdate: OraclePriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateMarkPrices(pricesToUpdate: MarkPriceUpdateArgs[], publishTimestamp?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateMaxLeverageForMarket(market: MarketName, maxLeverage: number, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updatePremiumIndexes(markets: MarketName[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    executePerpActiveTriggerOrders(market: MarketName): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    executeSpotActiveTriggerOrders(market: MarketName): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateFunding(markets: MarketName[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    applyFunding(addresses: Address[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    accrueBorrowLendInterest(): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    forceCancelOrders(address: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    forceClosePositions(address: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    liquidatePerpPositions(address: Address, positions?: {
        market: MarketName;
        size: Decimal;
    }[], subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    liquidateSpotLiability(address: Address, liabilityAssetId: AssetName, collateralAssetId: AssetName, liabilityAmount: Decimal, subAccountIndex?: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    depositToUsdcPnlPool(amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    depositToInsuranceFund(amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    initAssetMetadata(asset_id: number, assetName: string, tokenId: TokenId | null, decimals: number, withdrawFee: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateAssetMetadata(assetId: number, assetName: string | null, tokenId: TokenId | null, decimals: number | null, withdrawFee: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateGlobalConfig(maxOrdersPerUser: number | null, maxTriggerOrdersPerUser: number | null, maxOrdersPerBatchMsg: number | null, maxTriggerOrdersToExecutePerMsg: number | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    initVault(name: string, description: string, leader: Address, depositAssetIds: AssetId[], withdrawAssetId: AssetId, withdrawLockupPeriodHours: number, whitelistDeposits: boolean, profitSharePercentage: number, withdrawalFeeBps: number, depositLimit: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    initSpotMarket(marketId: number, baseAssetId: number, quoteAssetId: AssetId, baseMinLotSize: Decimal, quoteMinLotSize: Decimal, maxOrdersPerSide: number, maxOrdersPerUser: number, maxTriggerOrdersPerUser: number, takerFeesTenthBps: number[], makerFeesTenthBps: number[], maxOrderToTriggerPriceDeviationRatio: Decimal, name: string): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateSpotMarket(marketId: number, baseMinLotSize: Decimal | null, quoteMinLotSize: Decimal | null, maxOrdersPerSide: number | null, maxOrdersPerUser: number | null, maxTriggerOrdersPerUser: number | null, takerFeesTenthBps: number[] | null, makerFeesTenthBps: number[] | null, maxOrderToTriggerPriceDeviationRatio: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    initPerpMarket(marketId: number, baseAssetId: number, name: string, minTickSize: Decimal, minLotSize: Decimal, maxOrdersPerSide: number, maxOrdersPerUser: number, maxTriggerOrdersPerUser: number, minInterestRateClamp: Decimal, maxInterestRateClamp: Decimal, minFundingRateClamp: Decimal, maxFundingRateClamp: Decimal, maxOiNotional: Decimal, maxOrderToMarkPriceDeviationRatio: Decimal, maxTriggerToComparisonPriceDeviationRatio: Decimal, maxOrderToTriggerPriceDeviationRatio: Decimal, impactMargin: Decimal, interestRate: Decimal, leverageTableArgs: Record<string, number>, takerFeesTenthBps: number[], makerFeesTenthBps: number[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updatePerpMarket(marketId: number, minTickSize: Decimal | null, minLotSize: Decimal | null, maxOrdersPerSide: number | null, maxOrdersPerUser: number | null, maxTriggerOrdersPerUser: number | null, minInterestRateClamp: Decimal | null, maxInterestRateClamp: Decimal | null, minFundingRateClamp: Decimal | null, maxFundingRateClamp: Decimal | null, maxOiNotional: Decimal | null, impactMargin: Decimal | null, interestRate: Decimal | null, takerFeesTenthBps: number[] | null, makerFeesTenthBps: number[] | null, maxOrderToMarkPriceDeviationRatio: Decimal | null, maxTriggerToComparisonPriceDeviationRatio: Decimal | null, maxOrderToTriggerPriceDeviationRatio: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    initBorrowLendPool(assetId: number, optimalUtilisationRate: Decimal, minBorrowRate: Decimal, maxBorrowRate: Decimal, optimalBorrowRate: Decimal, assetWeight: Decimal, initialLiabilityWeight: Decimal, maintenanceLiabilityWeight: Decimal, depositLimit: Decimal, borrowLimit: Decimal, liquidationTotalRewardRatio: Decimal, protocolRewardRatio: Decimal, liabilityLiquidationLimitRatio: Decimal, interestFeeTenthBps: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateBorrowLendPool(asset: AssetName, optimalUtilisationRate: Decimal | null, minBorrowRate: Decimal | null, maxBorrowRate: Decimal | null, optimalBorrowRate: Decimal | null, assetWeight: Decimal | null, initialLiabilityWeight: Decimal | null, maintenanceLiabilityWeight: Decimal | null, depositLimit: Decimal | null, borrowLimit: Decimal | null, liquidationRewardRatio: Decimal | null, liabilityLiquidationLimitRatio: Decimal | null): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    updateLeverageTable(market: MarketName, leverageTable: Record<string, number>): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    createSubAccount(index: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    transferSubAccount(subAccountIndex: number, toSubAccount: boolean, asset: AssetName, amount: Decimal): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    delegateUser(delegate: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    revokeDelegation(delegate: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    vaultDelegateUser(vaultAddress: Address, delegate: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    vaultRevokeDelegation(vaultAddress: Address, delegate: Address): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminPruneMarket(marketId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminForceSettlePerpPosition(marketId: number, usersToForceSettle: Address[]): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminHaltPerpMarket(marketId: number, settlementPrice: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminHaltSpotMarket(marketId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminUnhaltPerpMarket(marketId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminUnhaltSpotMarket(marketId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminHaltBorrowLendPool(assetId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
    adminUnhaltBorrowLendPool(assetId: number): Promise<TransactionResult<Transaction<RuntimeCall>>>;
}
export declare namespace Client {
    function fromEndpoints(endpoints: Endpoints, wallet: Wallet, delegatorAddress?: Address, txOpts?: TransactionOpts): Promise<AuthenticatedClient>;
    function fromEndpoints(endpoints: Endpoints): Promise<ReadOnlyClient>;
    function fromNetwork(network: Network, wallet: Wallet, delegatorAddress?: Address, txOpts?: TransactionOpts): Promise<AuthenticatedClient>;
    function fromNetwork(network: Network): Promise<ReadOnlyClient>;
}
export {};
//# sourceMappingURL=client.d.ts.map