@pyxisjs/core 0.1.0

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.
@@ -0,0 +1,821 @@
1
+ import { InputEntryFunctionData, AptosSettings } from '@aptos-labs/ts-sdk';
2
+
3
+ /**
4
+ * Chain types for multi-chain support
5
+ */
6
+ declare enum NetworkType {
7
+ MAINNET = "mainnet",
8
+ TESTNET = "testnet"
9
+ }
10
+ declare enum ChainId {
11
+ APTOS_MAINNET = "aptos-mainnet",
12
+ APTOS_TESTNET = "aptos-testnet",
13
+ ETHEREUM_MAINNET = "ethereum-mainnet",
14
+ ETHEREUM_SEPOLIA = "ethereum-sepolia",
15
+ ARBITRUM_ONE = "arbitrum-one"
16
+ }
17
+ declare enum ChainType {
18
+ EVM = "evm",
19
+ MoveVM = "move_vm"
20
+ }
21
+ interface Currency {
22
+ /** The symbol of the currency (e.g., 'APT', 'ETH') */
23
+ symbol: string;
24
+ /** The number of decimal places */
25
+ decimals: number;
26
+ /** The full name of the currency */
27
+ name: string;
28
+ }
29
+ interface Chain {
30
+ /** Unique identifier for the chain */
31
+ readonly id: ChainId;
32
+ /** RPC URL for the chain */
33
+ readonly rpcUrl: string;
34
+ /** Optional indexer URL for Aptos chains */
35
+ readonly indexerUrl?: string;
36
+ /** Optional API key for authenticated access */
37
+ readonly apiKey?: string;
38
+ /** Optional contract addresses for vault operations */
39
+ readonly contractAddresses?: VaultContractAddressConfig;
40
+ }
41
+ interface ChainConfig {
42
+ type: ChainType;
43
+ networkType: NetworkType;
44
+ name: string;
45
+ chainId?: number;
46
+ nativeCurrency: Currency;
47
+ blockExplorerUrls?: string[];
48
+ isTestnet: boolean;
49
+ }
50
+ declare const CHAIN_CONFIGS: Record<ChainId, ChainConfig>;
51
+ declare function getChainConfig(chainId: ChainId): ChainConfig;
52
+ interface VaultContractAddressConfig {
53
+ /** Address of the accountant contract responsible for managing vault accounting */
54
+ accountant: string;
55
+ /** Address of the teller contract responsible for handling deposits and withdrawals */
56
+ teller: string;
57
+ /** Address of the atomic queue contract for managing transaction ordering */
58
+ atomicQueue: string;
59
+ }
60
+
61
+ /**
62
+ * Transaction payload types
63
+ */
64
+ interface EthereumJsonRpcRequest {
65
+ method: 'eth_sendTransaction';
66
+ params: Array<{
67
+ to?: string;
68
+ from?: string;
69
+ data?: string;
70
+ value?: string;
71
+ }>;
72
+ }
73
+ interface AptosTransactionPayload {
74
+ function: `${string}::${string}::${string}`;
75
+ typeArguments: string[];
76
+ functionArguments: any[];
77
+ }
78
+ type TransactionPayload = {
79
+ type: 'evm';
80
+ data: EthereumJsonRpcRequest;
81
+ } | {
82
+ type: 'aptos';
83
+ data: AptosTransactionPayload;
84
+ };
85
+
86
+ /**
87
+ * Wallet types for multi-chain support
88
+ */
89
+
90
+ interface WalletAccount {
91
+ /** Address of the account */
92
+ address: string;
93
+ /** Public key of the account */
94
+ publicKey?: string;
95
+ /** Name of the account (optional) */
96
+ name?: string;
97
+ }
98
+
99
+ interface WalletAdapter {
100
+ /**
101
+ * Sign and submit a transaction
102
+ */
103
+ signAndSubmitTransaction(transaction: TransactionPayload): Promise<{
104
+ hash: string;
105
+ }>;
106
+ }
107
+ /**
108
+ * Base transaction interface for all chains
109
+ */
110
+ interface BaseTransaction<T = any> {
111
+ /** Unique identifier for the transaction */
112
+ hash: string;
113
+ /** Transaction data */
114
+ data: T;
115
+ }
116
+ /**
117
+ * Aptos-specific transaction
118
+ */
119
+ interface AptosTransaction extends BaseTransaction<InputEntryFunctionData> {
120
+ }
121
+ /**
122
+ * Ethereum-specific transaction
123
+ */
124
+ interface EthereumTransaction extends BaseTransaction {
125
+ type: 'ethereum';
126
+ to: string;
127
+ data: string;
128
+ value: string;
129
+ gasLimit: string;
130
+ gasPrice?: string;
131
+ }
132
+ /**
133
+ * Union type for transactions across all chains
134
+ */
135
+ type AnyTransaction = AptosTransaction | EthereumTransaction;
136
+ /**
137
+ * Signed transaction interface
138
+ */
139
+ interface SignedTransaction {
140
+ /** Transaction hash */
141
+ hash: string;
142
+ /** Serialized transaction data */
143
+ serialized: any;
144
+ /** Chain this transaction is for */
145
+ chain: string;
146
+ }
147
+ /**
148
+ * Transaction result interface
149
+ */
150
+ interface TransactionResult {
151
+ /** Transaction hash */
152
+ hash: string;
153
+ /** Whether transaction was successful */
154
+ success: boolean;
155
+ /** Block number (if applicable) */
156
+ blockNumber?: number;
157
+ /** Block timestamp */
158
+ blockTimestamp?: number;
159
+ /** Gas used (EVM only) */
160
+ gasUsed?: string;
161
+ /** Error message if transaction failed */
162
+ error?: string;
163
+ }
164
+
165
+ /**
166
+ * Configuration options for the Pyxis SDK
167
+ * @deprecated Use MultiChainSDKConfig instead
168
+ */
169
+ interface SDKConfig {
170
+ /** Contract addresses */
171
+ contractAddresses?: VaultContractAddressConfig;
172
+ /** Event indexer config */
173
+ eventIndexerConfig: AptosSettings;
174
+ /** Main indexer config */
175
+ aptosIndexerConfig: AptosSettings;
176
+ }
177
+
178
+ /**
179
+ * Interface representing the state of request flags
180
+ */
181
+ interface PyxisRequestFlagState {
182
+ /** bit 0 (1): deadline passed (`now > deadline`) */
183
+ deadlinePassed: boolean;
184
+ /** bit 1 (2): zero offer amount (escrow balance is zero) */
185
+ zeroOfferAmount: boolean;
186
+ /** bit 2 (4): minimum age not met (`now - updated_at < minimum_request_age`) */
187
+ minimumAgeNotMet: boolean;
188
+ }
189
+ /**
190
+ * Interface representing a token with inner value
191
+ */
192
+ interface PyxisToken {
193
+ /** Inner token value */
194
+ inner: string;
195
+ }
196
+ /**
197
+ * Interface representing a withdrawal request
198
+ */
199
+ interface PyxisOnchainWithdrawalRequest {
200
+ /** Atomic price for the withdrawal */
201
+ atomic_price: string;
202
+ /** Deadline timestamp for the request */
203
+ deadline: string;
204
+ /** Request flags */
205
+ flags?: {
206
+ flag: number;
207
+ };
208
+ /** Amount being offered */
209
+ offer_amount: string;
210
+ /** Token being offered */
211
+ offer_token: PyxisToken;
212
+ /** User address making the withdrawal request */
213
+ user_address: string;
214
+ /** Amount wanted in return */
215
+ want_amount: string;
216
+ /** Token wanted in return */
217
+ want_token: PyxisToken;
218
+ }
219
+ /**
220
+ * Interface representing a withdrawal request with camelCase properties
221
+ */
222
+ interface PyxisWithdrawalRequest {
223
+ /** Atomic price for the withdrawal */
224
+ atomicPrice: string;
225
+ /** Deadline timestamp for the request */
226
+ deadline: string;
227
+ /** Request flags parsed into a RequestFlagState object */
228
+ flags: PyxisRequestFlagState;
229
+ /** Amount being offered */
230
+ offerAmount: string;
231
+ /** Token being offered */
232
+ offerToken: PyxisToken;
233
+ /** User address making the withdrawal request */
234
+ userAddress: string;
235
+ /** Amount wanted in return */
236
+ wantAmount: string;
237
+ /** Token wanted in return */
238
+ wantToken: PyxisToken;
239
+ /** Timestamp when the withdrawal request was last updated */
240
+ updatedAt: string;
241
+ }
242
+ interface BuildWithdrawTxArgs {
243
+ vault: string;
244
+ offerAsset: string;
245
+ wantAsset: string;
246
+ offerAmount: string;
247
+ price: string;
248
+ deadline: string;
249
+ }
250
+ interface BuildReclaimWithdrawalRequestTxArgs {
251
+ vault: string;
252
+ offerAsset: string;
253
+ wantAsset: string;
254
+ }
255
+ interface BuildCancelWithdrawalRequestTxArgs {
256
+ vault: string;
257
+ offerAsset: string;
258
+ wantAsset: string;
259
+ }
260
+ interface BuildDepositTxArgs {
261
+ vault: string;
262
+ asset: string;
263
+ amount: string;
264
+ minimumMint: string;
265
+ }
266
+ interface GetWithdrawRateInQuoteSafeArgs {
267
+ vault: string;
268
+ quoteAsset: string;
269
+ }
270
+ interface QuoteDepositArgs {
271
+ vault: string;
272
+ asset: string;
273
+ amount: string;
274
+ }
275
+ interface QuoteWithdrawArgs {
276
+ vault: string;
277
+ amount: string;
278
+ wantAsset: string;
279
+ }
280
+ interface GetDepositRateInQuoteSafeArgs {
281
+ vault: string;
282
+ quoteAsset: string;
283
+ }
284
+ interface GetMinimumRequestAgeArgs {
285
+ vault: string;
286
+ }
287
+ /**
288
+ * Arguments for the getWithdrawalRequestsOfUser function
289
+ */
290
+ interface GetWithdrawalRequestsOfUserArgs {
291
+ /** The vault address to query */
292
+ vault: string;
293
+ /** The user address to query for withdrawal requests */
294
+ userAddress: string;
295
+ /** The request flag state to filter by */
296
+ flag: PyxisRequestFlagState;
297
+ /** Whether to match all flags or any flag */
298
+ matchAll?: boolean;
299
+ }
300
+ interface GetActivitiesArgs {
301
+ /** The vault address to filter activities by */
302
+ vault?: string;
303
+ /** The user address to filter activities by */
304
+ user?: string;
305
+ /** The page number for pagination */
306
+ page?: number;
307
+ /** The number of items per page for pagination */
308
+ pageSize?: number;
309
+ }
310
+ interface IndexerVaultActivity {
311
+ /** The amount deposited in the activity */
312
+ deposit_amount: string | null;
313
+ /** The token type deposited in the activity */
314
+ deposit_token: string | null;
315
+ /** The type of event (deposit, withdrawal, etc.) */
316
+ event_type: string;
317
+ /** The transaction hash */
318
+ tx_hash: string;
319
+ /** The transaction version */
320
+ tx_version: string;
321
+ /** The timestamp when the activity occurred */
322
+ tx_timestamp: string;
323
+ /** The user address who performed the activity */
324
+ user: string;
325
+ /** The vault address where the activity occurred */
326
+ vault: string;
327
+ /** The amount withdrawn in the activity */
328
+ withdraw_amount: string | null;
329
+ /** The token type withdrawn in the activity */
330
+ withdraw_token: string | null;
331
+ }
332
+ interface VaultActivity {
333
+ /** The amount deposited in the activity */
334
+ depositAmount: string | null;
335
+ /** The token type deposited in the activity */
336
+ depositToken: string | null;
337
+ /** The type of event (deposit, withdrawal, etc.) */
338
+ eventType: string;
339
+ /** The transaction hash */
340
+ txHash: string;
341
+ /** The transaction version */
342
+ txVersion: string;
343
+ /** The timestamp when the activity occurred */
344
+ txTimestamp: string;
345
+ /** The user address who performed the activity */
346
+ user: string;
347
+ /** The vault address where the activity occurred */
348
+ vault: string;
349
+ /** The amount withdrawn in the activity */
350
+ withdrawAmount: string | null;
351
+ /** The token type withdrawn in the activity */
352
+ withdrawToken: string | null;
353
+ }
354
+ interface VaultTvlArgs {
355
+ /** The vault address to get TVL for */
356
+ vault: string;
357
+ /** The asset to denominate the TVL in
358
+ * Should be the base asset of the vault
359
+ */
360
+ asset: string;
361
+ }
362
+ interface IndexerExchangeRateEvent {
363
+ /** The timestamp when the exchange rate event occurred */
364
+ current_time: string;
365
+ /** The new deposit rate after the event */
366
+ new_deposit_rate: string;
367
+ /** The new withdrawal rate after the event */
368
+ new_withdraw_rate: string;
369
+ /** The previous deposit rate before the event */
370
+ old_deposit_rate: string;
371
+ /** The previous withdrawal rate before the event */
372
+ old_withdraw_rate: string;
373
+ /** The vault address where the exchange rate event occurred */
374
+ vault: string;
375
+ /** The type of the exchange rate event */
376
+ type: string;
377
+ }
378
+ interface ExchangeRateEvent {
379
+ /** The timestamp when the exchange rate event occurred */
380
+ timestamp: string;
381
+ /** The new deposit rate after the event */
382
+ newDepositRate: string;
383
+ /** The new withdrawal rate after the event */
384
+ newWithdrawRate: string;
385
+ /** The previous deposit rate before the event */
386
+ oldDepositRate: string;
387
+ /** The previous withdrawal rate before the event */
388
+ oldWithdrawRate: string;
389
+ /** The vault address where the exchange rate event occurred */
390
+ vault: string;
391
+ /** The type of the exchange rate event */
392
+ type: string;
393
+ }
394
+ interface HistoricalApyArgs {
395
+ /** The vault address to get APY for */
396
+ vault: string;
397
+ /** The start time of the range (timestamp in seconds) */
398
+ startTime: number;
399
+ /** The end time of the range (timestamp in seconds) */
400
+ endTime: number;
401
+ /** The window length of the range to calculate APY (e.g., 7d, 30d, alltime) */
402
+ window?: ApyWindow;
403
+ }
404
+ type ApyWindow = '7d' | '30d' | 'alltime';
405
+ interface ApyDataPoint {
406
+ /** The APY value as a percentage string */
407
+ value: string;
408
+ /** The timestamp in seconds */
409
+ timestamp: string;
410
+ }
411
+
412
+ /**
413
+ * Base error class for all Pyxis SDK errors
414
+ */
415
+ declare class PyxisError extends Error {
416
+ readonly code: string;
417
+ readonly details: Record<string, unknown> | undefined;
418
+ constructor(message: string, code: string, details?: Record<string, unknown>);
419
+ }
420
+ /**
421
+ * Network-related errors (blockchain connectivity, RPC issues, etc.)
422
+ */
423
+ declare class NetworkError extends PyxisError {
424
+ constructor(message: string, details?: Record<string, unknown>);
425
+ }
426
+ /**
427
+ * Input validation errors
428
+ */
429
+ declare class ValidationError extends PyxisError {
430
+ readonly field: string | undefined;
431
+ constructor(message: string, field?: string, details?: Record<string, unknown>);
432
+ }
433
+ /**
434
+ * Insufficient funds errors
435
+ */
436
+ declare class InsufficientFundsError extends PyxisError {
437
+ readonly requiredAmount: string;
438
+ readonly availableAmount: string;
439
+ readonly tokenType: string;
440
+ constructor(message: string, requiredAmount: string, availableAmount: string, tokenType: string);
441
+ }
442
+ /**
443
+ * Wallet connection errors
444
+ */
445
+ declare class WalletError extends PyxisError {
446
+ constructor(message: string, details?: Record<string, unknown>);
447
+ }
448
+ /**
449
+ * Smart contract interaction errors
450
+ */
451
+ declare class ContractError extends PyxisError {
452
+ readonly contractAddress: string | undefined;
453
+ readonly functionName: string | undefined;
454
+ constructor(message: string, contractAddress?: string, functionName?: string, details?: Record<string, unknown>);
455
+ }
456
+ /**
457
+ * Transaction-related errors
458
+ */
459
+ declare class TransactionError extends PyxisError {
460
+ readonly txHash: string | undefined;
461
+ constructor(message: string, txHash?: string, details?: Record<string, unknown>);
462
+ }
463
+ /**
464
+ * Vault-specific errors
465
+ */
466
+ declare class VaultError extends PyxisError {
467
+ readonly vaultId: string | undefined;
468
+ constructor(message: string, vaultId?: string, details?: Record<string, unknown>);
469
+ }
470
+ /**
471
+ * Strategy-related errors
472
+ */
473
+ declare class StrategyError extends PyxisError {
474
+ readonly strategyId: string | undefined;
475
+ constructor(message: string, strategyId?: string, details?: Record<string, unknown>);
476
+ }
477
+ /**
478
+ * Rate limiting errors
479
+ */
480
+ declare class RateLimitError extends PyxisError {
481
+ readonly retryAfter: number | undefined;
482
+ constructor(message: string, retryAfter?: number);
483
+ }
484
+ /**
485
+ * Configuration errors
486
+ */
487
+ declare class ConfigError extends PyxisError {
488
+ constructor(message: string, details?: Record<string, unknown>);
489
+ }
490
+ /**
491
+ * Error codes enum for easy reference
492
+ */
493
+ declare enum ErrorCodes {
494
+ NETWORK_ERROR = "NETWORK_ERROR",
495
+ VALIDATION_ERROR = "VALIDATION_ERROR",
496
+ INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
497
+ WALLET_ERROR = "WALLET_ERROR",
498
+ CONTRACT_ERROR = "CONTRACT_ERROR",
499
+ TRANSACTION_ERROR = "TRANSACTION_ERROR",
500
+ VAULT_ERROR = "VAULT_ERROR",
501
+ STRATEGY_ERROR = "STRATEGY_ERROR",
502
+ RATE_LIMIT_ERROR = "RATE_LIMIT_ERROR",
503
+ CONFIG_ERROR = "CONFIG_ERROR"
504
+ }
505
+ /**
506
+ * Utility function to create appropriate error instances
507
+ */
508
+ declare function createError(type: keyof typeof ErrorCodes, message: string, details?: Record<string, unknown>): PyxisError;
509
+
510
+ /**
511
+ * Base adapter interface for chain-specific implementations
512
+ */
513
+
514
+ interface TxParams {
515
+ /** Function name to call */
516
+ function: string;
517
+ /** Type arguments */
518
+ typeArguments?: string[];
519
+ /** Function arguments */
520
+ arguments?: any[];
521
+ /** To address (for EVM) */
522
+ to?: string;
523
+ /** Value (for EVM) */
524
+ value?: string;
525
+ /** ABI for encoding/decoding (optional) */
526
+ abi?: any;
527
+ }
528
+ interface ViewParams {
529
+ /** Function name to call */
530
+ function: string;
531
+ /** Type arguments */
532
+ typeArguments?: string[];
533
+ /** Function arguments */
534
+ arguments?: any[];
535
+ /** Contract address */
536
+ address?: string;
537
+ /** ABI for encoding/decoding (optional) */
538
+ abi?: any;
539
+ }
540
+ interface EventParams {
541
+ /** Contract address to filter events */
542
+ address?: string;
543
+ /** Event type to filter */
544
+ eventType?: string;
545
+ /** From block number */
546
+ fromBlock?: number;
547
+ /** To block number */
548
+ toBlock?: number;
549
+ }
550
+ interface QueryIndexerParams {
551
+ query: string;
552
+ variables?: {};
553
+ }
554
+ declare abstract class BaseChainAdapter<TClient> {
555
+ readonly chain: Chain;
556
+ protected client: TClient | null;
557
+ constructor(chain: Chain);
558
+ /**
559
+ * Create and initialize the blockchain client
560
+ */
561
+ abstract createClient(config?: any): TClient;
562
+ /**
563
+ * Get the current client
564
+ */
565
+ getClient(): TClient;
566
+ /**
567
+ * Get contract addresses from chain configuration
568
+ * @throws Error if contract addresses are not configured
569
+ */
570
+ getContractAddresses(): VaultContractAddressConfig;
571
+ /**
572
+ * Get a specific contract address
573
+ */
574
+ getContractAddress(contract: keyof VaultContractAddressConfig): string;
575
+ /**
576
+ * Build a transaction payload
577
+ */
578
+ abstract buildPayload(params: TxParams): Promise<TransactionPayload>;
579
+ /**
580
+ * Call a view function
581
+ */
582
+ abstract viewContract<T>(params: ViewParams): Promise<T>;
583
+ /**
584
+ * Subscribe to events
585
+ */
586
+ abstract subscribeToEvents(params: EventParams, callback: (event: any) => void): () => void;
587
+ /**
588
+ * Get transaction by hash
589
+ */
590
+ abstract getTransaction(hash: string): Promise<any>;
591
+ /**
592
+ * Get account balance
593
+ */
594
+ abstract getBalance(address: string, asset: string): Promise<string>;
595
+ /**
596
+ * Get current block number
597
+ */
598
+ abstract getBlockNumber(): Promise<number>;
599
+ /**
600
+ * Wait for transaction confirmation
601
+ */
602
+ abstract waitForTransaction(hash: string, maxWaitTime?: number): Promise<TransactionResult>;
603
+ /**
604
+ * Get the chain type
605
+ */
606
+ getChainType(): ChainType;
607
+ abstract queryIndexer<T extends {}>(params: QueryIndexerParams): Promise<T>;
608
+ }
609
+
610
+ /**
611
+ * Base interface for analytics client implementations
612
+ * Chain-specific analytics clients should implement this interface
613
+ */
614
+
615
+ /**
616
+ * Base interface defining the analytics API contract
617
+ * All chain-specific analytics clients must implement this interface
618
+ */
619
+ interface BaseAnalyticsClient {
620
+ /**
621
+ * Get vault activities with pagination
622
+ * @param args - Arguments for filtering and pagination
623
+ * @returns Promise with activities array and total count
624
+ */
625
+ getActivities(args: GetActivitiesArgs): Promise<{
626
+ activities: VaultActivity[];
627
+ total: number;
628
+ }>;
629
+ /**
630
+ * Get total value locked in base asset
631
+ * @param args - Vault and asset information
632
+ * @returns Promise with TVL as string
633
+ */
634
+ getTvlInBaseAsset(args: VaultTvlArgs): Promise<string>;
635
+ /**
636
+ * Get exchange rate update events within a time range
637
+ * @param args - Vault address and time range
638
+ * @returns Promise with array of exchange rate events
639
+ */
640
+ getUpdateExchangeRateEvents(args: HistoricalApyArgs): Promise<ExchangeRateEvent[]>;
641
+ /**
642
+ * Get 30-day APY for a vault
643
+ * @param vault - Vault address
644
+ * @returns Promise with APY as string percentage
645
+ */
646
+ get30DayApy(vault: string): Promise<string>;
647
+ /**
648
+ * Get historical APY data points
649
+ * @param args - Vault, time range, and optional window
650
+ * @returns Promise with array of APY data points
651
+ */
652
+ getHistoricalApy(args: HistoricalApyArgs): Promise<ApyDataPoint[]>;
653
+ }
654
+
655
+ /**
656
+ * Base API interfaces
657
+ */
658
+
659
+ interface BaseAPI<TAdapter extends BaseChainAdapter<any> = BaseChainAdapter<any>> {
660
+ adapter: TAdapter;
661
+ chain: Chain;
662
+ }
663
+
664
+ interface CalculateWithdrawalAmountParams {
665
+ /** Amount of vault token, in raw amount */
666
+ offerAmount: bigint;
667
+ /** Price of vault token in quote safe, in raw amount */
668
+ price: bigint;
669
+ /** Slippage percentage in basis points (eg: 500 for 5%) */
670
+ slippage: bigint;
671
+ /** Offer decimals */
672
+ offerDecimals: number;
673
+ }
674
+ interface WithdrawRequest {
675
+ /** Amount of vault token, in raw amount */
676
+ offerAmount: bigint;
677
+ /** Price of vault token in quote safe, in raw amount */
678
+ price: bigint;
679
+ /** Minimum amount to receive in quote safe, in raw amount */
680
+ minimumReceive: bigint;
681
+ }
682
+ declare const calculateWithdrawalAmount: ({ offerAmount, price, slippage, offerDecimals, }: CalculateWithdrawalAmountParams) => WithdrawRequest;
683
+ interface CalculateMinimumReceiveAmountParams {
684
+ /** Want amount in raw amount */
685
+ wantAmount: bigint;
686
+ /** Slippage percentage in basis points (eg: 500 for 5%) */
687
+ slippage: bigint;
688
+ }
689
+ declare const calculateMinimumReceiveAmount: ({ wantAmount, slippage, }: CalculateMinimumReceiveAmountParams) => bigint;
690
+
691
+ declare function normalizeAddress(address: string): string;
692
+
693
+ /**
694
+ * Calculate APY based on withdraw rate changes over time
695
+ * @param events - Array of APY events with withdraw/deposit rates and timestamps
696
+ * @returns APY percentage as a string with 2 decimal places
697
+ */
698
+ declare const calculateApy: (firstEvent: ExchangeRateEvent, lastEvent: ExchangeRateEvent) => string;
699
+
700
+ /**
701
+ * Constants for flag bit positions and values
702
+ */
703
+ declare const FLAG_BITS: {
704
+ /** bit 0 (1): deadline passed */
705
+ readonly DEADLINE_PASSED: 1;
706
+ /** bit 1 (2): zero offer amount */
707
+ readonly ZERO_OFFER_AMOUNT: 2;
708
+ /** bit 2 (4): minimum age not met */
709
+ readonly MINIMUM_AGE_NOT_MET: 4;
710
+ };
711
+ /**
712
+ * Type for flag bit keys
713
+ */
714
+ type FlagBitKey = keyof typeof FLAG_BITS;
715
+ /**
716
+ * Parses a numeric flag value into a RequestFlagState object.
717
+ *
718
+ * @param flagNumber - The numeric flag value (e.g., 5)
719
+ * @returns RequestFlagState object with boolean properties for each flag
720
+ *
721
+ * @example
722
+ * parseRequestFlags(0) // { deadlinePassed: false, zeroOfferAmount: false, minimumAgeNotMet: false }
723
+ * parseRequestFlags(5) // { deadlinePassed: true, zeroOfferAmount: false, minimumAgeNotMet: true }
724
+ */
725
+ declare const parseRequestFlags: (flagNumber: number) => PyxisRequestFlagState;
726
+ /**
727
+ * Builds a numeric flag value from a partial RequestFlagState object.
728
+ *
729
+ * @param flags - Partial object with boolean flag properties
730
+ * @returns Numeric flag value representing the combined flags
731
+ *
732
+ * @example
733
+ * buildRequestFlags({}) // 0
734
+ * buildRequestFlags({ deadlinePassed: true }) // 1
735
+ */
736
+ declare const buildRequestFlags: (flags: Partial<PyxisRequestFlagState>) => number;
737
+ /**
738
+ * Checks if a specific flag is set in the given flag number.
739
+ *
740
+ * @param flagNumber - The numeric flag value to check
741
+ * @param flagType - The specific flag type to check
742
+ * @returns true if the specified flag is set, false otherwise
743
+ *
744
+ * @example
745
+ * hasFlag(1, 'DEADLINE_PASSED') // true
746
+ * hasFlag(2, 'ZERO_OFFER_AMOUNT') // true
747
+ */
748
+ declare const hasFlag: (flagNumber: number, flagType: FlagBitKey) => boolean;
749
+ /**
750
+ * Gets an array of all active flag names for a given flag number.
751
+ *
752
+ * @param flagNumber - The numeric flag value to analyze
753
+ * @returns Array of flag type names that are currently set
754
+ *
755
+ * @example
756
+ * getActiveFlags(0) // []
757
+ * getActiveFlags(1) // ['DEADLINE_PASSED']
758
+ * getActiveFlags(5) // ['DEADLINE_PASSED', 'MINIMUM_AGE_NOT_MET']
759
+ * getActiveFlags(7) // ['DEADLINE_PASSED', 'ZERO_OFFER_AMOUNT', 'MINIMUM_AGE_NOT_MET']
760
+ */
761
+ declare const getActiveFlags: (flagNumber: number) => FlagBitKey[];
762
+
763
+ /**
764
+ * Maps an OnchainWithdrawalRequest to a WithdrawalRequest with camelCase properties
765
+ * @param onchainRequest The onchain withdrawal request with snake_case properties
766
+ * @param updatedAt Optional timestamp when the request was last updated
767
+ * @returns The withdrawal request with camelCase properties
768
+ */
769
+ declare function mapOnchainToWithdrawalRequest(onchainRequest: PyxisOnchainWithdrawalRequest, updatedAt?: string): PyxisWithdrawalRequest;
770
+ /**
771
+ * Maps an IndexerVaultActivity to a VaultActivity with camelCase properties
772
+ * @param indexerActivity The indexer activity with snake_case properties
773
+ * @returns The vault activity with camelCase properties
774
+ */
775
+ declare function mapIndexerToVaultActivity(indexerActivity: IndexerVaultActivity): VaultActivity;
776
+ /**
777
+ * Maps an IndexerExchangeRateEvent to an ExchangeRateEvent with camelCase properties
778
+ * @param indexerEvent The indexer exchange rate event with snake_case properties
779
+ * @returns The exchange rate event with camelCase properties
780
+ */
781
+ declare function mapIndexerToExchangeRateEvent(indexerEvent: IndexerExchangeRateEvent): ExchangeRateEvent;
782
+
783
+ declare const amountWithSlippage: (rawAmount: bigint, slippageBips: bigint) => bigint;
784
+
785
+ declare enum SamplingStrategy {
786
+ START = "start",// First event of the day
787
+ END = "end",// Last event of the day
788
+ MEDIAN = "median",// Middle event of the day
789
+ AVERAGE = "average"
790
+ }
791
+ /**
792
+ * Samples exchange rate events to get one event per day.
793
+ *
794
+ * @param events - Array of exchange rate events to sample
795
+ * @param strategy - Sampling strategy: 'start' (first event), 'end' (last event), 'median' (middle event), 'average' (averaged exchange rate)
796
+ * @returns Array of sampled events with one event per day, sorted by timestamp
797
+ */
798
+ declare const sampleEventsByDay: (events: ExchangeRateEvent[], strategy?: SamplingStrategy) => ExchangeRateEvent[];
799
+
800
+ declare const index_FLAG_BITS: typeof FLAG_BITS;
801
+ type index_FlagBitKey = FlagBitKey;
802
+ type index_SamplingStrategy = SamplingStrategy;
803
+ declare const index_SamplingStrategy: typeof SamplingStrategy;
804
+ declare const index_amountWithSlippage: typeof amountWithSlippage;
805
+ declare const index_buildRequestFlags: typeof buildRequestFlags;
806
+ declare const index_calculateApy: typeof calculateApy;
807
+ declare const index_calculateMinimumReceiveAmount: typeof calculateMinimumReceiveAmount;
808
+ declare const index_calculateWithdrawalAmount: typeof calculateWithdrawalAmount;
809
+ declare const index_getActiveFlags: typeof getActiveFlags;
810
+ declare const index_hasFlag: typeof hasFlag;
811
+ declare const index_mapIndexerToExchangeRateEvent: typeof mapIndexerToExchangeRateEvent;
812
+ declare const index_mapIndexerToVaultActivity: typeof mapIndexerToVaultActivity;
813
+ declare const index_mapOnchainToWithdrawalRequest: typeof mapOnchainToWithdrawalRequest;
814
+ declare const index_normalizeAddress: typeof normalizeAddress;
815
+ declare const index_parseRequestFlags: typeof parseRequestFlags;
816
+ declare const index_sampleEventsByDay: typeof sampleEventsByDay;
817
+ declare namespace index {
818
+ export { index_FLAG_BITS as FLAG_BITS, type index_FlagBitKey as FlagBitKey, index_SamplingStrategy as SamplingStrategy, index_amountWithSlippage as amountWithSlippage, index_buildRequestFlags as buildRequestFlags, index_calculateApy as calculateApy, index_calculateMinimumReceiveAmount as calculateMinimumReceiveAmount, index_calculateWithdrawalAmount as calculateWithdrawalAmount, index_getActiveFlags as getActiveFlags, index_hasFlag as hasFlag, index_mapIndexerToExchangeRateEvent as mapIndexerToExchangeRateEvent, index_mapIndexerToVaultActivity as mapIndexerToVaultActivity, index_mapOnchainToWithdrawalRequest as mapOnchainToWithdrawalRequest, index_normalizeAddress as normalizeAddress, index_parseRequestFlags as parseRequestFlags, index_sampleEventsByDay as sampleEventsByDay };
819
+ }
820
+
821
+ export { type AnyTransaction, type AptosTransaction, type AptosTransactionPayload, type ApyDataPoint, type ApyWindow, type BaseAPI, type BaseAnalyticsClient, BaseChainAdapter, type BaseTransaction, type BuildCancelWithdrawalRequestTxArgs, type BuildDepositTxArgs, type BuildReclaimWithdrawalRequestTxArgs, type BuildWithdrawTxArgs, CHAIN_CONFIGS, type Chain, type ChainConfig, ChainId, ChainType, ConfigError, ContractError, type Currency, ErrorCodes, type EthereumJsonRpcRequest, type EthereumTransaction, type EventParams, type ExchangeRateEvent, type GetActivitiesArgs, type GetDepositRateInQuoteSafeArgs, type GetMinimumRequestAgeArgs, type GetWithdrawRateInQuoteSafeArgs, type GetWithdrawalRequestsOfUserArgs, type HistoricalApyArgs, type IndexerExchangeRateEvent, type IndexerVaultActivity, InsufficientFundsError, NetworkError, NetworkType, PyxisError, type PyxisOnchainWithdrawalRequest, type PyxisRequestFlagState, type PyxisToken, index as PyxisUtils, type PyxisWithdrawalRequest, type QueryIndexerParams, type QuoteDepositArgs, type QuoteWithdrawArgs, RateLimitError, type SDKConfig, type SignedTransaction, StrategyError, TransactionError, type TransactionPayload, type TransactionResult, type TxParams, ValidationError, type VaultActivity, type VaultContractAddressConfig, VaultError, type VaultTvlArgs, type ViewParams, type WalletAccount, type WalletAdapter, WalletError, createError, getChainConfig };