/** * Tron resource types */ export type YieldXyzTronResource = 'BANDWIDTH' | 'ENERGY' /** * Execution modes for yield actions */ export type YieldXyzExecutionMode = 'individual' | 'batched' /** * Arguments for entering a yield opportunity */ export interface YieldXyzEnterArguments { amount?: string validatorAddress?: string validatorAddresses?: string[] providerId?: string duration?: number inputToken?: string subnetId?: number tronResource?: YieldXyzTronResource feeConfigurationId?: string cosmosPubKey?: string tezosPubKey?: string cAddressBech?: string pAddressBech?: string executionMode?: YieldXyzExecutionMode ledgerWalletApiCompatible?: boolean } /** * Request to enter a yield opportunity */ export interface YieldXyzEnterRequest { yieldId: string address: string arguments?: YieldXyzEnterArguments } /** * Request to exit a yield opportunity */ export interface YieldXyzExitRequest { yieldId: string address: string arguments?: YieldXyzEnterArguments } /** * Yield action intent types */ export type YieldXyzActionIntent = 'enter' | 'manage' | 'exit' /** * Yield action types */ export type YieldXyzActionType = | 'STAKE' | 'UNSTAKE' | 'CLAIM_REWARDS' | 'RESTAKE_REWARDS' | 'WITHDRAW' | 'WITHDRAW_ALL' | 'RESTAKE' | 'CLAIM_UNSTAKED' | 'UNLOCK_LOCKED' | 'STAKE_LOCKED' | 'VOTE' | 'REVOKE' | 'VOTE_LOCKED' | 'REVOTE' | 'REBOND' | 'MIGRATE' | 'VERIFY_WITHDRAW_CREDENTIALS' | 'DELEGATE' /** * Yield action execution patterns */ export type YieldXyzActionExecutionPattern = | 'synchronous' | 'asynchronous' | 'batch' /** * Yield action status */ export type YieldXyzActionStatus = | 'CANCELED' | 'CREATED' | 'WAITING_FOR_NEXT' | 'PROCESSING' | 'FAILED' | 'SUCCESS' | 'STALE' /** * Yield action transaction status */ export type YieldXyzActionTransactionStatus = | 'BLOCKED' | 'BROADCASTED' | 'CONFIRMED' | 'CREATED' | 'FAILED' | 'NOT_FOUND' | 'PENDING' | 'SIGNED' | 'SKIPPED' | 'WAITING_FOR_SIGNATURE' /** * Yield action transaction type */ export type YieldXyzActionTransactionType = | 'APPROVAL' | 'BRIDGE' | 'CLAIM_REWARDS' | 'CLAIM_UNSTAKED' | 'COMPLETE_QUEUED_WITHDRAWALS' | 'CREATE_ACCOUNT' | 'CREATE_EIGENPOD' | 'DELEGATE' | 'DEPOSIT' | 'FREEZE_BANDWIDTH' | 'FREEZE_ENERGY' | 'INFSTONES_CLAIM_REQUEST' | 'INFSTONES_EXIT_REQUEST' | 'INFSTONES_PROVISION' | 'LOCK' | 'LUGANODES_EXIT_REQUEST' | 'LUGANODES_PROVISION' | 'MERGE' | 'MIGRATE' | 'P2P_NODE_REQUEST' | 'QUEUE_WITHDRAWALS' | 'REBOND' | 'RESTAKE' | 'RESTAKE_REWARDS' | 'REVEAL' | 'REVOKE' | 'SPLIT' | 'STAKE' | 'START_CHECKPOINT' | 'SUPPLY' | 'SWAP' | 'UNDELEGATE' | 'UNDELEGATE_BANDWIDTH' | 'UNDELEGATE_ENERGY' | 'UNFREEZE_BANDWIDTH' | 'UNFREEZE_ENERGY' | 'UNFREEZE_LEGACY' | 'UNFREEZE_LEGACY_BANDWIDTH' | 'UNFREEZE_LEGACY_ENERGY' | 'UNLOCK' | 'UNSTAKE' | 'UNWRAP' | 'UTXO_C_TO_P_IMPORT' | 'UTXO_P_TO_C_IMPORT' | 'VERIFY_CHECKPOINT_PROOFS' | 'VERIFY_WITHDRAW_CREDENTIALS' | 'VOTE' | 'WITHDRAW' | 'WITHDRAW_ALL' | 'WRAP' /** * Yield action transaction */ export interface YieldXyzActionTransaction { id: string title: string network: string status: YieldXyzActionTransactionStatus type: YieldXyzActionTransactionType hash?: string createdAt: string broadcastedAt?: string signedTransaction?: string unsignedTransaction?: string annotatedTransaction?: Record structuredTransaction?: Record stepIndex: number description?: string error?: string gasEstimate?: string explorerUrl?: string isMessage?: boolean } export interface YieldXyzEnterRawResponse { id: string intent: YieldXyzActionIntent type: YieldXyzActionType yieldId: string address: string amount?: string amountRaw?: string amountUsd?: string transactions: YieldXyzActionTransaction[] executionPattern: YieldXyzActionExecutionPattern rawArguments?: YieldXyzEnterArguments createdAt: string completedAt?: string status: YieldXyzActionStatus } export interface YieldXyzEnterYieldData { rawResponse: YieldXyzEnterRawResponse } /** * Response from entering a yield opportunity */ export interface YieldXyzEnterYieldResponse { data?: YieldXyzEnterYieldData error?: string } export interface YieldXyzExitRawResponse { id: string intent: YieldXyzActionIntent type: YieldXyzActionType yieldId: string address: string amount?: string amountRaw?: string amountUsd?: string transactions: YieldXyzActionTransaction[] executionPattern: YieldXyzActionExecutionPattern rawArguments?: YieldXyzEnterArguments createdAt: string completedAt?: string status: YieldXyzActionStatus } export interface YieldXyzExitData { rawResponse: YieldXyzExitRawResponse } /** * Response from exiting a yield opportunity */ export interface YieldXyzExitResponse { data?: YieldXyzExitData error?: string } export interface YieldXyzBalanceQuery { address: string network: string yieldId?: string } /** * Request to get yield balances for specific addresses and networks */ export interface YieldXyzGetBalancesRequest { queries: YieldXyzBalanceQuery[] } export interface YieldXyzBalanceToken { address: string symbol: string name: string decimals: number logoURI?: string network: string isPoints?: boolean } export interface YieldXyzBalancePendingAction { intent: YieldXyzActionIntent type: YieldXyzActionType passthrough: string arguments?: YieldXyzArgument } export interface YieldXyzBalance { address: string amount: string amountRaw: string type: string token: YieldXyzBalanceToken pendingActions?: YieldXyzBalancePendingAction[] amountUsd?: string isEarning?: boolean } export interface YieldXyzGetBalancesItem { yieldId: string balances: YieldXyzBalance[] } export interface YieldXyzGetBalancesRawResponse { items: YieldXyzGetBalancesItem[] errors?: string[] } export interface YieldXyzGetBalancesData { rawResponse: YieldXyzGetBalancesRawResponse } export interface YieldXyzGetBalancesMetadata { clientId?: string } /** * Response from getting yield balances */ export interface YieldXyzGetBalancesResponse { data?: YieldXyzGetBalancesData error?: string metadata?: YieldXyzGetBalancesMetadata } /** * Request to get historical yield actions with optional filtering */ export interface YieldXyzGetHistoricalActionsRequest { offset?: number limit?: number address?: string status?: YieldXyzActionStatus intent?: YieldXyzActionIntent type?: YieldXyzActionType yieldId?: string } export interface YieldXyzGetHistoricalActionsRawResponse { items: YieldXyzEnterRawResponse[] total?: number offset?: number limit?: number } export interface YieldXyzGetHistoricalActionsData { rawResponse: YieldXyzGetHistoricalActionsRawResponse } /** * Response for fetching yield actions list for an address */ export interface YieldXyzGetHistoricalActionsResponse { data?: YieldXyzGetHistoricalActionsData error?: string metadata?: YieldXyzGetBalancesMetadata } /** * Sort options for yield opportunities */ export type YieldXyzGetYieldsSort = | 'statusEnterAsc' | 'statusEnterDesc' | 'statusExitAsc' | 'statusExitDesc' /** * Yield mechanics types */ export type YieldXyzMechanicsType = | 'staking' | 'restaking' | 'lending' | 'vault' | 'fixed_yield' | 'real_world_asset' /** * Request parameters for getting yield opportunities from Yield.xyz */ export interface YieldXyzGetYieldsRequest { offset?: number limit?: number network?: string yieldId?: string type?: YieldXyzMechanicsType hasCooldownPeriod?: boolean hasWarmupPeriod?: boolean token?: string inputToken?: string provider?: string search?: string sort?: YieldXyzGetYieldsSort } /** * Token information */ export interface YieldXyzToken { symbol: string name: string decimals?: number network?: string address?: string logoURI?: string isPoints?: boolean coinGeckoId?: string } /** * Rate type */ export type YieldXyzRateType = 'APR' | 'APY' /** * Yield source */ export type YieldXyzSource = | 'staking' | 'restaking' | 'protocol_incentive' | 'points' | 'lending_interest' | 'mev' | 'real_world_asset_yield' | 'validator_commission' /** * Reward rate component */ export interface YieldXyzRewardRateComponent { rate: number rateType: YieldXyzRateType token: YieldXyzToken yieldSource: YieldXyzSource description: string } /** * Reward rate information */ export interface YieldXyzRewardRate { total: number rateType: YieldXyzRateType components: YieldXyzRewardRateComponent[] } /** * Statistics for a yield opportunity */ export interface YieldXyzStatistics { tvlUsd?: string tvl?: number uniqueUsers?: number averagePositionSizeUsd?: number averagePositionSize?: number } /** * Status of a yield opportunity */ export interface YieldXyzStatus { enter: boolean exit: boolean } /** * Metadata for a yield opportunity */ export interface YieldXyzOpportunityMetadata { name: string logoURI: string description: string documentation: string underMaintenance: boolean deprecated: boolean supportedStandards: string[] } /** * Reward schedule */ export type YieldXyzRewardSchedule = | 'block' | 'hour' | 'day' | 'week' | 'month' | 'era' | 'epoch' | 'campaign' /** * Reward claiming */ export type YieldXyzRewardClaiming = 'auto' | 'manual' /** * Lockup period information */ export interface YieldXyzLockupPeriod { seconds: number } /** * Cooldown period information */ export interface YieldXyzCooldownPeriod { seconds: number } /** * Warmup period information */ export interface YieldXyzWarmupPeriod { seconds: number } /** * Fee information */ export interface YieldXyzFee { deposit: number withdrawal: number performance: number management: number } /** * Entry limits information */ export interface YieldXyzEntryLimits { minimum?: string maximum?: string } /** * Argument field name */ export type YieldXyzArgumentFieldName = | 'amount' | 'validatorAddress' | 'validatorAddresses' | 'receiverAddress' | 'providerId' | 'duration' | 'inputToken' | 'subnetId' | 'tronResource' | 'feeConfigurationId' | 'cosmosPubKey' | 'tezosPubKey' | 'cAddressBech' | 'pAddressBech' | 'executionMode' | 'ledgerWalletApiCompatible' /** * Argument field type */ export type YieldXyzArgumentFieldType = | 'string' | 'number' | 'address' | 'enum' | 'boolean' /** * Argument field definition */ export interface YieldXyzArgumentField { name: YieldXyzArgumentFieldName type: YieldXyzArgumentFieldType label: string description?: string required?: boolean options?: string[] optionsRef?: string default?: Record placeholder?: string minimum?: string maximum?: string isArray?: boolean } /** * Argument definition */ export interface YieldXyzArgument { fields: YieldXyzArgumentField[] notes?: string } /** * Arguments for yield operations */ export interface YieldXyzArguments { enter: YieldXyzArgument exit: YieldXyzArgument manage?: Record balance?: YieldXyzArgument } /** * Possible fee taking mechanisms */ export interface YieldXyzPossibleFeeTakingMechanisms { depositFee: boolean managementFee: boolean performanceFee: boolean validatorRebates: boolean } /** * Mechanics information for a yield opportunity */ export interface YieldXyzMechanics { type: YieldXyzMechanicsType requiresValidatorSelection: boolean rewardSchedule: YieldXyzRewardSchedule rewardClaiming: YieldXyzRewardClaiming gasFeeToken: YieldXyzToken lockupPeriod?: YieldXyzLockupPeriod cooldownPeriod?: YieldXyzCooldownPeriod warmupPeriod?: YieldXyzWarmupPeriod fee?: YieldXyzFee entryLimits: YieldXyzEntryLimits supportsLedgerWalletApi: boolean extraTransactionFormatsSupported?: string[] arguments: YieldXyzArguments possibleFeeTakingMechanisms: YieldXyzPossibleFeeTakingMechanisms } /** * A yield opportunity */ export interface YieldXyzOpportunity { id: string network: string inputTokens: YieldXyzToken[] outputToken: YieldXyzToken token: YieldXyzToken rewardRate: YieldXyzRewardRate statistics?: YieldXyzStatistics status: YieldXyzStatus metadata: YieldXyzOpportunityMetadata mechanics: YieldXyzMechanics providerId: string tags: string[] } export interface YieldXyzGetYieldsRawResponse { items: YieldXyzOpportunity[] limit: number offset: number total: number } export interface YieldXyzGetYieldsData { rawResponse: YieldXyzGetYieldsRawResponse } /** * Response containing yield opportunities from Yield.xyz */ export interface YieldXyzGetYieldsResponse { data?: YieldXyzGetYieldsData error?: string } /** * Request to manage a yield opportunity */ export interface YieldXyzManageYieldRequest { yieldId: string address: string arguments?: YieldXyzEnterArguments action: YieldXyzActionType passthrough: string } export interface YieldXyzManageYieldRawResponse { id: string intent: YieldXyzActionIntent type: YieldXyzActionType yieldId: string address: string amount?: string amountRaw?: string amountUsd?: string transactions: YieldXyzActionTransaction[] executionPattern: YieldXyzActionExecutionPattern rawArguments?: YieldXyzEnterArguments createdAt: string completedAt?: string status: YieldXyzActionStatus } export interface YieldXyzManageYieldData { rawResponse: YieldXyzManageYieldRawResponse } /** * Response from managing a yield opportunity */ export interface YieldXyzManageYieldResponse { data?: YieldXyzManageYieldData error?: string } // ============================================================================ // Track Transaction Types // ============================================================================ /** * Request to submit a transaction hash for tracking */ export interface YieldXyzTrackTransactionRequest { transactionId: string hash: string } export interface YieldXyzTrackTransactionRawResponse { id: string title: string network: string status: YieldXyzActionTransactionStatus type: YieldXyzActionTransactionType hash?: string createdAt: string broadcastedAt?: string signedTransaction?: string unsignedTransaction?: string stepIndex: number gasEstimate?: string } export interface YieldXyzTrackTransactionData { rawResponse: YieldXyzTrackTransactionRawResponse } /** * Response from submitting a transaction hash */ export interface YieldXyzTrackTransactionResponse { data?: YieldXyzTrackTransactionData error?: string } // ============================================================================ // Get Transaction Types // ============================================================================ export interface YieldXyzGetTransactionRawResponse { id: string title: string network: string status: YieldXyzActionTransactionStatus type: YieldXyzActionTransactionType hash?: string createdAt: string broadcastedAt?: string signedTransaction?: string unsignedTransaction?: string stepIndex: number gasEstimate?: string } export interface YieldXyzGetTransactionRequest { rawResponse: YieldXyzGetTransactionRawResponse } export interface YieldXyzGetTransactionMetadata { clientId?: string transactionId?: string } /** * Response for fetching a single yield action transaction by ID */ export interface YieldXyzGetTransactionResponse { data?: YieldXyzGetTransactionRequest error?: string metadata?: YieldXyzGetTransactionMetadata } // ============================================================================ // High-level Yield (deposit / withdraw / validators) — shared contract types // ============================================================================ export interface YieldDefaultYieldEntry { yieldId: string opportunity: YieldXyzOpportunity | null } export type YieldDefaultYieldsMap = Record export interface YieldXyzGetYieldDefaultsRequest { includeOpportunities?: boolean } export interface YieldXyzGetYieldDefaultsResponse { data?: YieldDefaultYieldsMap error?: string } export interface YieldXyzValidator { address: string name?: string commission?: string apy?: string [key: string]: unknown } export interface YieldXyzGetYieldValidatorsResponse { data?: { /** Validators may appear on data.validators or nested under data.rawResponse; consumers should read both. */ validators?: YieldXyzValidator[] rawResponse?: { validators?: YieldXyzValidator[] /** Paginated validator list shape on nested rawResponse for some native-staking responses. */ items?: YieldXyzValidator[] total?: number offset?: number limit?: number } } error?: string } /** * Progress event for deposit/withdraw high-level methods. * Lifecycle steps emitted by high-level deposit/withdraw: * - `signing`: about to call signAndSendTransaction * - `submitted`: hash received from signAndSendTransaction * - `confirming`: waiting for on-chain confirmation to reach required depth * - `confirmed`: on-chain confirmation complete; about to track */ export interface YieldSubmitProgress { step: 'signing' | 'submitted' | 'confirming' | 'confirmed' index: number total: number hash?: string } /** * High-level yield deposit / withdraw using an explicit Portal `yieldId` (no defaults lookup). */ export interface YieldDepositParamsByYieldId { yieldId: string amount: string address: string arguments?: YieldXyzEnterArguments } /** * High-level yield deposit / withdraw: the SDK resolves `yieldId` by fetching Portal yield * defaults and reading the entry for `{chain}:{token}`. Pass `token` **exactly** as that map key * suffix (same casing/symbol the API returns). */ export interface YieldDepositParamsByChainAndToken { chain: string token: string amount: string address: string arguments?: YieldXyzEnterArguments } /** * High-level yield deposit parameters: either {@link YieldDepositParamsByYieldId} or * {@link YieldDepositParamsByChainAndToken}. When `yieldId` is a non-empty string (after trim), it * is used directly and defaults lookup is skipped; otherwise `chain` and `token` are required. * At runtime, a non-empty `yieldId` takes precedence over any also-present `chain` / `token`. */ export type YieldDepositParams = | YieldDepositParamsByYieldId | YieldDepositParamsByChainAndToken /** * Same union as {@link YieldDepositParams}. */ export type YieldWithdrawParams = YieldDepositParams /** * Result status for deposit/withdraw operations */ export type YieldSubmitResultStatus = 'SUCCESS' | 'PARTIAL_SUCCESS' | 'FAILED' /** * Options for deposit/withdraw high-level methods (e.g. onProgress). */ export interface YieldSubmitOptions { onProgress?: (event: YieldSubmitProgress) => void /** * Per-call signer override. Takes priority over the instance-level setter * ({@link YieldXyz.setSignAndSendTransaction}) when provided. * Useful for one-off calls that need a different signer without reconfiguring the instance. */ signAndSendTransaction?: ( transaction: unknown, network: string, ) => Promise /** * Optional per-call override for post-submit confirmation logic. * Called for **every** transaction on **any** chain (EVM and non-EVM). * Takes priority over Portal.waitForConfirmation. * * When omitted, Portal.waitForConfirmation is used for EVM Yield networks * (eth_getTransactionReceipt via gatewayConfig), so multi-step EVM flows stay * nonce-safe without extra integrator code. */ waitForConfirmation?: ( txHash: string, network: string, ) => Promise /** * Optional per-call JSON-RPC transport used by the built-in EVM receipt poller when * `waitForConfirmation` is not supplied. */ evmRequestFn?: ( method: string, params: unknown[], network: string, ) => Promise /** * Per-call tuning for the built-in EVM receipt poller used when `waitForConfirmation` * is not provided and the standalone `evmRequestFn` fallback is active. * When omitted, the built-in defaults (4 s poll interval, 15 min timeout) are used. */ evmPollerOptions?: { pollIntervalMs?: number timeoutMs?: number } } /** * Result of high-level deposit. When the call used `chain` + `token`, those are echoed on the * result; when only `yieldId` was passed, `chain` and `token` are omitted. */ export interface YieldDepositResult { hashes: string[] yieldId: string chain?: string token?: string status: YieldSubmitResultStatus yieldOpportunityDetails: { yieldId: string intent?: YieldXyzActionIntent type?: YieldXyzActionType executionPattern?: YieldXyzActionExecutionPattern status?: YieldXyzActionStatus amount?: string | null amountUsd?: string | null } } /** * Result of high-level withdraw. Same `chain` / `token` echo rules as {@link YieldDepositResult}. */ export interface YieldWithdrawResult { hashes: string[] yieldId: string chain?: string token?: string status: YieldSubmitResultStatus yieldOpportunityDetails: { yieldId: string intent?: YieldXyzActionIntent type?: YieldXyzActionType executionPattern?: YieldXyzActionExecutionPattern status?: YieldXyzActionStatus amount?: string | null amountUsd?: string | null } }