@mobula_labs/types 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js.map +3 -3
- package/dist/v2/wallet/WalletDefiPositionsSchema.d.ts +1 -0
- package/dist/wss/BalancePayloadSchema.d.ts +1 -0
- package/dist/wss/PositionPayloadSchema.d.ts +1 -0
- package/package.json +1 -1
- package/dist/v2/explorer/BlockDataQuerySchema.d.ts +0 -33
- package/dist/v2/explorer/ContractVerifyQuerySchema.ts +0 -27
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -88,13 +88,13 @@
|
|
|
88
88
|
"import { z } from 'zod';\n\n// Zod schema for wallet analysis query parameters\nexport const WalletAnalysisParamsSchema = z.object({\n wallet: z.string().min(1, 'Wallet address is required'),\n blockchain: z.string().optional(),\n period: z\n .string()\n .optional()\n .default('7d')\n .transform((val) => val?.toLowerCase())\n .refine((val) => ['1d', '7d', '30d', '90d'].includes(val), {\n message: 'Period must be one of: 1d, 7d, 30d, 90d',\n }),\n});\n\nexport type WalletAnalysisParams = z.input<typeof WalletAnalysisParamsSchema>;\n\n// OpenAPI-compatible params schema (simplified without transformations)\nexport const WalletAnalysisParamsSchemaOpenAPI = z.object({\n wallet: z.string().min(1).describe('Wallet address to analyze'),\n blockchain: z.string().optional().describe('Blockchain ID (e.g., ethereum, base, solana:solana)'),\n period: z.string().optional().default('7d').describe('Analysis period: 1d, 7d, 30d, or 90d'),\n});\n\n// Zod schema for wallet analysis response\nexport const WalletAnalysisResponseSchema = z.object({\n data: z.object({\n winRateDistribution: z.object({\n '>500%': z.number(),\n '200%-500%': z.number(),\n '50%-200%': z.number(),\n '0%-50%': z.number(),\n '-50%-0%': z.number(),\n '<-50%': z.number(),\n }),\n marketCapDistribution: z.object({\n '>1000M': z.number(),\n '>100M': z.number(),\n '10M-100M': z.number(),\n '1M-10M': z.number(),\n '100k-1M': z.number(),\n '<100k': z.number(),\n }),\n periodTimeframes: z.array(\n z.object({\n date: z.date(),\n realized: z.number(),\n }),\n ),\n stat: z.object({\n totalValue: z.number(),\n periodTotalPnlUSD: z.number(),\n periodRealizedPnlUSD: z.number(),\n periodRealizedRate: z.number(),\n periodActiveTokensCount: z.number(),\n periodWinCount: z.number(),\n fundingInfo: z.object({\n from: z.string().nullable(),\n date: z.date().nullable(),\n chainId: z.string().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n periodVolumeBuy: z.number(),\n periodVolumeSell: z.number(),\n periodBuys: z.number(),\n periodSells: z.number(),\n nativeBalance: z\n .object({\n rawBalance: z.string(),\n formattedBalance: z.number(),\n assetId: z.number().nullable(),\n chainId: z.string(),\n address: z.string(),\n decimals: z.number(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n price: z.number(),\n balanceUSD: z.number(),\n })\n .nullable(),\n periodBuyTokens: z.number(),\n periodSellTokens: z.number(),\n periodTradingTokens: z.number(),\n holdingTokensCount: z.number(),\n holdingDuration: z.number(),\n tradingTimeFrames: z.number(),\n winRealizedPnl: z.number(),\n winRealizedPnlRate: z.number(),\n winToken: z\n .object({\n address: z.string(),\n chainId: z.string(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n decimals: z.number(),\n })\n .nullable(),\n }),\n labels: z.array(z.string()),\n }),\n});\n\nexport type WalletAnalysisResponse = z.infer<typeof WalletAnalysisResponseSchema>;\n\n// OpenAPI-compatible schema (dates as strings for OpenAPI spec generation)\nexport const WalletAnalysisResponseSchemaOpenAPI = z.object({\n data: z.object({\n winRateDistribution: z.object({\n '>500%': z.number(),\n '200%-500%': z.number(),\n '50%-200%': z.number(),\n '0%-50%': z.number(),\n '-50%-0%': z.number(),\n '<-50%': z.number(),\n }),\n marketCapDistribution: z.object({\n '>1000M': z.number(),\n '>100M': z.number(),\n '10M-100M': z.number(),\n '1M-10M': z.number(),\n '100k-1M': z.number(),\n '<100k': z.number(),\n }),\n periodTimeframes: z.array(\n z.object({\n date: z.string(),\n realized: z.number(),\n }),\n ),\n stat: z.object({\n totalValue: z.number(),\n periodTotalPnlUSD: z.number(),\n periodRealizedPnlUSD: z.number(),\n periodRealizedRate: z.number(),\n periodActiveTokensCount: z.number(),\n periodWinCount: z.number(),\n fundingInfo: z.object({\n from: z.string().nullable(),\n date: z.string().nullable(),\n chainId: z.string().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n periodVolumeBuy: z.number(),\n periodVolumeSell: z.number(),\n periodBuys: z.number(),\n periodSells: z.number(),\n nativeBalance: z\n .object({\n rawBalance: z.string(),\n formattedBalance: z.number(),\n assetId: z.number().nullable(),\n chainId: z.string(),\n address: z.string(),\n decimals: z.number(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n price: z.number(),\n balanceUSD: z.number(),\n })\n .nullable(),\n periodBuyTokens: z.number(),\n periodSellTokens: z.number(),\n periodTradingTokens: z.number(),\n holdingTokensCount: z.number(),\n holdingDuration: z.number(),\n tradingTimeFrames: z.number(),\n winRealizedPnl: z.number(),\n winRealizedPnlRate: z.number(),\n winToken: z\n .object({\n address: z.string(),\n chainId: z.string(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n decimals: z.number(),\n })\n .nullable(),\n }),\n labels: z.array(z.string()),\n }),\n});\n",
|
|
89
89
|
"import { z } from 'zod';\n\n// Zod schema for wallet funding query parameters\nexport const WalletFundingParamsSchema = z.object({\n wallet: z.string().min(1, 'Wallet address is required'),\n});\n\nexport type WalletFundingParams = z.input<typeof WalletFundingParamsSchema>;\n\n// Zod schema for wallet funding response\nexport const WalletFundingResponseSchema = z.object({\n data: z.object({\n from: z.string().nullable(),\n chainId: z.string().nullable(),\n date: z.date().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n});\n\nexport type WalletFundingResponse = z.infer<typeof WalletFundingResponseSchema>;\n",
|
|
90
90
|
"import { z } from 'zod';\nimport { TokenDetailsOutput } from '../../utils/schemas/TokenDetailsOutput.ts';\n\nexport type WalletActivityV2ControllerUnsafeParams = {\n wallet: string;\n blockchains?: string;\n blacklist?: string;\n offset?: number | string;\n limit?: number | string;\n order?: string;\n pagination_details?: boolean | string;\n unlistedAssets?: boolean | string;\n filterSpam?: boolean | string;\n backfillTransfers?: boolean | string;\n backfillBalances?: boolean | string;\n cursor_hash?: string;\n cursor_direction?: 'before' | 'after';\n};\n\nexport const WalletActivityV2ParamsSchema = z.object({\n wallet: z.string(),\n blockchains: z\n .string()\n .optional()\n .transform((val) => {\n if (val) {\n return val\n .split(',')\n .map((b) => b.trim())\n .filter((b) => b.length > 0);\n }\n return [];\n }),\n blacklist: z\n .string()\n .optional()\n .transform((val) => (val ? val.split(',').map((addr) => addr.trim().toLowerCase()) : [])),\n offset: z.coerce.number().optional().default(0),\n limit: z.coerce.number().optional().default(100),\n order: z.enum(['asc', 'desc']).optional().default('desc'),\n pagination: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n unlistedAssets: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(true),\n filterSpam: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(true),\n backfillTransfers: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n backfillBalances: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n cursor_hash: z.string().optional(),\n cursor_direction: z.enum(['before', 'after']).optional().default('before'),\n withTokens: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n});\n\nexport type WalletActivityV2Params = z.input<typeof WalletActivityV2ParamsSchema>;\n\n// Reusable asset schema used in nested activity items\nconst ActivityAssetSchema = z.object({\n id: z.number().nullable(),\n name: z.string(),\n symbol: z.string(),\n decimals: z.number(),\n totalSupply: z.number(),\n circulatingSupply: z.number(),\n price: z.number(),\n liquidity: z.number(),\n priceChange24hPercent: z.number(),\n marketCapUsd: z.number(),\n logo: z.string().nullable(),\n contract: z.string(),\n});\n\n// Activities that occurred within a single transaction\nexport const WalletActivityV2TransactionActivitySchema = z.object({\n model: z.enum(['swap', 'transfer']),\n\n // Swap-specific fields\n swapType: z.enum(['REGULAR', 'MEV', 'SANDWICHED_MEV', 'DEPOSIT', 'WITHDRAW']).optional(),\n swapRawAmountOut: z.number().optional(),\n swapRawAmountIn: z.number().optional(),\n swapAmountOut: z.number().optional(),\n swapAmountIn: z.number().optional(),\n swapPriceUsdTokenOut: z.number().optional(),\n swapPriceUsdTokenIn: z.number().optional(),\n swapAmountUsd: z.number().optional(),\n swapTransactionSenderAddress: z.string().optional(),\n swapBaseAddress: z.string().optional(),\n swapQuoteAddress: z.string().optional(),\n swapAmountQuote: z.number().optional(),\n swapAmountBase: z.number().optional(),\n swapAssetIn: ActivityAssetSchema.optional(),\n swapAssetOut: ActivityAssetSchema.optional(),\n\n // Transfer-specific fields\n transferRawAmount: z.string().optional(),\n transferAmount: z.number().optional(),\n transferAmountUsd: z.number().optional(),\n transferType: z\n .enum(['VAULT_DEPOSIT', 'VAULT_WITHDRAW', 'VAULT_UNSTAKE', 'TOKEN_IN', 'TOKEN_OUT', 'NATIVE_IN', 'NATIVE_OUT'])\n .optional(),\n transferFromAddress: z.string().optional().nullable(),\n transferToAddress: z.string().optional().nullable(),\n transferAsset: ActivityAssetSchema.optional(),\n});\n\n// Grouped by transaction hash\nexport const WalletActivityV2TransactionSchema = z.object({\n chainId: z.string(),\n txDateMs: z.number(),\n txDateIso: z.string(),\n txHash: z.string(),\n txRawFeesNative: z.string(),\n txFeesNativeUsd: z.number(),\n txBlockNumber: z.number(),\n txIndex: z.number(),\n txAction: z.string().optional().nullable(),\n\n actions: z.array(WalletActivityV2TransactionActivitySchema),\n});\n\nexport const WalletActivityV2OutputDataSchema = z.array(WalletActivityV2TransactionSchema);\n\nexport const WalletActivityV2OutputPaginationSchema = z.object({\n page: z.number(),\n offset: z.number(),\n limit: z.number(),\n pageEntries: z.number(),\n});\n\nexport const WalletActivityV2ResponseSchema = z.object({\n data: WalletActivityV2OutputDataSchema,\n pagination: WalletActivityV2OutputPaginationSchema,\n backfillStatus: z.enum(['processed', 'processing', 'pending']).optional(),\n tokens: z.array(TokenDetailsOutput).optional(),\n});\n\nexport type WalletActivityV2Response = z.input<typeof WalletActivityV2ResponseSchema>;\n",
|
|
91
|
-
"import { z } from 'zod';\n\n// ===========================================\n// Input Schema\n// ===========================================\n\n// Validates both EVM (0x + 40 hex chars = 42) and Solana (32-44 base58 chars) addresses\nconst walletAddressSchema = z\n .string()\n .min(32, 'Invalid wallet address')\n .max(44, 'Invalid wallet address')\n .or(z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid EVM wallet address'));\n\nexport const WalletDefiPositionsParamsSchema = z.object({\n wallet: walletAddressSchema.describe('Wallet address (EVM or Solana)'),\n blockchains: z.string().describe('Blockchain to fetch positions from (e.g., \"solana\", \"ethereum\")'),\n});\n\nexport type WalletDefiPositionsParams = z.infer<typeof WalletDefiPositionsParamsSchema>;\n\n// ===========================================\n// Output Types\n// ===========================================\n\nexport type ProtocolCategory =\n | 'lending'\n | 'lp'\n | 'liquid-staking'\n | 'native-staking'\n | 'restaking'\n | 'perps'\n | 'yield'\n | 'cdp'\n | 'streaming';\n\nexport type PositionType =\n | 'deposit'\n | 'borrow'\n | 'liquidity'\n | 'stake'\n | 'leverage'\n | 'collateral'\n | 'debt'\n | 'vesting'\n | 'streaming'\n | 'order';\n\n// ===========================================\n// Token\n// ===========================================\n\nexport interface TokenAmount {\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n amountRaw: string; // Raw amount\n amountFormatted: number; // Human readable\n priceUSD: number;\n valueUSD: number;\n logoUri?: string;\n}\n\n// ===========================================\n// Metadata by position type\n// ===========================================\n\nexport interface LendingMetadata {\n type: 'lending';\n market?: string; // Market name (e.g., \"Main Market\", \"JLP Market\")\n healthFactor?: string;\n liquidationThreshold?: string;\n ltv?: string;\n supplyAPY?: string; // Total APY (base + token APY for LSTs)\n baseSupplyAPY?: string; // Base lending APY from protocol\n tokenAPY?: string; // Native staking/yield APY for yield-bearing tokens (LST, JLP, etc.)\n borrowAPY?: string; // Base borrow APY from protocol\n baseBorrowAPY?: string; // Base borrow APY (same as borrowAPY, for consistency with supply)\n utilizationRate?: string;\n}\n\nexport interface LiquidityMetadata {\n type: 'liquidity';\n poolAddress: string;\n poolName: string;\n poolType: 'amm' | 'clmm' | 'dlmm';\n shareOfPool?: string;\n fee24h?: string;\n apy?: string;\n tickLower?: number;\n tickUpper?: number;\n inRange?: boolean;\n}\n\nexport interface LiquidStakingMetadata {\n type: 'liquid-staking';\n lstMint: string;\n lstSymbol: string;\n exchangeRate: string;\n apy?: string;\n unstakePending?: string;\n}\n\nexport interface PerpMetadata {\n type: 'perp';\n // Identification\n id: string;\n marketId: string;\n exchange: 'drift' | 'gains' | 'hyperliquid' | 'gte' | 'lighter';\n\n // Position\n side: 'BUY' | 'SELL';\n entryPriceQuote: number;\n currentPriceQuote: number;\n currentLeverage: number;\n liquidationPriceQuote: number;\n\n // Size\n amountUSD: number;\n amountRaw: string; // bigint -> string for JSON serialization\n\n // PnL\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n realizedPnlPercent: number;\n unrealizedPnlPercent: number;\n\n // Fees\n feesOpeningUSD: number;\n feesClosingUSD: number;\n feesFundingUSD: number;\n\n // TP/SL\n tp: Array<{ size: string; price: number; id: number }>;\n sl: Array<{ size: string; price: number; id: number }>;\n\n // Timestamps\n openDate?: string;\n lastUpdate?: string;\n\n // Chain info\n address: string;\n chainId: string;\n collateralAsset: string;\n}\n\nexport interface StreamingMetadata {\n type: 'streaming';\n streamType: 'vesting' | 'payment';\n sender?: string;\n recipient?: string;\n startTime: string;\n endTime: string;\n amountPerSecond: string;\n amountClaimed: string;\n amountRemaining: string;\n cliffDate?: string;\n}\n\nexport interface NativeStakingMetadata {\n type: 'native-staking';\n stakeAccountAddress: string;\n validatorVoteAccount: string;\n validatorName?: string;\n validatorCommission?: number;\n activationState: 'activating' | 'active' | 'deactivating' | 'inactive';\n activationEpoch?: number;\n deactivationEpoch?: number;\n currentEpoch: number;\n apy?: string;\n}\n\nexport interface RestakingMetadata {\n type: 'restaking';\n strategyAddress: string;\n strategyName: string;\n underlyingToken: string;\n underlyingSymbol: string;\n operatorAddress?: string;\n isDelegated: boolean;\n sharesRaw: string;\n}\n\nexport type PositionMetadata =\n | LendingMetadata\n | LiquidityMetadata\n | LiquidStakingMetadata\n | NativeStakingMetadata\n | RestakingMetadata\n | PerpMetadata\n | StreamingMetadata;\n\n// ===========================================\n// Position\n// ===========================================\n\nexport interface Position {\n id: string;\n type: PositionType;\n name: string;\n valueUSD: number;\n tokens: TokenAmount[];\n rewards?: TokenAmount[];\n metadata?: PositionMetadata;\n createdAt?: string;\n updatedAt?: string;\n}\n\n// ===========================================\n// Protocol\n// ===========================================\n\nexport interface Protocol {\n id: string;\n name: string;\n url: string;\n category: ProtocolCategory;\n}\n\nexport interface ProtocolPosition {\n protocol: Protocol;\n totalValueUSD: string;\n positions: Position[];\n}\n\n// ===========================================\n// API Response\n// ===========================================\n\nexport interface WalletDefiPositionsData {\n wallet: string;\n fetchedAt: string;\n totalValueUSD: string;\n totalDepositedUSD: string;\n totalBorrowedUSD: string;\n totalRewardsUSD: string;\n protocols: ProtocolPosition[];\n}\n\nexport interface WalletDefiPositionsResponse {\n data: WalletDefiPositionsData;\n}\n\nexport interface WalletDefiPositionsErrorResponse {\n error: {\n code: string;\n message: string;\n };\n}\n",
|
|
91
|
+
"import { z } from 'zod';\n\n// ===========================================\n// Input Schema\n// ===========================================\n\n// Validates both EVM (0x + 40 hex chars = 42) and Solana (32-44 base58 chars) addresses\nconst walletAddressSchema = z\n .string()\n .min(32, 'Invalid wallet address')\n .max(44, 'Invalid wallet address')\n .or(z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid EVM wallet address'));\n\nexport const WalletDefiPositionsParamsSchema = z.object({\n wallet: walletAddressSchema.describe('Wallet address (EVM or Solana)'),\n blockchains: z.string().describe('Blockchain to fetch positions from (e.g., \"solana\", \"ethereum\")'),\n});\n\nexport type WalletDefiPositionsParams = z.infer<typeof WalletDefiPositionsParamsSchema>;\n\n// ===========================================\n// Output Types\n// ===========================================\n\nexport type ProtocolCategory =\n | 'lending'\n | 'lp'\n | 'liquid-staking'\n | 'native-staking'\n | 'restaking'\n | 'perps'\n | 'yield'\n | 'cdp'\n | 'streaming';\n\nexport type PositionType =\n | 'deposit'\n | 'borrow'\n | 'liquidity'\n | 'stake'\n | 'leverage'\n | 'collateral'\n | 'debt'\n | 'vesting'\n | 'streaming'\n | 'order';\n\n// ===========================================\n// Token\n// ===========================================\n\nexport interface TokenAmount {\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n amountRaw: string; // Raw amount\n amountFormatted: number; // Human readable\n priceUSD: number;\n valueUSD: number;\n logoUri?: string;\n}\n\n// ===========================================\n// Metadata by position type\n// ===========================================\n\nexport interface LendingMetadata {\n type: 'lending';\n market?: string; // Market name (e.g., \"Main Market\", \"JLP Market\")\n healthFactor?: string;\n liquidationThreshold?: string;\n ltv?: string;\n supplyAPY?: string; // Total APY (base + token APY for LSTs)\n baseSupplyAPY?: string; // Base lending APY from protocol\n tokenAPY?: string; // Native staking/yield APY for yield-bearing tokens (LST, JLP, etc.)\n borrowAPY?: string; // Base borrow APY from protocol\n baseBorrowAPY?: string; // Base borrow APY (same as borrowAPY, for consistency with supply)\n utilizationRate?: string;\n}\n\nexport interface LiquidityMetadata {\n type: 'liquidity';\n poolAddress: string;\n poolName: string;\n poolType: 'amm' | 'clmm' | 'dlmm';\n shareOfPool?: string;\n fee24h?: string;\n apy?: string;\n tickLower?: number;\n tickUpper?: number;\n inRange?: boolean;\n}\n\nexport interface LiquidStakingMetadata {\n type: 'liquid-staking';\n lstMint: string;\n lstSymbol: string;\n exchangeRate: string;\n apy?: string;\n unstakePending?: string;\n}\n\nexport interface PerpMetadata {\n type: 'perp';\n // Identification\n id: string;\n marketId: string;\n exchange: 'drift' | 'gains' | 'hyperliquid' | 'gte' | 'lighter';\n\n // Position\n side: 'BUY' | 'SELL';\n entryPriceQuote: number;\n currentPriceQuote: number;\n currentLeverage: number;\n liquidationPriceQuote: number;\n\n // Size\n amountUSD: number;\n amountRaw: string; // bigint -> string for JSON serialization\n\n // PnL\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n realizedPnlPercent: number;\n unrealizedPnlPercent: number;\n\n // Fees\n feesOpeningUSD: number;\n feesClosingUSD: number;\n feesFundingUSD: number;\n\n // TP/SL\n tp: Array<{ size: string; price: number; id: number }>;\n sl: Array<{ size: string; price: number; id: number }>;\n\n // Timestamps\n openDate?: string;\n lastUpdate?: string;\n\n // Chain info\n address: string;\n chainId: string;\n collateralAsset: string;\n}\n\nexport interface StreamingMetadata {\n type: 'streaming';\n streamType: 'vesting' | 'payment';\n sender?: string;\n recipient?: string;\n startTime: string;\n endTime: string;\n amountPerSecond: string;\n amountClaimed: string;\n amountRemaining: string;\n cliffDate?: string;\n}\n\nexport interface NativeStakingMetadata {\n type: 'native-staking';\n stakeAccountAddress: string;\n validatorVoteAccount: string;\n validatorName?: string;\n validatorCommission?: number;\n activationState: 'activating' | 'active' | 'deactivating' | 'inactive';\n activationEpoch?: number;\n deactivationEpoch?: number;\n currentEpoch: number;\n apy?: string;\n}\n\nexport interface RestakingMetadata {\n type: 'restaking';\n strategyAddress: string;\n strategyName: string;\n underlyingToken: string;\n underlyingSymbol: string;\n operatorAddress?: string;\n isDelegated: boolean;\n sharesRaw: string;\n}\n\nexport type PositionMetadata =\n | LendingMetadata\n | LiquidityMetadata\n | LiquidStakingMetadata\n | NativeStakingMetadata\n | RestakingMetadata\n | PerpMetadata\n | StreamingMetadata;\n\n// ===========================================\n// Position\n// ===========================================\n\nexport interface Position {\n id: string;\n type: PositionType;\n name: string;\n valueUSD: number;\n tokens: TokenAmount[];\n rewards?: TokenAmount[];\n metadata?: PositionMetadata;\n createdAt?: string;\n updatedAt?: string;\n}\n\n// ===========================================\n// Protocol\n// ===========================================\n\nexport interface Protocol {\n id: string;\n name: string;\n url: string;\n logo: string;\n category: ProtocolCategory;\n}\n\nexport interface ProtocolPosition {\n protocol: Protocol;\n totalValueUSD: string;\n positions: Position[];\n}\n\n// ===========================================\n// API Response\n// ===========================================\n\nexport interface WalletDefiPositionsData {\n wallet: string;\n fetchedAt: string;\n totalValueUSD: string;\n totalDepositedUSD: string;\n totalBorrowedUSD: string;\n totalRewardsUSD: string;\n protocols: ProtocolPosition[];\n}\n\nexport interface WalletDefiPositionsResponse {\n data: WalletDefiPositionsData;\n}\n\nexport interface WalletDefiPositionsErrorResponse {\n error: {\n code: string;\n message: string;\n };\n}\n",
|
|
92
92
|
"import { z } from 'zod';\nimport {\n tokenPositionSchema,\n WalletDeployerQuery,\n walletDeployerOutputSchema,\n} from '../../utils/schemas/WalletDeployerSchema.ts';\n\nexport type TokenPositionSchema = z.infer<typeof tokenPositionSchema>;\nexport const WalletV2DeployerParamsSchema = WalletDeployerQuery;\nexport type WalletV2DeployerParams = z.input<typeof WalletV2DeployerParamsSchema>;\n\nexport const WalletV2DeployerResponseSchema = walletDeployerOutputSchema;\nexport type WalletV2DeployerResponse = z.infer<typeof WalletV2DeployerResponseSchema>;\n",
|
|
93
93
|
"import { z } from 'zod';\n\nexport const ExchangesIds = z.enum(['gains', 'hyperliquid', 'gte', 'lighter', 'drift']);\n\nconst tpSlSchema = z.object({ size: z.bigint(), price: z.number(), id: z.number() });\nexport const PerpsPositionSchema = z.object({\n id: z.string(),\n entryPriceQuote: z.number(),\n currentLeverage: z.number(),\n amountUSD: z.number(),\n amountRaw: z.bigint(),\n side: z.enum(['BUY', 'SELL']),\n liquidationPriceQuote: z.number(),\n currentPriceQuote: z.number(),\n realizedPnlUSD: z.number(),\n unrealizedPnlUSD: z.number(),\n realizedPnlPercent: z.number(),\n unrealizedPnlPercent: z.number(),\n tp: z.array(tpSlSchema),\n sl: z.array(tpSlSchema),\n marketId: z.string(),\n exchange: ExchangesIds,\n feesOpeningUSD: z.number(),\n feesClosingUSD: z.number(),\n feesFundingUSD: z.number(),\n openDate: z.date(),\n lastUpdate: z.date(),\n address: z.string(),\n chainId: z.string(),\n collateralAsset: z.string(),\n});\n\nexport type PerpsPosition = z.infer<typeof PerpsPositionSchema>;\nexport const PerpsPositionNonExecutedSchema = PerpsPositionSchema.extend({\n type: z.enum(['STOP', 'LIMIT']),\n});\n\nexport type PerpsPositionNonExecuted = z.infer<typeof PerpsPositionNonExecutedSchema>;\n\nexport const WalletPerpsPositionsResponseSchema = z.object({\n data: z.array(PerpsPositionSchema),\n});\n\nexport const WalletPerpsPositionsNonExecutedResponseSchema = z.object({\n data: z.array(PerpsPositionNonExecutedSchema),\n});\n",
|
|
94
94
|
"import { z } from 'zod';\nimport { tokenPositionSchema } from '../../utils/schemas/WalletDeployerSchema.ts';\n\nexport const WalletPositionsParamsSchema = z.object({\n wallet: z.string(),\n blockchain: z.string().optional(),\n backfillPositions: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n backfillSwapsAndPositions: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type WalletPositionsParams = z.input<typeof WalletPositionsParamsSchema>;\n\nexport const SinglePositionQuery = z.object({\n wallet: z.string(),\n asset: z.string(),\n blockchain: z.string(),\n});\n\n// Batch position query - single item schema\nconst SinglePositionItemSchema = z.object({\n wallet: z.string(),\n asset: z.string(),\n blockchain: z.string(),\n});\n\n// Batch position params - supports array or object with items\nexport const SinglePositionBatchParamsSchema = z.union([\n z.array(SinglePositionItemSchema),\n z.object({\n items: z.array(SinglePositionItemSchema),\n instanceTracking: z.preprocess((val) => {\n if (val === 'true') return true;\n if (val === 'false') return false;\n return val;\n }, z.boolean().optional()),\n }),\n]);\n\nexport type SinglePositionBatchParams = z.input<typeof SinglePositionBatchParamsSchema>;\n\nexport type TokenPositionType = z.infer<typeof tokenPositionSchema>;\n\nexport const WalletPositionsResponseSchema = z.object({\n data: z.array(tokenPositionSchema),\n});\n\nexport type WalletPositionsResponse = z.infer<typeof WalletPositionsResponseSchema>;\n\nexport const singlePositionOutputSchema = z.object({\n data: tokenPositionSchema,\n});\n\n// Batch position item schema - includes wallet for identification\nexport const batchPositionItemSchema = tokenPositionSchema.extend({\n wallet: z.string(),\n});\n\n// Batch response schema\nexport const SinglePositionBatchResponseSchema = z.object({\n payload: z.array(\n batchPositionItemSchema.or(z.object({ error: z.string().optional(), wallet: z.string().optional() })).nullable(),\n ),\n hostname: z.string().optional(),\n});\n\nexport type SinglePositionBatchResponse = z.infer<typeof SinglePositionBatchResponseSchema>;\nexport type BatchPositionItem = z.infer<typeof batchPositionItemSchema>;\n\n// Type aliases for SDK consistency\nexport type WalletPositionParams = z.input<typeof SinglePositionQuery>;\nexport type WalletPositionResponse = z.infer<typeof singlePositionOutputSchema>;\nexport type WalletPositionBatchParams = z.input<typeof SinglePositionBatchParamsSchema>;\nexport type WalletPositionBatchResponse = z.infer<typeof SinglePositionBatchResponseSchema>;\n",
|
|
95
95
|
"import { z } from 'zod';\nimport { SecurityFlagsSchema } from '../../utils/schemas/SecuritySchemas.ts';\n\nexport const tokenHoldingSchema = z.object({\n token: z.object({\n address: z.string(),\n chainId: z.string(),\n name: z.string().nullable(),\n symbol: z.string().nullable(),\n logo: z.string().nullable(),\n decimals: z.coerce.number().default(0),\n holdersCount: z.coerce.number().default(0),\n deployer: z.string().nullable(),\n website: z.string().nullable(),\n x: z.string().nullable(),\n telegram: z.string().nullable(),\n description: z.string().nullable(),\n security: SecurityFlagsSchema.nullable(),\n }),\n balance: z.number(),\n rawBalance: z.string(),\n /** Rent lamports for Solana token accounts (returned when account is closed). Only present for Solana SPL tokens. */\n lamports: z.string().nullable().optional(),\n});\n\nexport const WalletHoldingsResponseSchema = z.object({\n data: z.array(tokenHoldingSchema),\n});\n\nexport type TokenHolding = z.infer<typeof tokenHoldingSchema>;\nexport type WalletHoldingsResponse = z.infer<typeof WalletHoldingsResponseSchema>;\n",
|
|
96
96
|
"import { z } from 'zod';\n\nexport const FeedPayloadSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('asset_ids'),\n asset_ids: z.array(z.number()).optional(),\n quote_id: z.number().optional().nullable(),\n }),\n z.object({\n kind: z.literal('address'),\n tokens: z.array(\n z.object({\n blockchain: z.string(),\n address: z.string(),\n }),\n ),\n quote: z\n .object({\n address: z.string(),\n blockchain: z.string(),\n })\n .optional(),\n }),\n z.object({\n kind: z.literal('all'),\n }),\n]);\n\nexport type FeedPayloadType = z.input<typeof FeedPayloadSchema>;\n\nexport const FeedAssetIdSchema = z.object({\n asset_ids: z.array(z.number()).optional(),\n quote_id: z.number().optional().nullable(),\n});\n\nexport const FeedTokenSchema = z.object({\n tokens: z.array(\n z.object({\n blockchain: z.string(),\n address: z.string(),\n }),\n ),\n quote: z\n .object({\n address: z.string(),\n blockchain: z.string(),\n })\n .optional(),\n});\n",
|
|
97
|
-
"import { z } from 'zod';\n\nconst BalanceItemSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n});\n\nexport const BalancePayloadSchema = z.object({\n items: z.array(BalanceItemSchema),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type BalancePayload = z.infer<typeof BalancePayloadSchema>;\nexport type BalanceItem = z.infer<typeof BalanceItemSchema>;\n\nexport interface WalletBalanceData {\n wallet: string;\n token: string; // Token address or \"native\"\n chainId: string;\n balance: number; // Decimal-adjusted balance\n rawBalance: string; // Raw balance (no decimal adjustment)\n decimals: number;\n symbol: string;\n name: string;\n logo: string | null;\n}\n\nexport interface WalletBalanceUpdate extends WalletBalanceData {\n previousBalance?: number; // Previous balance (for delta updates)\n previousRawBalance?: string; // Previous raw balance (for delta updates)\n}\n",
|
|
97
|
+
"import { z } from 'zod';\n\nconst BalanceItemSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n});\n\nexport const BalancePayloadSchema = z.object({\n items: z.array(BalanceItemSchema),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type BalancePayload = z.infer<typeof BalancePayloadSchema>;\nexport type BalancePayloadType = z.input<typeof BalancePayloadSchema>;\nexport type BalanceItem = z.infer<typeof BalanceItemSchema>;\n\nexport interface WalletBalanceData {\n wallet: string;\n token: string; // Token address or \"native\"\n chainId: string;\n balance: number; // Decimal-adjusted balance\n rawBalance: string; // Raw balance (no decimal adjustment)\n decimals: number;\n symbol: string;\n name: string;\n logo: string | null;\n}\n\nexport interface WalletBalanceUpdate extends WalletBalanceData {\n previousBalance?: number; // Previous balance (for delta updates)\n previousRawBalance?: string; // Previous raw balance (for delta updates)\n}\n",
|
|
98
98
|
"import { z } from 'zod';\n\nexport const FastTradesPayloadSchema = z.object({\n assetMode: z.coerce.boolean().default(false),\n items: z.array(\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type FastTradesPayloadType = z.input<typeof FastTradesPayloadSchema>;\n\nexport interface BaseFastTrade {\n date: number;\n tokenPrice: number;\n tokenPriceVs: number;\n tokenAmount: number;\n tokenAmountVs: number;\n tokenAmountUsd: number;\n tokenNativePrice: number;\n tokenMarketCapUSD: number;\n type: 'buy' | 'sell';\n operation: 'regular' | 'liquidity' | 'arbitrage' | string;\n blockchain: string;\n hash: string;\n sender: string;\n tokenAmountRaw: string;\n tokenAmountRawVs: string;\n preBalanceBaseToken: string | null;\n preBalanceQuoteToken: string | null;\n postBalanceBaseToken: string | null;\n postBalanceQuoteToken: string | null;\n subscriptionId: string;\n timestamp: number;\n labels?: string[];\n platform?: string | null;\n swapRecipient?: string | null;\n // Fees breakdown\n totalFeesUSD?: number | null;\n gasFeesUSD?: number | null;\n platformFeesUSD?: number | null;\n mevFeesUSD?: number | null;\n}\n\nexport interface PairFastTrade extends BaseFastTrade {\n pair: string;\n token?: never;\n}\n\nexport interface TokenFastTrade extends BaseFastTrade {\n token: string;\n pair?: never;\n}\n\nexport type WssFastTradesResponseType = PairFastTrade | TokenFastTrade;\n",
|
|
99
99
|
"import { z } from 'zod';\n\nexport const FundingPayloadSchema = z.object({\n symbol: z.string(),\n quote: z.string().optional(),\n exchange: z\n .string()\n .optional()\n .transform((val) => {\n const validExchanges = ['binance', 'bybit', 'hyperliquid', 'deribit', 'okx', 'gate'];\n\n if (!val) return validExchanges;\n\n const requestedExchanges = val\n .split(',')\n .map((ex) => ex.trim().toLowerCase())\n .filter((ex) => validExchanges.includes(ex));\n\n return requestedExchanges.length > 0 ? requestedExchanges : validExchanges;\n }),\n interval: z.number().optional().default(5),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z.string().optional(),\n});\n\nexport type FundingPayloadType = z.input<typeof FundingPayloadSchema>;\n",
|
|
100
100
|
"import { z } from 'zod';\nimport type { HoldersStreamNewTokenPayload } from '../utils/schemas/EnrichedHoldersData.ts';\n\nexport const HoldersPayloadSchema = z.object({\n tokens: z.array(\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type HoldersPayloadType = z.input<typeof HoldersPayloadSchema>;\n\nexport type WssHoldersResponse = { data: z.infer<typeof HoldersStreamNewTokenPayload>; subscriptionId: string };\n",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"import { z } from 'zod';\n\nexport const MarketPayloadSchema = z.object({\n interval: z.number().default(30),\n subscriptionId: z.string().optional(),\n assets: z\n .array(\n z.union([\n z.object({ name: z.string() }),\n z.object({ symbol: z.string() }),\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ]),\n )\n .max(100),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type MarketPayloadType = z.input<typeof MarketPayloadSchema>;\n",
|
|
103
103
|
"import { z } from 'zod';\nimport normalizePeriod from '../utils/functions/period.ts';\n\nexport const OhlcvPayloadSchema = z.object({\n address: z.string().optional(),\n subscriptionId: z.string().optional(),\n blockchain: z.string().optional(),\n chainId: z.string().optional(),\n period: z\n .string()\n .optional()\n .transform((val) => {\n if (val) {\n return normalizePeriod(val);\n }\n return '5m';\n }),\n asset: z.string().optional(),\n currentPrice: z.string().optional(),\n mode: z.enum(['asset', 'pair']).optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type OhlcvPayloadType = z.input<typeof OhlcvPayloadSchema>;\n\nexport interface WssOhlcvDetailsResponseType {\n subscriptionId?: string;\n high: number | null;\n low: number | null;\n open: number | null;\n close: number | null;\n volume: number;\n time: number;\n period: string;\n tradeTime?: number;\n}\n",
|
|
104
104
|
"import { z } from 'zod';\n\nexport const PairsPayloadSchema = z.object({\n mode: z.enum(['asset', 'pair']).optional().default('pair'),\n subscriptionId: z.string().optional(),\n blockchain: z.string().optional(),\n factory: z.string().optional(),\n interval: z.number().default(30),\n address: z.string().optional(),\n asset: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PairsPayloadType = z.input<typeof PairsPayloadSchema>;\n",
|
|
105
|
-
"import { z } from 'zod';\n\nexport const PositionPayloadSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionPayloadType = z.infer<typeof PositionPayloadSchema>;\n\nexport const PositionsPayloadSchema = z.object({\n wallet: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionsPayload = z.infer<typeof PositionsPayloadSchema>;\n\nexport interface WalletPositionData {\n wallet: string;\n token: string;\n chainId: string;\n balance: number;\n rawBalance: string;\n amountUSD: number;\n buys: number;\n sells: number;\n volumeBuyToken: number;\n volumeSellToken: number;\n volumeBuy: number;\n volumeSell: number;\n avgBuyPriceUSD: number;\n avgSellPriceUSD: number;\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n totalPnlUSD: number;\n firstDate: Date | null;\n lastDate: Date | null;\n tokenDetails?: {\n address: string;\n chainId: string;\n name: string;\n symbol: string;\n decimals: number;\n logo: string | null;\n price: number;\n priceChange24h: number | null;\n liquidity: number | null;\n marketCap: number | null;\n };\n}\n\nexport interface WalletPositionsData {\n wallet: string;\n chainId: string;\n positions: WalletPositionData[];\n}\n",
|
|
105
|
+
"import { z } from 'zod';\n\nexport const PositionPayloadSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionPayloadType = z.infer<typeof PositionPayloadSchema>;\n\nexport const PositionsPayloadSchema = z.object({\n wallet: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionsPayload = z.infer<typeof PositionsPayloadSchema>;\nexport type PositionsPayloadType = z.input<typeof PositionsPayloadSchema>;\n\nexport interface WalletPositionData {\n wallet: string;\n token: string;\n chainId: string;\n balance: number;\n rawBalance: string;\n amountUSD: number;\n buys: number;\n sells: number;\n volumeBuyToken: number;\n volumeSellToken: number;\n volumeBuy: number;\n volumeSell: number;\n avgBuyPriceUSD: number;\n avgSellPriceUSD: number;\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n totalPnlUSD: number;\n firstDate: Date | null;\n lastDate: Date | null;\n tokenDetails?: {\n address: string;\n chainId: string;\n name: string;\n symbol: string;\n decimals: number;\n logo: string | null;\n price: number;\n priceChange24h: number | null;\n liquidity: number | null;\n marketCap: number | null;\n };\n}\n\nexport interface WalletPositionsData {\n wallet: string;\n chainId: string;\n positions: WalletPositionData[];\n}\n",
|
|
106
106
|
"import { z } from 'zod';\n\nexport const PausePulsePayloadSchema = z.object({\n action: z.enum(['pause', 'unpause']),\n views: z.array(z.string()).min(1),\n});\n\nexport type PausePulsePayloadType = z.input<typeof PausePulsePayloadSchema>;\n",
|
|
107
107
|
"import { z } from 'zod';\nimport FilterWithLimit from '../../utils/schemas/Filter.ts';\n\nexport const StreamPayloadSchema = z.object({\n filters: FilterWithLimit.optional(),\n chainIds: z.array(z.string()).nonempty(),\n name: z.string().optional(),\n events: z.array(z.enum(['swap', 'transfer', 'swap-enriched', 'block', 'order'])).nonempty(),\n authorization: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z.string().optional(),\n debugSubscriptionId: z.string().optional(),\n});\n\nexport type StreamPayloadType = z.infer<typeof StreamPayloadSchema>;\n\nexport const UnsubscribeStreamPayloadSchema = z\n .object({\n type: z.enum(['stream']).optional(),\n subscriptionId: z.string().optional(),\n personalizedId: z.string().optional(),\n viewName: z.string().optional(),\n })\n .transform((data) => {\n // Transform personalizedId to subscriptionId if provided\n if (data.personalizedId && !data.subscriptionId) {\n return {\n ...data,\n subscriptionId: data.personalizedId,\n };\n }\n return data;\n })\n .optional();\n\nexport type UnsubscribeStreamPayloadType = z.input<typeof UnsubscribeStreamPayloadSchema>;\n\nexport const UpdateStreamPayloadSchema = z.object({\n subscriptionId: z.string(),\n authorization: z.string(),\n mode: z.enum(['merge', 'replace']).default('replace'),\n filters: FilterWithLimit.optional(),\n chainIds: z.array(z.string()).optional(),\n events: z.array(z.string()).optional(),\n subscriptionTracking: z.string().optional(),\n});\n\nexport type UpdateStreamPayloadType = z.input<typeof UpdateStreamPayloadSchema>;\n",
|
|
108
108
|
"import { z } from 'zod';\n\nconst BaseFilter = z.object({\n eq: z.tuple([z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])]).optional(),\n neq: z.tuple([z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])]).optional(),\n lt: z.tuple([z.string(), z.coerce.number()]).optional(),\n lte: z.tuple([z.string(), z.coerce.number()]).optional(),\n gt: z.tuple([z.string(), z.coerce.number()]).optional(),\n gte: z.tuple([z.string(), z.coerce.number()]).optional(),\n in: z\n .tuple([\n z.string(),\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])),\n ]),\n ])\n .optional(),\n});\n\ntype BaseFilter = z.infer<typeof BaseFilter>;\nexport type Filter = BaseFilter & ({ and?: Filter[] } | { or?: Filter[] });\n\nconst Filter: z.ZodType<Filter> = BaseFilter.and(\n z.union([\n BaseFilter.extend({ and: z.undefined(), or: z.undefined() }),\n BaseFilter.extend({ and: z.array(z.lazy(() => Filter)), or: z.undefined() }),\n BaseFilter.extend({ and: z.undefined(), or: z.array(z.lazy(() => Filter)) }),\n ]),\n);\n\nexport function countOperations(filter: Filter | undefined): number {\n if (!filter) return 0;\n\n let count = 0;\n\n for (const key of ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in'] as const) {\n if (filter[key]) count += 1;\n }\n\n if ('and' in filter && Array.isArray(filter.and)) {\n for (const child of filter.and) {\n count += countOperations(child);\n }\n }\n\n if ('or' in filter && Array.isArray(filter.or)) {\n for (const child of filter.or) {\n count += countOperations(child);\n }\n }\n\n return count;\n}\n\nconst FilterWithLimit = Filter.superRefine((val, ctx) => {\n const total = countOperations(val);\n const max = 1000;\n if (total > max) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Your filter contains ${total} leaf operations, exceeding the maximum of ${max}. Only leaf conditions like \"eq\", \"neq\", \"lt\", \"lte\", \"gt\", \"gte\", \"in\" are counted; logical operators (\"and\", \"or\") are ignored.`,\n });\n }\n});\n\nexport default FilterWithLimit;\n",
|
package/dist/esm/index.js.map
CHANGED
|
@@ -88,13 +88,13 @@
|
|
|
88
88
|
"import { z } from 'zod';\n\n// Zod schema for wallet analysis query parameters\nexport const WalletAnalysisParamsSchema = z.object({\n wallet: z.string().min(1, 'Wallet address is required'),\n blockchain: z.string().optional(),\n period: z\n .string()\n .optional()\n .default('7d')\n .transform((val) => val?.toLowerCase())\n .refine((val) => ['1d', '7d', '30d', '90d'].includes(val), {\n message: 'Period must be one of: 1d, 7d, 30d, 90d',\n }),\n});\n\nexport type WalletAnalysisParams = z.input<typeof WalletAnalysisParamsSchema>;\n\n// OpenAPI-compatible params schema (simplified without transformations)\nexport const WalletAnalysisParamsSchemaOpenAPI = z.object({\n wallet: z.string().min(1).describe('Wallet address to analyze'),\n blockchain: z.string().optional().describe('Blockchain ID (e.g., ethereum, base, solana:solana)'),\n period: z.string().optional().default('7d').describe('Analysis period: 1d, 7d, 30d, or 90d'),\n});\n\n// Zod schema for wallet analysis response\nexport const WalletAnalysisResponseSchema = z.object({\n data: z.object({\n winRateDistribution: z.object({\n '>500%': z.number(),\n '200%-500%': z.number(),\n '50%-200%': z.number(),\n '0%-50%': z.number(),\n '-50%-0%': z.number(),\n '<-50%': z.number(),\n }),\n marketCapDistribution: z.object({\n '>1000M': z.number(),\n '>100M': z.number(),\n '10M-100M': z.number(),\n '1M-10M': z.number(),\n '100k-1M': z.number(),\n '<100k': z.number(),\n }),\n periodTimeframes: z.array(\n z.object({\n date: z.date(),\n realized: z.number(),\n }),\n ),\n stat: z.object({\n totalValue: z.number(),\n periodTotalPnlUSD: z.number(),\n periodRealizedPnlUSD: z.number(),\n periodRealizedRate: z.number(),\n periodActiveTokensCount: z.number(),\n periodWinCount: z.number(),\n fundingInfo: z.object({\n from: z.string().nullable(),\n date: z.date().nullable(),\n chainId: z.string().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n periodVolumeBuy: z.number(),\n periodVolumeSell: z.number(),\n periodBuys: z.number(),\n periodSells: z.number(),\n nativeBalance: z\n .object({\n rawBalance: z.string(),\n formattedBalance: z.number(),\n assetId: z.number().nullable(),\n chainId: z.string(),\n address: z.string(),\n decimals: z.number(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n price: z.number(),\n balanceUSD: z.number(),\n })\n .nullable(),\n periodBuyTokens: z.number(),\n periodSellTokens: z.number(),\n periodTradingTokens: z.number(),\n holdingTokensCount: z.number(),\n holdingDuration: z.number(),\n tradingTimeFrames: z.number(),\n winRealizedPnl: z.number(),\n winRealizedPnlRate: z.number(),\n winToken: z\n .object({\n address: z.string(),\n chainId: z.string(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n decimals: z.number(),\n })\n .nullable(),\n }),\n labels: z.array(z.string()),\n }),\n});\n\nexport type WalletAnalysisResponse = z.infer<typeof WalletAnalysisResponseSchema>;\n\n// OpenAPI-compatible schema (dates as strings for OpenAPI spec generation)\nexport const WalletAnalysisResponseSchemaOpenAPI = z.object({\n data: z.object({\n winRateDistribution: z.object({\n '>500%': z.number(),\n '200%-500%': z.number(),\n '50%-200%': z.number(),\n '0%-50%': z.number(),\n '-50%-0%': z.number(),\n '<-50%': z.number(),\n }),\n marketCapDistribution: z.object({\n '>1000M': z.number(),\n '>100M': z.number(),\n '10M-100M': z.number(),\n '1M-10M': z.number(),\n '100k-1M': z.number(),\n '<100k': z.number(),\n }),\n periodTimeframes: z.array(\n z.object({\n date: z.string(),\n realized: z.number(),\n }),\n ),\n stat: z.object({\n totalValue: z.number(),\n periodTotalPnlUSD: z.number(),\n periodRealizedPnlUSD: z.number(),\n periodRealizedRate: z.number(),\n periodActiveTokensCount: z.number(),\n periodWinCount: z.number(),\n fundingInfo: z.object({\n from: z.string().nullable(),\n date: z.string().nullable(),\n chainId: z.string().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n periodVolumeBuy: z.number(),\n periodVolumeSell: z.number(),\n periodBuys: z.number(),\n periodSells: z.number(),\n nativeBalance: z\n .object({\n rawBalance: z.string(),\n formattedBalance: z.number(),\n assetId: z.number().nullable(),\n chainId: z.string(),\n address: z.string(),\n decimals: z.number(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n price: z.number(),\n balanceUSD: z.number(),\n })\n .nullable(),\n periodBuyTokens: z.number(),\n periodSellTokens: z.number(),\n periodTradingTokens: z.number(),\n holdingTokensCount: z.number(),\n holdingDuration: z.number(),\n tradingTimeFrames: z.number(),\n winRealizedPnl: z.number(),\n winRealizedPnlRate: z.number(),\n winToken: z\n .object({\n address: z.string(),\n chainId: z.string(),\n name: z.string(),\n symbol: z.string(),\n logo: z.string().nullable(),\n decimals: z.number(),\n })\n .nullable(),\n }),\n labels: z.array(z.string()),\n }),\n});\n",
|
|
89
89
|
"import { z } from 'zod';\n\n// Zod schema for wallet funding query parameters\nexport const WalletFundingParamsSchema = z.object({\n wallet: z.string().min(1, 'Wallet address is required'),\n});\n\nexport type WalletFundingParams = z.input<typeof WalletFundingParamsSchema>;\n\n// Zod schema for wallet funding response\nexport const WalletFundingResponseSchema = z.object({\n data: z.object({\n from: z.string().nullable(),\n chainId: z.string().nullable(),\n date: z.date().nullable(),\n txHash: z.string().nullable(),\n amount: z.string().nullable(),\n fromWalletLogo: z.string().nullable(),\n fromWalletTag: z.string().nullable(),\n }),\n});\n\nexport type WalletFundingResponse = z.infer<typeof WalletFundingResponseSchema>;\n",
|
|
90
90
|
"import { z } from 'zod';\nimport { TokenDetailsOutput } from '../../utils/schemas/TokenDetailsOutput.ts';\n\nexport type WalletActivityV2ControllerUnsafeParams = {\n wallet: string;\n blockchains?: string;\n blacklist?: string;\n offset?: number | string;\n limit?: number | string;\n order?: string;\n pagination_details?: boolean | string;\n unlistedAssets?: boolean | string;\n filterSpam?: boolean | string;\n backfillTransfers?: boolean | string;\n backfillBalances?: boolean | string;\n cursor_hash?: string;\n cursor_direction?: 'before' | 'after';\n};\n\nexport const WalletActivityV2ParamsSchema = z.object({\n wallet: z.string(),\n blockchains: z\n .string()\n .optional()\n .transform((val) => {\n if (val) {\n return val\n .split(',')\n .map((b) => b.trim())\n .filter((b) => b.length > 0);\n }\n return [];\n }),\n blacklist: z\n .string()\n .optional()\n .transform((val) => (val ? val.split(',').map((addr) => addr.trim().toLowerCase()) : [])),\n offset: z.coerce.number().optional().default(0),\n limit: z.coerce.number().optional().default(100),\n order: z.enum(['asc', 'desc']).optional().default('desc'),\n pagination: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n unlistedAssets: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(true),\n filterSpam: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(true),\n backfillTransfers: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n backfillBalances: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n cursor_hash: z.string().optional(),\n cursor_direction: z.enum(['before', 'after']).optional().default('before'),\n withTokens: z\n .union([z.boolean(), z.string()])\n .optional()\n .transform((val) => val === true || val === 'true')\n .default(false),\n});\n\nexport type WalletActivityV2Params = z.input<typeof WalletActivityV2ParamsSchema>;\n\n// Reusable asset schema used in nested activity items\nconst ActivityAssetSchema = z.object({\n id: z.number().nullable(),\n name: z.string(),\n symbol: z.string(),\n decimals: z.number(),\n totalSupply: z.number(),\n circulatingSupply: z.number(),\n price: z.number(),\n liquidity: z.number(),\n priceChange24hPercent: z.number(),\n marketCapUsd: z.number(),\n logo: z.string().nullable(),\n contract: z.string(),\n});\n\n// Activities that occurred within a single transaction\nexport const WalletActivityV2TransactionActivitySchema = z.object({\n model: z.enum(['swap', 'transfer']),\n\n // Swap-specific fields\n swapType: z.enum(['REGULAR', 'MEV', 'SANDWICHED_MEV', 'DEPOSIT', 'WITHDRAW']).optional(),\n swapRawAmountOut: z.number().optional(),\n swapRawAmountIn: z.number().optional(),\n swapAmountOut: z.number().optional(),\n swapAmountIn: z.number().optional(),\n swapPriceUsdTokenOut: z.number().optional(),\n swapPriceUsdTokenIn: z.number().optional(),\n swapAmountUsd: z.number().optional(),\n swapTransactionSenderAddress: z.string().optional(),\n swapBaseAddress: z.string().optional(),\n swapQuoteAddress: z.string().optional(),\n swapAmountQuote: z.number().optional(),\n swapAmountBase: z.number().optional(),\n swapAssetIn: ActivityAssetSchema.optional(),\n swapAssetOut: ActivityAssetSchema.optional(),\n\n // Transfer-specific fields\n transferRawAmount: z.string().optional(),\n transferAmount: z.number().optional(),\n transferAmountUsd: z.number().optional(),\n transferType: z\n .enum(['VAULT_DEPOSIT', 'VAULT_WITHDRAW', 'VAULT_UNSTAKE', 'TOKEN_IN', 'TOKEN_OUT', 'NATIVE_IN', 'NATIVE_OUT'])\n .optional(),\n transferFromAddress: z.string().optional().nullable(),\n transferToAddress: z.string().optional().nullable(),\n transferAsset: ActivityAssetSchema.optional(),\n});\n\n// Grouped by transaction hash\nexport const WalletActivityV2TransactionSchema = z.object({\n chainId: z.string(),\n txDateMs: z.number(),\n txDateIso: z.string(),\n txHash: z.string(),\n txRawFeesNative: z.string(),\n txFeesNativeUsd: z.number(),\n txBlockNumber: z.number(),\n txIndex: z.number(),\n txAction: z.string().optional().nullable(),\n\n actions: z.array(WalletActivityV2TransactionActivitySchema),\n});\n\nexport const WalletActivityV2OutputDataSchema = z.array(WalletActivityV2TransactionSchema);\n\nexport const WalletActivityV2OutputPaginationSchema = z.object({\n page: z.number(),\n offset: z.number(),\n limit: z.number(),\n pageEntries: z.number(),\n});\n\nexport const WalletActivityV2ResponseSchema = z.object({\n data: WalletActivityV2OutputDataSchema,\n pagination: WalletActivityV2OutputPaginationSchema,\n backfillStatus: z.enum(['processed', 'processing', 'pending']).optional(),\n tokens: z.array(TokenDetailsOutput).optional(),\n});\n\nexport type WalletActivityV2Response = z.input<typeof WalletActivityV2ResponseSchema>;\n",
|
|
91
|
-
"import { z } from 'zod';\n\n// ===========================================\n// Input Schema\n// ===========================================\n\n// Validates both EVM (0x + 40 hex chars = 42) and Solana (32-44 base58 chars) addresses\nconst walletAddressSchema = z\n .string()\n .min(32, 'Invalid wallet address')\n .max(44, 'Invalid wallet address')\n .or(z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid EVM wallet address'));\n\nexport const WalletDefiPositionsParamsSchema = z.object({\n wallet: walletAddressSchema.describe('Wallet address (EVM or Solana)'),\n blockchains: z.string().describe('Blockchain to fetch positions from (e.g., \"solana\", \"ethereum\")'),\n});\n\nexport type WalletDefiPositionsParams = z.infer<typeof WalletDefiPositionsParamsSchema>;\n\n// ===========================================\n// Output Types\n// ===========================================\n\nexport type ProtocolCategory =\n | 'lending'\n | 'lp'\n | 'liquid-staking'\n | 'native-staking'\n | 'restaking'\n | 'perps'\n | 'yield'\n | 'cdp'\n | 'streaming';\n\nexport type PositionType =\n | 'deposit'\n | 'borrow'\n | 'liquidity'\n | 'stake'\n | 'leverage'\n | 'collateral'\n | 'debt'\n | 'vesting'\n | 'streaming'\n | 'order';\n\n// ===========================================\n// Token\n// ===========================================\n\nexport interface TokenAmount {\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n amountRaw: string; // Raw amount\n amountFormatted: number; // Human readable\n priceUSD: number;\n valueUSD: number;\n logoUri?: string;\n}\n\n// ===========================================\n// Metadata by position type\n// ===========================================\n\nexport interface LendingMetadata {\n type: 'lending';\n market?: string; // Market name (e.g., \"Main Market\", \"JLP Market\")\n healthFactor?: string;\n liquidationThreshold?: string;\n ltv?: string;\n supplyAPY?: string; // Total APY (base + token APY for LSTs)\n baseSupplyAPY?: string; // Base lending APY from protocol\n tokenAPY?: string; // Native staking/yield APY for yield-bearing tokens (LST, JLP, etc.)\n borrowAPY?: string; // Base borrow APY from protocol\n baseBorrowAPY?: string; // Base borrow APY (same as borrowAPY, for consistency with supply)\n utilizationRate?: string;\n}\n\nexport interface LiquidityMetadata {\n type: 'liquidity';\n poolAddress: string;\n poolName: string;\n poolType: 'amm' | 'clmm' | 'dlmm';\n shareOfPool?: string;\n fee24h?: string;\n apy?: string;\n tickLower?: number;\n tickUpper?: number;\n inRange?: boolean;\n}\n\nexport interface LiquidStakingMetadata {\n type: 'liquid-staking';\n lstMint: string;\n lstSymbol: string;\n exchangeRate: string;\n apy?: string;\n unstakePending?: string;\n}\n\nexport interface PerpMetadata {\n type: 'perp';\n // Identification\n id: string;\n marketId: string;\n exchange: 'drift' | 'gains' | 'hyperliquid' | 'gte' | 'lighter';\n\n // Position\n side: 'BUY' | 'SELL';\n entryPriceQuote: number;\n currentPriceQuote: number;\n currentLeverage: number;\n liquidationPriceQuote: number;\n\n // Size\n amountUSD: number;\n amountRaw: string; // bigint -> string for JSON serialization\n\n // PnL\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n realizedPnlPercent: number;\n unrealizedPnlPercent: number;\n\n // Fees\n feesOpeningUSD: number;\n feesClosingUSD: number;\n feesFundingUSD: number;\n\n // TP/SL\n tp: Array<{ size: string; price: number; id: number }>;\n sl: Array<{ size: string; price: number; id: number }>;\n\n // Timestamps\n openDate?: string;\n lastUpdate?: string;\n\n // Chain info\n address: string;\n chainId: string;\n collateralAsset: string;\n}\n\nexport interface StreamingMetadata {\n type: 'streaming';\n streamType: 'vesting' | 'payment';\n sender?: string;\n recipient?: string;\n startTime: string;\n endTime: string;\n amountPerSecond: string;\n amountClaimed: string;\n amountRemaining: string;\n cliffDate?: string;\n}\n\nexport interface NativeStakingMetadata {\n type: 'native-staking';\n stakeAccountAddress: string;\n validatorVoteAccount: string;\n validatorName?: string;\n validatorCommission?: number;\n activationState: 'activating' | 'active' | 'deactivating' | 'inactive';\n activationEpoch?: number;\n deactivationEpoch?: number;\n currentEpoch: number;\n apy?: string;\n}\n\nexport interface RestakingMetadata {\n type: 'restaking';\n strategyAddress: string;\n strategyName: string;\n underlyingToken: string;\n underlyingSymbol: string;\n operatorAddress?: string;\n isDelegated: boolean;\n sharesRaw: string;\n}\n\nexport type PositionMetadata =\n | LendingMetadata\n | LiquidityMetadata\n | LiquidStakingMetadata\n | NativeStakingMetadata\n | RestakingMetadata\n | PerpMetadata\n | StreamingMetadata;\n\n// ===========================================\n// Position\n// ===========================================\n\nexport interface Position {\n id: string;\n type: PositionType;\n name: string;\n valueUSD: number;\n tokens: TokenAmount[];\n rewards?: TokenAmount[];\n metadata?: PositionMetadata;\n createdAt?: string;\n updatedAt?: string;\n}\n\n// ===========================================\n// Protocol\n// ===========================================\n\nexport interface Protocol {\n id: string;\n name: string;\n url: string;\n category: ProtocolCategory;\n}\n\nexport interface ProtocolPosition {\n protocol: Protocol;\n totalValueUSD: string;\n positions: Position[];\n}\n\n// ===========================================\n// API Response\n// ===========================================\n\nexport interface WalletDefiPositionsData {\n wallet: string;\n fetchedAt: string;\n totalValueUSD: string;\n totalDepositedUSD: string;\n totalBorrowedUSD: string;\n totalRewardsUSD: string;\n protocols: ProtocolPosition[];\n}\n\nexport interface WalletDefiPositionsResponse {\n data: WalletDefiPositionsData;\n}\n\nexport interface WalletDefiPositionsErrorResponse {\n error: {\n code: string;\n message: string;\n };\n}\n",
|
|
91
|
+
"import { z } from 'zod';\n\n// ===========================================\n// Input Schema\n// ===========================================\n\n// Validates both EVM (0x + 40 hex chars = 42) and Solana (32-44 base58 chars) addresses\nconst walletAddressSchema = z\n .string()\n .min(32, 'Invalid wallet address')\n .max(44, 'Invalid wallet address')\n .or(z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid EVM wallet address'));\n\nexport const WalletDefiPositionsParamsSchema = z.object({\n wallet: walletAddressSchema.describe('Wallet address (EVM or Solana)'),\n blockchains: z.string().describe('Blockchain to fetch positions from (e.g., \"solana\", \"ethereum\")'),\n});\n\nexport type WalletDefiPositionsParams = z.infer<typeof WalletDefiPositionsParamsSchema>;\n\n// ===========================================\n// Output Types\n// ===========================================\n\nexport type ProtocolCategory =\n | 'lending'\n | 'lp'\n | 'liquid-staking'\n | 'native-staking'\n | 'restaking'\n | 'perps'\n | 'yield'\n | 'cdp'\n | 'streaming';\n\nexport type PositionType =\n | 'deposit'\n | 'borrow'\n | 'liquidity'\n | 'stake'\n | 'leverage'\n | 'collateral'\n | 'debt'\n | 'vesting'\n | 'streaming'\n | 'order';\n\n// ===========================================\n// Token\n// ===========================================\n\nexport interface TokenAmount {\n address: string;\n symbol: string;\n name: string;\n decimals: number;\n amountRaw: string; // Raw amount\n amountFormatted: number; // Human readable\n priceUSD: number;\n valueUSD: number;\n logoUri?: string;\n}\n\n// ===========================================\n// Metadata by position type\n// ===========================================\n\nexport interface LendingMetadata {\n type: 'lending';\n market?: string; // Market name (e.g., \"Main Market\", \"JLP Market\")\n healthFactor?: string;\n liquidationThreshold?: string;\n ltv?: string;\n supplyAPY?: string; // Total APY (base + token APY for LSTs)\n baseSupplyAPY?: string; // Base lending APY from protocol\n tokenAPY?: string; // Native staking/yield APY for yield-bearing tokens (LST, JLP, etc.)\n borrowAPY?: string; // Base borrow APY from protocol\n baseBorrowAPY?: string; // Base borrow APY (same as borrowAPY, for consistency with supply)\n utilizationRate?: string;\n}\n\nexport interface LiquidityMetadata {\n type: 'liquidity';\n poolAddress: string;\n poolName: string;\n poolType: 'amm' | 'clmm' | 'dlmm';\n shareOfPool?: string;\n fee24h?: string;\n apy?: string;\n tickLower?: number;\n tickUpper?: number;\n inRange?: boolean;\n}\n\nexport interface LiquidStakingMetadata {\n type: 'liquid-staking';\n lstMint: string;\n lstSymbol: string;\n exchangeRate: string;\n apy?: string;\n unstakePending?: string;\n}\n\nexport interface PerpMetadata {\n type: 'perp';\n // Identification\n id: string;\n marketId: string;\n exchange: 'drift' | 'gains' | 'hyperliquid' | 'gte' | 'lighter';\n\n // Position\n side: 'BUY' | 'SELL';\n entryPriceQuote: number;\n currentPriceQuote: number;\n currentLeverage: number;\n liquidationPriceQuote: number;\n\n // Size\n amountUSD: number;\n amountRaw: string; // bigint -> string for JSON serialization\n\n // PnL\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n realizedPnlPercent: number;\n unrealizedPnlPercent: number;\n\n // Fees\n feesOpeningUSD: number;\n feesClosingUSD: number;\n feesFundingUSD: number;\n\n // TP/SL\n tp: Array<{ size: string; price: number; id: number }>;\n sl: Array<{ size: string; price: number; id: number }>;\n\n // Timestamps\n openDate?: string;\n lastUpdate?: string;\n\n // Chain info\n address: string;\n chainId: string;\n collateralAsset: string;\n}\n\nexport interface StreamingMetadata {\n type: 'streaming';\n streamType: 'vesting' | 'payment';\n sender?: string;\n recipient?: string;\n startTime: string;\n endTime: string;\n amountPerSecond: string;\n amountClaimed: string;\n amountRemaining: string;\n cliffDate?: string;\n}\n\nexport interface NativeStakingMetadata {\n type: 'native-staking';\n stakeAccountAddress: string;\n validatorVoteAccount: string;\n validatorName?: string;\n validatorCommission?: number;\n activationState: 'activating' | 'active' | 'deactivating' | 'inactive';\n activationEpoch?: number;\n deactivationEpoch?: number;\n currentEpoch: number;\n apy?: string;\n}\n\nexport interface RestakingMetadata {\n type: 'restaking';\n strategyAddress: string;\n strategyName: string;\n underlyingToken: string;\n underlyingSymbol: string;\n operatorAddress?: string;\n isDelegated: boolean;\n sharesRaw: string;\n}\n\nexport type PositionMetadata =\n | LendingMetadata\n | LiquidityMetadata\n | LiquidStakingMetadata\n | NativeStakingMetadata\n | RestakingMetadata\n | PerpMetadata\n | StreamingMetadata;\n\n// ===========================================\n// Position\n// ===========================================\n\nexport interface Position {\n id: string;\n type: PositionType;\n name: string;\n valueUSD: number;\n tokens: TokenAmount[];\n rewards?: TokenAmount[];\n metadata?: PositionMetadata;\n createdAt?: string;\n updatedAt?: string;\n}\n\n// ===========================================\n// Protocol\n// ===========================================\n\nexport interface Protocol {\n id: string;\n name: string;\n url: string;\n logo: string;\n category: ProtocolCategory;\n}\n\nexport interface ProtocolPosition {\n protocol: Protocol;\n totalValueUSD: string;\n positions: Position[];\n}\n\n// ===========================================\n// API Response\n// ===========================================\n\nexport interface WalletDefiPositionsData {\n wallet: string;\n fetchedAt: string;\n totalValueUSD: string;\n totalDepositedUSD: string;\n totalBorrowedUSD: string;\n totalRewardsUSD: string;\n protocols: ProtocolPosition[];\n}\n\nexport interface WalletDefiPositionsResponse {\n data: WalletDefiPositionsData;\n}\n\nexport interface WalletDefiPositionsErrorResponse {\n error: {\n code: string;\n message: string;\n };\n}\n",
|
|
92
92
|
"import { z } from 'zod';\nimport {\n tokenPositionSchema,\n WalletDeployerQuery,\n walletDeployerOutputSchema,\n} from '../../utils/schemas/WalletDeployerSchema.ts';\n\nexport type TokenPositionSchema = z.infer<typeof tokenPositionSchema>;\nexport const WalletV2DeployerParamsSchema = WalletDeployerQuery;\nexport type WalletV2DeployerParams = z.input<typeof WalletV2DeployerParamsSchema>;\n\nexport const WalletV2DeployerResponseSchema = walletDeployerOutputSchema;\nexport type WalletV2DeployerResponse = z.infer<typeof WalletV2DeployerResponseSchema>;\n",
|
|
93
93
|
"import { z } from 'zod';\n\nexport const ExchangesIds = z.enum(['gains', 'hyperliquid', 'gte', 'lighter', 'drift']);\n\nconst tpSlSchema = z.object({ size: z.bigint(), price: z.number(), id: z.number() });\nexport const PerpsPositionSchema = z.object({\n id: z.string(),\n entryPriceQuote: z.number(),\n currentLeverage: z.number(),\n amountUSD: z.number(),\n amountRaw: z.bigint(),\n side: z.enum(['BUY', 'SELL']),\n liquidationPriceQuote: z.number(),\n currentPriceQuote: z.number(),\n realizedPnlUSD: z.number(),\n unrealizedPnlUSD: z.number(),\n realizedPnlPercent: z.number(),\n unrealizedPnlPercent: z.number(),\n tp: z.array(tpSlSchema),\n sl: z.array(tpSlSchema),\n marketId: z.string(),\n exchange: ExchangesIds,\n feesOpeningUSD: z.number(),\n feesClosingUSD: z.number(),\n feesFundingUSD: z.number(),\n openDate: z.date(),\n lastUpdate: z.date(),\n address: z.string(),\n chainId: z.string(),\n collateralAsset: z.string(),\n});\n\nexport type PerpsPosition = z.infer<typeof PerpsPositionSchema>;\nexport const PerpsPositionNonExecutedSchema = PerpsPositionSchema.extend({\n type: z.enum(['STOP', 'LIMIT']),\n});\n\nexport type PerpsPositionNonExecuted = z.infer<typeof PerpsPositionNonExecutedSchema>;\n\nexport const WalletPerpsPositionsResponseSchema = z.object({\n data: z.array(PerpsPositionSchema),\n});\n\nexport const WalletPerpsPositionsNonExecutedResponseSchema = z.object({\n data: z.array(PerpsPositionNonExecutedSchema),\n});\n",
|
|
94
94
|
"import { z } from 'zod';\nimport { tokenPositionSchema } from '../../utils/schemas/WalletDeployerSchema.ts';\n\nexport const WalletPositionsParamsSchema = z.object({\n wallet: z.string(),\n blockchain: z.string().optional(),\n backfillPositions: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n backfillSwapsAndPositions: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type WalletPositionsParams = z.input<typeof WalletPositionsParamsSchema>;\n\nexport const SinglePositionQuery = z.object({\n wallet: z.string(),\n asset: z.string(),\n blockchain: z.string(),\n});\n\n// Batch position query - single item schema\nconst SinglePositionItemSchema = z.object({\n wallet: z.string(),\n asset: z.string(),\n blockchain: z.string(),\n});\n\n// Batch position params - supports array or object with items\nexport const SinglePositionBatchParamsSchema = z.union([\n z.array(SinglePositionItemSchema),\n z.object({\n items: z.array(SinglePositionItemSchema),\n instanceTracking: z.preprocess((val) => {\n if (val === 'true') return true;\n if (val === 'false') return false;\n return val;\n }, z.boolean().optional()),\n }),\n]);\n\nexport type SinglePositionBatchParams = z.input<typeof SinglePositionBatchParamsSchema>;\n\nexport type TokenPositionType = z.infer<typeof tokenPositionSchema>;\n\nexport const WalletPositionsResponseSchema = z.object({\n data: z.array(tokenPositionSchema),\n});\n\nexport type WalletPositionsResponse = z.infer<typeof WalletPositionsResponseSchema>;\n\nexport const singlePositionOutputSchema = z.object({\n data: tokenPositionSchema,\n});\n\n// Batch position item schema - includes wallet for identification\nexport const batchPositionItemSchema = tokenPositionSchema.extend({\n wallet: z.string(),\n});\n\n// Batch response schema\nexport const SinglePositionBatchResponseSchema = z.object({\n payload: z.array(\n batchPositionItemSchema.or(z.object({ error: z.string().optional(), wallet: z.string().optional() })).nullable(),\n ),\n hostname: z.string().optional(),\n});\n\nexport type SinglePositionBatchResponse = z.infer<typeof SinglePositionBatchResponseSchema>;\nexport type BatchPositionItem = z.infer<typeof batchPositionItemSchema>;\n\n// Type aliases for SDK consistency\nexport type WalletPositionParams = z.input<typeof SinglePositionQuery>;\nexport type WalletPositionResponse = z.infer<typeof singlePositionOutputSchema>;\nexport type WalletPositionBatchParams = z.input<typeof SinglePositionBatchParamsSchema>;\nexport type WalletPositionBatchResponse = z.infer<typeof SinglePositionBatchResponseSchema>;\n",
|
|
95
95
|
"import { z } from 'zod';\nimport { SecurityFlagsSchema } from '../../utils/schemas/SecuritySchemas.ts';\n\nexport const tokenHoldingSchema = z.object({\n token: z.object({\n address: z.string(),\n chainId: z.string(),\n name: z.string().nullable(),\n symbol: z.string().nullable(),\n logo: z.string().nullable(),\n decimals: z.coerce.number().default(0),\n holdersCount: z.coerce.number().default(0),\n deployer: z.string().nullable(),\n website: z.string().nullable(),\n x: z.string().nullable(),\n telegram: z.string().nullable(),\n description: z.string().nullable(),\n security: SecurityFlagsSchema.nullable(),\n }),\n balance: z.number(),\n rawBalance: z.string(),\n /** Rent lamports for Solana token accounts (returned when account is closed). Only present for Solana SPL tokens. */\n lamports: z.string().nullable().optional(),\n});\n\nexport const WalletHoldingsResponseSchema = z.object({\n data: z.array(tokenHoldingSchema),\n});\n\nexport type TokenHolding = z.infer<typeof tokenHoldingSchema>;\nexport type WalletHoldingsResponse = z.infer<typeof WalletHoldingsResponseSchema>;\n",
|
|
96
96
|
"import { z } from 'zod';\n\nexport const FeedPayloadSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('asset_ids'),\n asset_ids: z.array(z.number()).optional(),\n quote_id: z.number().optional().nullable(),\n }),\n z.object({\n kind: z.literal('address'),\n tokens: z.array(\n z.object({\n blockchain: z.string(),\n address: z.string(),\n }),\n ),\n quote: z\n .object({\n address: z.string(),\n blockchain: z.string(),\n })\n .optional(),\n }),\n z.object({\n kind: z.literal('all'),\n }),\n]);\n\nexport type FeedPayloadType = z.input<typeof FeedPayloadSchema>;\n\nexport const FeedAssetIdSchema = z.object({\n asset_ids: z.array(z.number()).optional(),\n quote_id: z.number().optional().nullable(),\n});\n\nexport const FeedTokenSchema = z.object({\n tokens: z.array(\n z.object({\n blockchain: z.string(),\n address: z.string(),\n }),\n ),\n quote: z\n .object({\n address: z.string(),\n blockchain: z.string(),\n })\n .optional(),\n});\n",
|
|
97
|
-
"import { z } from 'zod';\n\nconst BalanceItemSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n});\n\nexport const BalancePayloadSchema = z.object({\n items: z.array(BalanceItemSchema),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type BalancePayload = z.infer<typeof BalancePayloadSchema>;\nexport type BalanceItem = z.infer<typeof BalanceItemSchema>;\n\nexport interface WalletBalanceData {\n wallet: string;\n token: string; // Token address or \"native\"\n chainId: string;\n balance: number; // Decimal-adjusted balance\n rawBalance: string; // Raw balance (no decimal adjustment)\n decimals: number;\n symbol: string;\n name: string;\n logo: string | null;\n}\n\nexport interface WalletBalanceUpdate extends WalletBalanceData {\n previousBalance?: number; // Previous balance (for delta updates)\n previousRawBalance?: string; // Previous raw balance (for delta updates)\n}\n",
|
|
97
|
+
"import { z } from 'zod';\n\nconst BalanceItemSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n});\n\nexport const BalancePayloadSchema = z.object({\n items: z.array(BalanceItemSchema),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type BalancePayload = z.infer<typeof BalancePayloadSchema>;\nexport type BalancePayloadType = z.input<typeof BalancePayloadSchema>;\nexport type BalanceItem = z.infer<typeof BalanceItemSchema>;\n\nexport interface WalletBalanceData {\n wallet: string;\n token: string; // Token address or \"native\"\n chainId: string;\n balance: number; // Decimal-adjusted balance\n rawBalance: string; // Raw balance (no decimal adjustment)\n decimals: number;\n symbol: string;\n name: string;\n logo: string | null;\n}\n\nexport interface WalletBalanceUpdate extends WalletBalanceData {\n previousBalance?: number; // Previous balance (for delta updates)\n previousRawBalance?: string; // Previous raw balance (for delta updates)\n}\n",
|
|
98
98
|
"import { z } from 'zod';\n\nexport const FastTradesPayloadSchema = z.object({\n assetMode: z.coerce.boolean().default(false),\n items: z.array(\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type FastTradesPayloadType = z.input<typeof FastTradesPayloadSchema>;\n\nexport interface BaseFastTrade {\n date: number;\n tokenPrice: number;\n tokenPriceVs: number;\n tokenAmount: number;\n tokenAmountVs: number;\n tokenAmountUsd: number;\n tokenNativePrice: number;\n tokenMarketCapUSD: number;\n type: 'buy' | 'sell';\n operation: 'regular' | 'liquidity' | 'arbitrage' | string;\n blockchain: string;\n hash: string;\n sender: string;\n tokenAmountRaw: string;\n tokenAmountRawVs: string;\n preBalanceBaseToken: string | null;\n preBalanceQuoteToken: string | null;\n postBalanceBaseToken: string | null;\n postBalanceQuoteToken: string | null;\n subscriptionId: string;\n timestamp: number;\n labels?: string[];\n platform?: string | null;\n swapRecipient?: string | null;\n // Fees breakdown\n totalFeesUSD?: number | null;\n gasFeesUSD?: number | null;\n platformFeesUSD?: number | null;\n mevFeesUSD?: number | null;\n}\n\nexport interface PairFastTrade extends BaseFastTrade {\n pair: string;\n token?: never;\n}\n\nexport interface TokenFastTrade extends BaseFastTrade {\n token: string;\n pair?: never;\n}\n\nexport type WssFastTradesResponseType = PairFastTrade | TokenFastTrade;\n",
|
|
99
99
|
"import { z } from 'zod';\n\nexport const FundingPayloadSchema = z.object({\n symbol: z.string(),\n quote: z.string().optional(),\n exchange: z\n .string()\n .optional()\n .transform((val) => {\n const validExchanges = ['binance', 'bybit', 'hyperliquid', 'deribit', 'okx', 'gate'];\n\n if (!val) return validExchanges;\n\n const requestedExchanges = val\n .split(',')\n .map((ex) => ex.trim().toLowerCase())\n .filter((ex) => validExchanges.includes(ex));\n\n return requestedExchanges.length > 0 ? requestedExchanges : validExchanges;\n }),\n interval: z.number().optional().default(5),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z.string().optional(),\n});\n\nexport type FundingPayloadType = z.input<typeof FundingPayloadSchema>;\n",
|
|
100
100
|
"import { z } from 'zod';\nimport type { HoldersStreamNewTokenPayload } from '../utils/schemas/EnrichedHoldersData.ts';\n\nexport const HoldersPayloadSchema = z.object({\n tokens: z.array(\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type HoldersPayloadType = z.input<typeof HoldersPayloadSchema>;\n\nexport type WssHoldersResponse = { data: z.infer<typeof HoldersStreamNewTokenPayload>; subscriptionId: string };\n",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"import { z } from 'zod';\n\nexport const MarketPayloadSchema = z.object({\n interval: z.number().default(30),\n subscriptionId: z.string().optional(),\n assets: z\n .array(\n z.union([\n z.object({ name: z.string() }),\n z.object({ symbol: z.string() }),\n z.object({\n address: z.string(),\n blockchain: z.string(),\n }),\n ]),\n )\n .max(100),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type MarketPayloadType = z.input<typeof MarketPayloadSchema>;\n",
|
|
103
103
|
"import { z } from 'zod';\nimport normalizePeriod from '../utils/functions/period.ts';\n\nexport const OhlcvPayloadSchema = z.object({\n address: z.string().optional(),\n subscriptionId: z.string().optional(),\n blockchain: z.string().optional(),\n chainId: z.string().optional(),\n period: z\n .string()\n .optional()\n .transform((val) => {\n if (val) {\n return normalizePeriod(val);\n }\n return '5m';\n }),\n asset: z.string().optional(),\n currentPrice: z.string().optional(),\n mode: z.enum(['asset', 'pair']).optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type OhlcvPayloadType = z.input<typeof OhlcvPayloadSchema>;\n\nexport interface WssOhlcvDetailsResponseType {\n subscriptionId?: string;\n high: number | null;\n low: number | null;\n open: number | null;\n close: number | null;\n volume: number;\n time: number;\n period: string;\n tradeTime?: number;\n}\n",
|
|
104
104
|
"import { z } from 'zod';\n\nexport const PairsPayloadSchema = z.object({\n mode: z.enum(['asset', 'pair']).optional().default('pair'),\n subscriptionId: z.string().optional(),\n blockchain: z.string().optional(),\n factory: z.string().optional(),\n interval: z.number().default(30),\n address: z.string().optional(),\n asset: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PairsPayloadType = z.input<typeof PairsPayloadSchema>;\n",
|
|
105
|
-
"import { z } from 'zod';\n\nexport const PositionPayloadSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionPayloadType = z.infer<typeof PositionPayloadSchema>;\n\nexport const PositionsPayloadSchema = z.object({\n wallet: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionsPayload = z.infer<typeof PositionsPayloadSchema>;\n\nexport interface WalletPositionData {\n wallet: string;\n token: string;\n chainId: string;\n balance: number;\n rawBalance: string;\n amountUSD: number;\n buys: number;\n sells: number;\n volumeBuyToken: number;\n volumeSellToken: number;\n volumeBuy: number;\n volumeSell: number;\n avgBuyPriceUSD: number;\n avgSellPriceUSD: number;\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n totalPnlUSD: number;\n firstDate: Date | null;\n lastDate: Date | null;\n tokenDetails?: {\n address: string;\n chainId: string;\n name: string;\n symbol: string;\n decimals: number;\n logo: string | null;\n price: number;\n priceChange24h: number | null;\n liquidity: number | null;\n marketCap: number | null;\n };\n}\n\nexport interface WalletPositionsData {\n wallet: string;\n chainId: string;\n positions: WalletPositionData[];\n}\n",
|
|
105
|
+
"import { z } from 'zod';\n\nexport const PositionPayloadSchema = z.object({\n wallet: z.string(),\n token: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionPayloadType = z.infer<typeof PositionPayloadSchema>;\n\nexport const PositionsPayloadSchema = z.object({\n wallet: z.string(),\n blockchain: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z\n .union([z.boolean(), z.string()])\n .default(false)\n .transform((val) => (typeof val === 'string' ? val === 'true' : val)),\n});\n\nexport type PositionsPayload = z.infer<typeof PositionsPayloadSchema>;\nexport type PositionsPayloadType = z.input<typeof PositionsPayloadSchema>;\n\nexport interface WalletPositionData {\n wallet: string;\n token: string;\n chainId: string;\n balance: number;\n rawBalance: string;\n amountUSD: number;\n buys: number;\n sells: number;\n volumeBuyToken: number;\n volumeSellToken: number;\n volumeBuy: number;\n volumeSell: number;\n avgBuyPriceUSD: number;\n avgSellPriceUSD: number;\n realizedPnlUSD: number;\n unrealizedPnlUSD: number;\n totalPnlUSD: number;\n firstDate: Date | null;\n lastDate: Date | null;\n tokenDetails?: {\n address: string;\n chainId: string;\n name: string;\n symbol: string;\n decimals: number;\n logo: string | null;\n price: number;\n priceChange24h: number | null;\n liquidity: number | null;\n marketCap: number | null;\n };\n}\n\nexport interface WalletPositionsData {\n wallet: string;\n chainId: string;\n positions: WalletPositionData[];\n}\n",
|
|
106
106
|
"import { z } from 'zod';\n\nexport const PausePulsePayloadSchema = z.object({\n action: z.enum(['pause', 'unpause']),\n views: z.array(z.string()).min(1),\n});\n\nexport type PausePulsePayloadType = z.input<typeof PausePulsePayloadSchema>;\n",
|
|
107
107
|
"import { z } from 'zod';\nimport FilterWithLimit from '../../utils/schemas/Filter.ts';\n\nexport const StreamPayloadSchema = z.object({\n filters: FilterWithLimit.optional(),\n chainIds: z.array(z.string()).nonempty(),\n name: z.string().optional(),\n events: z.array(z.enum(['swap', 'transfer', 'swap-enriched', 'block', 'order'])).nonempty(),\n authorization: z.string(),\n subscriptionId: z.string().optional(),\n subscriptionTracking: z.string().optional(),\n debugSubscriptionId: z.string().optional(),\n});\n\nexport type StreamPayloadType = z.infer<typeof StreamPayloadSchema>;\n\nexport const UnsubscribeStreamPayloadSchema = z\n .object({\n type: z.enum(['stream']).optional(),\n subscriptionId: z.string().optional(),\n personalizedId: z.string().optional(),\n viewName: z.string().optional(),\n })\n .transform((data) => {\n // Transform personalizedId to subscriptionId if provided\n if (data.personalizedId && !data.subscriptionId) {\n return {\n ...data,\n subscriptionId: data.personalizedId,\n };\n }\n return data;\n })\n .optional();\n\nexport type UnsubscribeStreamPayloadType = z.input<typeof UnsubscribeStreamPayloadSchema>;\n\nexport const UpdateStreamPayloadSchema = z.object({\n subscriptionId: z.string(),\n authorization: z.string(),\n mode: z.enum(['merge', 'replace']).default('replace'),\n filters: FilterWithLimit.optional(),\n chainIds: z.array(z.string()).optional(),\n events: z.array(z.string()).optional(),\n subscriptionTracking: z.string().optional(),\n});\n\nexport type UpdateStreamPayloadType = z.input<typeof UpdateStreamPayloadSchema>;\n",
|
|
108
108
|
"import { z } from 'zod';\n\nconst BaseFilter = z.object({\n eq: z.tuple([z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])]).optional(),\n neq: z.tuple([z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])]).optional(),\n lt: z.tuple([z.string(), z.coerce.number()]).optional(),\n lte: z.tuple([z.string(), z.coerce.number()]).optional(),\n gt: z.tuple([z.string(), z.coerce.number()]).optional(),\n gte: z.tuple([z.string(), z.coerce.number()]).optional(),\n in: z\n .tuple([\n z.string(),\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])),\n ]),\n ])\n .optional(),\n});\n\ntype BaseFilter = z.infer<typeof BaseFilter>;\nexport type Filter = BaseFilter & ({ and?: Filter[] } | { or?: Filter[] });\n\nconst Filter: z.ZodType<Filter> = BaseFilter.and(\n z.union([\n BaseFilter.extend({ and: z.undefined(), or: z.undefined() }),\n BaseFilter.extend({ and: z.array(z.lazy(() => Filter)), or: z.undefined() }),\n BaseFilter.extend({ and: z.undefined(), or: z.array(z.lazy(() => Filter)) }),\n ]),\n);\n\nexport function countOperations(filter: Filter | undefined): number {\n if (!filter) return 0;\n\n let count = 0;\n\n for (const key of ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in'] as const) {\n if (filter[key]) count += 1;\n }\n\n if ('and' in filter && Array.isArray(filter.and)) {\n for (const child of filter.and) {\n count += countOperations(child);\n }\n }\n\n if ('or' in filter && Array.isArray(filter.or)) {\n for (const child of filter.or) {\n count += countOperations(child);\n }\n }\n\n return count;\n}\n\nconst FilterWithLimit = Filter.superRefine((val, ctx) => {\n const total = countOperations(val);\n const max = 1000;\n if (total > max) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Your filter contains ${total} leaf operations, exceeding the maximum of ${max}. Only leaf conditions like \"eq\", \"neq\", \"lt\", \"lte\", \"gt\", \"gte\", \"in\" are counted; logical operators (\"and\", \"or\") are ignored.`,\n });\n }\n});\n\nexport default FilterWithLimit;\n",
|
|
@@ -46,6 +46,7 @@ export declare const BalancePayloadSchema: z.ZodObject<{
|
|
|
46
46
|
subscriptionTracking?: string | boolean | undefined;
|
|
47
47
|
}>;
|
|
48
48
|
export type BalancePayload = z.infer<typeof BalancePayloadSchema>;
|
|
49
|
+
export type BalancePayloadType = z.input<typeof BalancePayloadSchema>;
|
|
49
50
|
export type BalanceItem = z.infer<typeof BalanceItemSchema>;
|
|
50
51
|
export interface WalletBalanceData {
|
|
51
52
|
wallet: string;
|
|
@@ -36,6 +36,7 @@ export declare const PositionsPayloadSchema: z.ZodObject<{
|
|
|
36
36
|
subscriptionTracking?: string | boolean | undefined;
|
|
37
37
|
}>;
|
|
38
38
|
export type PositionsPayload = z.infer<typeof PositionsPayloadSchema>;
|
|
39
|
+
export type PositionsPayloadType = z.input<typeof PositionsPayloadSchema>;
|
|
39
40
|
export interface WalletPositionData {
|
|
40
41
|
wallet: string;
|
|
41
42
|
token: string;
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const BlockDataQuerySchema: z.ZodObject<{
|
|
3
|
-
limit: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>;
|
|
4
|
-
blockchain: z.ZodOptional<z.ZodString>;
|
|
5
|
-
order: z.ZodDefault<z.ZodOptional<z.ZodEnum<["ASC", "DESC"]>>>;
|
|
6
|
-
page: z.ZodEffects<z.ZodOptional<z.ZodString>, number, string | undefined>;
|
|
7
|
-
pagination: z.ZodEffects<z.ZodOptional<z.ZodString>, boolean, string | undefined>;
|
|
8
|
-
blockId: z.ZodEffects<z.ZodOptional<z.ZodString>, string | number | undefined, string | undefined>;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
limit: number;
|
|
11
|
-
pagination: boolean;
|
|
12
|
-
page: number;
|
|
13
|
-
order: "ASC" | "DESC";
|
|
14
|
-
blockchain?: string | undefined;
|
|
15
|
-
blockId?: string | number | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
blockchain?: string | undefined;
|
|
18
|
-
limit?: string | undefined;
|
|
19
|
-
pagination?: string | undefined;
|
|
20
|
-
page?: string | undefined;
|
|
21
|
-
order?: "ASC" | "DESC" | undefined;
|
|
22
|
-
blockId?: string | undefined;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const RawBlockSpecificQueryParamsSchema: z.ZodObject<{
|
|
25
|
-
blockId: z.ZodEffects<z.ZodString, string | number | undefined, string>;
|
|
26
|
-
blockchain: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, "strip", z.ZodTypeAny, {
|
|
28
|
-
blockchain?: string | undefined;
|
|
29
|
-
blockId?: string | number | undefined;
|
|
30
|
-
}, {
|
|
31
|
-
blockId: string;
|
|
32
|
-
blockchain?: string | undefined;
|
|
33
|
-
}>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// Define the Zod schema for contract verification query
|
|
4
|
-
export const ContractVerifyQuerySchema = z.object({
|
|
5
|
-
blockchain: z
|
|
6
|
-
.string(),
|
|
7
|
-
sourceCode: z.string().optional(),
|
|
8
|
-
contractAddress: z.string().min(1, 'Contract address is required and cannot be empty'),
|
|
9
|
-
compilerVersion: z.string().min(1, 'Pragma version is required and cannot be empty'),
|
|
10
|
-
constructorArguments: z.string().optional(),
|
|
11
|
-
optimizationUsed: z.string().optional(),
|
|
12
|
-
runs: z.string().optional(),
|
|
13
|
-
evmVersion: z.string().optional(),
|
|
14
|
-
contractName: z.string(),
|
|
15
|
-
|
|
16
|
-
codeFormat: z.string(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export type ContractVerifyQuery = z.infer<typeof ContractVerifyQuerySchema>;
|
|
20
|
-
|
|
21
|
-
export const ContractInterfaceQuery = z.object({
|
|
22
|
-
blockchain: z
|
|
23
|
-
.string(),
|
|
24
|
-
contractAddress: z.string().min(1, 'Contract address is required and cannot be empty'),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type ContractInterfaceQuery = z.infer<typeof ContractInterfaceQuery>;
|